From 5994f687594bd69f86a10ec8df39da4e84c572bc Mon Sep 17 00:00:00 2001 From: CDS Translator Agent Date: Fri, 27 Sep 2024 11:01:04 +0000 Subject: [PATCH 1/5] fix(i18n): add missing translations [CDS 3343] Signed-off-by: CDS Translator Agent From 027d8d6532125f184c0a0809af854c2133c0768b Mon Sep 17 00:00:00 2001 From: CDS Translator Agent Date: Fri, 27 Sep 2024 11:01:04 +0000 Subject: [PATCH 2/5] fix(i18n): add missing translations [CDS 3343] Signed-off-by: CDS Translator Agent From 7dd2b64e283d546fe51df161f229d4b5a47caa6e Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Thu, 21 Nov 2024 16:53:57 +0100 Subject: [PATCH 3/5] feat(pci.rancher): ad clipboard id ref: TAPC-1024 Signed-off-by: Pierre-Philippe --- .../ClipBoardCell/ClipBoardCell.component.tsx | 21 +++++++++++++++++++ .../TableContainer.component.tsx | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx diff --git a/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx new file mode 100644 index 000000000000..8796076e43bf --- /dev/null +++ b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import { Clipboard, DataGridTextCell } from '@ovh-ux/manager-react-components'; +import { Cell } from '@tanstack/react-table'; +import './Table.scss'; +import { RancherService } from '@/types/api.type'; + +interface DataGridCellInterface { + readonly cell: Cell; +} + +const DataGridCell = ({ cell }: DataGridCellInterface) => { + const id = cell.renderValue() as RancherService['id']; + + return ( + + + + ); +}; + +export default DataGridCell; diff --git a/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx index 5134d8bd0a1c..572b9e9f32a8 100644 --- a/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx @@ -23,6 +23,7 @@ import '../Table.scss'; import { deleteRancherServiceQueryKey } from '@/data/api/services'; import StatusChip from '../../StatusChip/StatusChip.component'; import DisplayCellNumber from '../NumberCell/NumberCell.component'; +import ClipBoardCell from '../ClipBoardCell/ClipBoardCell.component'; export default function TableContainer({ data, @@ -58,6 +59,12 @@ export default function TableContainer({ accessorKey: 'currentState.name', cell: LinkService, }, + { + id: 'id', + header: 'ID', + accessorKey: 'id', + cell: ClipBoardCell, + }, { id: 'serviceLevel', header: t('serviceLevel'), From ff8351b4d4d1a9c7f622d34004217069057c65c0 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Fri, 22 Nov 2024 14:30:05 +0100 Subject: [PATCH 4/5] feat(pci.rancher): update cellboard id ref: TAPC-1024 Signed-off-by: Pierre-Philippe --- .../manager/apps/pci-rancher/package.json | 3 +- .../ClipBoardCell/ClipBoardCell.component.tsx | 7 ++- .../ClipBoardCell/ClipBoardCell.test.tsx | 47 +++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.test.tsx diff --git a/packages/manager/apps/pci-rancher/package.json b/packages/manager/apps/pci-rancher/package.json index da127e6d8098..a3b42b2588c4 100644 --- a/packages/manager/apps/pci-rancher/package.json +++ b/packages/manager/apps/pci-rancher/package.json @@ -18,7 +18,8 @@ "start": "lerna exec --stream --scope='@ovh-ux/manager-pci-rancher-app' --include-dependencies -- npm run build --if-present", "start:dev": "lerna exec --stream --scope='@ovh-ux/manager-pci-rancher-app' --include-dependencies -- npm run dev --if-present", "start:watch": "lerna exec --stream --parallel --scope='@ovh-ux/manager-pci-rancher-app' --include-dependencies -- npm run dev:watch --if-present", - "test": "jest" + "test": "jest", + "test:watch": "jest --watch" }, "dependencies": { "@ovh-ux/manager-config": "^8.0.0", diff --git a/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx index 8796076e43bf..a1ec61991a46 100644 --- a/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx @@ -1,14 +1,13 @@ import React from 'react'; import { Clipboard, DataGridTextCell } from '@ovh-ux/manager-react-components'; import { Cell } from '@tanstack/react-table'; -import './Table.scss'; import { RancherService } from '@/types/api.type'; -interface DataGridCellInterface { +interface ClipBoardCellProps { readonly cell: Cell; } -const DataGridCell = ({ cell }: DataGridCellInterface) => { +const ClipBoardCell = ({ cell }: ClipBoardCellProps) => { const id = cell.renderValue() as RancherService['id']; return ( @@ -18,4 +17,4 @@ const DataGridCell = ({ cell }: DataGridCellInterface) => { ); }; -export default DataGridCell; +export default ClipBoardCell; diff --git a/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.test.tsx b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.test.tsx new file mode 100644 index 000000000000..c5b60af0eea8 --- /dev/null +++ b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.test.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import * as managerReactComponents from '@ovh-ux/manager-react-components'; +import { Cell } from '@tanstack/react-table'; +import { screen } from '@testing-library/react'; +import ClipBoardCell from './ClipBoardCell.component'; + +import { render } from '@/utils/test/test.provider'; +import { RancherService } from '@/types/api.type'; + +jest.mock('@ovh-ux/manager-react-components', () => ({ + ...jest.requireActual('@ovh-ux/manager-react-components'), + Clipboard: jest.fn(), + DataGridTextCell: jest.fn(), +})); + +const mockCell = (value: string): Cell => + ({ + renderValue: () => value, + } as Cell); + +afterEach(() => {}); + +const setupSpecTest = (cell: Cell) => + render(); + +describe('DataGridCell', () => { + jest + .spyOn(managerReactComponents, 'Clipboard') + .mockImplementation(({ value }) => ( +
{value}
+ )); + jest + .spyOn(managerReactComponents, 'DataGridTextCell') + .mockImplementation(({ children }) => <>{children}); + + it('should render the component with the correct value', () => { + const cell = mockCell('12345'); + setupSpecTest(cell); + expect(screen.getByTestId('clipboard')).toHaveTextContent('12345'); + }); + + it('should render the component with a different value', () => { + const cell = mockCell('67890'); + setupSpecTest(cell); + expect(screen.getByTestId('clipboard')).toHaveTextContent('67890'); + }); +}); From e3b638d2f12e56ec0510fa5b5400bc2846ac801a Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 26 Nov 2024 11:02:48 +0100 Subject: [PATCH 5/5] feat(pci.rancher): maj pt ref: TAPC-1024 Signed-off-by: Pierre-Philippe --- .../components/Table/ClipBoardCell/ClipBoardCell.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx index a1ec61991a46..779652a1e863 100644 --- a/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/Table/ClipBoardCell/ClipBoardCell.component.tsx @@ -8,7 +8,7 @@ interface ClipBoardCellProps { } const ClipBoardCell = ({ cell }: ClipBoardCellProps) => { - const id = cell.renderValue() as RancherService['id']; + const id = cell.renderValue(); return (