From bb94598a0842a0a4751213cc7eb4ff592f09b0b4 Mon Sep 17 00:00:00 2001 From: Julian Kniephoff Date: Wed, 19 Jun 2024 11:36:21 +0200 Subject: [PATCH 01/30] Remove poorly formatted dead code This comment describes a potential feature in the dialog for editing scheduled event, but who knows if it even still works like this, or if people want it. **If** anyone wants it, feel free to make an issue, but this kind of stuff does not belong in live code, IMO. --- .../EditScheduledEventsEditPage.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx b/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx index 2e03046a49..80276d6d5c 100644 --- a/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx @@ -398,18 +398,6 @@ const EditScheduledEventsEditPage = ({ /> - - {/* the following seven lines can be commented in, when the possibility of a selection of individual inputs is desired and the backend has been adapted to support it - - {t('EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.INPUTS')} - - {/* Render checkbox for each input option of the selected input device*/ - /*} - {renderInputDeviceOptions(key)} - - - */} - {/* Radio buttons for weekdays * * Per event there are 14 input fields, so with 'key * 14', the right From e69aafc35b9379a6c83e10076e9fef04e38d0c2f Mon Sep 17 00:00:00 2001 From: Ron Lucke Date: Thu, 6 Jun 2024 15:58:53 +0200 Subject: [PATCH 02/30] use button instead of div --- src/components/shared/Stats.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/shared/Stats.tsx b/src/components/shared/Stats.tsx index 44f2fca0c2..8ca7ee2de3 100644 --- a/src/components/shared/Stats.tsx +++ b/src/components/shared/Stats.tsx @@ -60,7 +60,7 @@ const Stats = ({ {stats.map((st, key) => (
-
showStatsFilter(st)} > @@ -76,7 +76,7 @@ const Stats = ({ )) )} -
+
))} From d38354949b7244239360746bd462853248292d25 Mon Sep 17 00:00:00 2001 From: Ron Lucke Date: Thu, 6 Jun 2024 15:59:42 +0200 Subject: [PATCH 03/30] style stat button --- src/styles/components/_stats.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/styles/components/_stats.scss b/src/styles/components/_stats.scss index 15f8018cc4..f6ba80279d 100644 --- a/src/styles/components/_stats.scss +++ b/src/styles/components/_stats.scss @@ -43,10 +43,20 @@ cursor: pointer; overflow: hidden; color: $stats-color; + border: none; + border-radius: 0; + background-color: transparent; + height: unset; + width: 100%; + font-weight: unset; + font-size: unset; &:hover { color: $stats-hover-color; } + &:focus { + outline: $stats-color solid thin; + } h1 { font-weight: 100; From c53b99cff46cf98a6da81d0e548132a6a702e8f7 Mon Sep 17 00:00:00 2001 From: Julian Kniephoff Date: Wed, 19 Jun 2024 15:32:14 +0200 Subject: [PATCH 04/30] Get rid of Vite build warnings There are quite a few errors like the following in the output of `npm run build`: Error when using sourcemap for reporting an error: Can't resolve original location of error. They all relate to the `@mui` package(-s). This seems to be related to https://github.com/vitejs/vite/issues/15012. I don't fully understand it, but apparently Rollup, which is used by Vite internally somehow, doesn't preserve enough information to generate source maps properly. This patch adds a plugin to do exactly that. We should probably remove it in the long run, if the upstream issue(-s) ever get fixed. I created #708 to track that. /cc https://github.com/opencast/opencast-admin-interface/pull/685 --- package-lock.json | 85 ++++++++++++++++++++++++++++------------------- package.json | 1 + vite.config.ts | 3 +- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6ee46cd21..d797e915a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,7 @@ "@types/uuid": "^9.0.8", "@vitejs/plugin-react-swc": "^3.7.0", "prop-types": "^15.8.1", + "rollup-preserve-directives": "^1.1.1", "sass": "^1.77.4", "typescript": "^5.4.5", "uuid": "^9.0.1", @@ -4304,6 +4305,55 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/rollup": { + "version": "4.18.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", + "integrity": "sha512-QmJz14PX3rzbJCN1SG4Xe/bAAX2a6NpCP8ab2vfu2GiUr8AQcr2nCV/oEO3yneFarB67zk8ShlIyWb2LGTb3Sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.5" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.18.0", + "@rollup/rollup-android-arm64": "4.18.0", + "@rollup/rollup-darwin-arm64": "4.18.0", + "@rollup/rollup-darwin-x64": "4.18.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.18.0", + "@rollup/rollup-linux-arm-musleabihf": "4.18.0", + "@rollup/rollup-linux-arm64-gnu": "4.18.0", + "@rollup/rollup-linux-arm64-musl": "4.18.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.18.0", + "@rollup/rollup-linux-riscv64-gnu": "4.18.0", + "@rollup/rollup-linux-s390x-gnu": "4.18.0", + "@rollup/rollup-linux-x64-gnu": "4.18.0", + "@rollup/rollup-linux-x64-musl": "4.18.0", + "@rollup/rollup-win32-arm64-msvc": "4.18.0", + "@rollup/rollup-win32-ia32-msvc": "4.18.0", + "@rollup/rollup-win32-x64-msvc": "4.18.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-preserve-directives": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/rollup-preserve-directives/-/rollup-preserve-directives-1.1.1.tgz", + "integrity": "sha512-+eQafbuEfDPfxQ9hQPlwaROfin4yiVRxap8hnrvvvcSGoukv1tTiYpAW9mvm3uR8J+fe4xd8FdVd5rz9q7jZ+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "magic-string": "^0.30.5" + }, + "peerDependencies": { + "rollup": "^2.0.0 || ^3.0.0 || ^4.0.0" + } + }, "node_modules/sass": { "version": "1.77.4", "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.4.tgz", @@ -4872,41 +4922,6 @@ } } }, - "node_modules/vite/node_modules/rollup": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", - "integrity": "sha512-QmJz14PX3rzbJCN1SG4Xe/bAAX2a6NpCP8ab2vfu2GiUr8AQcr2nCV/oEO3yneFarB67zk8ShlIyWb2LGTb3Sg==", - "dev": true, - "dependencies": { - "@types/estree": "1.0.5" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.18.0", - "@rollup/rollup-android-arm64": "4.18.0", - "@rollup/rollup-darwin-arm64": "4.18.0", - "@rollup/rollup-darwin-x64": "4.18.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.18.0", - "@rollup/rollup-linux-arm-musleabihf": "4.18.0", - "@rollup/rollup-linux-arm64-gnu": "4.18.0", - "@rollup/rollup-linux-arm64-musl": "4.18.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.18.0", - "@rollup/rollup-linux-riscv64-gnu": "4.18.0", - "@rollup/rollup-linux-s390x-gnu": "4.18.0", - "@rollup/rollup-linux-x64-gnu": "4.18.0", - "@rollup/rollup-linux-x64-musl": "4.18.0", - "@rollup/rollup-win32-arm64-msvc": "4.18.0", - "@rollup/rollup-win32-ia32-msvc": "4.18.0", - "@rollup/rollup-win32-x64-msvc": "4.18.0", - "fsevents": "~2.3.2" - } - }, "node_modules/vitest": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/vitest/-/vitest-1.6.0.tgz", diff --git a/package.json b/package.json index 86c663b1a3..8dc9977a7e 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "@types/uuid": "^9.0.8", "@vitejs/plugin-react-swc": "^3.7.0", "prop-types": "^15.8.1", + "rollup-preserve-directives": "^1.1.1", "sass": "^1.77.4", "typescript": "^5.4.5", "uuid": "^9.0.1", diff --git a/vite.config.ts b/vite.config.ts index 44dcc8e023..7238421677 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,10 +2,11 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import svgr from "vite-plugin-svgr"; import viteTsconfigPaths from "vite-tsconfig-paths"; +import preserveDirectives from "rollup-preserve-directives"; export default defineConfig({ base: process.env.PUBLIC_URL || "", - plugins: [react(), svgr(), viteTsconfigPaths()], + plugins: [react(), svgr(), viteTsconfigPaths(), preserveDirectives()], build: { outDir: "build", sourcemap: true, From 03581fe1cf9314a3bda3c7cfc7e133c85fd5201b Mon Sep 17 00:00:00 2001 From: Ron Lucke Date: Wed, 19 Jun 2024 15:53:07 +0200 Subject: [PATCH 05/30] remove outline: none for a11y reasons --- src/styles/base/_layout.scss | 8 -------- src/styles/components/_dropdowns.scss | 9 --------- src/styles/components/_inputs.scss | 1 - src/styles/components/modals/_modal-components.scss | 1 - src/styles/mixins/_button.scss | 1 - src/styles/views/_core.scss | 1 - 6 files changed, 21 deletions(-) diff --git a/src/styles/base/_layout.scss b/src/styles/base/_layout.scss index f25e3dccd3..7a4d471b30 100644 --- a/src/styles/base/_layout.scss +++ b/src/styles/base/_layout.scss @@ -52,14 +52,6 @@ strong { font-weight: 600; } -textarea, -input, -button { - &:focus { - outline: none; - } -} - .text-left { text-align: left; } diff --git a/src/styles/components/_dropdowns.scss b/src/styles/components/_dropdowns.scss index 1be3be1f57..93daae4eb5 100644 --- a/src/styles/components/_dropdowns.scss +++ b/src/styles/components/_dropdowns.scss @@ -38,7 +38,6 @@ background: linear-gradient(#fff, #f7f7f7); border: $thin-border-stroke $main-border-color; box-shadow: inset 0px 1px 0px 0px #fff, 0px 1px 2px rgba(0,0,0,.05); - outline: none; color: $medium-prim-color; text-shadow: 0px 1px 0px #fff; @@ -52,10 +51,6 @@ box-shadow: inset 0px 1px 6px 2px rgba(0,0,0,.05); } - &:focus { - outline: none; - } - // Menu Icon Settings $icon-color: $medium-prim-color; $icon-font-size: 15px; @@ -157,10 +152,6 @@ user-select: none; background-repeat: repeat-x; - &:focus { - outline: none; - } - &:after { position: absolute; top: 7px; diff --git a/src/styles/components/_inputs.scss b/src/styles/components/_inputs.scss index b0a7884717..2b055a2bb8 100644 --- a/src/styles/components/_inputs.scss +++ b/src/styles/components/_inputs.scss @@ -134,7 +134,6 @@ input[type="radio"].ios { border: 1px solid $grey; border-radius: 26px; box-shadow: inset 0 0 0 1px $grey; - outline: none; cursor: pointer; height: 28px; position: relative; diff --git a/src/styles/components/modals/_modal-components.scss b/src/styles/components/modals/_modal-components.scss index 354b570621..5d9902fedd 100644 --- a/src/styles/components/modals/_modal-components.scss +++ b/src/styles/components/modals/_modal-components.scss @@ -371,7 +371,6 @@ // Reset appearance: none; background: none; - outline: none; border: none; margin: auto;; height: 100%; diff --git a/src/styles/mixins/_button.scss b/src/styles/mixins/_button.scss index 7f00338107..f3d3b28de8 100644 --- a/src/styles/mixins/_button.scss +++ b/src/styles/mixins/_button.scss @@ -200,7 +200,6 @@ background: linear-gradient(#fff, #f7f7f7); border: $thin-border-stroke $main-border-color; box-shadow: inset 0px 1px 0px 0px #fff, 0px 1px 2px rgba(0,0,0,.05); - outline: none; color: $medium-prim-color; text-shadow: 0px 1px 0px #fff; diff --git a/src/styles/views/_core.scss b/src/styles/views/_core.scss index a02594dc0d..77bca74083 100644 --- a/src/styles/views/_core.scss +++ b/src/styles/views/_core.scss @@ -158,7 +158,6 @@ body { background: linear-gradient(#fff, #f7f7f7); border: $thin-border-stroke $main-border-color; box-shadow: inset 0px 1px 0px 0px #fff, 0px 1px 2px rgba(0,0,0,.05); - outline: none; color: $medium-prim-color; text-shadow: 0px 1px 0px #fff; From d8f91da09538a2ad129024e1003b359b868a238b Mon Sep 17 00:00:00 2001 From: Arnei Date: Wed, 19 Jun 2024 16:37:15 +0200 Subject: [PATCH 06/30] Typing event details Adds typescript types to the parameters of the `EventDetails` component and various related components. --- .../events/partials/EventActionCell.tsx | 15 ++-- .../DetailsExtendedMetadataTab.tsx | 22 +++--- .../ModalTabsAndPages/DetailsMetadataTab.tsx | 22 +++--- .../EventDetailsAccessPolicyTab.tsx | 14 ++-- .../EventDetailsAssetAttachmentDetails.tsx | 13 ++-- .../EventDetailsAssetAttachments.tsx | 13 ++-- .../EventDetailsAssetCatalogDetails.tsx | 14 ++-- .../EventDetailsAssetCatalogs.tsx | 13 ++-- .../EventDetailsAssetMedia.tsx | 13 ++-- .../EventDetailsAssetMediaDetails.tsx | 14 ++-- .../EventDetailsAssetPublicationDetails.tsx | 11 +-- .../EventDetailsAssetPublications.tsx | 16 ++-- .../EventDetailsAssetsAddAsset.tsx | 13 ++-- .../EventDetailsAssetsTab.tsx | 24 ++---- .../EventDetailsCommentsTab.tsx | 9 ++- .../EventDetailsPublicationTab.tsx | 3 +- .../EventDetailsSchedulingTab.tsx | 9 ++- .../EventDetailsStatisticsTab.tsx | 9 ++- .../EventDetailsWorkflowDetails.tsx | 13 ++-- .../EventDetailsWorkflowErrorDetails.tsx | 14 ++-- .../EventDetailsWorkflowErrors.tsx | 16 ++-- .../EventDetailsWorkflowOperationDetails.tsx | 10 +-- .../EventDetailsWorkflowOperations.tsx | 6 +- .../EventDetailsWorkflowTab.tsx | 26 +++---- .../SeriesDetailsAccessTab.tsx | 3 +- .../events/partials/modals/EventDetails.tsx | 59 +++++--------- .../partials/modals/EventDetailsModal.tsx | 66 ++++++++-------- .../modals/ResourceDetailsAccessPolicyTab.tsx | 76 ++++++++----------- src/slices/eventDetailsSlice.ts | 42 ++++------ src/slices/seriesDetailsSlice.ts | 16 +--- src/utils/resourceUtils.ts | 13 ++-- 31 files changed, 271 insertions(+), 336 deletions(-) diff --git a/src/components/events/partials/EventActionCell.tsx b/src/components/events/partials/EventActionCell.tsx index e828f1676e..85fc36fa05 100644 --- a/src/components/events/partials/EventActionCell.tsx +++ b/src/components/events/partials/EventActionCell.tsx @@ -102,13 +102,14 @@ const EventActionCell = ({ return ( <> {/* Display modal for editing table view if table edit button is clicked */} - + {displayEventDetailsModal && + + } {displaySeriesDetailsModal && ( = ({ +const DetailsExtendedMetadataTab = ({ resourceId, editAccessRole, metadata, updateResource, +}: { + resourceId: string, + editAccessRole: string, + metadata: MetadataCatalog[], + updateResource: (id: string, values: { [key: string]: any }, catalog: MetadataCatalog) => void, }) => { const { t } = useTranslation(); const user = useAppSelector(state => getUserInformation(state)); -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - const handleSubmit = (values, catalog) => { + const handleSubmit = (values: { [key: string]: any }, catalog: MetadataCatalog) => { updateResource(resourceId, values, catalog); }; // set current values of metadata fields as initial values -// @ts-expect-error TS(7006): Parameter 'metadataCatalog' implicitly has an 'any... Remove this comment to see the full error message - const getInitialValues = (metadataCatalog) => { + const getInitialValues = (metadataCatalog: MetadataCatalog) => { let initialValues = {}; // Transform metadata fields and their values provided by backend (saved in redux) if (!!metadataCatalog.fields && metadataCatalog.fields.length > 0) { -// @ts-expect-error TS(7006): Parameter 'field' implicitly has an 'any' type. metadataCatalog.fields.forEach((field) => { let value = parseValueForBooleanStrings(field.value); // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message @@ -77,7 +75,6 @@ const DetailsExtendedMetadataTab: React.FC<{ //iterate through metadata catalogs !!metadata && metadata.length > 0 && -// @ts-expect-error TS(7006): Parameter 'catalog' implicitly has an 'any' type. metadata.map((catalog, key) => ( // initialize form {/* Render table row for each metadata field depending on type */} {!!catalog.fields && -// @ts-expect-error TS(7006): Parameter 'field' implicitly has an 'any' type. catalog.fields.map((field, index) => ( diff --git a/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx b/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx index c86d7606fb..0ac8b838ca 100644 --- a/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx @@ -11,29 +11,29 @@ import { getUserInformation } from "../../../../selectors/userInfoSelectors"; import { hasAccess, isJson } from "../../../../utils/utils"; import { getMetadataCollectionFieldName } from "../../../../utils/resourceUtils"; import { useAppSelector } from "../../../../store"; +import { MetadataCatalog } from "../../../../slices/eventDetailsSlice"; /** * This component renders metadata details of a certain event or series */ -const DetailsMetadataTab: React.FC<{ - metadataFields: any, //TODO: Type this - updateResource: any, //TODO: Type this - resourceId: any, //TODO: Type this - header: any, //TODO: Type this - editAccessRole: any, //TODO: Type this -}> = ({ +const DetailsMetadataTab = ({ metadataFields, updateResource, resourceId, header, editAccessRole, +}: { + metadataFields: MetadataCatalog, + updateResource: (id: string, values: { [key: string]: any }) => void, + resourceId: string, + header: string, + editAccessRole: string, }) => { const { t } = useTranslation(); const user = useAppSelector(state => getUserInformation(state)); -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - const handleSubmit = (values) => { + const handleSubmit = (values: { [key: string]: any }) => { updateResource(resourceId, values); }; @@ -47,7 +47,6 @@ const DetailsMetadataTab: React.FC<{ !!metadataFields.fields && metadataFields.fields.length > 0 ) { -// @ts-expect-error TS(7006): Parameter 'field' implicitly has an 'any' type. metadataFields.fields.forEach((field) => { // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message initialValues[field.id] = field.value; @@ -88,7 +87,6 @@ const DetailsMetadataTab: React.FC<{ {/* Render table row for each metadata field depending on type */} {!!metadataFields && !!metadataFields.fields && -// @ts-expect-error TS(7006): Parameter 'field' implicitly has an 'any' type. metadataFields.fields.map((field, key) => ( @@ -126,7 +124,7 @@ const DetailsMetadataTab: React.FC<{ ) : ( { field.type === "time" || field.type === "date" - ? + ? : field.value } ) diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx index a9061e7f3f..a9f7f65f44 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx @@ -8,22 +8,23 @@ import { saveAccessPolicies, } from "../../../../slices/eventDetailsSlice"; import { unwrapResult } from "@reduxjs/toolkit"; +import { useTranslation } from "react-i18next"; /** * This component manages the access policy tab of the event details modal */ const EventDetailsAccessPolicyTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 'header' implicitly has an 'any' t... Remove this comment to see the full error message header, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'policyChanged' implicitly has an ... Remove this comment to see the full error message policyChanged, -// @ts-expect-error TS(7031): Binding element 'setPolicyChanged' implicitly has ... Remove this comment to see the full error message setPolicyChanged, +}: { + eventId: string, + header: string, + policyChanged: boolean, + setPolicyChanged: (value: boolean) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); // TODO: Get rid of the wrappers when modernizing redux is done @@ -45,7 +46,6 @@ const EventDetailsAccessPolicyTab = ({ header={header} buttonText={"EVENTS.EVENTS.DETAILS.ACCESS.ACCESS_POLICY.LABEL"} saveButtonText={"SAVE"} - t={t} policies={policies} fetchAccessPolicies={fetchAccessPoliciesWrapper} fetchHasActiveTransactions={fetchHasActiveTransactionsWrapper} diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachmentDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachmentDetails.tsx index 545ae500a1..e8de1a0ef3 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachmentDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachmentDetails.tsx @@ -7,23 +7,22 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { humanReadableBytesFilter } from "../../../../utils/eventDetailsUtils"; import { useAppSelector } from "../../../../store"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the attachment details sub-tab for assets tab of event details modal */ const EventDetailsAssetAttachmentDetails = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message - eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const attachment = useAppSelector(state => getAssetAttachmentDetails(state)); const isFetching = useAppSelector(state => isFetchingAssetAttachmentDetails(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName) => { + const openSubTab = (subTabName: AssetTabHierarchy) => { setHierarchy(subTabName); }; diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx index aca5e4e9ba..503e3530ba 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx @@ -7,25 +7,26 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchAssetAttachmentDetails } from "../../../../slices/eventDetailsSlice"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the attachments sub-tab for assets tab of event details modal */ const EventDetailsAssetAttachments = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const attachments = useAppSelector(state => getAssetAttachments(state)); const isFetching = useAppSelector(state => isFetchingAssetAttachments(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName, attachmentId = "") => { + const openSubTab = (subTabName: AssetTabHierarchy, attachmentId = "") => { if (subTabName === "attachment-details") { dispatch(fetchAssetAttachmentDetails({eventId, attachmentId})).then(); } diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogDetails.tsx index fac8ad8b5e..a37635875f 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogDetails.tsx @@ -7,23 +7,23 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { humanReadableBytesFilter } from "../../../../utils/eventDetailsUtils"; import { useAppSelector } from "../../../../store"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the catalog details sub-tab for assets tab of event details modal */ const EventDetailsAssetCatalogDetails = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message - eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); + const catalog = useAppSelector(state => getAssetCatalogDetails(state)); const isFetching = useAppSelector(state => isFetchingAssetCatalogDetails(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName) => { + const openSubTab = (subTabName: AssetTabHierarchy) => { setHierarchy(subTabName); }; diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx index 4a43a751b0..f8fe6d637d 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx @@ -7,25 +7,26 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchAssetCatalogDetails } from "../../../../slices/eventDetailsSlice"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the catalogs sub-tab for assets tab of event details modal */ const EventDetailsAssetCatalogs = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const catalogs = useAppSelector(state => getAssetCatalogs(state)); const isFetching = useAppSelector(state => isFetchingAssetCatalogs(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName, catalogId = "") => { + const openSubTab = (subTabName: AssetTabHierarchy, catalogId = "") => { if (subTabName === "catalog-details") { dispatch(fetchAssetCatalogDetails({eventId, catalogId})).then(); } diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMedia.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMedia.tsx index 74486ca21e..503a59912e 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMedia.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMedia.tsx @@ -7,25 +7,26 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchAssetMediaDetails } from "../../../../slices/eventDetailsSlice"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the media sub-tab for assets tab of event details modal */ const EventDetailsAssetMedia = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const media = useAppSelector(state => getAssetMedia(state)); const isFetching = useAppSelector(state => isFetchingAssetMedia(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName, mediaId = "") => { + const openSubTab = (subTabName: AssetTabHierarchy, mediaId = "") => { if (subTabName === "media-details") { dispatch(fetchAssetMediaDetails({eventId, mediaId})).then(); } diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMediaDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMediaDetails.tsx index a64cde7fae..4d3a71a9ba 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMediaDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMediaDetails.tsx @@ -10,23 +10,23 @@ import { humanReadableBytesFilter, } from "../../../../utils/eventDetailsUtils"; import { useAppSelector } from "../../../../store"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the media details sub-tab for assets tab of event details modal */ const EventDetailsAssetMediaDetails = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message - eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); + const media = useAppSelector(state => getAssetMediaDetails(state)); const isFetching = useAppSelector(state => isFetchingAssetMediaDetails(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName) => { + const openSubTab = (subTabName: AssetTabHierarchy) => { setHierarchy(subTabName); }; diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx index 660a674782..599332fa9a 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx @@ -7,18 +7,19 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { humanReadableBytesFilter } from "../../../../utils/eventDetailsUtils"; import { useAppSelector } from "../../../../store"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the publication details sub-tab for assets tab of event details modal */ const EventDetailsAssetPublicationDetails = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message - eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); + const publication = useAppSelector(state => getAssetPublicationDetails(state)); const isFetching = useAppSelector(state => isFetchingAssetPublicationDetails(state)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublications.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublications.tsx index 1ea55480f5..72b9de1d0b 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublications.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublications.tsx @@ -7,22 +7,26 @@ import { } from "../../../../selectors/eventDetailsSelectors"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchAssetPublicationDetails } from "../../../../slices/eventDetailsSlice"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the publications sub-tab for assets tab of event details modal */ const EventDetailsAssetPublications = ({ - eventId, - t, - setHierarchy, -}: any) => { + eventId, + setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: AssetTabHierarchy) => void, +}) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const publications = useAppSelector(state => getAssetPublications(state)); const isFetching = useAppSelector(state => isFetchingAssetPublications(state)); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName, publicationId = "") => { + const openSubTab = (subTabName: AssetTabHierarchy, publicationId = "") => { if (subTabName === "publication-details") { dispatch(fetchAssetPublicationDetails({eventId, publicationId})).then(); } diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx index 8d63b5fa76..e7d7977e04 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx @@ -7,18 +7,20 @@ import { getAssetUploadOptions } from "../../../../selectors/eventSelectors"; import { translateOverrideFallback } from "../../../../utils/utils"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { updateAssets } from "../../../../slices/eventDetailsSlice"; +import { AssetTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the add asset sub-tab for assets tab of event details modal */ const EventDetailsAssetsAddAsset = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state)); @@ -28,8 +30,7 @@ const EventDetailsAssetsAddAsset = ({ (asset) => asset.type !== "track" ); -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - const openSubTab = (subTabName) => { + const openSubTab = (subTabName: AssetTabHierarchy) => { setHierarchy(subTabName); }; diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsTab.tsx index fd538c7ba5..5c28d74635 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsTab.tsx @@ -18,18 +18,20 @@ import { fetchAssetPublications, fetchAssets, } from "../../../../slices/eventDetailsSlice"; +import { useTranslation } from "react-i18next"; +import { AssetTabHierarchy } from "../modals/EventDetails"; /** * This component manages the main assets tab of event details modal */ const EventDetailsAssetsTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); @@ -42,24 +44,16 @@ const EventDetailsAssetsTab = ({ useEffect(() => { dispatch(removeNotificationWizardForm()); dispatch(fetchAssets(eventId)).then(); - - // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const openSubTab = ( -// @ts-expect-error TS(7006): Parameter 'subTabName' implicitly has an 'any' typ... Remove this comment to see the full error message - subTabName, -// @ts-expect-error TS(7006): Parameter 'newassetupload' implicitly has an 'any'... Remove this comment to see the full error message - newassetupload, - bool1 = false, - bool2 = true + subTabName: AssetTabHierarchy, + newassetupload: string, ) => { dispatch(removeNotificationWizardForm()); if (subTabName === "asset-attachments") { dispatch(fetchAssetAttachments(eventId)).then(); - } else if (subTabName === "asset-attachments") { - dispatch(fetchAssetAttachments(eventId)).then(); } else if (subTabName === "asset-catalogs") { dispatch(fetchAssetCatalogs(eventId)).then(); } else if (subTabName === "asset-media") { @@ -112,8 +106,6 @@ const EventDetailsAssetsTab = ({ openSubTab( "add-asset", "newassetupload", - false, - true ) } > diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx index 482d0f3689..e5b0df8543 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx @@ -18,18 +18,19 @@ import { deleteCommentReply, } from "../../../../slices/eventDetailsSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; +import { useTranslation } from "react-i18next"; /** * This component manages the comment tab of the event details modal */ const EventDetailsCommentsTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 'header' implicitly has an 'any' t... Remove this comment to see the full error message header, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, +}: { + eventId: string, + header: string, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const comments = useAppSelector(state => getComments(state)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsPublicationTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsPublicationTab.tsx index 2132cc2a44..ca9a0b97f6 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsPublicationTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsPublicationTab.tsx @@ -6,8 +6,9 @@ import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchEventPublications } from "../../../../slices/eventDetailsSlice"; const EventDetailsPublicationTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, +}: { + eventId: string, }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx index c3a665a0fd..c6c2418dff 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx @@ -47,16 +47,17 @@ import { addNotification, } from "../../../../slices/notificationSlice"; import { Recording } from "../../../../slices/recordingSlice"; +import { useTranslation } from "react-i18next"; /** * This component manages the main assets tab of event details modal */ const EventDetailsSchedulingTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, +}: { + eventId: string, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); @@ -647,7 +648,7 @@ const EventDetailsSchedulingTab = ({ formik.values.captureAgent ).find( (agent) => agent.id === input - )?.value + )?.value ?? "" )}
diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx index 6c3f67af5d..eb400fa50d 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx @@ -6,18 +6,19 @@ import { import TimeSeriesStatistics from "../../../shared/TimeSeriesStatistics"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchEventStatisticsValueUpdate } from "../../../../slices/eventDetailsSlice"; +import { useTranslation } from "react-i18next"; /** * This component manages the statistics tab of the event details modal */ const EventDetailsStatisticsTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 'header' implicitly has an 'any' t... Remove this comment to see the full error message header, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, +}: { + eventId: string, + header: string, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const statistics = useAppSelector(state => getStatistics(state)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowDetails.tsx index e4dd981f2d..2f11485ebb 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowDetails.tsx @@ -15,26 +15,27 @@ import { } from "../../../../slices/eventDetailsSlice"; import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; +import { WorkflowTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the workflow details for the workflows tab of the event details modal */ const EventDetailsWorkflowDetails = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: WorkflowTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); const workflowData = useAppSelector(state => getWorkflow(state)); const isFetching = useAppSelector(state => isFetchingWorkflowDetails(state)); -// @ts-expect-error TS(7006): Parameter 'tabType' implicitly has an 'any' type. - const openSubTab = (tabType) => { + const openSubTab = (tabType: WorkflowTabHierarchy) => { dispatch(removeNotificationWizardForm()); setHierarchy(tabType); if (tabType === "workflow-operations") { diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrorDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrorDetails.tsx index e6a4a4d4fe..89e7df2408 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrorDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrorDetails.tsx @@ -9,22 +9,24 @@ import EventDetailsTabHierarchyNavigation from "./EventDetailsTabHierarchyNaviga import { useAppDispatch, useAppSelector } from "../../../../store"; import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; +import { WorkflowTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the workflow error details for the workflows tab of the event details modal */ const EventDetailsWorkflowErrorDetails = ({ - eventId, - t, - setHierarchy, -}: any) => { + setHierarchy, +}: { + setHierarchy: (subTabName: WorkflowTabHierarchy) => void, +}) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const errorDetails = useAppSelector(state => getWorkflowErrorDetails(state)); const isFetching = useAppSelector(state => isFetchingWorkflowErrorDetails(state)); -// @ts-expect-error TS(7006): Parameter 'tabType' implicitly has an 'any' type. - const openSubTab = (tabType) => { + const openSubTab = (tabType: WorkflowTabHierarchy) => { dispatch(removeNotificationWizardForm()); setHierarchy(tabType); }; diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrors.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrors.tsx index a245201577..56249d64ef 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrors.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowErrors.tsx @@ -10,26 +10,27 @@ import { useAppDispatch, useAppSelector } from "../../../../store"; import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { fetchWorkflowErrorDetails } from "../../../../slices/eventDetailsSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; +import { WorkflowTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the workflow errors for the workflows tab of the event details modal */ const EventDetailsWorkflowErrors = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: WorkflowTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const workflow = useAppSelector(state => getWorkflow(state)); const errors = useAppSelector(state => getWorkflowErrors(state)); const isFetching = useAppSelector(state => isFetchingWorkflowErrors(state)); -// @ts-expect-error TS(7006): Parameter 'severity' implicitly has an 'any' type. - const severityColor = (severity) => { + const severityColor = (severity: "FAILURE" | "INFO" | "WARNING" | string) => { switch (severity.toUpperCase()) { case "FAILURE": return "red"; @@ -42,8 +43,7 @@ const EventDetailsWorkflowErrors = ({ } }; -// @ts-expect-error TS(7006): Parameter 'tabType' implicitly has an 'any' type. - const openSubTab = (tabType, errorId: number | undefined = undefined) => { + const openSubTab = (tabType: WorkflowTabHierarchy, errorId: number | undefined = undefined) => { dispatch(removeNotificationWizardForm()); setHierarchy(tabType); if (tabType === "workflow-error-details") { diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperationDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperationDetails.tsx index a5d645a96c..d7929a4acb 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperationDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperationDetails.tsx @@ -8,18 +8,18 @@ import EventDetailsTabHierarchyNavigation from "./EventDetailsTabHierarchyNaviga import { useAppDispatch, useAppSelector } from "../../../../store"; import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; +import { WorkflowTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the workflow operation details for the workflows tab of the event details modal */ const EventDetailsWorkflowOperationDetails = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message - eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + setHierarchy: (subTabName: WorkflowTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const operationDetails = useAppSelector(state => getWorkflowOperationDetails(state)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperations.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperations.tsx index b97c18bfd3..2c307e0887 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperations.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowOperations.tsx @@ -9,15 +9,17 @@ import { useAppDispatch, useAppSelector } from "../../../../store"; import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { fetchWorkflowOperationDetails, fetchWorkflowOperations } from "../../../../slices/eventDetailsSlice"; import { useTranslation } from "react-i18next"; +import { WorkflowTabHierarchy } from "../modals/EventDetails"; /** * This component manages the workflow operations for the workflows tab of the event details modal */ const EventDetailsWorkflowOperations = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: WorkflowTabHierarchy) => void, }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowTab.tsx index 8b1cccb55f..ce38fece3a 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowTab.tsx @@ -28,20 +28,20 @@ import { import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; import { Tooltip } from "../../../shared/Tooltip"; +import { WorkflowTabHierarchy } from "../modals/EventDetails"; +import { useTranslation } from "react-i18next"; /** * This component manages the workflows tab of the event details modal */ const EventDetailsWorkflowTab = ({ -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, -// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type. - t, -// @ts-expect-error TS(7031): Binding element 'close' implicitly has an 'any' ty... Remove this comment to see the full error message - close, -// @ts-expect-error TS(7031): Binding element 'setHierarchy' implicitly has an '... Remove this comment to see the full error message setHierarchy, +}: { + eventId: string, + setHierarchy: (subTabName: WorkflowTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); @@ -69,28 +69,24 @@ const EventDetailsWorkflowTab = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); -// @ts-expect-error TS(7006): Parameter 'workflowId' implicitly has an 'any' typ... Remove this comment to see the full error message - const isCurrentWorkflow = (workflowId) => { + const isCurrentWorkflow = (workflowId: string) => { let currentWorkflow = workflows.entries[workflows.entries.length - 1]; return currentWorkflow.id === workflowId; }; -// @ts-expect-error TS(7006): Parameter 'workflowId' implicitly has an 'any' typ... Remove this comment to see the full error message - const workflowAction = (workflowId, action) => { + const workflowAction = (workflowId: string, action: string) => { if (!performingWorkflowAction) { - dispatch(performWorkflowAction({eventId, workflowId, action, close})); + dispatch(performWorkflowAction({eventId, workflowId, action})); } }; -// @ts-expect-error TS(7006): Parameter 'workflowId' implicitly has an 'any' typ... Remove this comment to see the full error message - const deleteWorkflow = (workflowId) => { + const deleteWorkflow = (workflowId: string) => { if (!deletingWorkflow) { dispatch(deleteWf({eventId, workflowId})); } }; -// @ts-expect-error TS(7006): Parameter 'tabType' implicitly has an 'any' type. - const openSubTab = (tabType, workflowId) => { + const openSubTab = (tabType: WorkflowTabHierarchy, workflowId: string) => { dispatch(fetchWorkflowDetails({eventId, workflowId})).then(); setHierarchy(tabType); dispatch(removeNotificationWizardForm()); diff --git a/src/components/events/partials/ModalTabsAndPages/SeriesDetailsAccessTab.tsx b/src/components/events/partials/ModalTabsAndPages/SeriesDetailsAccessTab.tsx index 0159765e42..f9d73c0e6c 100644 --- a/src/components/events/partials/ModalTabsAndPages/SeriesDetailsAccessTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/SeriesDetailsAccessTab.tsx @@ -31,7 +31,7 @@ const SeriesDetailsAccessTab = ({ const fetchSeriesDetailsAclsWrapper = (id: any) => { dispatch(fetchSeriesDetailsAcls(id)); } - const updateSeriesAccessWrapper = (id: any, policies: any) => { + const updateSeriesAccessWrapper = async (id: any, policies: any) => { dispatch(updateSeriesAccess({id, policies})); } @@ -44,7 +44,6 @@ const SeriesDetailsAccessTab = ({ = ({ +const EventDetails = ({ tabIndex, eventId, close, policyChanged, setPolicyChanged, +}: { + tabIndex: number, + eventId: string, + close?: () => void, + policyChanged: boolean, + setPolicyChanged: (value: boolean) => void, }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); @@ -77,8 +80,8 @@ const EventDetails : React.FC<{ }, []); const [page, setPage] = useState(tabIndex); - const [workflowTabHierarchy, setWorkflowTabHierarchy] = useState("entry"); - const [assetsTabHierarchy, setAssetsTabHierarchy] = useState("entry"); + const [workflowTabHierarchy, setWorkflowTabHierarchy] = useState("entry"); + const [assetsTabHierarchy, setAssetsTabHierarchy] = useState("entry"); // TODO: Get rid of the wrappers when modernizing redux is done const updateMetadataWrapper = (id: any, values: any) => { @@ -157,8 +160,7 @@ const EventDetails : React.FC<{ }, ]; -// @ts-expect-error TS(7006): Parameter 'tabNr' implicitly has an 'any' type. - const openTab = (tabNr) => { + const openTab = (tabNr: number) => { dispatch(removeNotificationWizardForm()); setWorkflowTabHierarchy("entry"); setAssetsTabHierarchy("entry"); @@ -221,7 +223,7 @@ const EventDetails : React.FC<{ @@ -239,89 +241,72 @@ const EventDetails : React.FC<{ ((assetsTabHierarchy === "entry" && ( )) || (assetsTabHierarchy === "add-asset" && ( )) || (assetsTabHierarchy === "asset-attachments" && ( )) || (assetsTabHierarchy === "attachment-details" && ( )) || (assetsTabHierarchy === "asset-catalogs" && ( )) || (assetsTabHierarchy === "catalog-details" && ( )) || (assetsTabHierarchy === "asset-media" && ( )) || (assetsTabHierarchy === "media-details" && ( )) || (assetsTabHierarchy === "asset-publications" && ( )) || (assetsTabHierarchy === "publication-details" && ( )))} {page === 4 && !isLoadingScheduling && ( - + )} {page === 5 && ((workflowTabHierarchy === "entry" && ( )) || (workflowTabHierarchy === "workflow-details" && ( )) || @@ -333,30 +318,24 @@ const EventDetails : React.FC<{ )) || (workflowTabHierarchy === "workflow-operation-details" && ( )) || (workflowTabHierarchy === "errors-and-warnings" && ( )) || (workflowTabHierarchy === "workflow-error-details" && ( )))} {page === 6 && ( @@ -364,15 +343,13 @@ const EventDetails : React.FC<{ {page === 7 && ( )} {page === 8 && !isLoadingStatistics && ( )} diff --git a/src/components/events/partials/modals/EventDetailsModal.tsx b/src/components/events/partials/modals/EventDetailsModal.tsx index 8b72efacb0..30adc4496b 100644 --- a/src/components/events/partials/modals/EventDetailsModal.tsx +++ b/src/components/events/partials/modals/EventDetailsModal.tsx @@ -10,16 +10,15 @@ import { availableHotkeys } from "../../../../configs/hotkeysConfig"; * This component renders the modal for displaying event details */ const EventDetailsModal = ({ -// @ts-expect-error TS(7031): Binding element 'handleClose' implicitly has an 'a... Remove this comment to see the full error message handleClose, -// @ts-expect-error TS(7031): Binding element 'showModal' implicitly has an 'any... Remove this comment to see the full error message - showModal, -// @ts-expect-error TS(7031): Binding element 'tabIndex' implicitly has an 'any'... Remove this comment to see the full error message tabIndex, -// @ts-expect-error TS(7031): Binding element 'eventTitle' implicitly has an 'an... Remove this comment to see the full error message eventTitle, -// @ts-expect-error TS(7031): Binding element 'eventId' implicitly has an 'any' ... Remove this comment to see the full error message eventId, +}: { + handleClose: () => void, + tabIndex: number, + eventTitle: string, + eventId: string, }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); @@ -48,36 +47,33 @@ const EventDetailsModal = ({ return ( // todo: add hotkeys - showModal && ( - <> -
-
-
-
+ <> +
+
+
+
- setPolicyChanged(value)} - /> -
- - ) - ); + setPolicyChanged(value)} + /> +
+ + ) }; export default EventDetailsModal; diff --git a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx index 327256a0ec..d265235cb0 100644 --- a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx +++ b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import RenderMultiField from "../wizard/RenderMultiField"; import { + Acl, Role, fetchAclActions, fetchAclTemplateById, @@ -8,7 +9,7 @@ import { fetchRolesWithTarget, } from "../../../slices/aclSlice"; import Notifications from "../Notifications"; -import { Formik, Field, FieldArray } from "formik"; +import { Formik, Field, FieldArray, FormikErrors } from "formik"; import { NOTIFICATION_CONTEXT } from "../../../configs/modalConfig"; import { createPolicy, @@ -20,28 +21,15 @@ import DropDown from "../DropDown"; import { filterRoles, getAclTemplateText } from "../../../utils/aclUtils"; import { useAppDispatch, useAppSelector } from "../../../store"; import { removeNotificationWizardForm, addNotification } from "../../../slices/notificationSlice"; +import { useTranslation } from "react-i18next"; +import { Ace, TransformedAcl } from "../../../slices/aclDetailsSlice"; /** * This component manages the access policy tab of resource details modals */ -const ResourceDetailsAccessPolicyTab : React.FC <{ - resourceId: any, - header: any, - t: any, - policies: any, - fetchHasActiveTransactions?: any, - fetchAccessPolicies: any, - saveNewAccessPolicies: any, - descriptionText: string, - buttonText: string, - saveButtonText: string, - editAccessRole: string, - policyChanged: any, - setPolicyChanged: any, -}> = ({ +const ResourceDetailsAccessPolicyTab = ({ resourceId, header, - t, policies, fetchHasActiveTransactions, fetchAccessPolicies, @@ -52,7 +40,21 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ editAccessRole, policyChanged, setPolicyChanged, +}: { + resourceId: string, + header: string, + policies: TransformedAcl[], + fetchHasActiveTransactions?: (id: string) => Promise, + fetchAccessPolicies: (id: string) => void, + saveNewAccessPolicies: (id: string, policies: { acl: { ace: Ace[] } }) => Promise, + descriptionText: string, + buttonText: string, + saveButtonText: string, + editAccessRole: string, + policyChanged: boolean, + setPolicyChanged: (value: boolean) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const baseAclId = ""; @@ -116,16 +118,14 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ }, []); /* resets the formik form and hides the save and cancel buttons */ -// @ts-expect-error TS(7006): Parameter 'resetFormik' implicitly has an 'any' ty... Remove this comment to see the full error message - const resetPolicies = (resetFormik) => { + const resetPolicies = (resetFormik: () => void) => { setPolicyChanged(false); resetFormik(); }; /* transforms rules into proper format for saving and checks validity * if the policies are valid, the new policies are saved in the backend */ -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - const saveAccess = (values) => { + const saveAccess = (values: { policies: TransformedAcl[] }) => { dispatch(removeNotificationWizardForm()); const { roleWithFullRightsExists, allRulesValid } = validatePolicies( values @@ -153,7 +153,6 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ } if (allRulesValid && roleWithFullRightsExists) { -// @ts-expect-error TS(2693): 'any' only refers to a type, but is being used as ... Remove this comment to see the full error message saveNewAccessPolicies(resourceId, access).then((success) => { // fetch new policies from the backend, if save successful if (success) { @@ -165,15 +164,12 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ }; /* validates the policies in the formik form */ -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - const validateFormik = (values) => { - const errors = {}; + const validateFormik = (values: { policies: TransformedAcl[] }) => { + const errors: FormikErrors<{ emptyRole: string }> = {}; setPolicyChanged(isPolicyChanged(values.policies)); // each policy needs a role -// @ts-expect-error TS(7006): Parameter 'policy' implicitly has an 'any' type. if (values.policies.find((policy) => !policy.role || policy.role === "")) { -// @ts-expect-error TS(2339): Property 'emptyRole' does not exist on type '{}'. errors.emptyRole = "Empty role!"; } @@ -183,12 +179,10 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ /* checks validity of the policies * each policy needs a role and at least one of: read-rights, write-rights, additional action * there needs to be at least one role, which has both read and write rights */ -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - const validatePolicies = (values) => { + const validatePolicies = (values: { policies: TransformedAcl[] }) => { let roleWithFullRightsExists = false; let allRulesValid = true; -// @ts-expect-error TS(7006): Parameter 'policy' implicitly has an 'any' type. values.policies.forEach((policy) => { if (policy.read && policy.write) { roleWithFullRightsExists = true; @@ -208,13 +202,11 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ /* checks whether the current state of the policies from the formik is different form the * initial policies or equal to them */ -// @ts-expect-error TS(7006): Parameter 'newPolicies' implicitly has an 'any' ty... Remove this comment to see the full error message - const isPolicyChanged = (newPolicies) => { + const isPolicyChanged = (newPolicies: TransformedAcl[]) => { if (newPolicies.length !== policies.length) { return true; } -// @ts-expect-error TS(7006): Parameter 'pol1' implicitly has an 'any' type. - const sortSchema = (pol1, pol2) => { + const sortSchema = (pol1: TransformedAcl, pol2: TransformedAcl) => { return pol1.role > pol2.role ? 1 : -1; }; const sortedNewPolicies = [...newPolicies].sort(sortSchema); @@ -248,8 +240,7 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ }; /* fetches the policies for the chosen template and sets the policies in the formik form to those policies */ -// @ts-expect-error TS(7006): Parameter 'templateId' implicitly has an 'any' typ... Remove this comment to see the full error message - const handleTemplateChange = async (templateId, setFormikFieldValue) => { + const handleTemplateChange = async (templateId: string, setFormikFieldValue: (field: string, value: any) => Promise) => { // fetch information about chosen template from backend let template = await fetchAclTemplateById(templateId); @@ -282,9 +273,8 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ }} enableReinitialize validate={(values) => validateFormik(values)} - onSubmit={(values, actions) => -// @ts-expect-error TS(2339): Property 'then' does not exist on type 'void'. - saveAccess(values).then((r) => {}) + onSubmit={(values) => + saveAccess(values) } > {(formik) => ( @@ -489,8 +479,7 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ ? "disabled" : "false" }`} -// @ts-expect-error TS(7006): Parameter 'read' implicitly has an 'any' type. - onChange={(read) => + onChange={(read: React.ChangeEvent) => replace(index, { ...policy, read: read.target.checked, @@ -514,8 +503,7 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ ? "disabled" : "false" }`} -// @ts-expect-error TS(7006): Parameter 'write' implicitly has an 'any' type. - onChange={(write) => + onChange={(write: React.ChangeEvent) => replace(index, { ...policy, write: @@ -555,9 +543,7 @@ const ResourceDetailsAccessPolicyTab : React.FC <{ )) && policy.actions.map( ( -// @ts-expect-error TS(7006): Parameter 'customAction' implicitly has an 'any' t... Remove this comment to see the full error message customAction, -// @ts-expect-error TS(7006): Parameter 'actionKey' implicitly has an 'any' type... Remove this comment to see the full error message actionKey ) => (
diff --git a/src/slices/eventDetailsSlice.ts b/src/slices/eventDetailsSlice.ts index 31e5d20b9e..5be2f84977 100644 --- a/src/slices/eventDetailsSlice.ts +++ b/src/slices/eventDetailsSlice.ts @@ -31,6 +31,7 @@ import { Statistics, fetchStatistics, fetchStatisticsValueUpdate } from './stati import { Ace, TransformedAcl, TransformedAcls } from './aclDetailsSlice'; type MetadataField = { + collection?: { [key: string]: unknown }[], // different for e.g. languages and presenters id: string, label: string, // translation key readOnly: boolean, @@ -39,6 +40,12 @@ type MetadataField = { value: string, } +export type MetadataCatalog = { + title: string, // translation key + flavor: string, + fields: MetadataField[] | undefined, +} + interface Assets { id: string, mimetype: string, @@ -67,7 +74,7 @@ type CommentAuthor = { type Workflow = { scheduling: boolean, entries: { - id: number, + id: string, status: string, //translation key submitted: string, //date submitter: string, @@ -162,16 +169,8 @@ type EventDetailsState = { statusStatisticsValue: 'uninitialized' | 'loading' | 'succeeded' | 'failed', errorStatisticsValue: SerializedError | null, eventId: string, - metadata: { - title: string, // translation key - flavor: string, - fields: MetadataField[] | undefined - }, - extendedMetadata: { - title: string, // not (necessarily) translation key - flavor: string, - fields: MetadataField[] | undefined - }[], + metadata: MetadataCatalog, + extendedMetadata: MetadataCatalog[], assets: { attachments: number, catalogs: number, @@ -234,12 +233,7 @@ type EventDetailsState = { assetPublicationDetails: AssetDetails & { channel: string, }, - policies: { - actions: string[], - read: boolean, - role: string, - write: boolean, - }[], + policies: TransformedAcl[], comments: { author: CommentAuthor, creationDate: string, @@ -1296,7 +1290,7 @@ export const performWorkflowAction = createAsyncThunk('eventDetails/performWorkf eventId: string, workflowId: string, action: string, - close: () => void, + close?: () => void, }, { dispatch }) => { const { eventId, workflowId, action, close} = params; let headers = { @@ -1327,7 +1321,7 @@ export const performWorkflowAction = createAsyncThunk('eventDetails/performWorkf context: NOTIFICATION_CONTEXT }) ); - close(); + close && close(); }) .catch((response) => { dispatch( @@ -1345,7 +1339,7 @@ export const performWorkflowAction = createAsyncThunk('eventDetails/performWorkf export const deleteWorkflow = createAsyncThunk('eventDetails/deleteWorkflow', async (params: { eventId: string, - workflowId: number + workflowId: string }, { dispatch, getState }) => { const { eventId, workflowId } = params; @@ -1505,11 +1499,7 @@ export const updateMetadata = createAsyncThunk('eventDetails/updateMetadata', as export const updateExtendedMetadata = createAsyncThunk('eventDetails/updateExtendedMetadata', async (params: { eventId: string, values: { [key: string]: any }, - catalog: { - flavor: string, - title: string, - fields: { [key: string]: any }[] - } + catalog: MetadataCatalog }, { dispatch, getState }) => { const { eventId, values, catalog } = params; @@ -1617,7 +1607,7 @@ export const updateAssets = createAsyncThunk('eventDetails/updateAssets', async export const saveAccessPolicies = createAsyncThunk('eventDetails/saveAccessPolicies', async (params: { eventId: string, - policies: { [key: string]: TransformedAcl } + policies: { acl: { ace: Ace[] } } }, { dispatch }) => { const { eventId, policies } = params; const headers = getHttpHeaders(); diff --git a/src/slices/seriesDetailsSlice.ts b/src/slices/seriesDetailsSlice.ts index a12c28a78c..a028d883f9 100644 --- a/src/slices/seriesDetailsSlice.ts +++ b/src/slices/seriesDetailsSlice.ts @@ -18,25 +18,11 @@ import { NOTIFICATION_CONTEXT } from "../configs/modalConfig"; import { RootState } from '../store'; import { Statistics, fetchStatistics, fetchStatisticsValueUpdate } from './statisticsSlice'; import { Ace, TransformedAcl, TransformedAcls } from './aclDetailsSlice'; +import { MetadataCatalog } from './eventDetailsSlice'; /** * This file contains redux reducer for actions affecting the state of a series */ -type MetadataCatalog = { - title: string, - flavor: string, - fields: { - collection?: {}[], // different for e.g. languages and presenters - id: string, - label: string, - readOnly: boolean, - required: boolean, - translatable?: boolean, - type: string, - value: string | string[], - }[] -} - type Feed = { link: string, type: string, diff --git a/src/utils/resourceUtils.ts b/src/utils/resourceUtils.ts index d16c350986..3c29f4f437 100644 --- a/src/utils/resourceUtils.ts +++ b/src/utils/resourceUtils.ts @@ -1,3 +1,4 @@ +import { Ace } from './../slices/aclDetailsSlice'; import { getFilters, getTextFilter } from "../selectors/tableFilterSelectors"; import { getPageLimit, @@ -397,10 +398,13 @@ export const getMetadataCollectionFieldName = (metadataField, field) => { }; // Prepare rules of access policies for post of new events or series -// @ts-expect-error TS(7006): Parameter 'policies' implicitly has an 'any' type. -export const prepareAccessPolicyRulesForPost = (policies) => { +export const prepareAccessPolicyRulesForPost = (policies: TransformedAcl[]) => { // access policies for post request - let access = { + let access : { + acl : { + ace: Ace[] + } + } = { acl: { ace: [], }, @@ -410,7 +414,6 @@ export const prepareAccessPolicyRulesForPost = (policies) => { for (let i = 0; policies.length > i; i++) { if (policies[i].read) { access.acl.ace = access.acl.ace.concat({ -// @ts-expect-error TS(2769): No overload matches this call. action: "read", allow: policies[i].read, role: policies[i].role, @@ -418,7 +421,6 @@ export const prepareAccessPolicyRulesForPost = (policies) => { } if (policies[i].write) { access.acl.ace = access.acl.ace.concat({ -// @ts-expect-error TS(2769): No overload matches this call. action: "write", allow: policies[i].write, role: policies[i].role, @@ -427,7 +429,6 @@ export const prepareAccessPolicyRulesForPost = (policies) => { if (policies[i].actions.length > 0) { for (let j = 0; policies[i].actions.length > j; j++) { access.acl.ace = access.acl.ace.concat({ -// @ts-expect-error TS(2769): No overload matches this call. action: policies[i].actions[j], allow: true, role: policies[i].role, From 71dbbea75d5ce1fcd9fbad33e441e11892745a9d Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Wed, 19 Jun 2024 17:39:04 +0200 Subject: [PATCH 07/30] Fix type error for missing organization property If an organization property does not exist, the admin interface completely breaks in some cases. This seems to happen on admin-interface.opencast.org right now: ``` Uncaught TypeError: u.toLowerCase is not a function qr Footer.tsx:25 React 8 D scheduler.production.min.js:13 $ scheduler.production.min.js:14 Footer.tsx:25:80 ``` What's interesting is that this only seems to happen with the compiled code. Starting the development server, calling `toLowerCase()` just works. In any case, this patch fixes the issue by providing the default value first, so that `toLowerCase()` is always called on a string. --- src/components/Footer.tsx | 2 +- src/components/events/partials/modals/SeriesDetails.tsx | 2 +- src/components/events/partials/wizards/NewSeriesWizard.tsx | 2 +- src/components/shared/MainNav.tsx | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 1671dc6f57..33ef6dc0b5 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -22,7 +22,7 @@ const Footer: React.FC = () => { const lastModified = user?.ocVersion?.['last-modified'] ? new Date(user.ocVersion['last-modified']).toISOString().substring(0, 10) : 'unknown'; - const aboutEnabled = orgProperties['org.opencastproject.admin.display_about']?.toLowerCase() === 'true'; + const aboutEnabled = (orgProperties['org.opencastproject.admin.display_about'] || 'false').toLowerCase() === 'true'; return (
diff --git a/src/components/events/partials/modals/SeriesDetails.tsx b/src/components/events/partials/modals/SeriesDetails.tsx index 0eefdacec3..3806492fff 100644 --- a/src/components/events/partials/modals/SeriesDetails.tsx +++ b/src/components/events/partials/modals/SeriesDetails.tsx @@ -62,7 +62,7 @@ const SeriesDetails = ({ const user = useAppSelector(state => getUserInformation(state)); const orgProperties = useAppSelector(state => getOrgProperties(state)); - const themesEnabled = (orgProperties['admin.themes.enabled']?.toLowerCase() || 'true') === 'true'; + const themesEnabled = (orgProperties['admin.themes.enabled'] || 'true').toLowerCase() === 'true'; // information about each tab const tabs = [ diff --git a/src/components/events/partials/wizards/NewSeriesWizard.tsx b/src/components/events/partials/wizards/NewSeriesWizard.tsx index a85a06e5f6..976f4ec90a 100644 --- a/src/components/events/partials/wizards/NewSeriesWizard.tsx +++ b/src/components/events/partials/wizards/NewSeriesWizard.tsx @@ -35,7 +35,7 @@ const NewSeriesWizard: React.FC<{ const user = useAppSelector(state => getUserInformation(state)); const orgProperties = useAppSelector(state => getOrgProperties(state)); - const themesEnabled = (orgProperties['admin.themes.enabled']?.toLowerCase() || 'true') === 'true'; + const themesEnabled = (orgProperties['admin.themes.enabled'] || 'true').toLowerCase() === 'true'; const initialValues = getInitialValues(metadataFields, extendedMetadata, user); diff --git a/src/components/shared/MainNav.tsx b/src/components/shared/MainNav.tsx index 1b17843a10..1c6318e0fc 100644 --- a/src/components/shared/MainNav.tsx +++ b/src/components/shared/MainNav.tsx @@ -74,8 +74,8 @@ const MainNav = ({ const user = useAppSelector(state => getUserInformation(state)); const orgProperties = useAppSelector(state => getOrgProperties(state)); - const statisticsEnabled = orgProperties['admin.statistics.enabled']?.toLowerCase() === 'true'; - const themesEnabled = (orgProperties['admin.themes.enabled']?.toLowerCase() || 'true') === 'true'; + const statisticsEnabled = (orgProperties['admin.statistics.enabled'] || 'false').toLowerCase() === 'true'; + const themesEnabled = (orgProperties['admin.themes.enabled'] || 'true').toLowerCase() === 'true'; const loadEvents = () => { dispatch(fetchFilters("events")); From 067136422e3268b5b73efc72ac96ff2d87d9f2bf Mon Sep 17 00:00:00 2001 From: Ron Lucke Date: Thu, 20 Jun 2024 10:24:07 +0200 Subject: [PATCH 08/30] fix a11y issues in header nav --- src/components/Header.tsx | 22 ++++++------ src/styles/components/_header.scss | 58 ++++++++++++------------------ 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 54521bf5ac..653a8f01c4 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -165,11 +165,11 @@ const Header = ({ {/* Select language */}
-
setMenuLang(!displayMenuLang)}> +
+
{displayMenuLang && }
@@ -213,7 +213,7 @@ const Header = ({ id="info-dd" ref={containerNotify} > -
setMenuNotify(!displayMenuNotify)}> +