// Copyright (C) 2020-2022 Intel Corporation // // SPDX-License-Identifier: MIT import './styles.scss'; import React, { useCallback } from 'react'; import Menu from 'antd/lib/menu'; import Modal from 'antd/lib/modal'; import { LoadingOutlined } from '@ant-design/icons'; // eslint-disable-next-line import/no-extraneous-dependencies import { MenuInfo } from 'rc-menu/lib/interface'; import LoadSubmenu from './load-submenu'; import { DimensionType } from '../../reducers/interfaces'; interface Props { taskID: number; taskMode: string; bugTracker: string; loaders: any[]; dumpers: any[]; loadActivity: string | null; inferenceIsActive: boolean; taskDimension: DimensionType; onClickMenu: (params: MenuInfo) => void; onUploadAnnotations: (format: string, file: File) => void; exportIsActive: boolean; } export enum Actions { LOAD_TASK_ANNO = 'load_task_anno', EXPORT_TASK_DATASET = 'export_task_dataset', DELETE_TASK = 'delete_task', RUN_AUTO_ANNOTATION = 'run_auto_annotation', MOVE_TASK_TO_PROJECT = 'move_task_to_project', OPEN_BUG_TRACKER = 'open_bug_tracker', EXPORT_TASK = 'export_task', } function ActionsMenuComponent(props: Props): JSX.Element { const { taskID, bugTracker, inferenceIsActive, loaders, onClickMenu, onUploadAnnotations, loadActivity, taskDimension, exportIsActive, } = props; const onClickMenuWrapper = useCallback( (params: MenuInfo) => { if (!params) { return; } if (params.key === Actions.DELETE_TASK) { Modal.confirm({ title: `The task ${taskID} will be deleted`, content: 'All related data (images, annotations) will be lost. Continue?', className: 'cvat-modal-confirm-delete-task', onOk: () => { onClickMenu(params); }, okButtonProps: { type: 'primary', danger: true, }, okText: 'Delete', }); } else { onClickMenu(params); } }, [taskID], ); return ( {LoadSubmenu({ loaders, loadActivity, onFileUpload: (format: string, file: File): void => { if (file) { Modal.confirm({ title: 'Current annotation will be lost', content: 'You are going to upload new annotations to this task. Continue?', className: 'cvat-modal-content-load-task-annotation', onOk: () => { onUploadAnnotations(format, file); }, okButtonProps: { type: 'primary', danger: true, }, okText: 'Update', }); } }, menuKey: Actions.LOAD_TASK_ANNO, taskDimension, })} Export task dataset {!!bugTracker && Open bug tracker} Automatic annotation } > Backup Task Move to project Delete ); } export default React.memo(ActionsMenuComponent);