From 447fe5759d15dc22c5d80f190ff22165f50c90a5 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 29 Feb 2024 18:55:23 +0200 Subject: [PATCH 1/3] Disable submit button while creating GT job --- .../components/create-job-page/job-form.tsx | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/cvat-ui/src/components/create-job-page/job-form.tsx b/cvat-ui/src/components/create-job-page/job-form.tsx index 06d37ff791cb..60445c6a0ef8 100644 --- a/cvat-ui/src/components/create-job-page/job-form.tsx +++ b/cvat-ui/src/components/create-job-page/job-form.tsx @@ -1,48 +1,47 @@ -// Copyright (C) 2023 CVAT.ai Corporation +// Copyright (C) 2023-2024 CVAT.ai Corporation // // SPDX-License-Identifier: MIT import './styles.scss'; -import React, { useCallback } from 'react'; +import React, { useCallback, useState } from 'react'; +import { useHistory } from 'react-router'; +import { useDispatch } from 'react-redux'; import { Row, Col } from 'antd/lib/grid'; import Form from 'antd/lib/form'; import Button from 'antd/lib/button'; import Select from 'antd/lib/select'; import InputNumber from 'antd/lib/input-number'; +import Space from 'antd/lib/space'; +import { QuestionCircleOutlined } from '@ant-design/icons'; import CVATTooltip from 'components/common/cvat-tooltip'; -import { CombinedState } from 'reducers'; -import { useDispatch, useSelector } from 'react-redux'; import { JobType } from 'cvat-core/src/enums'; import { Task } from 'cvat-core-wrapper'; import { createJobAsync } from 'actions/jobs-actions'; -import { useHistory } from 'react-router'; -import Space from 'antd/lib/space'; -import { QuestionCircleOutlined } from '@ant-design/icons'; export enum FrameSelectionMethod { RANDOM = 'random_uniform', } interface JobDataMutual { - task_id: number, - frame_selection_method: FrameSelectionMethod, - type: JobType, - seed?: number, + task_id: number; + frame_selection_method: FrameSelectionMethod; + type: JobType; + seed?: number; } export interface JobData extends JobDataMutual { - frame_count: number, + frame_count: number; } export interface JobFormData extends JobDataMutual { - quantity: number, - frame_count: number, + quantity: number; + frame_count: number; } interface Props { - task: Task + task: Task; } const defaultQuantity = 5; @@ -53,8 +52,7 @@ function JobForm(props: Props): JSX.Element { const [form] = Form.useForm(); const dispatch = useDispatch(); const history = useHistory(); - - const fetching = useSelector((state: CombinedState) => state.models.fetching); + const [fetching, setFetching] = useState(false); const submit = useCallback(async (): Promise => { try { @@ -66,8 +64,8 @@ function JobForm(props: Props): JSX.Element { frame_count: values.frame_count, task_id: task.id, }; - const createdJob = await dispatch(createJobAsync(data)); + const createdJob = await dispatch(createJobAsync(data)); return createdJob; } catch (e) { return false; @@ -75,9 +73,15 @@ function JobForm(props: Props): JSX.Element { }, [task]); const onSubmit = async (): Promise => { - const createdJob = await submit(); - if (createdJob) { - history.push(`/tasks/${task.id}/jobs/${createdJob.id}`); + try { + setFetching(true); + + const createdJob = await submit(); + if (createdJob) { + history.push(`/tasks/${task.id}/jobs/${createdJob.id}`); + } + } finally { + setFetching(false); } }; @@ -221,6 +225,7 @@ function JobForm(props: Props): JSX.Element { type='primary' onClick={onSubmit} loading={fetching} + disabled={fetching} > Submit From e322ac4eaf64fa028922b9a889ea30bf971caff4 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 29 Feb 2024 18:56:24 +0200 Subject: [PATCH 2/3] Updated version, changelog --- changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md | 4 ++++ cvat-ui/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md diff --git a/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md b/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md new file mode 100644 index 000000000000..cfc37cd7e69f --- /dev/null +++ b/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md @@ -0,0 +1,4 @@ +### Fixed + +- Submit button is enabled while creating a ground truth job + () diff --git a/cvat-ui/package.json b/cvat-ui/package.json index b8d4b1e5259c..2211771e9038 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.63.0", + "version": "1.63.1", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { From f443ca14df56d6eba4080e7310477e91d2f67c24 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Thu, 29 Feb 2024 18:58:07 +0200 Subject: [PATCH 3/3] Update changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md --- changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md b/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md index cfc37cd7e69f..33574470dc70 100644 --- a/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md +++ b/changelog.d/20240229_185536_sekachev.bs_disable_gt_button.md @@ -1,4 +1,4 @@ ### Fixed - Submit button is enabled while creating a ground truth job - () + ()