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

Added track removing confirmation #4846

Merged
merged 6 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Publishing dev version of CVAT docker images (<https://github.com/cvat-ai/cvat/pull/53>)
- Support of Human Pose Estimation, Facial Landmarks (and similar) use-cases, new shape type: Skeleton (<https://github.com/cvat-ai/cvat/pull/1>)
- Added helm chart support for serverless functions and analytics (<https://github.com/cvat-ai/cvat/pull/110>)
- Added confirmation when remove a track (<https://github.com/opencv/cvat/pull/4846>)

### Changed
- Bumped nuclio version to 1.8.14
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.41.0",
"version": "1.41.1",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// Copyright (C) 2022 Intel Corporation
// Copyright (C) CVAT.ai corp
//
// SPDX-License-Identifier: MIT

import React, { useCallback, useEffect, useState } from 'react';

import { useDispatch, useSelector } from 'react-redux';
import { CombinedState } from 'reducers';

import { CombinedState, ObjectType } from 'reducers';
import Text from 'antd/lib/typography/Text';
import Modal from 'antd/lib/modal';

import consts from 'consts';
import { removeObjectAsync, removeObject as removeObjectAction } from 'actions/annotation-actions';

export default function RemoveConfirmComponent(): JSX.Element | null {
const [visible, setVisible] = useState(false);
const [title, setTitle] = useState('');
const [description, setDescription] = useState<JSX.Element>(<></>);
const objectState = useSelector((state: CombinedState) => state.annotation.remove.objectState);
const force = useSelector((state: CombinedState) => state.annotation.remove.force);
const jobInstance = useSelector((state: CombinedState) => state.annotation.job.instance);
Expand All @@ -21,13 +24,37 @@ export default function RemoveConfirmComponent(): JSX.Element | null {
const onOk = useCallback(() => {
dispatch(removeObjectAsync(jobInstance, objectState, true));
}, [jobInstance, objectState]);

const onCancel = useCallback(() => {
dispatch(removeObjectAction(null, false));
}, []);

useEffect(() => {
const newVisible = !!objectState && !force && objectState.lock;
const newVisible = (!!objectState && !force && objectState.lock) ||
(objectState?.objectType === ObjectType.TRACK && !force);
setTitle(objectState?.lock ? 'Object is locked' : 'Remove object');
let descriptionMessage: string | JSX.Element = 'Are you sure you want to remove it?';

if (objectState?.objectType === ObjectType.TRACK && !force) {
descriptionMessage = (
<>
<Text>
{
`The object you are trying to remove is a track.
If you continue, it removes many drawn objects on different frames.
If you want to hide it only on this frame, use the outside feature instead.
${descriptionMessage}`
}
</Text>
<div className='cvat-remove-object-confirm-wrapper'>
{/* eslint-disable-next-line */}
<img src={consts.OUTSIDE_PIC_URL} />
</div>
</>
);
}

setDescription(descriptionMessage);
setVisible(newVisible);
if (!newVisible && objectState) {
dispatch(removeObjectAsync(jobInstance, objectState, true));
Expand All @@ -46,7 +73,7 @@ export default function RemoveConfirmComponent(): JSX.Element | null {
className='cvat-modal-confirm'
>
<div>
Are you sure you want to remove it?
{description}
</div>
</Modal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,9 @@
margin: 0 5px;
}
}

.cvat-remove-object-confirm-wrapper {
display: flex;
justify-content: center;
margin-top: $grid-unit-size * 2;
}
2 changes: 2 additions & 0 deletions cvat-ui/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const DEFAULT_PROJECT_SUBSETS = ['Train', 'Test', 'Validation'];
const INTEL_TERMS_OF_USE_URL = 'https://www.intel.com/content/www/us/en/legal/terms-of-use.html';
const INTEL_COOKIES_URL = 'https://www.intel.com/content/www/us/en/privacy/intel-cookie-notice.html';
const INTEL_PRIVACY_URL = 'https://www.intel.com/content/www/us/en/privacy/intel-privacy-notice.html';
const OUTSIDE_PIC_URL = 'https://opencv.github.io/cvat/images/image019.jpg';
const DEFAULT_AWS_S3_REGIONS: string[][] = [
['us-east-1', 'US East (N. Virginia)'],
['us-east-2', 'US East (Ohio)'],
Expand Down Expand Up @@ -108,4 +109,5 @@ export default {
INTEL_PRIVACY_URL,
DEFAULT_AWS_S3_REGIONS,
DEFAULT_GOOGLE_CLOUD_STORAGE_LOCATIONS,
OUTSIDE_PIC_URL,
};