|
|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
// Copyright (C) 2021-2022 Intel Corporation
|
|
|
|
|
// Copyright (C) 2023 CVAT.ai Corporation
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
import { DeleteOutlined, PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
|
|
|
import Button from 'antd/lib/button';
|
|
|
|
|
import Col from 'antd/lib/col';
|
|
|
|
|
@ -10,7 +11,6 @@ import Form, { RuleObject } from 'antd/lib/form';
|
|
|
|
|
import { FormListFieldData, FormListOperation } from 'antd/lib/form/FormList';
|
|
|
|
|
import Input from 'antd/lib/input';
|
|
|
|
|
import Row from 'antd/lib/row';
|
|
|
|
|
import notification from 'antd/lib/notification';
|
|
|
|
|
import Tooltip from 'antd/lib/tooltip';
|
|
|
|
|
import config from 'config';
|
|
|
|
|
|
|
|
|
|
@ -22,8 +22,6 @@ interface Props {
|
|
|
|
|
|
|
|
|
|
export default function ManifestsManager(props: Props): JSX.Element {
|
|
|
|
|
const { form, manifestNames, setManifestNames } = props;
|
|
|
|
|
const maxManifestsCount = useRef(5);
|
|
|
|
|
const [limitingAddingManifestNotification, setLimitingAddingManifestNotification] = useState(false);
|
|
|
|
|
const { DATASET_MANIFEST_GUIDE_URL } = config;
|
|
|
|
|
|
|
|
|
|
const updateManifestFields = (): void => {
|
|
|
|
|
@ -40,15 +38,6 @@ export default function ManifestsManager(props: Props): JSX.Element {
|
|
|
|
|
updateManifestFields();
|
|
|
|
|
}, [manifestNames]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (limitingAddingManifestNotification) {
|
|
|
|
|
notification.warning({
|
|
|
|
|
message: `Unable to add manifest. The maximum number of files is ${maxManifestsCount.current}`,
|
|
|
|
|
className: 'cvat-notification-limiting-adding-manifest',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [limitingAddingManifestNotification]);
|
|
|
|
|
|
|
|
|
|
const onChangeManifestPath = (manifestName: string | undefined, manifestId: number): void => {
|
|
|
|
|
if (manifestName !== undefined) {
|
|
|
|
|
setManifestNames(manifestNames.map((name, idx) => (idx !== manifestId ? name : manifestName)));
|
|
|
|
|
@ -56,18 +45,11 @@ export default function ManifestsManager(props: Props): JSX.Element {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onDeleteManifestItem = (key: number): void => {
|
|
|
|
|
if (maxManifestsCount.current === manifestNames.length && limitingAddingManifestNotification) {
|
|
|
|
|
setLimitingAddingManifestNotification(false);
|
|
|
|
|
}
|
|
|
|
|
setManifestNames(manifestNames.filter((name, idx) => idx !== key));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onAddManifestItem = (): void => {
|
|
|
|
|
if (maxManifestsCount.current <= manifestNames.length) {
|
|
|
|
|
setLimitingAddingManifestNotification(true);
|
|
|
|
|
} else {
|
|
|
|
|
setManifestNames(manifestNames.concat(['']));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|