Skip to content

Commit

Permalink
feat(vcd): add vcd reset password
Browse files Browse the repository at this point in the history
  ref: MANAGER-15191

Signed-off-by: Paul Dickerson <[email protected]>
  • Loading branch information
Paul Dickerson committed Nov 13, 2024
1 parent faea8fb commit c9bd17e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import React from 'react';
import { DashboardTile } from '@ovh-ux/manager-react-components';
import {
OsdsChip,
OsdsIcon,
OsdsLink,
OsdsTooltip,
OsdsTooltipContent,
} from '@ovhcloud/ods-components/react';
import { useTranslation } from 'react-i18next';
import { useNavigate, useParams } from 'react-router-dom';
import { DashboardTile, Links } from '@ovh-ux/manager-react-components';
import { OsdsChip } from '@ovhcloud/ods-components/react';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import {
ODS_CHIP_SIZE,
ODS_ICON_NAME,
ODS_ICON_SIZE,
} from '@ovhcloud/ods-components';
import { ODS_CHIP_SIZE } from '@ovhcloud/ods-components';
import ServiceRenewTileItem from './renew-tile-item/ServiceRenewTileItem';
import ServiceContactsTileItem from './contact-tile-item/ServiceContactsTileItem';
import { subRoutes, urls } from '@/routes/routes.constant';

export default function OrganizationServiceManagementTile() {
const { t } = useTranslation('dashboard');
const { id } = useParams();
const navigate = useNavigate();

return (
<div className="h-fit">
Expand Down Expand Up @@ -48,35 +42,12 @@ export default function OrganizationServiceManagementTile() {
id: 'servicePassword',
label: t('managed_vcd_dashboard_password'),
value: (
<div className="flex-wrap">
<div className="flex items-center gap-x-2">
<OsdsLink disabled>
{t('managed_vcd_dashboard_password_renew')}
</OsdsLink>
<OsdsTooltip className="flex items-center">
<OsdsIcon
className="cursor-pointer"
name={ODS_ICON_NAME.HELP}
size={ODS_ICON_SIZE.xxs}
color={ODS_THEME_COLOR_INTENT.text}
/>
<OsdsTooltipContent
slot="tooltip-content"
className="break-normal"
>
{t('managed_vcd_dashboard_password_tooltip')}
</OsdsTooltipContent>
</OsdsTooltip>
</div>
<OsdsChip
inline
color={ODS_THEME_COLOR_INTENT.primary}
className="ml-3"
size={ODS_CHIP_SIZE.sm}
>
{t('managed_vcd_dashboard_coming_soon')}
</OsdsChip>
</div>
<Links
label={t('managed_vcd_dashboard_password_renew')}
onClickReturn={() =>
navigate(urls.resetPassword.replace(subRoutes.dashboard, id))
}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
renderTest,
labels,
checkModalVisibility,
waitForEnabledElement,
mockSubmitNewValue,
checkModalError,
DEFAULT_TIMEOUT,
Expand Down Expand Up @@ -100,4 +101,50 @@ describe('Organization General Information Page', () => {
await checkModalVisibility({ container, isVisible: true });
await checkModalError({ container, error: 'Organization update error' });
});

it('resets the password of the organization', async () => {
const { container } = await renderTest({
initialRoute: `/${organizationList[1].id}`,
});

await checkTextVisibility(
labels.dashboard.managed_vcd_dashboard_password_renew,
);

const resetPasswordLink = await waitForEnabledElement(
labels.dashboard.managed_vcd_dashboard_password_renew,
);
await waitFor(() => userEvents.click(resetPasswordLink));

await checkModalVisibility({ container, isVisible: true });

const validateButton = await waitForEnabledElement(
labels.dashboard.managed_vcd_dashboard_edit_modal_cta_validate,
);
await waitFor(() => userEvents.click(validateButton));

await checkModalVisibility({ container, isVisible: false });
await checkTextVisibility(
labels.dashboard.managed_vcd_dashboard_password_renew_success,
);
});

it('trying to reset password displays an error if reset password service is KO', async () => {
const { container } = await renderTest({
initialRoute: `/${organizationList[0].id}/reset-password`,
isOrganizationResetPasswordKo: true,
});

await checkModalVisibility({ container, isVisible: true });

const validateButton = await waitForEnabledElement(
labels.dashboard.managed_vcd_dashboard_edit_modal_cta_validate,
);
await waitFor(() => userEvents.click(validateButton));

await checkModalVisibility({ container, isVisible: false });
await checkTextVisibility(
labels.dashboard.managed_vcd_dashboard_password_renew_error,
);
});
});
15 changes: 15 additions & 0 deletions packages/manager/apps/hpc-vmware-managed-vcd/src/routes/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ export const Routes: any = [
},
},
},
{
id: 'reset-password',
path: urls.resetPassword,
...lazyRouteConfig(() =>
import(
'@/pages/dashboard/organization/general-information/edit/EditPassword.page'
),
),
handle: {
tracking: {
pageName: 'reset-password',
pageType: PageType.popup,
},
},
},
],
},
{
Expand Down

0 comments on commit c9bd17e

Please sign in to comment.