From 582e23bf889ef4a47dc09cdcd8074ac65e3fe00d Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Wed, 19 Aug 2020 14:47:58 +0300 Subject: [PATCH] Batch of fixes (#2031) --- CHANGELOG.md | 1 + cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- cvat-ui/src/actions/tasks-actions.ts | 10 ++++--- .../create-task-page/create-task-content.tsx | 20 +++++++++++--- .../create-task-page/create-task-page.tsx | 3 +++ cvat-ui/src/components/header/header.tsx | 26 ++++++++++++++----- .../labels-editor/constructor-creator.tsx | 22 +++++++++++++--- .../components/labels-editor/label-form.tsx | 9 +++++++ .../labels-editor/labels-editor.tsx | 2 ++ .../components/labels-editor/raw-viewer.tsx | 4 +++ .../create-task-page/create-task-page.tsx | 1 + cvat-ui/src/reducers/interfaces.ts | 1 + cvat-ui/src/reducers/tasks-reducer.ts | 4 +++ cvat/apps/engine/serializers.py | 10 +++++++ tests/cypress/support/commands.js | 2 +- 16 files changed, 100 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df9cb1cbd51..a85c3c33060d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Issue loading openvino models for semi-automatic and automatic annotation () - Basic functions of CVAT works without activated nuclio dashboard +- Fixed error with creating task with labels with the same name () ### Security - diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 8def8aaa4709..1f47f08107da 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.7.1", + "version": "1.7.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index f20e3eb6da67..f1a563ee4e8e 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.7.1", + "version": "1.7.2", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/actions/tasks-actions.ts b/cvat-ui/src/actions/tasks-actions.ts index 4097f0198e85..c61c12d756eb 100644 --- a/cvat-ui/src/actions/tasks-actions.ts +++ b/cvat-ui/src/actions/tasks-actions.ts @@ -344,10 +344,12 @@ function createTask(): AnyAction { return action; } -function createTaskSuccess(): AnyAction { +function createTaskSuccess(taskId: number): AnyAction { const action = { type: TasksActionTypes.CREATE_TASK_SUCCESS, - payload: {}, + payload: { + taskId, + }, }; return action; @@ -433,10 +435,10 @@ ThunkAction, {}, {}, AnyAction> { dispatch(createTask()); try { - await taskInstance.save((status: string): void => { + const savedTask = await taskInstance.save((status: string): void => { dispatch(createTaskUpdateStatus(status)); }); - dispatch(createTaskSuccess()); + dispatch(createTaskSuccess(savedTask.id)); } catch (error) { dispatch(createTaskFailed(error)); } diff --git a/cvat-ui/src/components/create-task-page/create-task-content.tsx b/cvat-ui/src/components/create-task-page/create-task-content.tsx index 7ee99a6a1e5e..18de3d7aa348 100644 --- a/cvat-ui/src/components/create-task-page/create-task-content.tsx +++ b/cvat-ui/src/components/create-task-page/create-task-content.tsx @@ -3,6 +3,8 @@ // SPDX-License-Identifier: MIT import React from 'react'; +import { RouteComponentProps } from 'react-router'; +import { withRouter } from 'react-router-dom'; import { Row, Col } from 'antd/lib/grid'; import Alert from 'antd/lib/alert'; import Button from 'antd/lib/button'; @@ -26,6 +28,7 @@ export interface CreateTaskData { interface Props { onCreate: (data: CreateTaskData) => void; status: string; + taskId: number | null; installedGit: boolean; } @@ -48,22 +51,31 @@ const defaultState = { }, }; -export default class CreateTaskContent extends React.PureComponent { +class CreateTaskContent extends React.PureComponent { private basicConfigurationComponent: any; private advancedConfigurationComponent: any; private fileManagerContainer: any; - public constructor(props: Props) { + public constructor(props: Props & RouteComponentProps) { super(props); this.state = { ...defaultState }; } public componentDidUpdate(prevProps: Props): void { - const { status } = this.props; + const { status, history, taskId } = this.props; if (status === 'CREATED' && prevProps.status !== 'CREATED') { + const btn = ( + + ); + notification.info({ message: 'The task has been created', + btn, }); this.basicConfigurationComponent.resetFields(); @@ -252,3 +264,5 @@ export default class CreateTaskContent extends React.PureComponent ); } } + +export default withRouter(CreateTaskContent); diff --git a/cvat-ui/src/components/create-task-page/create-task-page.tsx b/cvat-ui/src/components/create-task-page/create-task-page.tsx index 15c5f18c47a6..39549ea68dd8 100644 --- a/cvat-ui/src/components/create-task-page/create-task-page.tsx +++ b/cvat-ui/src/components/create-task-page/create-task-page.tsx @@ -16,6 +16,7 @@ interface Props { onCreate: (data: CreateTaskData) => void; status: string; error: string; + taskId: number | null; installedGit: boolean; } @@ -23,6 +24,7 @@ export default function CreateTaskPage(props: Props): JSX.Element { const { error, status, + taskId, onCreate, installedGit, } = props; @@ -66,6 +68,7 @@ export default function CreateTaskPage(props: Props): JSX.Element { Create a new task props.history.push('/tasks?page=1') + (event: React.MouseEvent): void => { + event.preventDefault(); + props.history.push('/tasks?page=1'); + } } > Tasks @@ -184,8 +188,12 @@ function HeaderContainer(props: Props): JSX.Element { className='cvat-header-button' type='link' value='models' + href='/models' onClick={ - (): void => props.history.push('/models') + (event: React.MouseEvent): void => { + event.preventDefault(); + props.history.push('/models'); + } } > Models @@ -195,8 +203,10 @@ function HeaderContainer(props: Props): JSX.Element {