From 06f602082b4ebf7fe7a4b5fd4e443ee951e5634c Mon Sep 17 00:00:00 2001 From: spaenleh Date: Mon, 2 Oct 2023 13:25:33 +0200 Subject: [PATCH 1/7] fix: edit dialog does not allow to edit twice --- src/components/common/EditButton.tsx | 20 +- src/components/item/form/EditModalWrapper.tsx | 72 ++- src/components/main/ItemsToolbar.tsx | 22 +- yarn.lock | 454 ++++++++++++++++-- 4 files changed, 479 insertions(+), 89 deletions(-) diff --git a/src/components/common/EditButton.tsx b/src/components/common/EditButton.tsx index 8c3dd6c9d..0bc86305e 100644 --- a/src/components/common/EditButton.tsx +++ b/src/components/common/EditButton.tsx @@ -1,11 +1,14 @@ import { useState } from 'react'; +import { Dialog } from '@mui/material'; + import { DiscriminatedItem, ItemType } from '@graasp/sdk'; import { EditButton as GraaspEditButton } from '@graasp/ui'; import { useBuilderTranslation } from '../../config/i18n'; import { EDIT_ITEM_BUTTON_CLASS, + EDIT_MODAL_ID, buildEditButtonId, } from '../../config/selectors'; import { BUILDER } from '../../langs/constants'; @@ -50,12 +53,19 @@ const EditButton = ({ item }: Props): JSX.Element => { return ( <> - + // onClose={onClose} + maxWidth="sm" + fullWidth + > + + ) => void; updatedProperties: Partial; } - export type EditModalContentType = CT; type Props = { ComponentType: EditModalContentType; - open: boolean; item: DiscriminatedItem; setOpen: Dispatch; @@ -47,7 +42,6 @@ const EditModalWrapper = ({ item, setOpen, ComponentType, - open, }: Props): JSX.Element => { const { t: translateBuilder } = useBuilderTranslation(); const { t: translateCommon } = useCommonTranslation(); @@ -56,26 +50,27 @@ const EditModalWrapper = ({ // updated properties are separated from the original item // so only necessary properties are sent when editing - const [updatedProperties, setUpdatedItem] = useState< - Partial - >({}); - const [isConfirmButtonDisabled, setConfirmButtonDisabled] = useState(false); + const [updatedItem, setUpdatedItem] = useState(item); + + const onClose = () => { + setOpen(false); + }; const submit = () => { - if (isConfirmButtonDisabled) { - return; - } + // if (isConfirmButtonDisabled) { + // return; + // } if ( !isItemValid({ ...item, - ...updatedProperties, + ...updatedItem, } as DiscriminatedItem) ) { toast.error(translateBuilder(BUILDER.EDIT_ITEM_ERROR_MESSAGE)); return; } - setConfirmButtonDisabled(true); + // setConfirmButtonDisabled(true); // add id to changed properties if (!item?.id) { @@ -84,34 +79,33 @@ const EditModalWrapper = ({ payload: { error: new Error(FAILURE_MESSAGES.UNEXPECTED_ERROR) }, }); } else { - editItem({ id: item.id, ...updatedProperties }); + editItem({ + id: updatedItem.id, + name: updatedItem.name, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + description: updatedItem.description, + // todo: find a fix since the folder has an invalid extra + // extra: updatedItem.extra, + }); } - setOpen(false); + onClose(); }; const setChanges = (payload: Partial) => { - setUpdatedItem({ ...updatedProperties, ...payload } as DiscriminatedItem); + setUpdatedItem({ ...updatedItem, ...payload } as DiscriminatedItem); }; - const onClose = () => { - setOpen(false); - setUpdatedItem({}); - // schedule button disable state reset AFTER end of click event handling - // todo: factor out this logic to graasp-ui - setTimeout(() => setConfirmButtonDisabled(false), DOUBLE_CLICK_DELAY_MS); - }; + // eslint-disable-next-line no-console + console.log('current', updatedItem); + // eslint-disable-next-line no-console + console.log('item valid', isItemValid(updatedItem)); return ( - + <> - {translateBuilder(BUILDER.EDIT_ITEM_MODAL_TITLE, { name: item.name })} + {translateBuilder(BUILDER.EDIT_ITEM_MODAL_TITLE)} @@ -130,13 +124,13 @@ const EditModalWrapper = ({ + ); }; export default EditModalWrapper; diff --git a/src/components/main/ItemsToolbar.tsx b/src/components/main/ItemsToolbar.tsx index 42f4059b5..ce682ac62 100644 --- a/src/components/main/ItemsToolbar.tsx +++ b/src/components/main/ItemsToolbar.tsx @@ -1,4 +1,4 @@ -import { Grid, Stack, Typography } from '@mui/material'; +import { Stack, Typography } from '@mui/material'; type Props = { title: string; @@ -6,18 +6,14 @@ type Props = { }; const ItemsToolbar = ({ title, headerElements }: Props): JSX.Element => ( - - - - {title} - - - - - {headerElements} - - - + + + {title} + + + {headerElements} + + ); export default ItemsToolbar; diff --git a/yarn.lock b/yarn.lock index 68d7177e9..ce414cc51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2902,6 +2902,26 @@ __metadata: languageName: node linkType: hard +"@smithy/abort-controller@npm:^2.0.10": + version: 2.0.10 + resolution: "@smithy/abort-controller@npm:2.0.10" + dependencies: + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: e0b3a5573c8a7b7ef2bd30dfa4ea50968a7d5c4046b5b9190ad885e33bbe4a08d3c023c4b8bee10bf01dcad85421d7ff35658223c605fd994de3d14835f24279 + languageName: node + linkType: hard + +"@smithy/abort-controller@npm:^2.0.11": + version: 2.0.11 + resolution: "@smithy/abort-controller@npm:2.0.11" + dependencies: + "@smithy/types": ^2.4.0 + tslib: ^2.5.0 + checksum: 33a639bb1dd57a4495ef70f3d7ffa6f7eb40256121412e2d1e1d353524d140e483160871653bd9af67a0ec751ffbcae60a3972f85c996569f0c7a88064447dab + languageName: node + linkType: hard + "@smithy/abort-controller@npm:^2.0.12": version: 2.0.12 resolution: "@smithy/abort-controller@npm:2.0.12" @@ -2931,7 +2951,20 @@ __metadata: languageName: node linkType: hard -"@smithy/config-resolver@npm:^2.0.11, @smithy/config-resolver@npm:^2.0.16, @smithy/config-resolver@npm:^2.0.8": +"@smithy/config-resolver@npm:^2.0.11, @smithy/config-resolver@npm:^2.0.8": + version: 2.0.11 + resolution: "@smithy/config-resolver@npm:2.0.11" + dependencies: + "@smithy/node-config-provider": ^2.0.13 + "@smithy/types": ^2.3.4 + "@smithy/util-config-provider": ^2.0.0 + "@smithy/util-middleware": ^2.0.3 + tslib: ^2.5.0 + checksum: 57a14ccf65a472881b1d30589a81637157b52824b20f69a54c5bda291791c7585a07879e8d50524eb710f46064d2258064496bf7f0b66d675410447218f9c7b6 + languageName: node + linkType: hard + +"@smithy/config-resolver@npm:^2.0.16": version: 2.0.16 resolution: "@smithy/config-resolver@npm:2.0.16" dependencies: @@ -2957,6 +2990,18 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-codec@npm:^2.0.10": + version: 2.0.10 + resolution: "@smithy/eventstream-codec@npm:2.0.10" + dependencies: + "@aws-crypto/crc32": 3.0.0 + "@smithy/types": ^2.3.4 + "@smithy/util-hex-encoding": ^2.0.0 + tslib: ^2.5.0 + checksum: a488882308001fc898370bfe26ed17eed7cdac497648dfe6949b332af7f381cf65436b6b9619a7b6fee16217eda4e9c0ed9c1567e2ff24e6eddf5e6696eb0812 + languageName: node + linkType: hard + "@smithy/eventstream-codec@npm:^2.0.12": version: 2.0.12 resolution: "@smithy/eventstream-codec@npm:2.0.12" @@ -2969,7 +3014,7 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-browser@npm:^2.0.10, @smithy/eventstream-serde-browser@npm:^2.0.7": +"@smithy/eventstream-serde-browser@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/eventstream-serde-browser@npm:2.0.12" dependencies: @@ -2980,7 +3025,18 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-config-resolver@npm:^2.0.10, @smithy/eventstream-serde-config-resolver@npm:^2.0.7": +"@smithy/eventstream-serde-browser@npm:^2.0.7": + version: 2.0.10 + resolution: "@smithy/eventstream-serde-browser@npm:2.0.10" + dependencies: + "@smithy/eventstream-serde-universal": ^2.0.10 + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: d980b597ed5515ad4d2eb474d0a418bf5f7679d06cc6dcbc32158c9287cf90dbc4d9b3fc395ae545515a6180495782d1a385f0dd0b5281084b9a40d1e1306ed2 + languageName: node + linkType: hard + +"@smithy/eventstream-serde-config-resolver@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/eventstream-serde-config-resolver@npm:2.0.12" dependencies: @@ -2990,7 +3046,17 @@ __metadata: languageName: node linkType: hard -"@smithy/eventstream-serde-node@npm:^2.0.10, @smithy/eventstream-serde-node@npm:^2.0.7": +"@smithy/eventstream-serde-config-resolver@npm:^2.0.7": + version: 2.0.10 + resolution: "@smithy/eventstream-serde-config-resolver@npm:2.0.10" + dependencies: + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: 83f8755d98c322d384dfbb7f2da83edf9abc0a25956b0fddb5682ca09dc30d5fbaf13761270721539a55cbdec2f8fbb4931e892a9ad0369694ddbaa26be33caf + languageName: node + linkType: hard + +"@smithy/eventstream-serde-node@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/eventstream-serde-node@npm:2.0.12" dependencies: @@ -3001,6 +3067,28 @@ __metadata: languageName: node linkType: hard +"@smithy/eventstream-serde-node@npm:^2.0.7": + version: 2.0.10 + resolution: "@smithy/eventstream-serde-node@npm:2.0.10" + dependencies: + "@smithy/eventstream-serde-universal": ^2.0.10 + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: cee9c97e1c81a372c7c072174fe2b748e7d56881947266c3e266390a49da1479dc150ded11efed8215c73889a55f7b5806945e557ebaf57e27524d93f07f4863 + languageName: node + linkType: hard + +"@smithy/eventstream-serde-universal@npm:^2.0.10": + version: 2.0.10 + resolution: "@smithy/eventstream-serde-universal@npm:2.0.10" + dependencies: + "@smithy/eventstream-codec": ^2.0.10 + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: d5acdb82125ea2bcb7df46f27c07d611c19aeaf5739909fd085b22946c431e838ea8a45802e9944692adbacf93461e6d577e961a273d1e4d78bf360ee0cc5e4f + languageName: node + linkType: hard + "@smithy/eventstream-serde-universal@npm:^2.0.12": version: 2.0.12 resolution: "@smithy/eventstream-serde-universal@npm:2.0.12" @@ -3025,7 +3113,20 @@ __metadata: languageName: node linkType: hard -"@smithy/hash-blob-browser@npm:^2.0.10, @smithy/hash-blob-browser@npm:^2.0.7": +"@smithy/fetch-http-handler@npm:^2.2.0": + version: 2.2.0 + resolution: "@smithy/fetch-http-handler@npm:2.2.0" + dependencies: + "@smithy/protocol-http": ^3.0.6 + "@smithy/querystring-builder": ^2.0.10 + "@smithy/types": ^2.3.4 + "@smithy/util-base64": ^2.0.0 + tslib: ^2.5.0 + checksum: e2c175b04562af9018913ffcd1d727aed2be5f79dc6668dd621a6c3a5d17ef82f312cec1cace1ab091557fe81ebee4cb5d3b8a6de5d493181b9107e6ca910b81 + languageName: node + linkType: hard + +"@smithy/hash-blob-browser@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/hash-blob-browser@npm:2.0.12" dependencies: @@ -3037,6 +3138,19 @@ __metadata: languageName: node linkType: hard +"@smithy/hash-blob-browser@npm:^2.0.7": + version: 2.0.10 + resolution: "@smithy/hash-blob-browser@npm:2.0.10" + dependencies: + "@smithy/protocol-http": ^3.0.7 + "@smithy/querystring-builder": ^2.0.11 + "@smithy/types": ^2.3.5 + "@smithy/util-base64": ^2.0.0 + tslib: ^2.5.0 + checksum: e6dffccef9de0df199144b4bbdc1b4a2347dcdf4406d92ea89357549143715bf66e1e189faa08ad58e886d4aab91fe471124bc60d8827ebd644f1f18dbc79054 + languageName: node + linkType: hard + "@smithy/hash-node@npm:^2.0.10, @smithy/hash-node@npm:^2.0.7": version: 2.0.12 resolution: "@smithy/hash-node@npm:2.0.12" @@ -3049,7 +3163,7 @@ __metadata: languageName: node linkType: hard -"@smithy/hash-stream-node@npm:^2.0.10, @smithy/hash-stream-node@npm:^2.0.7": +"@smithy/hash-stream-node@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/hash-stream-node@npm:2.0.12" dependencies: @@ -3060,7 +3174,18 @@ __metadata: languageName: node linkType: hard -"@smithy/invalid-dependency@npm:^2.0.10, @smithy/invalid-dependency@npm:^2.0.7": +"@smithy/hash-stream-node@npm:^2.0.7": + version: 2.0.9 + resolution: "@smithy/hash-stream-node@npm:2.0.9" + dependencies: + "@smithy/types": ^2.3.3 + "@smithy/util-utf8": ^2.0.0 + tslib: ^2.5.0 + checksum: fbb29f7f5401c702c92c8d15b43b5a2b5249e9ad0a055c6a235a816c64d7efa28b27eecbef06c783f70da3c168c677db5303e5e0903100e0ac8ead93c21a3791 + languageName: node + linkType: hard + +"@smithy/invalid-dependency@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/invalid-dependency@npm:2.0.12" dependencies: @@ -3070,6 +3195,16 @@ __metadata: languageName: node linkType: hard +"@smithy/invalid-dependency@npm:^2.0.7": + version: 2.0.9 + resolution: "@smithy/invalid-dependency@npm:2.0.9" + dependencies: + "@smithy/types": ^2.3.3 + tslib: ^2.5.0 + checksum: 52353e053a0dc30d6f2f1e29872c2cb52cd7edfb607c7cd209daf858d5034f284c86b22d6ac57818774e8ad5a51e0f4cf9c612cf781c4c8629d6ab4382c73c04 + languageName: node + linkType: hard + "@smithy/is-array-buffer@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/is-array-buffer@npm:2.0.0" @@ -3079,7 +3214,7 @@ __metadata: languageName: node linkType: hard -"@smithy/md5-js@npm:^2.0.10, @smithy/md5-js@npm:^2.0.7": +"@smithy/md5-js@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/md5-js@npm:2.0.12" dependencies: @@ -3090,6 +3225,17 @@ __metadata: languageName: node linkType: hard +"@smithy/md5-js@npm:^2.0.7": + version: 2.0.10 + resolution: "@smithy/md5-js@npm:2.0.10" + dependencies: + "@smithy/types": ^2.3.5 + "@smithy/util-utf8": ^2.0.0 + tslib: ^2.5.0 + checksum: 64169515aa9187723c3c3e5fa6e3fdaac0384da2b8a8a386874bbb4bbff93c362d6211c5b94298ac2b0283a479f2133510032e892f22c181e9b7d7c2506f4218 + languageName: node + linkType: hard + "@smithy/middleware-content-length@npm:^2.0.12, @smithy/middleware-content-length@npm:^2.0.9": version: 2.0.14 resolution: "@smithy/middleware-content-length@npm:2.0.14" @@ -3101,7 +3247,7 @@ __metadata: languageName: node linkType: hard -"@smithy/middleware-endpoint@npm:^2.0.10, @smithy/middleware-endpoint@npm:^2.0.7": +"@smithy/middleware-endpoint@npm:^2.0.10": version: 2.1.3 resolution: "@smithy/middleware-endpoint@npm:2.1.3" dependencies: @@ -3116,6 +3262,19 @@ __metadata: languageName: node linkType: hard +"@smithy/middleware-endpoint@npm:^2.0.7": + version: 2.0.9 + resolution: "@smithy/middleware-endpoint@npm:2.0.9" + dependencies: + "@smithy/middleware-serde": ^2.0.9 + "@smithy/types": ^2.3.3 + "@smithy/url-parser": ^2.0.9 + "@smithy/util-middleware": ^2.0.2 + tslib: ^2.5.0 + checksum: 8fe2286d765224e3ff64088549007452d97a2dbfdf3b66e8246d5f3a6340305f176c68651e842aabe40996c85c33c466d860a0a0e9de268f3b95eba05050a5d7 + languageName: node + linkType: hard + "@smithy/middleware-retry@npm:^2.0.10, @smithy/middleware-retry@npm:^2.0.13": version: 2.0.18 resolution: "@smithy/middleware-retry@npm:2.0.18" @@ -3132,7 +3291,7 @@ __metadata: languageName: node linkType: hard -"@smithy/middleware-serde@npm:^2.0.10, @smithy/middleware-serde@npm:^2.0.12, @smithy/middleware-serde@npm:^2.0.7": +"@smithy/middleware-serde@npm:^2.0.10, @smithy/middleware-serde@npm:^2.0.12": version: 2.0.12 resolution: "@smithy/middleware-serde@npm:2.0.12" dependencies: @@ -3142,7 +3301,17 @@ __metadata: languageName: node linkType: hard -"@smithy/middleware-stack@npm:^2.0.0, @smithy/middleware-stack@npm:^2.0.4, @smithy/middleware-stack@npm:^2.0.6": +"@smithy/middleware-serde@npm:^2.0.7, @smithy/middleware-serde@npm:^2.0.9": + version: 2.0.9 + resolution: "@smithy/middleware-serde@npm:2.0.9" + dependencies: + "@smithy/types": ^2.3.3 + tslib: ^2.5.0 + checksum: 4bfa4105c05b18b716d97ee0bca8b4c02e3b823b61e3109eba5722c54eed2a516efdb2916268650684a6f4f4a7f58de775149edafed332d7d01ff9fe033f76a1 + languageName: node + linkType: hard + +"@smithy/middleware-stack@npm:^2.0.0, @smithy/middleware-stack@npm:^2.0.6": version: 2.0.6 resolution: "@smithy/middleware-stack@npm:2.0.6" dependencies: @@ -3152,7 +3321,16 @@ __metadata: languageName: node linkType: hard -"@smithy/node-config-provider@npm:^2.0.10, @smithy/node-config-provider@npm:^2.0.13, @smithy/node-config-provider@npm:^2.1.3": +"@smithy/middleware-stack@npm:^2.0.4, @smithy/service-error-classification@npm:^2.0.5": + version: 2.0.5 + resolution: "@smithy/service-error-classification@npm:2.0.5" + dependencies: + "@smithy/types": ^2.4.0 + checksum: cd4b9fcc5cd940035ca4f3e832f8480d75eb81c90501bdb5c9295c5fd26487ca2e2f3d3efa9a322faeaedf10d6d8324327cd3341fc05d38f8605006ad836abaa + languageName: node + linkType: hard + +"@smithy/node-config-provider@npm:^2.0.10, @smithy/node-config-provider@npm:^2.1.3": version: 2.1.3 resolution: "@smithy/node-config-provider@npm:2.1.3" dependencies: @@ -3164,7 +3342,19 @@ __metadata: languageName: node linkType: hard -"@smithy/node-http-handler@npm:^2.1.3, @smithy/node-http-handler@npm:^2.1.6, @smithy/node-http-handler@npm:^2.1.8": +"@smithy/node-config-provider@npm:^2.0.13": + version: 2.1.1 + resolution: "@smithy/node-config-provider@npm:2.1.1" + dependencies: + "@smithy/property-provider": ^2.0.12 + "@smithy/shared-ini-file-loader": ^2.2.0 + "@smithy/types": ^2.3.5 + tslib: ^2.5.0 + checksum: b9bca5ba2b1ef60221f7bf24e876dabba46652ead428ec31a528ef57ee14af559752736317f870d55f1b90c6bb6c52886194475190a05339235ffe123217a9bd + languageName: node + linkType: hard + +"@smithy/node-http-handler@npm:^2.1.3, @smithy/node-http-handler@npm:^2.1.8": version: 2.1.8 resolution: "@smithy/node-http-handler@npm:2.1.8" dependencies: @@ -3177,6 +3367,19 @@ __metadata: languageName: node linkType: hard +"@smithy/node-http-handler@npm:^2.1.6": + version: 2.1.7 + resolution: "@smithy/node-http-handler@npm:2.1.7" + dependencies: + "@smithy/abort-controller": ^2.0.11 + "@smithy/protocol-http": ^3.0.7 + "@smithy/querystring-builder": ^2.0.11 + "@smithy/types": ^2.3.5 + tslib: ^2.5.0 + checksum: 2a40f8bcb75eddb682691137a4134f33e97daba775945a45513fdfe2bf1dfafc9d74843f3f698eacf64569baf952d19361b2bb28dd19030a6f3cbe9ee5fdecc3 + languageName: node + linkType: hard + "@smithy/property-provider@npm:^2.0.0, @smithy/property-provider@npm:^2.0.13": version: 2.0.13 resolution: "@smithy/property-provider@npm:2.0.13" @@ -3187,7 +3390,27 @@ __metadata: languageName: node linkType: hard -"@smithy/protocol-http@npm:^3.0.3, @smithy/protocol-http@npm:^3.0.6, @smithy/protocol-http@npm:^3.0.8": +"@smithy/property-provider@npm:^2.0.11": + version: 2.0.11 + resolution: "@smithy/property-provider@npm:2.0.11" + dependencies: + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: 943d77232c346c154632fa54329f68d6e1d90b62fb6ddcec991a3808eda5400ff8a1f727224d6b72f62360c464fb474e982704fb571cc99ad3dd1979aa36c0ca + languageName: node + linkType: hard + +"@smithy/property-provider@npm:^2.0.12": + version: 2.0.12 + resolution: "@smithy/property-provider@npm:2.0.12" + dependencies: + "@smithy/types": ^2.3.5 + tslib: ^2.5.0 + checksum: 5d7afa158d66f4cd7f9561fbbb9adef987abfc490dfd5f0e5dcae5596611618f83a856273308f70e56347115a0f07ecc2f0eb434b4186725f8dc461b3be3cd5c + languageName: node + linkType: hard + +"@smithy/protocol-http@npm:^3.0.3, @smithy/protocol-http@npm:^3.0.8": version: 3.0.8 resolution: "@smithy/protocol-http@npm:3.0.8" dependencies: @@ -3197,6 +3420,38 @@ __metadata: languageName: node linkType: hard +"@smithy/protocol-http@npm:^3.0.6, @smithy/protocol-http@npm:^3.0.7": + version: 3.0.7 + resolution: "@smithy/protocol-http@npm:3.0.7" + dependencies: + "@smithy/types": ^2.3.5 + tslib: ^2.5.0 + checksum: bbc13fdddf1891daaa086849c19731e6ca825229b9c90324e50641390f84e957af796464f642f74426038a4d6a0f8d4b05364e0729cf7f8a828328e921ba72cd + languageName: node + linkType: hard + +"@smithy/querystring-builder@npm:^2.0.10": + version: 2.0.10 + resolution: "@smithy/querystring-builder@npm:2.0.10" + dependencies: + "@smithy/types": ^2.3.4 + "@smithy/util-uri-escape": ^2.0.0 + tslib: ^2.5.0 + checksum: bac04753ae658eab26a5433aba659e534a91bcd655d33657f88c38ebb7307db013558d7815f5c04dd0030aa6b6e089d26f3ed9430f5b6d6ea5de4a393dd66798 + languageName: node + linkType: hard + +"@smithy/querystring-builder@npm:^2.0.11": + version: 2.0.11 + resolution: "@smithy/querystring-builder@npm:2.0.11" + dependencies: + "@smithy/types": ^2.3.5 + "@smithy/util-uri-escape": ^2.0.0 + tslib: ^2.5.0 + checksum: a9ad6389051b24170c178ae0bbac73d224f2ba2c005eca7dfa3c5631e2e7522ffdd17fc1779f80d2480c444e01ba8da9d0553b0b7d68967c1fa283c737dec886 + languageName: node + linkType: hard + "@smithy/querystring-builder@npm:^2.0.12": version: 2.0.12 resolution: "@smithy/querystring-builder@npm:2.0.12" @@ -3218,12 +3473,22 @@ __metadata: languageName: node linkType: hard -"@smithy/service-error-classification@npm:^2.0.5": - version: 2.0.5 - resolution: "@smithy/service-error-classification@npm:2.0.5" +"@smithy/querystring-parser@npm:^2.0.9": + version: 2.0.9 + resolution: "@smithy/querystring-parser@npm:2.0.9" dependencies: - "@smithy/types": ^2.4.0 - checksum: cd4b9fcc5cd940035ca4f3e832f8480d75eb81c90501bdb5c9295c5fd26487ca2e2f3d3efa9a322faeaedf10d6d8324327cd3341fc05d38f8605006ad836abaa + "@smithy/types": ^2.3.3 + tslib: ^2.5.0 + checksum: c334bab2bde7a863f1c86b567677eede2f20c5e96a0123c3b5b167d7b2eb165811221df51349cee7f04e5167f4c6f7ae6ff8f237e9114ac5fbfe9c936b4b40d2 + languageName: node + linkType: hard + +"@smithy/service-error-classification@npm:^2.0.4": + version: 2.0.4 + resolution: "@smithy/service-error-classification@npm:2.0.4" + dependencies: + "@smithy/types": ^2.3.5 + checksum: e0d90a5daf6af375963ac5521938158124a4df2ae431a08b4cbd40c68d68ca62a5e6f12b17e378ceec9e0023c49114f561e747c9396a513323c987cdcaff68eb languageName: node linkType: hard @@ -3237,23 +3502,33 @@ __metadata: languageName: node linkType: hard +"@smithy/shared-ini-file-loader@npm:^2.2.0": + version: 2.2.0 + resolution: "@smithy/shared-ini-file-loader@npm:2.2.0" + dependencies: + "@smithy/types": ^2.3.5 + tslib: ^2.5.0 + checksum: 77563b09f961c12d1afe3c5006074be3590fd3b44b096b5b7d5244b6924a5988731c4903d13f13cef4f6139e10735fb04d63e8c78bece1f6594dc3158033a7e2 + languageName: node + linkType: hard + "@smithy/signature-v4@npm:^2.0.0": - version: 2.0.12 - resolution: "@smithy/signature-v4@npm:2.0.12" + version: 2.0.10 + resolution: "@smithy/signature-v4@npm:2.0.10" dependencies: - "@smithy/eventstream-codec": ^2.0.12 + "@smithy/eventstream-codec": ^2.0.10 "@smithy/is-array-buffer": ^2.0.0 - "@smithy/types": ^2.4.0 + "@smithy/types": ^2.3.4 "@smithy/util-hex-encoding": ^2.0.0 - "@smithy/util-middleware": ^2.0.5 + "@smithy/util-middleware": ^2.0.3 "@smithy/util-uri-escape": ^2.0.0 "@smithy/util-utf8": ^2.0.0 tslib: ^2.5.0 - checksum: e786146c65cc6c748c0699db0a082b589bc332a1db9461e0ca8a3e5465712639ec02a352f31f5099f1fc0ee75d956a21a5927ec9079ae6152e220cb2cba14f9d + checksum: 6055b96e1bdef90243e227cccc9d5f49240c7866d5a9e633ae1a61e8d5b193cd57672a70adf8c98ee918dcddf92771524aa25e2c467fad8e9f51d0f567735636 languageName: node linkType: hard -"@smithy/smithy-client@npm:^2.1.12, @smithy/smithy-client@npm:^2.1.4, @smithy/smithy-client@npm:^2.1.9": +"@smithy/smithy-client@npm:^2.1.12, @smithy/smithy-client@npm:^2.1.9": version: 2.1.12 resolution: "@smithy/smithy-client@npm:2.1.12" dependencies: @@ -3265,7 +3540,19 @@ __metadata: languageName: node linkType: hard -"@smithy/types@npm:^2.3.1, @smithy/types@npm:^2.3.4, @smithy/types@npm:^2.4.0": +"@smithy/smithy-client@npm:^2.1.4, @smithy/smithy-client@npm:^2.1.8": + version: 2.1.8 + resolution: "@smithy/smithy-client@npm:2.1.8" + dependencies: + "@smithy/middleware-stack": ^2.0.4 + "@smithy/types": ^2.3.4 + "@smithy/util-stream": ^2.0.13 + tslib: ^2.5.0 + checksum: b72cf1cc5b6e72f85624c13aaa6d206a5bd320b923f172002a0d93f5d4407016adc35c9f64d3848fd53d91a12a7e33f8e3b9ac2f2fd19d17a90a4cb4eade0287 + languageName: node + linkType: hard + +"@smithy/types@npm:^2.3.1, @smithy/types@npm:^2.4.0": version: 2.4.0 resolution: "@smithy/types@npm:2.4.0" dependencies: @@ -3274,7 +3561,27 @@ __metadata: languageName: node linkType: hard -"@smithy/url-parser@npm:^2.0.10, @smithy/url-parser@npm:^2.0.12, @smithy/url-parser@npm:^2.0.7": +"@smithy/types@npm:^2.3.3": + version: 2.3.3 + resolution: "@smithy/types@npm:2.3.3" + dependencies: + "@smithy/querystring-parser": ^2.0.12 + "@smithy/types": ^2.4.0 + tslib: ^2.5.0 + checksum: e40a508e41c0df6bb540a554cc42c31c4f6ad4473c7d124827122d959bada29df06a040a2c980b9e3b9420d7b30bd03033ecaf968a7ffd945ad6385824267a3a + languageName: node + linkType: hard + +"@smithy/types@npm:^2.3.4, @smithy/types@npm:^2.3.5": + version: 2.3.5 + resolution: "@smithy/types@npm:2.3.5" + dependencies: + tslib: ^2.5.0 + checksum: b758ba1e21132cccc8b612fe56e9c0eb27fe6b00dcc002965a13dae40c172ae3bff2d994dae61e9c8bdadb844fd370a4c4cb031af6d954e4e1fb897ce5d6b54e + languageName: node + linkType: hard + +"@smithy/url-parser@npm:^2.0.10, @smithy/url-parser@npm:^2.0.12": version: 2.0.12 resolution: "@smithy/url-parser@npm:2.0.12" dependencies: @@ -3285,6 +3592,17 @@ __metadata: languageName: node linkType: hard +"@smithy/url-parser@npm:^2.0.7, @smithy/url-parser@npm:^2.0.9": + version: 2.0.9 + resolution: "@smithy/url-parser@npm:2.0.9" + dependencies: + "@smithy/querystring-parser": ^2.0.9 + "@smithy/types": ^2.3.3 + tslib: ^2.5.0 + checksum: 25157d01a789e5bcf9b2b45116268be2dec8c63fcfbceafef526138e8d6419efc547f02a7836c1aaad10d54a4169e234d674846ac53970e1cfb571ce98d42a6b + languageName: node + linkType: hard + "@smithy/util-base64@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/util-base64@npm:2.0.0" @@ -3332,7 +3650,7 @@ __metadata: languageName: node linkType: hard -"@smithy/util-defaults-mode-browser@npm:^2.0.13, @smithy/util-defaults-mode-browser@npm:^2.0.8": +"@smithy/util-defaults-mode-browser@npm:^2.0.13": version: 2.0.16 resolution: "@smithy/util-defaults-mode-browser@npm:2.0.16" dependencies: @@ -3345,6 +3663,19 @@ __metadata: languageName: node linkType: hard +"@smithy/util-defaults-mode-browser@npm:^2.0.8": + version: 2.0.12 + resolution: "@smithy/util-defaults-mode-browser@npm:2.0.12" + dependencies: + "@smithy/property-provider": ^2.0.11 + "@smithy/smithy-client": ^2.1.8 + "@smithy/types": ^2.3.4 + bowser: ^2.11.0 + tslib: ^2.5.0 + checksum: 9031bf790fec0bdc748e7f9fd9febbb6c4f19ba40b7cde456625975f94daaca72c3307d4f8622939d5c025d941aaab3c12f6da4611b5c1b777b7cf6a1a8da651 + languageName: node + linkType: hard + "@smithy/util-defaults-mode-node@npm:^2.0.10, @smithy/util-defaults-mode-node@npm:^2.0.15": version: 2.0.21 resolution: "@smithy/util-defaults-mode-node@npm:2.0.21" @@ -3369,7 +3700,7 @@ __metadata: languageName: node linkType: hard -"@smithy/util-middleware@npm:^2.0.0, @smithy/util-middleware@npm:^2.0.3, @smithy/util-middleware@npm:^2.0.5": +"@smithy/util-middleware@npm:^2.0.0, @smithy/util-middleware@npm:^2.0.5": version: 2.0.5 resolution: "@smithy/util-middleware@npm:2.0.5" dependencies: @@ -3379,7 +3710,28 @@ __metadata: languageName: node linkType: hard -"@smithy/util-retry@npm:^2.0.0, @smithy/util-retry@npm:^2.0.3, @smithy/util-retry@npm:^2.0.5": +"@smithy/util-middleware@npm:^2.0.2": + version: 2.0.2 + resolution: "@smithy/util-middleware@npm:2.0.2" + dependencies: + "@smithy/types": ^2.4.0 + tslib: ^2.5.0 + checksum: f0f9682acf4f9673e157371ecd52669f00f90133fdaf8384d2f3356b831eb4f55901fb98b0d0e9302cd5e2007bf2b06b0385e39ef0fd205cdc615cad4dc036e1 + languageName: node + linkType: hard + +"@smithy/util-middleware@npm:^2.0.3": + version: 2.0.4 + resolution: "@smithy/util-middleware@npm:2.0.4" + dependencies: + "@smithy/service-error-classification": ^2.0.5 + "@smithy/types": ^2.4.0 + tslib: ^2.5.0 + checksum: 8c1fb2351ea1d3283fbf5f14407a2942bed5b78663cd4890fd98b86ec242fbeb55418930dd3b4b39d4bffa455afcbefd822e09ed3d7dbe511e1186c3c3e4ed54 + languageName: node + linkType: hard + +"@smithy/util-retry@npm:^2.0.0, @smithy/util-retry@npm:^2.0.5": version: 2.0.5 resolution: "@smithy/util-retry@npm:2.0.5" dependencies: @@ -3390,6 +3742,17 @@ __metadata: languageName: node linkType: hard +"@smithy/util-retry@npm:^2.0.3": + version: 2.0.4 + resolution: "@smithy/util-retry@npm:2.0.4" + dependencies: + "@smithy/service-error-classification": ^2.0.4 + "@smithy/types": ^2.3.5 + tslib: ^2.5.0 + checksum: 351235e1cc70b836c063c90ee14de29660d2661e412b009d97da6c4633ddd73f5629b37af4646c1d180b0c746c3872a0a561702b8d4ae9d27b8974ecd59e0fcc + languageName: node + linkType: hard + "@smithy/util-stream@npm:^2.0.10, @smithy/util-stream@npm:^2.0.14, @smithy/util-stream@npm:^2.0.17": version: 2.0.17 resolution: "@smithy/util-stream@npm:2.0.17" @@ -3406,6 +3769,22 @@ __metadata: languageName: node linkType: hard +"@smithy/util-stream@npm:^2.0.13": + version: 2.0.13 + resolution: "@smithy/util-stream@npm:2.0.13" + dependencies: + "@smithy/fetch-http-handler": ^2.2.0 + "@smithy/node-http-handler": ^2.1.6 + "@smithy/types": ^2.3.4 + "@smithy/util-base64": ^2.0.0 + "@smithy/util-buffer-from": ^2.0.0 + "@smithy/util-hex-encoding": ^2.0.0 + "@smithy/util-utf8": ^2.0.0 + tslib: ^2.5.0 + checksum: 4487e43bc27269539a1f9486c407747529e7337688b0908f924c5ad4d2f73ae77b095e1a6c1acc7f3ed715a0aabbf97c5a71da1789eecf7588061fffdccc131b + languageName: node + linkType: hard + "@smithy/util-uri-escape@npm:^2.0.0": version: 2.0.0 resolution: "@smithy/util-uri-escape@npm:2.0.0" @@ -3425,7 +3804,7 @@ __metadata: languageName: node linkType: hard -"@smithy/util-waiter@npm:^2.0.10, @smithy/util-waiter@npm:^2.0.7": +"@smithy/util-waiter@npm:^2.0.10": version: 2.0.12 resolution: "@smithy/util-waiter@npm:2.0.12" dependencies: @@ -3436,6 +3815,17 @@ __metadata: languageName: node linkType: hard +"@smithy/util-waiter@npm:^2.0.7": + version: 2.0.10 + resolution: "@smithy/util-waiter@npm:2.0.10" + dependencies: + "@smithy/abort-controller": ^2.0.10 + "@smithy/types": ^2.3.4 + tslib: ^2.5.0 + checksum: 469ec56d8a2b1f90e743b903d754d2cd012a93a9d010144941ae76483d94dfe9e32612a0b3e0bc2968801255bb6963d954123b7ee32fccf162074784b3e060aa + languageName: node + linkType: hard + "@sqltools/formatter@npm:^1.2.5": version: 1.2.5 resolution: "@sqltools/formatter@npm:1.2.5" From ef80651644e18411411b967764e3e88c9ee7ff33 Mon Sep 17 00:00:00 2001 From: spaenleh Date: Mon, 23 Oct 2023 08:40:27 +0200 Subject: [PATCH 2/7] fix: small issues and cleanup --- package.json | 62 +- src/components/RecycleBinScreen.tsx | 4 +- src/components/SharedItems.tsx | 4 +- src/components/common/EditButton.tsx | 2 +- src/components/common/FavoriteButton.tsx | 5 +- src/components/item/form/DocumentForm.tsx | 4 +- src/components/item/form/EditModalWrapper.tsx | 13 +- src/components/item/form/FileForm.tsx | 123 +- src/components/item/settings/FileSettings.tsx | 2 +- .../item/settings/ThumbnailSetting.tsx | 1 - src/components/main/FavoriteItems.tsx | 29 +- src/components/member/AvatarSetting.tsx | 1 - src/components/table/ItemNameCellRenderer.tsx | 11 +- tsconfig.json | 20 +- yarn.lock | 1510 +++++++---------- 15 files changed, 772 insertions(+), 1019 deletions(-) diff --git a/package.json b/package.json index ab00b7900..84e720324 100644 --- a/package.json +++ b/package.json @@ -17,14 +17,14 @@ "@emotion/react": "11.11.1", "@emotion/styled": "11.11.0", "@graasp/chatbox": "2.0.1", - "@graasp/query-client": "1.11.0", - "@graasp/sdk": "1.8.0", + "@graasp/query-client": "github:graasp/graasp-query-client#update-sdk", + "@graasp/sdk": "github:graasp/graasp-sdk#remove-unknown-extra", "@graasp/translations": "1.19.2", "@graasp/ui": "3.6.0", - "@mui/icons-material": "5.14.13", + "@mui/icons-material": "5.14.14", "@mui/lab": "5.0.0-alpha.148", - "@mui/material": "5.14.13", - "@sentry/react": "7.73.0", + "@mui/material": "5.14.14", + "@sentry/react": "7.74.1", "@uppy/core": "3.3.1", "@uppy/dashboard": "3.4.2", "@uppy/drag-drop": "3.0.2", @@ -38,11 +38,12 @@ "ag-grid-react": "29.3.5", "axios": "1.5.0", "date-fns": "2.30.0", - "filesize": "10.0.12", - "http-status-codes": "2.2.0", + "filesize": "10.1.0", + "http-status-codes": "2.3.0", "immutable": "4.3.4", "katex": "0.16.9", "lodash.groupby": "4.6.0", + "lodash.isequal": "4.5.0", "lodash.partition": "4.6.0", "lodash.truncate": "4.4.2", "papaparse": "5.4.1", @@ -52,13 +53,13 @@ "react-csv": "2.2.2", "react-dom": "18.2.0", "react-ga4": "2.1.0", - "react-i18next": "13.2.0", + "react-i18next": "13.3.1", "react-image-crop": "9.1.1", "react-qr-code": "2.0.12", "react-query": "3.39.3", "react-quill": "2.0.0", - "react-router": "6.15.0", - "react-router-dom": "6.15.0", + "react-router": "6.17.0", + "react-router-dom": "6.17.0", "react-toastify": "9.1.3", "short-uuid": "4.2.2", "stylis": "4.3.0", @@ -104,30 +105,31 @@ "devDependencies": { "@commitlint/cli": "17.8.1", "@commitlint/config-conventional": "17.8.1", - "@cypress/code-coverage": "3.11.0", - "@testing-library/jest-dom": "^6.0.0", + "@cypress/code-coverage": "3.12.4", + "@testing-library/jest-dom": "^6.1.4", "@testing-library/react": "^14.0.0", - "@testing-library/user-event": "^14.4.3", + "@testing-library/user-event": "^14.5.1", "@trivago/prettier-plugin-sort-imports": "4.2.0", - "@types/jest": "29.5.4", + "@types/jest": "29.5.6", + "@types/lodash.isequal": "4.5.7", "@types/lodash.partition": "4.6.8", "@types/lodash.truncate": "4.4.8", - "@types/node": "18.17.12", - "@types/papaparse": "5.3.8", - "@types/qs": "6.9.7", - "@types/react": "18.2.31", - "@types/react-csv": "1.1.3", - "@types/react-dom": "18.2.7", - "@types/uuid": "9.0.2", - "@types/validator": "13.11.1", - "@typescript-eslint/eslint-plugin": "6.5.0", - "@typescript-eslint/parser": "6.5.0", - "@vitejs/plugin-react": "4.0.4", - "concurrently": "8.2.1", - "cypress": "13.3.0", + "@types/node": "20.8.7", + "@types/papaparse": "5.3.10", + "@types/qs": "6.9.9", + "@types/react": "18.2.30", + "@types/react-csv": "1.1.7", + "@types/react-dom": "18.2.14", + "@types/uuid": "9.0.6", + "@types/validator": "13.11.5", + "@typescript-eslint/eslint-plugin": "6.8.0", + "@typescript-eslint/parser": "6.8.0", + "@vitejs/plugin-react": "4.1.0", + "concurrently": "8.2.2", + "cypress": "13.3.2", "cypress-localstorage-commands": "2.2.4", "env-cmd": "10.1.0", - "eslint": "^8.47.0", + "eslint": "^8.51.0", "eslint-config-airbnb": "19.0.4", "eslint-config-prettier": "9.0.0", "eslint-import-resolver-typescript": "3.6.1", @@ -137,10 +139,10 @@ "eslint-plugin-react-hooks": "4.6.0", "husky": "8.0.3", "nyc": "15.1.0", - "prettier": "3.0.2", + "prettier": "3.0.3", "rollup-plugin-visualizer": "5.9.2", "typescript": "5.2.2", - "vite": "4.4.9", + "vite": "4.5.0", "vite-plugin-checker": "0.6.2", "vite-plugin-istanbul": "5.0.0" }, diff --git a/src/components/RecycleBinScreen.tsx b/src/components/RecycleBinScreen.tsx index d1eeb29fe..35742b2f1 100644 --- a/src/components/RecycleBinScreen.tsx +++ b/src/components/RecycleBinScreen.tsx @@ -2,8 +2,6 @@ import { Box } from '@mui/material'; import { Loader } from '@graasp/ui'; -import { List } from 'immutable'; - import { useBuilderTranslation } from '../config/i18n'; import { hooks } from '../config/queryClient'; import { @@ -67,7 +65,7 @@ const RecycleBinLoadableContent = (): JSX.Element => { id={RECYCLED_ITEMS_ID} clickable={false} title={translateBuilder(BUILDER.RECYCLE_BIN_TITLE)} - items={recycledItems ?? List()} + items={recycledItems} actions={RowActions} ToolbarActions={ToolbarActions} showThumbnails={false} diff --git a/src/components/SharedItems.tsx b/src/components/SharedItems.tsx index a28476076..dd700fb69 100644 --- a/src/components/SharedItems.tsx +++ b/src/components/SharedItems.tsx @@ -2,8 +2,6 @@ import Box from '@mui/material/Box'; import { Loader } from '@graasp/ui'; -import { List } from 'immutable'; - import { BUILDER } from '@/langs/constants'; import { useBuilderTranslation } from '../config/i18n'; @@ -35,7 +33,7 @@ const SharedItemsLoadableContent = (): JSX.Element => { diff --git a/src/components/common/EditButton.tsx b/src/components/common/EditButton.tsx index 0bc86305e..288613c53 100644 --- a/src/components/common/EditButton.tsx +++ b/src/components/common/EditButton.tsx @@ -33,7 +33,7 @@ const EditButton = ({ item }: Props): JSX.Element => { }; const typeToFormComponent = (): EditModalContentType => { - switch (item?.type) { + switch (item.type) { case ItemType.DOCUMENT: return DocumentForm; case ItemType.LOCAL_FILE: diff --git a/src/components/common/FavoriteButton.tsx b/src/components/common/FavoriteButton.tsx index f639e3220..e1fa06bf7 100644 --- a/src/components/common/FavoriteButton.tsx +++ b/src/components/common/FavoriteButton.tsx @@ -41,7 +41,10 @@ const FavoriteButton = ({ return null; } - const isFavorite = isItemFavorite(item, favorites); + const isFavorite = isItemFavorite( + item, + favorites as List, + ); const handleFavorite = () => { addFavorite.mutate(item.id); diff --git a/src/components/item/form/DocumentForm.tsx b/src/components/item/form/DocumentForm.tsx index 3c001e8e9..0405967bf 100644 --- a/src/components/item/form/DocumentForm.tsx +++ b/src/components/item/form/DocumentForm.tsx @@ -17,7 +17,7 @@ import { ITEM_FORM_DOCUMENT_TEXT_ID } from '../../../config/selectors'; import { BUILDER } from '../../../langs/constants'; import { buildDocumentExtra } from '../../../utils/itemExtra'; import type { EditModalContentPropType } from './EditModalWrapper'; -import BaseForm from './NameForm'; +import NameForm from './NameForm'; export const DocumentExtraForm = ({ documentItemId, @@ -138,7 +138,7 @@ const DocumentForm = ({ return ( <> - diff --git a/src/components/item/form/FileForm.tsx b/src/components/item/form/FileForm.tsx index 7c241bf68..a0b8ec0fd 100644 --- a/src/components/item/form/FileForm.tsx +++ b/src/components/item/form/FileForm.tsx @@ -1,11 +1,10 @@ import { TextField } from '@mui/material'; import { + DiscriminatedItem, FileItemProperties, ItemType, - LocalFileItemType, MimeTypes, - S3FileItemType, getFileExtra, getS3FileExtra, } from '@graasp/sdk'; @@ -16,7 +15,7 @@ import { ITEM_FORM_IMAGE_ALT_TEXT_EDIT_FIELD_ID } from '@/config/selectors'; import { BUILDER } from '../../../langs/constants'; import DescriptionForm from './DescriptionForm'; import { EditModalContentPropType } from './EditModalWrapper'; -import BaseItemForm from './NameForm'; +import NameForm from './NameForm'; const FileForm = (props: EditModalContentPropType): JSX.Element | null => { const { item, setChanges, updatedProperties } = props; @@ -27,54 +26,80 @@ const FileForm = (props: EditModalContentPropType): JSX.Element | null => { return null; } - const localFileExtra = - item.type === ItemType.LOCAL_FILE ? getFileExtra(item.extra) : undefined; - const s3FileExtra = - item.type === ItemType.S3_FILE ? getS3FileExtra(item.extra) : undefined; - const { mimetype, altText } = { - ...s3FileExtra, - ...localFileExtra, - }; + if ( + item && + (item.type === ItemType.LOCAL_FILE || item.type === ItemType.S3_FILE) && + (updatedProperties.type === ItemType.LOCAL_FILE || + updatedProperties.type === ItemType.S3_FILE) + ) { + const getExtra = ( + testItem: Partial, + ): Partial => { + const localFileExtra = + testItem.type === ItemType.LOCAL_FILE + ? getFileExtra(testItem.extra) + : undefined; + const s3FileExtra = + testItem.type === ItemType.S3_FILE + ? getS3FileExtra(testItem.extra) + : undefined; + const extra = { + ...s3FileExtra, + ...localFileExtra, + }; + return extra; + }; - return ( - <> - - {mimetype && MimeTypes.isImage(mimetype) && ( - - setChanges({ - extra: { - [item.type]: { ...updatedProperties, altText: e.target.value }, - }, - } as Partial) - } - // always shrink because setting name from defined app does not shrink automatically - InputLabelProps={{ shrink: true }} - sx={{ width: '50%', my: 1 }} - multiline + const itemExtra = getExtra(item); + const { mimetype, altText } = itemExtra; + const updatedExtra = getExtra(updatedProperties); + return ( + <> + - )} - - - ); + {mimetype && MimeTypes.isImage(mimetype) && ( + { + const newExtra = { + ...itemExtra, + ...updatedExtra, + altText: e.target.value, + } as FileItemProperties; + + setChanges( + item.type === ItemType.S3_FILE + ? { + extra: { + [ItemType.S3_FILE]: newExtra, + }, + } + : { + extra: { [ItemType.LOCAL_FILE]: newExtra }, + }, + ); + }} + // always shrink because setting name from defined app does not shrink automatically + InputLabelProps={{ shrink: true }} + sx={{ width: '50%', my: 1 }} + multiline + /> + )} + + + ); + } + return null; }; export default FileForm; diff --git a/src/components/item/settings/FileSettings.tsx b/src/components/item/settings/FileSettings.tsx index f2b9cc478..9f71503f5 100644 --- a/src/components/item/settings/FileSettings.tsx +++ b/src/components/item/settings/FileSettings.tsx @@ -40,7 +40,7 @@ const FileSettings = ({ - +