diff --git a/src/components/events/partials/EventActionCell.tsx b/src/components/events/partials/EventActionCell.tsx index 349712ee7b..9c85b53298 100644 --- a/src/components/events/partials/EventActionCell.tsx +++ b/src/components/events/partials/EventActionCell.tsx @@ -101,13 +101,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 1cb0e85aea..b22fb56e90 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 1111714319..5e1375918e 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachmentDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachmentDetails.tsx @@ -6,18 +6,18 @@ 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)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx index c360951ae0..dac854920c 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetAttachments.tsx @@ -6,25 +6,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 516eaef5f8..4ec013a0e5 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogDetails.tsx @@ -6,18 +6,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 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)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx index 2c6e6dbc68..462e2c4b17 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetCatalogs.tsx @@ -6,25 +6,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 8bb345f46b..26d391458e 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMedia.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMedia.tsx @@ -6,25 +6,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 8f4a5e8121..91b8ad6e50 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMediaDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetMediaDetails.tsx @@ -9,18 +9,19 @@ 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)); diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx index 7d3a8cfd5f..526f030f66 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublicationDetails.tsx @@ -6,18 +6,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 cff0ba6749..e9feb4c257 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublications.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetPublications.tsx @@ -6,22 +6,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 b46d9d714a..035e063970 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 96b05cbe6e..ab97f1d903 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsTab.tsx @@ -18,6 +18,8 @@ import { fetchAssetPublications, fetchAssets, } from "../../../../slices/eventDetailsSlice"; +import { useTranslation } from "react-i18next"; +import { AssetTabHierarchy } from "../modals/EventDetails"; import EventDetailsAssetsAddAsset from "./EventDetailsAssetsAddAsset"; import EventDetailsAssetAttachments from "./EventDetailsAssetAttachments"; import EventDetailsAssetAttachmentDetails from "./EventDetailsAssetAttachmentDetails"; @@ -32,15 +34,15 @@ import EventDetailsAssetPublicationDetails from "./EventDetailsAssetPublicationD * 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 'assetsTabHierarchy' implicitly has an '... Remove this comment to see the full error message - assetsTabHierarchy, -// @ts-expect-error TS(7031): Binding element 'setAssetsTabHierarchy' implicitly has an '... Remove this comment to see the full error message - setAssetsTabHierarchy, + assetsTabHierarchy, + setAssetsTabHierarchy, +}: { + eventId: string, + assetsTabHierarchy: AssetTabHierarchy, + setAssetsTabHierarchy: (subTabName: AssetTabHierarchy) => void, }) => { + const { t } = useTranslation(); const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); @@ -95,24 +97,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") { @@ -179,8 +173,6 @@ const EventDetailsAssetsTab = ({ openSubTab( "add-asset", "newassetupload", - false, - true ) } > @@ -305,63 +297,50 @@ const EventDetailsAssetsTab = ({ (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" && ( )))} diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx index d0f24ceeeb..63e66145d5 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 261772398d..534f96ddf4 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)); @@ -640,7 +641,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 9e7cc4bbea..8b32a89ecc 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(); @@ -68,8 +71,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) => { @@ -148,8 +151,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"); @@ -212,7 +214,7 @@ const EventDetails : React.FC<{ @@ -229,27 +231,23 @@ const EventDetails : React.FC<{ {page === 3 && ( )} {page === 4 && !isLoadingScheduling && ( - + )} {page === 5 && ((workflowTabHierarchy === "entry" && ( )) || (workflowTabHierarchy === "workflow-details" && ( )) || @@ -261,30 +259,24 @@ const EventDetails : React.FC<{ )) || (workflowTabHierarchy === "workflow-operation-details" && ( )) || (workflowTabHierarchy === "errors-and-warnings" && ( )) || (workflowTabHierarchy === "workflow-error-details" && ( )))} {page === 6 && ( @@ -292,15 +284,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 8c109dfb69..8b72d0be4d 100644 --- a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx +++ b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx @@ -8,7 +8,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 +20,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 +39,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 +117,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 +152,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 +163,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 +178,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 +201,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 +239,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 +272,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) => ( @@ -487,8 +476,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, @@ -512,8 +500,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: @@ -553,9 +540,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 bdde6074a4..26728167b4 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,