diff --git a/CHANGELOG.md b/CHANGELOG.md index af41a9bc6d1e..14a492c09bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Downloading additional data from cloud storage if use_cache=true and job_file_mapping are specified () - Leaving an organization () +- Validation on Cloud Storage form / error message on create task form () + ## \[2.7.1\] - 2023-09-15 diff --git a/cvat-ui/package.json b/cvat-ui/package.json index b24ee60adba6..ef151fdee642 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.57.0", + "version": "1.57.1", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/create-cloud-storage-page/manifests-manager.tsx b/cvat-ui/src/components/create-cloud-storage-page/manifests-manager.tsx index 36a646f85540..2a5809b5268d 100644 --- a/cvat-ui/src/components/create-cloud-storage-page/manifests-manager.tsx +++ b/cvat-ui/src/components/create-cloud-storage-page/manifests-manager.tsx @@ -90,6 +90,11 @@ export default function ManifestsManager(props: Props): JSX.Element { required: true, message: 'Please specify a manifest name', }, + { + type: 'string', + pattern: /^.*\.(jsonl)$/, + message: 'Manifest file must have .jsonl extension', + }, ]} initialValue={field.name} > diff --git a/cvat-ui/src/components/create-task-page/create-task-content.tsx b/cvat-ui/src/components/create-task-page/create-task-content.tsx index 362e32ca31be..a1ab6c27b177 100644 --- a/cvat-ui/src/components/create-task-page/create-task-content.tsx +++ b/cvat-ui/src/components/create-task-page/create-task-content.tsx @@ -99,26 +99,44 @@ const defaultState: State = { }; const UploadFileErrorMessages = { - one: 'It can not be processed. You can upload an archive with images, a video, a pdf file or multiple images', - multi: 'It can not be processed. You can upload one or more videos', + one: 'Wrong list of files. You can upload an archive with images, a video, a pdf file or multiple images. ', + multi: 'Wrong list of files. You can upload one or more videos. ', }; +function receiveExtensions(files: RemoteFile[]): string[] { + const fileTypes = files.filter((file: RemoteFile) => file.name.includes('.')) + .map((file: RemoteFile) => `.${file.name.split('.').pop()}`); + return fileTypes; +} + +function checkFiles(files: RemoteFile[], type: SupportedShareTypes, baseError: string): string { + const erroredFiles = files.filter( + (it) => it.mimeType !== type, + ); + if (erroredFiles.length !== 0) { + const unsupportedTypes = receiveExtensions(erroredFiles); + const extensionList = Array.from(new Set(unsupportedTypes)); + return extensionList.length ? `${baseError} Found unsupported types: ${extensionList.join(', ')}. ` : baseError; + } + return ''; +} + function validateRemoteFiles(remoteFiles: RemoteFile[], many: boolean): string { let uploadFileErrorMessage = ''; - let filteredFiles = remoteFiles; const regFiles = remoteFiles.filter((file) => file.type === 'REG'); const excludedManifests = regFiles.filter((file) => !file.key.endsWith('.jsonl')); if (!many && excludedManifests.length > 1) { - uploadFileErrorMessage = excludedManifests.every( - (it) => it.mimeType === SupportedShareTypes.IMAGE, - ) ? '' : UploadFileErrorMessages.one; + uploadFileErrorMessage = checkFiles( + excludedManifests, + SupportedShareTypes.IMAGE, + UploadFileErrorMessages.one, + ); } else if (many) { - filteredFiles = filteredFiles.filter((it) => it.mimeType === SupportedShareTypes.VIDEO); - // something is selected and no one video - // or something except of videos selected (excluding directories) - uploadFileErrorMessage = remoteFiles.length && ( - !filteredFiles.length || filteredFiles.length !== regFiles.length - ) ? UploadFileErrorMessages.multi : ''; + uploadFileErrorMessage = checkFiles( + regFiles, + SupportedShareTypes.VIDEO, + UploadFileErrorMessages.multi, + ); } return uploadFileErrorMessage; } diff --git a/cvat-ui/src/components/file-manager/remote-browser.tsx b/cvat-ui/src/components/file-manager/remote-browser.tsx index a9e7266f35a6..ceb74330a4ac 100644 --- a/cvat-ui/src/components/file-manager/remote-browser.tsx +++ b/cvat-ui/src/components/file-manager/remote-browser.tsx @@ -29,7 +29,7 @@ interface Node { nextToken?: string | null; } -export type RemoteFile = Pick; +export type RemoteFile = Pick; interface Props { resource: 'share' | CloudStorage;