diff --git a/packages/manager/apps/pci-billing/src/pages/billing/estimate/Alerts.part.tsx b/packages/manager/apps/pci-billing/src/pages/billing/estimate/Alerts.part.tsx index c17dcd881b7d..d1c6d0c74134 100644 --- a/packages/manager/apps/pci-billing/src/pages/billing/estimate/Alerts.part.tsx +++ b/packages/manager/apps/pci-billing/src/pages/billing/estimate/Alerts.part.tsx @@ -30,6 +30,7 @@ import { useState } from 'react'; import { ApiError } from '@ovh-ux/manager-core-api'; import { useNotifications } from '@ovh-ux/manager-react-components'; import { Currency } from '@ovh-ux/manager-config'; +import { useProjectRights } from '@ovh-ux/manager-pci-common'; import { AlertModalComponent } from '@/pages/billing/estimate/components/AlertModal.component'; import queryClient from '@/queryClient'; @@ -72,11 +73,13 @@ export const AlertsPart = ({ onCreate, onUpdate, onDelete, - isLoading, + isLoading: isAlertDataLoading, }: TAlertsPart): JSX.Element => { const { t: tEstimate } = useTranslation('estimate'); const { addError } = useNotifications(); + const { hasReadWriteRights, isPending: isRightsPending } = useProjectRights(); + const isLoading = isAlertDataLoading || isRightsPending; const [isModalOpen, setIsModalOpen] = useState(false); @@ -212,48 +215,54 @@ export const AlertsPart = ({
+ {hasReadWriteRights && ( + <> + + {tEstimate('cpbe_estimate_alert_edit')}{' '} + + remove()} + > + {tEstimate('cpbe_estimate_alert_delete')}{' '} + + + )} +
+ + ) : ( + hasReadWriteRights && ( +
- {tEstimate('cpbe_estimate_alert_edit')}{' '} - - remove()} + onClick={openModal} + disabled={!!currentPricesError || undefined} > - {tEstimate('cpbe_estimate_alert_delete')}{' '} +
- - ) : ( -
- - -
+ ) )} )} diff --git a/packages/manager/apps/pci-billing/src/setupTests.tsx b/packages/manager/apps/pci-billing/src/setupTests.tsx index 1758a8ea03e7..9d16f52b833a 100644 --- a/packages/manager/apps/pci-billing/src/setupTests.tsx +++ b/packages/manager/apps/pci-billing/src/setupTests.tsx @@ -25,6 +25,10 @@ vi.mock('@ovh-ux/manager-pci-common', async () => { projectName: 'project-name', project_id: 'project-id', }), + useProjectRights: vi.fn().mockReturnValue({ + hasReadWriteRights: true, + isPending: false, + }), }; }); @@ -63,6 +67,7 @@ vi.mock('react-i18next', () => ({ }, }), Trans: ({ children }: { children: string }) => children, + Translation: ({ children }: { children: string }) => children, })); const mocks = vi.hoisted(() => ({