Skip to content

Commit

Permalink
Adapt code from modifications in commons-ui to remove a maximum occur…
Browse files Browse the repository at this point in the history
…rences of 'any' type (#601)

* Adapt code from modifications in commons-ui to remove 'any' type ...

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
  • Loading branch information
FranckLecuyer authored Jan 27, 2025
1 parent c0cbc61 commit 310570b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions src/components/menus/content-contextual-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
activeElement.description,
activeElement.elementUuid,
selectedDirectory?.elementUuid,
// @ts-expect-error TODO: seems to be an object but we await a string???
activeElement.specificMetadata.type
);
break;
Expand Down Expand Up @@ -222,7 +221,6 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
activeElement.elementUuid,
undefined,
activeElement.type,
// @ts-expect-error TODO: seems to be an object but we await a string???
activeElement.specificMetadata.type
).catch((error) => handleDuplicateError(error.message));
break;
Expand Down Expand Up @@ -314,6 +312,7 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
);

const [renameCB, renameState] = useDeferredFetch(
// @ts-expect-error refacto typing of useDefferedFetch
renameElement,
(elementUuid: string, renamedElement: any[]) => {
// if copied element is renamed
Expand Down Expand Up @@ -717,7 +716,6 @@ export default function ContentContextualMenu(props: Readonly<ContentContextualM
onClose={handleCloseDialog}
sourceFilterForExplicitNamingConversion={{
id: activeElement.elementUuid,
// @ts-expect-error TODO: seems to be an object but we await a string???
equipmentType: activeElement.specificMetadata.equipmentType,
}}
activeDirectory={activeDirectory}
Expand Down
1 change: 1 addition & 0 deletions src/components/menus/directory-tree-contextual-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default function DirectoryTreeContextualMenu(props: Readonly<DirectoryTre
);

const [renameCB, renameState] = useDeferredFetch(
// @ts-expect-error refacto typing of useDefferedFetch
renameElement,
handleCloseDialog,
(HTTPStatusCode: number) => {
Expand Down
5 changes: 4 additions & 1 deletion src/components/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const otherProperties = {
lastModifiedBy: 'user1',
children: [],
parentUuid: null,
specificMetadata: {},
specificMetadata: {
type: '',
equipmentType: '',
},
};

test('boot1', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/utils/directory-content-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const formatMetadata = (
childrenMetadata: Record<UUID, ElementAttributes>
): ElementAttributes => ({
...data,
// @ts-expect-error TODO: "Type `object` is not assignable to type `string`"
subtype: childrenMetadata[data.elementUuid]?.specificMetadata.type,
hasMetadata: !!childrenMetadata[data.elementUuid],
});
Expand Down
7 changes: 5 additions & 2 deletions src/components/utils/downloadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const triggerDownload = ({ blob, filename }: DownloadData): void => {
const downloadStrategies: { [key in ElementType]?: (element: ElementAttributes) => Promise<DownloadData> } = {
[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) => {
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/renderers/type-cell-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function TypeCellRenderer({ data, childrenMetadata }: Readonly<TypeCellRe
data?.type,
specificMetadata?.type?.toString(),
data?.type === ElementType.SPREADSHEET_CONFIG
? toTitleCase(specificMetadata.sheetType?.toString()) ?? null
? toTitleCase(specificMetadata.sheetType ?? 'no-type') ?? null
: specificMetadata.format?.toString() ?? null,
intl
)}
Expand Down

0 comments on commit 310570b

Please sign in to comment.