-
+
setEditModalDisplayed(true)}
+ onClick={() => navigate('update-name')}
>
setEditModalDisplayed(true)}
name={ODS_ICON_NAME.PEN}
size={ODS_ICON_SIZE.xs}
color={ODS_THEME_COLOR_INTENT.primary}
@@ -113,6 +106,7 @@ const InformationsTile = ({ okmsData }: InformationTileProps) => {
{okmsData?.swaggerEndpoint}
+
);
};
diff --git a/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyDeactivateModal.component.tsx b/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyDeactivateModal.component.tsx
index 5f82a23d1bc9..72326d854947 100644
--- a/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyDeactivateModal.component.tsx
+++ b/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyDeactivateModal.component.tsx
@@ -38,7 +38,7 @@ export const ServiceKeyDeactivateModal = ({
const [deactivationReason, setDeactivationReason] = useState<
OkmsServiceKeyDeactivationReason
>();
- const { addSuccess } = useNotifications();
+ const { addSuccess, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/serviceKeys');
const { t: tCommon } = useTranslation('key-management-service/common');
@@ -50,6 +50,7 @@ export const ServiceKeyDeactivateModal = ({
okmsId,
keyId,
onSuccess: () => {
+ clearNotifications();
addSuccess(
t('key_management_service_service-keys_deactivation_success'),
true,
diff --git a/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyEditNameModal.component.tsx b/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyEditNameModal.component.tsx
index a09d93f4f0a4..7b259e3df195 100644
--- a/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyEditNameModal.component.tsx
+++ b/packages/manager/apps/key-management-service/src/components/serviceKey/modals/ServiceKeyEditNameModal.component.tsx
@@ -37,7 +37,7 @@ export const ServiceKeyEditNameModal = ({
}: ServiceKeyEditNameModalProps) => {
const [serviceKeyName, setServiceKeyName] = useState(name);
const serviceKeyNameError = validateServiceKeyName(serviceKeyName);
- const { addSuccess } = useNotifications();
+ const { addSuccess, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/serviceKeys');
const { t: tCommon } = useTranslation('key-management-service/common');
@@ -49,6 +49,7 @@ export const ServiceKeyEditNameModal = ({
okmsId,
keyId,
onSuccess: () => {
+ clearNotifications();
addSuccess(
t('key_management_service_service-keys_update_name_success'),
true,
diff --git a/packages/manager/apps/key-management-service/src/components/serviceKey/serviceKeyStateActions/ServiceKeyStateActions.component.tsx b/packages/manager/apps/key-management-service/src/components/serviceKey/serviceKeyStateActions/ServiceKeyStateActions.component.tsx
index f12ca98cb561..8fd659428096 100644
--- a/packages/manager/apps/key-management-service/src/components/serviceKey/serviceKeyStateActions/ServiceKeyStateActions.component.tsx
+++ b/packages/manager/apps/key-management-service/src/components/serviceKey/serviceKeyStateActions/ServiceKeyStateActions.component.tsx
@@ -1,5 +1,6 @@
-import { OsdsIcon, OsdsButton } from '@ovhcloud/ods-components/react';
import React from 'react';
+import { OsdsIcon, OsdsButton } from '@ovhcloud/ods-components/react';
+import { ManagerButton } from '@ovh-ux/manager-react-components';
import {
ODS_BUTTON_SIZE,
ODS_BUTTON_TEXT_ALIGN,
@@ -9,9 +10,10 @@ import {
} from '@ovhcloud/ods-components';
import { OkmsAllServiceKeys } from '@/types/okmsServiceKey.type';
import useServiceKeyActionsList from '@/hooks/serviceKey/useServiceKeyActionsList';
+import { OKMS } from '@/types/okms.type';
type ServiceKeyStateActionsProps = {
- okmsId: string;
+ okms: OKMS;
okmsKey: OkmsAllServiceKeys;
};
@@ -23,38 +25,62 @@ const ActionsIcons = [
];
const ServiceKeyStateActions = ({
- okmsId,
+ okms,
okmsKey,
}: ServiceKeyStateActionsProps) => {
- const actionList = useServiceKeyActionsList(okmsId, okmsKey);
+ const actionList = useServiceKeyActionsList(okms, okmsKey);
const getActionIcon = (id: number) => {
return ActionsIcons.find((actionIcon) => actionIcon.id === id)?.icon;
};
return (
<>
- {actionList.map((action) => (
-
- {action.label}
-
-
-
-
- ))}
+ {actionList.map((action) => {
+ return action.iamActions ? (
+
+ {action.label}
+
+
+
+
+ ) : (
+
+ {action.label}
+
+
+
+
+ );
+ })}
>
);
};
diff --git a/packages/manager/apps/key-management-service/src/data/api/okms.ts b/packages/manager/apps/key-management-service/src/data/api/okms.ts
index caa5e0f830f9..f5f9865186f8 100644
--- a/packages/manager/apps/key-management-service/src/data/api/okms.ts
+++ b/packages/manager/apps/key-management-service/src/data/api/okms.ts
@@ -92,20 +92,6 @@ export const getListingIcebergV2 = async ({
}
};
-/**
- * Get okms listing with iceberg V2
- */
-export const getListingIceberg = async () => {
- try {
- const List = await fetchIcebergV2({
- route: '/okms/resource',
- });
- return List.data as OKMS[];
- } catch (error) {
- return null;
- }
-};
-
export const getOkmsResourceQueryKey = (okmsId: string) => [
`get/okms/resource/${okmsId}`,
];
diff --git a/packages/manager/apps/key-management-service/src/data/api/okmsService.ts b/packages/manager/apps/key-management-service/src/data/api/okmsService.ts
index 8f60cff29731..de066437a23e 100644
--- a/packages/manager/apps/key-management-service/src/data/api/okmsService.ts
+++ b/packages/manager/apps/key-management-service/src/data/api/okmsService.ts
@@ -16,24 +16,20 @@ export const updateOkmsName = async ({
displayName,
});
-export type GetOkmsServiceIdParams = {
- /** Filter on a specific service family */
- okms: string;
-};
-
-export const getOkmsServiceIdQueryKey = ({
- okms = '',
-}: GetOkmsServiceIdParams) => [`get/services${okms}`];
+export const getOkmsServiceIdQueryKey = (okmsId: string) => [
+ `get/okms/services`,
+ okmsId,
+];
/**
* allowedServices operations : List all services allowed in this kms
*/
-export const getOkmsServiceId = async ({ okms }: GetOkmsServiceIdParams) => {
- const resourceName = okms ? `?resourceName=${okms}` : '';
+export const getOkmsServiceId = async (okmsId: string) => {
+ const resourceName = okmsId ? `?resourceName=${okmsId}` : '';
return apiClient.v6.get(`/services${resourceName}`);
};
-export const getServiceInfos = async ({ okms }: GetOkmsServiceIdParams) => {
- const serviceId = await getOkmsServiceId({ okms });
+export const getServiceInfos = async (okmsId: string) => {
+ const serviceId = await getOkmsServiceId(okmsId);
return apiClient.v6.get(`/services/${serviceId.data[0]}`);
};
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsCredential.ts b/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsCredential.ts
index 42061cf963ab..db078b5a7e0c 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsCredential.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsCredential.ts
@@ -21,7 +21,7 @@ export const useCreateOkmsCredential = ({
onError,
}: CreateOkmsCredentialParams) => {
const queryClient = useQueryClient();
- const { addError, addSuccess } = useNotifications();
+ const { addError, addSuccess, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/credential');
@@ -34,10 +34,12 @@ export const useCreateOkmsCredential = ({
await queryClient.invalidateQueries({
queryKey: getOkmsCredentialsQueryKey(okmsId),
});
+ clearNotifications();
addSuccess(t('key_management_service_credential_create_success'), true);
onSuccess?.(credential);
},
onError: (result: ApiError) => {
+ clearNotifications();
addError(
t('key_management_service_credential_create_error', {
error: result.message,
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsServiceKey.ts b/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsServiceKey.ts
index 5240c813572b..302f2c2e1193 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsServiceKey.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useCreateOkmsServiceKey.ts
@@ -20,7 +20,7 @@ export const useCreateOkmsServiceKey = ({
onError,
}: CreateOkmsServiceKeyParams) => {
const queryClient = useQueryClient();
- const { addError, addSuccess } = useNotifications();
+ const { addError, addSuccess, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/serviceKeys');
@@ -32,10 +32,12 @@ export const useCreateOkmsServiceKey = ({
await queryClient.invalidateQueries({
queryKey: getOkmsServiceKeyResourceListQueryKey(okmsId),
});
+ clearNotifications();
addSuccess(t('key_management_service_service-keys_create_success'), true);
onSuccess?.();
},
onError: (result: ApiError) => {
+ clearNotifications();
addError(
t('key_management_service_service-keys_create_error', {
error: result.message,
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsCredential.ts b/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsCredential.ts
index 81d86113ea6e..8c78bc28a4c8 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsCredential.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsCredential.ts
@@ -22,7 +22,7 @@ export const useDeleteOkmsCredential = ({
onError,
}: IUseDeleteOkmsCredential) => {
const queryClient = useQueryClient();
- const { addError, addSuccess } = useNotifications();
+ const { addError, addSuccess, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/credential');
const { mutate, isPending } = useMutation({
@@ -34,11 +34,12 @@ export const useDeleteOkmsCredential = ({
await queryClient.invalidateQueries({
queryKey: getOkmsCredentialsQueryKey(okmsId),
});
-
+ clearNotifications();
addSuccess(t('key_management_service_credential_delete_success'), true);
onSuccess();
},
onError: (result: ApiError) => {
+ clearNotifications();
addError(
t('key_management_service_credential_delete_error', {
error: result.message,
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsServiceKey.ts b/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsServiceKey.ts
index fb4aa0b96f45..d65425fec7c1 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsServiceKey.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useDeleteOkmsServiceKey.ts
@@ -23,7 +23,7 @@ export const useDeleteOkmsServiceKey = ({
onError,
}: DeleteOkmsServiceKeyParams) => {
const queryClient = useQueryClient();
- const { addError, addSuccess } = useNotifications();
+ const { addError, addSuccess, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/serviceKeys');
@@ -39,10 +39,12 @@ export const useDeleteOkmsServiceKey = ({
await queryClient.invalidateQueries({
queryKey: getOkmsServiceKeyResourceQueryKey({ okmsId, keyId }),
});
+ clearNotifications();
addSuccess(t('key_management_service_service-keys_delete_success'), true);
onSuccess();
},
onError: (result: ApiError) => {
+ clearNotifications();
addError(
t('key_management_service_service-keys_delete_error', {
error: result.message,
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useKMSServiceInfos.ts b/packages/manager/apps/key-management-service/src/data/hooks/useKMSServiceInfos.ts
index acc26a7515bf..c637da680dd6 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useKMSServiceInfos.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useKMSServiceInfos.ts
@@ -1,16 +1,16 @@
import { useQuery } from '@tanstack/react-query';
-import { OKMS } from '@/types/okms.type';
import { ErrorResponse } from '@/types/api.type';
import { KMSServiceInfos } from '@/types/okmsService.type';
import { getServiceInfos } from '../api/okmsService';
-export const useKMSServiceInfos = (okms?: OKMS) => {
+export const getKMSServiceInfosQueryKey = (okmsId: string) => [
+ 'okms/service/infos',
+ okmsId,
+];
+export const useKMSServiceInfos = (okmId?: string) => {
return useQuery<{ data: KMSServiceInfos }, ErrorResponse>({
- queryKey: ['okms/service/infos', okms?.id],
- queryFn: () => getServiceInfos({ okms: okms?.id }),
+ queryKey: getKMSServiceInfosQueryKey(okmId),
+ queryFn: () => getServiceInfos(okmId),
retry: false,
- ...{
- keepPreviousData: true,
- },
});
};
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useOKMS.ts b/packages/manager/apps/key-management-service/src/data/hooks/useOKMS.ts
index 2a326e9bf6de..6e254e0ed428 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useOKMS.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useOKMS.ts
@@ -1,13 +1,12 @@
import { useQuery } from '@tanstack/react-query';
import apiClient from '@ovh-ux/manager-core-api';
+import { useResourcesIcebergV2 } from '@ovh-ux/manager-react-components';
-import { OKMS, OKMSOptions } from '@/types/okms.type';
+import { OKMS } from '@/types/okms.type';
import { ErrorResponse } from '@/types/api.type';
import {
- getListingIceberg,
getOkmsResourceQueryKey,
getOkmsServicesResourceListQueryKey,
- sortOKMS,
} from '../api/okms';
export const getOKMSResource = async (
@@ -16,18 +15,6 @@ export const getOKMSResource = async (
return apiClient.v2.get(`okms/resource/${okmsId}`);
};
-export const useAllOKMS = () => {
- return useQuery({
- queryKey: getOkmsServicesResourceListQueryKey,
- queryFn: () => getListingIceberg(),
- retry: false,
- ...{
- keepPreviousData: true,
- },
- refetchInterval: 5000,
- });
-};
-
export const useOKMSById = (okmsId: string) => {
return useQuery<{ data: OKMS }, ErrorResponse>({
queryKey: getOkmsResourceQueryKey(okmsId),
@@ -36,21 +23,12 @@ export const useOKMSById = (okmsId: string) => {
...{
keepPreviousData: true,
},
- refetchInterval: 5000,
});
};
-export const useOKMS = ({ sorting }: OKMSOptions) => {
- // retrieve All OKMS from API
- const {
- data: okms,
- error: allOKMSError,
- isLoading: allOKMSLoading,
- } = useAllOKMS();
-
- return {
- isLoading: allOKMSLoading,
- error: allOKMSError,
- data: sortOKMS(okms || [], sorting),
- };
-};
+export const useOKMSList = ({ pageSize }: { pageSize?: number }) =>
+ useResourcesIcebergV2({
+ route: '/okms/resource',
+ queryKey: getOkmsServicesResourceListQueryKey,
+ pageSize,
+ });
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useOkmsServiceKeys.ts b/packages/manager/apps/key-management-service/src/data/hooks/useOkmsServiceKeys.ts
index b4f06145fce3..814af9dba6fd 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useOkmsServiceKeys.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useOkmsServiceKeys.ts
@@ -1,5 +1,6 @@
import { useQuery } from '@tanstack/react-query';
+import { ApiError } from '@ovh-ux/manager-core-api';
import { ErrorResponse } from '@/types/api.type';
import {
getOkmsServiceKeyResource,
@@ -16,7 +17,7 @@ import {
/* Service Key List */
export const useAllOkmsServiceKeys = (okmsId: string) => {
- return useQuery({
+ return useQuery<{ data: OkmsAllServiceKeys[] }, ApiError>({
queryKey: getOkmsServiceKeyResourceListQueryKey(okmsId),
queryFn: () => getListingOkmsServiceKey(okmsId),
retry: false,
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useTerminateOKms.ts b/packages/manager/apps/key-management-service/src/data/hooks/useTerminateOKms.ts
index d45109ddbc96..a862377f09d9 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useTerminateOKms.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useTerminateOKms.ts
@@ -29,8 +29,8 @@ export const useTerminateOKms = ({
const { data: servicesId } = await queryClient.fetchQuery<
ApiResponse
>({
- queryKey: getOkmsServiceIdQueryKey({ okms: okmsId }),
- queryFn: () => getOkmsServiceId({ okms: okmsId }),
+ queryKey: getOkmsServiceIdQueryKey(okmsId),
+ queryFn: () => getOkmsServiceId(okmsId),
});
return terminateOKms({ serviceId: servicesId[0] });
},
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsName.ts b/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsName.ts
index e153e4996f2c..8a7471075431 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsName.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsName.ts
@@ -1,14 +1,24 @@
import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api';
import { useMutation, useQueryClient } from '@tanstack/react-query';
-import React from 'react';
-import { getOkmsServicesResourceListQueryKey } from '../api/okms';
+import { useTranslation } from 'react-i18next';
+import { useNotifications } from '@ovh-ux/manager-react-components';
+import {
+ getOkmsResourceQueryKey,
+ getOkmsServicesResourceListQueryKey,
+} from '../api/okms';
import {
updateOkmsNameQueryKey,
getOkmsServiceIdQueryKey,
getOkmsServiceId,
updateOkmsName,
} from '../api/okmsService';
+import { getKMSServiceInfosQueryKey } from './useKMSServiceInfos';
+export type UpdateOkmsParams = {
+ okmsId: string;
+ onSuccess: () => void;
+ onError?: (result: ApiError) => void;
+};
export type UpdateOkmsNameMutationParams = {
/** Okms service id */
okms: string;
@@ -20,14 +30,13 @@ export type UpdateOkmsNameMutationParams = {
* Get the function to mutate a okms Services
*/
export const useUpdateOkmsName = ({
+ okmsId,
onSuccess,
onError,
-}: {
- onSuccess?: () => void;
- onError?: (result: ApiError) => void;
-}) => {
- const [isErrorVisible, setIsErrorVisible] = React.useState(false);
+}: UpdateOkmsParams) => {
const queryClient = useQueryClient();
+ const { t } = useTranslation('key-management-service/serviceKeys');
+ const { addError, addSuccess, clearNotifications } = useNotifications();
const {
mutate: updateKmsName,
@@ -39,19 +48,36 @@ export const useUpdateOkmsName = ({
const { data: servicesId } = await queryClient.fetchQuery<
ApiResponse
>({
- queryKey: getOkmsServiceIdQueryKey({ okms }),
- queryFn: () => getOkmsServiceId({ okms }),
+ queryKey: getOkmsServiceIdQueryKey(okms),
+ queryFn: () => getOkmsServiceId(okms),
});
return updateOkmsName({ serviceId: servicesId[0], displayName });
},
- onSuccess: () => {
- queryClient.invalidateQueries({
+ onSuccess: async () => {
+ await queryClient.invalidateQueries({
queryKey: getOkmsServicesResourceListQueryKey,
});
+ await queryClient.invalidateQueries({
+ queryKey: getKMSServiceInfosQueryKey(okmsId),
+ });
+ await queryClient.invalidateQueries({
+ queryKey: getOkmsResourceQueryKey(okmsId),
+ });
+ clearNotifications();
+ addSuccess(
+ t('key_management_service_service-keys_update_name_success'),
+ true,
+ );
onSuccess?.();
},
onError: (result: ApiError) => {
- setIsErrorVisible(true);
+ clearNotifications();
+ addError(
+ t('key_management_service_service-keys_update_error', {
+ error: result.message,
+ }),
+ true,
+ );
onError?.(result);
},
});
@@ -59,8 +85,6 @@ export const useUpdateOkmsName = ({
return {
updateKmsName,
isPending,
- isErrorVisible: updateNameError && isErrorVisible,
error: updateNameError,
- hideError: () => setIsErrorVisible(false),
};
};
diff --git a/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsServiceKey.ts b/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsServiceKey.ts
index 58b220130222..a4df369e1ec4 100644
--- a/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsServiceKey.ts
+++ b/packages/manager/apps/key-management-service/src/data/hooks/useUpdateOkmsServiceKey.ts
@@ -24,7 +24,7 @@ export const useUpdateOkmsServiceKey = ({
onError,
}: UpdateOkmsServiceKeyParams) => {
const queryClient = useQueryClient();
- const { addError } = useNotifications();
+ const { addError, clearNotifications } = useNotifications();
const { t } = useTranslation('key-management-service/serviceKeys');
@@ -43,6 +43,7 @@ export const useUpdateOkmsServiceKey = ({
onSuccess();
},
onError: (result: ApiError) => {
+ clearNotifications();
addError(
t('key_management_service_service-keys_update_error', {
error: result.message,
diff --git a/packages/manager/apps/key-management-service/src/hooks/guide/guidesLinks.constant.ts b/packages/manager/apps/key-management-service/src/hooks/guide/guidesLinks.constant.ts
index e9fe16e93a25..4cded76f56d1 100644
--- a/packages/manager/apps/key-management-service/src/hooks/guide/guidesLinks.constant.ts
+++ b/packages/manager/apps/key-management-service/src/hooks/guide/guidesLinks.constant.ts
@@ -2,6 +2,11 @@ import { CountryCode } from '@ovh-ux/manager-config';
type GuideLinks = { [key in CountryCode]: string };
+export const SUPPORT_URL: Record = {
+ EU: 'https://help.ovhcloud.com',
+ US: 'https://support.us.ovhcloud.com',
+};
+
export const GUIDE_LIST: {
[guideName: string]: Partial;
} = {
@@ -27,7 +32,8 @@ export const GUIDE_LIST: {
'/csm/fr-ca-kms-quick-start?id=kb_article_view&sysparm_article=KB0063373',
SG:
'/csm/en-sg-kms-quick-start?id=kb_article_view&sysparm_article=KB006337',
- US: '/csm/en-kms-quick-start?id=kb_article_view&sysparm_article=KB0063366',
+ US:
+ '/hc/en-us/articles/31481250033811-Getting-Started-with-OVHcloud-Key-Management-Service-KMS',
WE: '/csm/en-kms-quick-start?id=kb_article_view&sysparm_article=KB0063366',
WS:
'/csm/es-es-kms-quick-start?id=kb_article_view&sysparm_article=KB0063370',
diff --git a/packages/manager/apps/key-management-service/src/hooks/guide/useGuideUtils.tsx b/packages/manager/apps/key-management-service/src/hooks/guide/useGuideUtils.tsx
index 54e86d1d200c..445a1c07b82a 100644
--- a/packages/manager/apps/key-management-service/src/hooks/guide/useGuideUtils.tsx
+++ b/packages/manager/apps/key-management-service/src/hooks/guide/useGuideUtils.tsx
@@ -1,9 +1,7 @@
import { useContext, useEffect, useState } from 'react';
import { CountryCode } from '@ovh-ux/manager-config';
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
-import { GUIDE_LIST } from './guidesLinks.constant';
-
-const helpCenterUrl = 'https://help.ovhcloud.com';
+import { GUIDE_LIST, SUPPORT_URL } from './guidesLinks.constant';
type GetGuideLinkProps = {
name?: string;
@@ -17,7 +15,8 @@ function getGuideListLink({ subsidiary }: GetGuideLinkProps) {
const guide =
GUIDE_LIST[key[0]][subsidiary as CountryCode] || GUIDE_LIST[key[0]].GB;
- list[key[0]] = helpCenterUrl + guide;
+ const helpCenterUrl = SUPPORT_URL[subsidiary] ?? SUPPORT_URL.EU;
+ list[key[0]] = `${helpCenterUrl}${guide}`;
});
return list;
}
diff --git a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActions.spec.tsx b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActions.spec.tsx
index 2664b2ab4b64..ad674f1fcf08 100644
--- a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActions.spec.tsx
+++ b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActions.spec.tsx
@@ -1,8 +1,13 @@
import { describe, expect, it, vi } from 'vitest';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { renderHook } from '@testing-library/react';
-import { OkmsKeyTypes, OkmsServiceKeyState } from '@/types/okmsServiceKey.type';
+import {
+ OkmsAllServiceKeys,
+ OkmsKeyTypes,
+ OkmsServiceKeyState,
+} from '@/types/okmsServiceKey.type';
import useServiceKeyActionsList from './useServiceKeyActionsList';
+import { OKMS } from '@/types/okms.type';
vi.mock('react-i18next', () => ({
useTranslation: vi.fn(() => ({ t: vi.fn((key) => key) })),
@@ -31,13 +36,25 @@ vi.mock('@/data/hooks/useUpdateOkmsServiceKey', () => ({
}));
describe('useServiceKeyActionsList', () => {
- const okmsId = 'testOkmsId';
- const commonKeyProps = {
+ const okms: OKMS = {
+ iam: {
+ displayName: 'kms-1',
+ id: '1b4e7c8e-d1b8-4b46-a584-52c8b4b0225c',
+ urn: `urn:v1:eu:resource:okms:1b4e7c8e-d1b8-4b46-a584-52c8b4b0225c`,
+ },
+ id: '7f3a82ac-a8d8-4c2a-ab0c-f6e86ddf6a7c',
+ kmipEndpoint: 'eu-west-rbx.okms.ovh.net:1234',
+ region: 'EU_WEST_RBX',
+ restEndpoint: 'https://eu-west-rbx.okms.ovh.net',
+ swaggerEndpoint: '"https://swagger-eu-west-rbx.okms.ovh.net',
+ };
+
+ const commonKeyProps: Omit = {
id: 'testKeyId',
name: 'testKeyName',
- keys: [] as any[],
+ keys: [],
createdAt: '2023-01-01T00:00:00Z',
- operations: [] as any[],
+ operations: [],
};
const useCases = [
@@ -171,7 +188,7 @@ describe('useServiceKeyActionsList', () => {
useCases.forEach(({ description, okmsKey, expectedActions }) => {
it(description, () => {
const { result } = renderHook(() =>
- useServiceKeyActionsList(okmsId, okmsKey),
+ useServiceKeyActionsList(okms, okmsKey),
);
expect(result.current).toEqual(
expect.arrayContaining(
diff --git a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActionsList.tsx b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActionsList.tsx
index 2f696ab258ee..818f8c4de944 100644
--- a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActionsList.tsx
+++ b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyActionsList.tsx
@@ -13,23 +13,24 @@ import {
OkmsKeyTypes,
OkmsServiceKeyState,
} from '@/types/okmsServiceKey.type';
+import { OKMS } from '@/types/okms.type';
const useServiceKeyActionsList = (
- okmsId: string,
+ okms: OKMS,
okmsKey?: OkmsAllServiceKeys,
isListMode?: boolean,
) => {
const { t } = useTranslation('key-management-service/serviceKeys');
- const { addSuccess } = useNotifications();
+ const { addSuccess, clearNotifications } = useNotifications();
const navigate = useNavigate();
const {
deleteKmsServiceKey,
isPending: deleteIsPending,
} = useDeleteOkmsServiceKey({
- okmsId,
+ okmsId: okms.id,
keyId: okmsKey?.id,
onSuccess: () => {
- navigate(`/${okmsId}/${ROUTES_URLS.keys}`);
+ navigate(`/${okms.id}/${ROUTES_URLS.keys}`);
},
onError: () => {},
});
@@ -38,9 +39,10 @@ const useServiceKeyActionsList = (
updateKmsServiceKey,
isPending: updateIsPending,
} = useUpdateOkmsServiceKey({
- okmsId,
+ okmsId: okms.id,
keyId: okmsKey?.id,
onSuccess: () => {
+ clearNotifications();
addSuccess(
t('key_management_service_service-keys_reactivate_success'),
true,
@@ -72,9 +74,11 @@ const useServiceKeyActionsList = (
return isListMode
? navigate(`${ROUTES_URLS.serviceKeyDeactivate}/${okmsKey?.id}`)
: navigate(
- `/${okmsId}/${ROUTES_URLS.keys}/${okmsKey?.id}/${ROUTES_URLS.serviceKeyDeactivate}`,
+ `/${okms.id}/${ROUTES_URLS.keys}/${okmsKey?.id}/${ROUTES_URLS.serviceKeyDeactivate}`,
);
},
+ iamActions: ['okms:apiovh:resource/serviceKey/deactivate'],
+ urn: okms.iam.urn,
});
}
if (
@@ -87,6 +91,8 @@ const useServiceKeyActionsList = (
color: ODS_THEME_COLOR_INTENT.primary,
disabled: updateIsPending,
onClick: () => updateKmsServiceKey({ state: OkmsServiceKeyState.active }),
+ iamActions: ['okms:apiovh:resource/serviceKey/activate'],
+ urn: okms.iam.urn,
});
}
if (
@@ -100,6 +106,8 @@ const useServiceKeyActionsList = (
disabled:
okmsKey?.state === OkmsServiceKeyState.active || deleteIsPending,
onClick: () => deleteKmsServiceKey(),
+ iamActions: ['okms:apiovh:resource/serviceKey/delete'],
+ urn: okms.iam.urn,
});
}
return items;
diff --git a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyOperationsTranslations.spec.tsx b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyOperationsTranslations.spec.tsx
index c5a30fe9462c..13b98ec1e7d9 100644
--- a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyOperationsTranslations.spec.tsx
+++ b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyOperationsTranslations.spec.tsx
@@ -1,7 +1,16 @@
-import { describe, expect, it, test } from 'vitest';
+import { describe, expect, it, test, vi } from 'vitest';
import { OkmsServiceKeyOperations } from '@/types/okmsServiceKey.type';
import { useServiceKeyOperationsTranslations } from './useServiceKeyOperationsTranslations';
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (translationKey: string) => translationKey,
+ i18n: {
+ changeLanguage: () => new Promise(() => {}),
+ },
+ }),
+}));
+
describe('get service key operations translation ', () => {
const useCases: {
operation: OkmsServiceKeyOperations;
diff --git a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyTypeTranslations.spec.tsx b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyTypeTranslations.spec.tsx
index 1c08795cd6b4..a916f9533012 100644
--- a/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyTypeTranslations.spec.tsx
+++ b/packages/manager/apps/key-management-service/src/hooks/serviceKey/useServiceKeyTypeTranslations.spec.tsx
@@ -1,7 +1,16 @@
-import { describe, expect, it, test } from 'vitest';
+import { describe, expect, it, test, vi } from 'vitest';
import { OkmsKeyTypes } from '@/types/okmsServiceKey.type';
import { useServiceKeyTypeTranslations } from './useServiceKeyTypeTranslations';
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (translationKey: string) => translationKey,
+ i18n: {
+ changeLanguage: () => new Promise(() => {}),
+ },
+ }),
+}));
+
describe('get service key type translation ', () => {
const useCases: {
type: OkmsKeyTypes;
diff --git a/packages/manager/apps/key-management-service/src/mocks/okms.mock.ts b/packages/manager/apps/key-management-service/src/mocks/okms.mock.ts
new file mode 100644
index 000000000000..c7a1103b4b51
--- /dev/null
+++ b/packages/manager/apps/key-management-service/src/mocks/okms.mock.ts
@@ -0,0 +1,42 @@
+import { PathParams } from 'msw';
+import { Handler } from '../../../../../../playwright-helpers';
+import { OKMS } from '@/types/okms.type';
+
+export const okmsList: OKMS[] = [
+ {
+ iam: {
+ displayName: 'kms-1',
+ id: '1b4e7c8e-d1b8-4b46-a584-52c8b4b0225c',
+ urn: `urn:v1:eu:resource:okms:1b4e7c8e-d1b8-4b46-a584-52c8b4b0225c`,
+ },
+ id: '7f3a82ac-a8d8-4c2a-ab0c-f6e86ddf6a7c',
+ kmipEndpoint: 'eu-west-rbx.okms.ovh.net:1234',
+ region: 'EU_WEST_RBX',
+ restEndpoint: 'https://eu-west-rbx.okms.ovh.net',
+ swaggerEndpoint: '"https://swagger-eu-west-rbx.okms.ovh.net',
+ },
+];
+
+export type GetOkmsMocksParams = {
+ nbOkms?: number;
+};
+
+const findOkmsById = (params: PathParams) =>
+ okmsList.find(({ id }) => id === params.id);
+
+export const getOkmsMocks = ({
+ nbOkms = okmsList.length,
+}: GetOkmsMocksParams): Handler[] => [
+ {
+ url: '/okms/resource/:id',
+ response: (_: unknown, params: PathParams) => findOkmsById(params),
+ status: 200,
+ api: 'v2',
+ },
+ {
+ url: '/okms/resource',
+ response: okmsList.slice(0, nbOkms),
+ status: 200,
+ api: 'v2',
+ },
+];
diff --git a/packages/manager/apps/key-management-service/src/mocks/services.mock.ts b/packages/manager/apps/key-management-service/src/mocks/services.mock.ts
new file mode 100644
index 000000000000..19fe0b3e8db6
--- /dev/null
+++ b/packages/manager/apps/key-management-service/src/mocks/services.mock.ts
@@ -0,0 +1,36 @@
+import { KMSServiceInfos, OkmsState } from '@/types/okmsService.type';
+import { Handler } from '../../../../../../playwright-helpers';
+
+const serviceList: KMSServiceInfos[] = [
+ {
+ billing: {
+ lifecycle: { current: { creationDate: '2024-04-12T18:00:00.000Z' } },
+ nextBillingDate: '2024-05-12T18:00:00.000Z',
+ },
+ customer: { contacts: [{ customerCode: 'code', type: 'type' }] },
+ resource: {
+ displayName: 'name',
+ name: 'name',
+ product: { name: 'name', description: 'descripton' },
+ resellingProvider: 'test',
+ state: OkmsState.Active,
+ },
+ },
+];
+
+export const getServicesMocks = (): Handler[] => [
+ {
+ url: '/services/:id',
+ response: serviceList[0],
+ status: 200,
+ method: 'get',
+ api: 'v6',
+ },
+ {
+ url: '/services',
+ response: () => [1234567890],
+ status: 200,
+ method: 'get',
+ api: 'v6',
+ },
+];
diff --git a/packages/manager/apps/key-management-service/src/pages/credential/create/CreateAddIdentities.component.tsx b/packages/manager/apps/key-management-service/src/pages/credential/create/CreateAddIdentities.component.tsx
index 820c776c97b0..4de995d7eb00 100644
--- a/packages/manager/apps/key-management-service/src/pages/credential/create/CreateAddIdentities.component.tsx
+++ b/packages/manager/apps/key-management-service/src/pages/credential/create/CreateAddIdentities.component.tsx
@@ -83,9 +83,9 @@ const CreateAddIdentities = ({
)}
-
-
-
+
+
+
>
)}