diff --git a/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadContainerRevisionForm.component.tsx b/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadContainerRevisionForm.component.tsx index 9b20e123d3..dbbf573c29 100644 --- a/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadContainerRevisionForm.component.tsx +++ b/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadContainerRevisionForm.component.tsx @@ -90,9 +90,7 @@ export const UploadContainerRevisionForm = ({ const project = ProjectsHooksSelectors.selectCurrentProject(); const allUploadsComplete = ContainerRevisionsHooksSelectors.selectUploadIsComplete(); const revisionsArePending = ContainerRevisionsHooksSelectors.selectRevisionsPending(presetContainerId); - const revisions = ContainerRevisionsHooksSelectors.selectRevisions(presetContainerId); const presetContainer = ContainersHooksSelectors.selectContainerById(presetContainerId); - const [alreadyExistingTags, setAlreadyExistingTags] = useState([]); const [isUploading, setIsUploading] = useState(false); const formData = useForm({ @@ -100,7 +98,6 @@ export const UploadContainerRevisionForm = ({ resolver: !isUploading ? yupResolver(UploadsSchema) : undefined, context: { alreadyExistingNames: [], - alreadyExistingTags, teamspace, project, }, @@ -201,11 +198,6 @@ export const UploadContainerRevisionForm = ({ ContainerRevisionsActionsDispatchers.fetch(teamspace, project, presetContainerId); }, []); - useEffect(() => { - if (!revisions.length) return; - setAlreadyExistingTags(revisions.map((r) => r.tag)); - }, [revisions.length]); - return ( {/* @ts-ignore */} diff --git a/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadList/uploadListItem/uploadListItem.component.tsx b/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadList/uploadListItem/uploadListItem.component.tsx index 503f7dd4cc..80c77e3d65 100644 --- a/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadList/uploadListItem/uploadListItem.component.tsx +++ b/frontend/src/v5/ui/routes/dashboard/projects/containers/uploadContainerRevisionForm/uploadList/uploadListItem/uploadListItem.component.tsx @@ -27,7 +27,7 @@ import { useFormContext } from 'react-hook-form'; import { useEffect } from 'react'; import { IContainer, UploadStatus } from '@/v5/store/containers/containers.types'; import { UploadItemFields } from '@/v5/store/containers/revisions/containerRevisions.types'; -import { ContainersActionsDispatchers } from '@/v5/services/actionsDispatchers'; +import { ContainerRevisionsActionsDispatchers, ContainersActionsDispatchers } from '@/v5/services/actionsDispatchers'; import { UploadListItemFileIcon } from '@components/shared/uploadFiles/uploadList/uploadListItem/uploadListItemFileIcon/uploadListItemFileIcon.component'; import { UploadListItemTitle } from '@components/shared/uploadFiles/uploadList/uploadListItem/uploadListItemTitle/uploadListItemTitle.component'; import { UploadProgress } from '@components/shared/uploadFiles/uploadList/uploadListItem/uploadProgress/uploadProgress.component'; @@ -95,6 +95,9 @@ export const UploadListItem = ({ }); useEffect(() => { + if (containerId) { + ContainerRevisionsActionsDispatchers.fetch(teamspace, projectId, containerId); + } trigger(`${revisionPrefix}.revisionTag`); for (const [key, val] of Object.entries(sanitiseContainer(selectedContainer))) { diff --git a/frontend/src/v5/validation/containerAndFederationSchemes/validators.ts b/frontend/src/v5/validation/containerAndFederationSchemes/validators.ts index 83af6f415d..c2277ca602 100644 --- a/frontend/src/v5/validation/containerAndFederationSchemes/validators.ts +++ b/frontend/src/v5/validation/containerAndFederationSchemes/validators.ts @@ -18,6 +18,8 @@ import * as Yup from 'yup'; import { formatMessage } from '@/v5/services/intl'; import { alphaNumericHyphens, stripIfBlankString } from '../shared/validators'; +import { selectRevisions } from '@/v5/store/containers/revisions/containerRevisions.selectors'; +import { getState } from '@/v5/helpers/redux.helpers'; export const nullableNumberField = Yup.number() .transform((value) => (Number.isNaN(value) ? null : value)) @@ -64,8 +66,8 @@ export const revisionTag = Yup.string() defaultMessage: 'This tag is already used within this container', }), (value, testContext) => { - if (!testContext.options?.context) return true; - return !testContext.options.context.alreadyExistingTags?.map((n) => n.trim().toLocaleLowerCase()).includes(value?.toLocaleLowerCase()); + const revisions = selectRevisions(getState(), testContext.parent.containerId); + return !revisions?.map(({ tag }) => tag.trim().toLocaleLowerCase()).includes(value?.toLocaleLowerCase()); }, );