From 310570b9c41ee015294080570189325a464115f8 Mon Sep 17 00:00:00 2001 From: FranckLecuyer <47824306+FranckLecuyer@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:08:37 +0100 Subject: [PATCH] Adapt code from modifications in commons-ui to remove a maximum occurrences of 'any' type (#601) * Adapt code from modifications in commons-ui to remove 'any' type ... Signed-off-by: Franck LECUYER --- package-lock.json | 8 ++++---- package.json | 2 +- src/components/menus/content-contextual-menu.tsx | 4 +--- src/components/menus/directory-tree-contextual-menu.tsx | 1 + src/components/tree.test.ts | 5 ++++- src/components/utils/directory-content-utils.ts | 1 - src/components/utils/downloadUtils.ts | 7 +++++-- src/components/utils/renderers/type-cell-renderer.tsx | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c744586..bf638e7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.79.0", + "@gridsuite/commons-ui": "0.80.0", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -3013,9 +3013,9 @@ } }, "node_modules/@gridsuite/commons-ui": { - "version": "0.79.0", - "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.79.0.tgz", - "integrity": "sha512-+oOrb8BShIghtxcEnqnFH6LTaGdCznVAn02CUVOutLlYOrNLKcgqNoPt3DLZAoNEv51UftYTZyAkU1z6/tlgMw==", + "version": "0.80.0", + "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.80.0.tgz", + "integrity": "sha512-2KxQEOMD2ys+3Q/TlYbjf2o6xdUMtISGQEIMHQXWqV85cnEfaQr3vst0G8MELm/r7Y7xcnmst5K2QcX3Gl+8FQ==", "dependencies": { "@react-querybuilder/dnd": "^7.2.0", "@react-querybuilder/material": "^7.2.0", diff --git a/package.json b/package.json index fee6fa0f..015d2155 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.79.0", + "@gridsuite/commons-ui": "0.80.0", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", diff --git a/src/components/menus/content-contextual-menu.tsx b/src/components/menus/content-contextual-menu.tsx index 40bfa94d..f331ab3b 100644 --- a/src/components/menus/content-contextual-menu.tsx +++ b/src/components/menus/content-contextual-menu.tsx @@ -192,7 +192,6 @@ export default function ContentContextualMenu(props: Readonly handleDuplicateError(error.message)); break; @@ -314,6 +312,7 @@ export default function ContentContextualMenu(props: Readonly { // if copied element is renamed @@ -717,7 +716,6 @@ export default function ContentContextualMenu(props: Readonly { diff --git a/src/components/tree.test.ts b/src/components/tree.test.ts index 75911218..56713d7b 100644 --- a/src/components/tree.test.ts +++ b/src/components/tree.test.ts @@ -20,7 +20,10 @@ const otherProperties = { lastModifiedBy: 'user1', children: [], parentUuid: null, - specificMetadata: {}, + specificMetadata: { + type: '', + equipmentType: '', + }, }; test('boot1', () => { diff --git a/src/components/utils/directory-content-utils.ts b/src/components/utils/directory-content-utils.ts index 4ad2f96d..3230c8fc 100644 --- a/src/components/utils/directory-content-utils.ts +++ b/src/components/utils/directory-content-utils.ts @@ -22,7 +22,6 @@ export const formatMetadata = ( childrenMetadata: Record ): ElementAttributes => ({ ...data, - // @ts-expect-error TODO: "Type `object` is not assignable to type `string`" subtype: childrenMetadata[data.elementUuid]?.specificMetadata.type, hasMetadata: !!childrenMetadata[data.elementUuid], }); diff --git a/src/components/utils/downloadUtils.ts b/src/components/utils/downloadUtils.ts index 66c3aa74..443641cf 100644 --- a/src/components/utils/downloadUtils.ts +++ b/src/components/utils/downloadUtils.ts @@ -35,7 +35,7 @@ const triggerDownload = ({ blob, filename }: DownloadData): void => { const downloadStrategies: { [key in ElementType]?: (element: ElementAttributes) => Promise } = { [ElementType.CASE]: async (element: ElementAttributes) => { const result = await downloadCase(element.elementUuid); - const filename = result.headers.get('caseName'); + const filename = result.headers.get('caseName') ?? element.elementName; return { blob: await result.blob(), filename }; }, [ElementType.SPREADSHEET_CONFIG]: async (element: ElementAttributes) => { @@ -113,7 +113,10 @@ export function useDownloadUtils() { abortController2 ); - let downloadFileName = result.headers.get('Content-Disposition').split('filename=')[1]; + let downloadFileName = + result.headers.get('Content-Disposition')?.split('filename=')[1] ?? + fileName ?? + caseElement.elementName; // We remove quotes downloadFileName = downloadFileName.substring(1, downloadFileName.length - 1); diff --git a/src/components/utils/renderers/type-cell-renderer.tsx b/src/components/utils/renderers/type-cell-renderer.tsx index d6bde931..87150e34 100644 --- a/src/components/utils/renderers/type-cell-renderer.tsx +++ b/src/components/utils/renderers/type-cell-renderer.tsx @@ -68,7 +68,7 @@ export function TypeCellRenderer({ data, childrenMetadata }: Readonly