Skip to content

Commit

Permalink
applied comments
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed Oct 2, 2023
1 parent d70f9bf commit f220a0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function ManifestsManager(props: Props): JSX.Element {
{
type: 'string',
pattern: /^.*\.(jsonl)$/,
message: 'Manifest file should be in the .jsonl format',
message: 'Manifest file must have .jsonl extension',
},
]}
initialValue={field.name}
Expand Down
15 changes: 8 additions & 7 deletions cvat-ui/src/components/create-task-page/create-task-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,23 @@ 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 fileExtensionList(files: RemoteFile[]): string {
const fileTypes = files.map((file: RemoteFile) => `.${file.name.split('.').pop()}`);
return Array.from(new Set(fileTypes)).join(', ');
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 = fileExtensionList(erroredFiles);
return `${baseError} Found unsupported types: ${unsupportedTypes} `;
const unsupportedTypes = receiveExtensions(erroredFiles);
return unsupportedTypes.length ? `${baseError} Found unsupported types: ${unsupportedTypes} ` : baseError;
}
return '';
}
Expand Down

0 comments on commit f220a0e

Please sign in to comment.