Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Cloud Storage form/create task error message #6890

Merged
merged 9 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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
(<https://github.com/opencv/cvat/pull/6879>)
- Leaving an organization (<https://github.com/opencv/cvat/pull/6422>)
- Validation on Cloud Storage form / error message on create task form (<https://github.com/opencv/cvat/pull/6890>)


## \[2.7.1\] - 2023-09-15

Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
>
Expand Down
42 changes: 30 additions & 12 deletions cvat-ui/src/components/create-task-page/create-task-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/components/file-manager/remote-browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Node {
nextToken?: string | null;
}

export type RemoteFile = Pick<Node, 'key' | 'type' | 'mimeType'>;
export type RemoteFile = Pick<Node, 'key' | 'type' | 'mimeType' | 'name'>;

interface Props {
resource: 'share' | CloudStorage;
Expand Down
Loading