Skip to content

Commit

Permalink
Merge branch 'develop' into mk/fix_ability_to_leave_org
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov authored Sep 22, 2023
2 parents 36278e8 + 26693dd commit 10969ca
Show file tree
Hide file tree
Showing 25 changed files with 395 additions and 181 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'

- name: Download CVAT server image
uses: actions/download-artifact@v3
Expand Down
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- TDB

### Changed
- TDB
- Do not reload annotation view when renew the job or update job state (<https://github.com/opencv/cvat/pull/6851>)

### Deprecated
- TDB
Expand All @@ -19,23 +19,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- TDB

### Fixed
- Downloading additional data from cloud storage if use_cache=true and job_file_mapping are specified
(<https://github.com/opencv/cvat/pull/6879>)
- Leaving an organization (<https://github.com/opencv/cvat/pull/6422>)

### Security
- TDB

## \[2.7.1\] - 2023-09-15
### Fixed

- Include cloud storage manifest file to selected files if manifest was used as data source (<https://github.com/opencv/cvat/pull/6850>)
- Keep sequence of files when directories were specified in server_files (<https://github.com/opencv/cvat/pull/6850>)

## \[2.7.0\] - 2023-09-10
### Added

- Admin actions for easy activation/deactivation of users (<https://github.com/opencv/cvat/pull/6314>)

### Fixed

- Invalid input validation in for `cloud_storage_id` (<https://github.com/opencv/cvat/pull/6825>)
- Incorrect task progress report for 3rdparty users (<https://github.com/opencv/cvat/pull/6834>)
- Include cloud storage manifest file to selected files if manifest was used as data source (<https://github.com/opencv/cvat/pull/6850>)
- Keep sequence of files when directories were specified in server_files (<https://github.com/opencv/cvat/pull/6850>)

### Security

- Security upgrade gitpython from 3.1.33 to 3.1.35 (<https://github.com/opencv/cvat/pull/6843>)
- Security upgrade numpy from 1.22.0 to 1.22.4 (<https://github.com/opencv/cvat/pull/6843>)

Expand Down
18 changes: 15 additions & 3 deletions cvat-core/src/session-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,21 @@ export function implementJob(Job) {
jobData.assignee = jobData.assignee.id;
}

const data = await serverProxy.jobs.save(this.id, jobData);
this._updateTrigger.reset();
return new Job(data);
let updatedJob = null;
try {
const data = await serverProxy.jobs.save(this.id, jobData);
updatedJob = new Job(data);
this._updateTrigger.reset();
} catch (error) {
updatedJob = new Job(this._initialData);
throw error;
} finally {
this.stage = updatedJob.stage;
this.state = updatedJob.state;
this.assignee = updatedJob.assignee;
}

return this;
}

const jobSpec = {
Expand Down
5 changes: 4 additions & 1 deletion cvat-core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export class Job extends Session {
log: CallableFunction;
};

constructor(initialData: SerializedJob) {
constructor(initialData: Readonly<SerializedJob>) {
super();
const data = {
id: undefined,
Expand Down Expand Up @@ -536,6 +536,9 @@ export class Job extends Session {
_updateTrigger: {
get: () => updateTrigger,
},
_initialData: {
get: () => initialData,
},
}),
);

Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
ShapeType,
Workspace,
} from 'reducers';
import { updateJobAsync } from './tasks-actions';
import { updateJobAsync } from './jobs-actions';
import { switchToolsBlockerState } from './settings-actions';

interface AnnotationsParameters {
Expand Down
27 changes: 27 additions & 0 deletions cvat-ui/src/actions/jobs-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export enum JobsActionTypes {
GET_JOB_PREVIEW_SUCCESS = 'GET_JOB_PREVIEW_SUCCESS',
GET_JOB_PREVIEW_FAILED = 'GET_JOB_PREVIEW_FAILED',
CREATE_JOB_FAILED = 'CREATE_JOB_FAILED',
UPDATE_JOB = 'UPDATE_JOB',
UPDATE_JOB_SUCCESS = 'UPDATE_JOB_SUCCESS',
UPDATE_JOB_FAILED = 'UPDATE_JOB_FAILED',
DELETE_JOB = 'DELETE_JOB',
DELETE_JOB_SUCCESS = 'DELETE_JOB_SUCCESS',
DELETE_JOB_FAILED = 'DELETE_JOB_FAILED',
Expand Down Expand Up @@ -46,6 +49,15 @@ const jobsActions = {
createJobFailed: (error: any) => (
createAction(JobsActionTypes.CREATE_JOB_FAILED, { error })
),
updateJob: () => (
createAction(JobsActionTypes.UPDATE_JOB)
),
updateJobSuccess: (job: Job) => (
createAction(JobsActionTypes.UPDATE_JOB_SUCCESS, { job })
),
updateJobFailed: (jobID: number, error: any) => (
createAction(JobsActionTypes.UPDATE_JOB_FAILED, { jobID, error })
),
deleteJob: (jobID: number) => (
createAction(JobsActionTypes.DELETE_JOB, { jobID })
),
Expand Down Expand Up @@ -93,6 +105,21 @@ export const createJobAsync = (data: JobData): ThunkAction => async (dispatch) =
}
};

export function updateJobAsync(jobInstance: Job): ThunkAction<Promise<boolean>> {
return async (dispatch): Promise<boolean> => {
try {
dispatch(jobsActions.updateJob());
const updated = await jobInstance.save();
dispatch(jobsActions.updateJobSuccess(updated));
} catch (error) {
dispatch(jobsActions.updateJobFailed(jobInstance.id, error));
return false;
}

return true;
};
}

export const deleteJobAsync = (job: Job): ThunkAction => async (dispatch) => {
dispatch(jobsActions.deleteJob(job.id));
try {
Expand Down
20 changes: 0 additions & 20 deletions cvat-ui/src/actions/tasks-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export enum TasksActionTypes {
DELETE_TASK_SUCCESS = 'DELETE_TASK_SUCCESS',
DELETE_TASK_FAILED = 'DELETE_TASK_FAILED',
CREATE_TASK_FAILED = 'CREATE_TASK_FAILED',
UPDATE_JOB_FAILED = 'UPDATE_JOB_FAILED',
SWITCH_MOVE_TASK_MODAL_VISIBLE = 'SWITCH_MOVE_TASK_MODAL_VISIBLE',
GET_TASK_PREVIEW = 'GET_TASK_PREVIEW',
GET_TASK_PREVIEW_SUCCESS = 'GET_TASK_PREVIEW_SUCCESS',
Expand Down Expand Up @@ -294,25 +293,6 @@ ThunkAction<Promise<void>, {}, {}, AnyAction> {
};
}

function updateJobFailed(jobID: number, error: any): AnyAction {
const action = {
type: TasksActionTypes.UPDATE_JOB_FAILED,
payload: { jobID, error },
};

return action;
}

export function updateJobAsync(jobInstance: any): ThunkAction<Promise<void>, {}, {}, AnyAction> {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
try {
await jobInstance.save();
} catch (error) {
dispatch(updateJobFailed(jobInstance.id, error));
}
};
}

export function switchMoveTaskModalVisible(visible: boolean, taskId: number | null = null): AnyAction {
const action = {
type: TasksActionTypes.SWITCH_MOVE_TASK_MODAL_VISIBLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import Collapse from 'antd/lib/collapse';
// eslint-disable-next-line import/no-extraneous-dependencies
import { MenuInfo } from 'rc-menu/lib/interface';
import CVATTooltip from 'components/common/cvat-tooltip';
import { getCore } from 'cvat-core-wrapper';
import { JobStage } from 'reducers';
import { getCore, JobStage } from 'cvat-core-wrapper';

const core = getCore();

Expand Down Expand Up @@ -213,7 +212,7 @@ function AnnotationMenuComponent(props: Props & RouteComponentProps): JSX.Elemen
<Text className={computeClassName(JobState.COMPLETED)}>{JobState.COMPLETED}</Text>
</Menu.Item>
</Menu.SubMenu>
{[JobStage.ANNOTATION, JobStage.REVIEW].includes(jobStage) ?
{[JobStage.ANNOTATION, JobStage.VALIDATION].includes(jobStage) ?
<Menu.Item key={Actions.FINISH_JOB}>Finish the job</Menu.Item> : null}
{jobStage === JobStage.ACCEPTANCE ?
<Menu.Item key={Actions.RENEW_JOB}>Renew the job</Menu.Item> : null}
Expand Down
16 changes: 4 additions & 12 deletions cvat-ui/src/components/job-item/job-actions-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import React, { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { useHistory } from 'react-router';
Expand All @@ -15,13 +16,12 @@ import {
} from 'cvat-core-wrapper';
import { deleteJobAsync } from 'actions/jobs-actions';
import { importActions } from 'actions/import-actions';
import { updateJobAsync } from 'actions/tasks-actions';

const core = getCore();

interface Props {
job: Job;
onJobUpdate?: (job: Job) => void;
onJobUpdate: (job: Job) => void;
}

function JobActionsMenu(props: Props): JSX.Element {
Expand Down Expand Up @@ -62,19 +62,11 @@ function JobActionsMenu(props: Props): JSX.Element {
} else if (action.key === 'renew_job') {
job.state = core.enums.JobState.NEW;
job.stage = JobStage.ANNOTATION;
if (onJobUpdate) {
onJobUpdate(job);
} else {
dispatch(updateJobAsync(job));
}
onJobUpdate(job);
} else if (action.key === 'finish_job') {
job.stage = JobStage.ACCEPTANCE;
job.state = core.enums.JobState.COMPLETED;
if (onJobUpdate) {
onJobUpdate(job);
} else {
dispatch(updateJobAsync(job));
}
onJobUpdate(job);
}
}}
>
Expand Down
4 changes: 2 additions & 2 deletions cvat-ui/src/components/job-item/job-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import CVATTooltip from 'components/common/cvat-tooltip';
import JobActionsMenu from './job-actions-menu';

interface Props {
job: Job,
task: Task,
job: Job;
task: Task;
onJobUpdate: (job: Job) => void;
}

Expand Down
11 changes: 7 additions & 4 deletions cvat-ui/src/components/jobs-page/job-card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -9,6 +9,8 @@ import Card from 'antd/lib/card';
import Descriptions from 'antd/lib/descriptions';
import { MoreOutlined } from '@ant-design/icons';
import Dropdown from 'antd/lib/dropdown';

import { Job } from 'cvat-core-wrapper';
import { useCardHeightHOC } from 'utils/hooks';
import Preview from 'components/common/preview';
import JobActionsMenu from 'components/job-item/job-actions-menu';
Expand All @@ -22,11 +24,12 @@ const useCardHeight = useCardHeightHOC({
});

interface Props {
job: any;
job: Job;
onJobUpdate: (job: Job) => void;
}

function JobCardComponent(props: Props): JSX.Element {
const { job } = props;
const { job, onJobUpdate } = props;
const [expanded, setExpanded] = useState<boolean>(false);
const history = useHistory();
const height = useCardHeight();
Expand Down Expand Up @@ -73,7 +76,7 @@ function JobCardComponent(props: Props): JSX.Element {
<Descriptions.Item label='Assignee'>{job.assignee.username}</Descriptions.Item>
) : null}
</Descriptions>
<Dropdown overlay={<JobActionsMenu job={job} />}>
<Dropdown overlay={<JobActionsMenu onJobUpdate={onJobUpdate} job={job} />}>
<MoreOutlined className='cvat-job-card-more-button' />
</Dropdown>
</Card>
Expand Down
10 changes: 8 additions & 2 deletions cvat-ui/src/components/jobs-page/jobs-content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (C) 2022 Intel Corporation
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -9,7 +10,12 @@ import { CombinedState } from 'reducers';
import { Job, JobType } from 'cvat-core-wrapper';
import JobCard from './job-card';

function JobsContentComponent(): JSX.Element {
interface Props {
onJobUpdate(job: Job): void;
}

function JobsContentComponent(props: Props): JSX.Element {
const { onJobUpdate } = props;
const jobs = useSelector((state: CombinedState) => state.jobs.current);
const dimensions = {
md: 22,
Expand All @@ -22,7 +28,7 @@ function JobsContentComponent(): JSX.Element {
<Row justify='center' align='middle'>
<Col className='cvat-jobs-page-list' {...dimensions}>
{jobs.filter((job: Job) => job.type === JobType.ANNOTATION).map((job: Job): JSX.Element => (
<JobCard job={job} key={job.id} />
<JobCard onJobUpdate={onJobUpdate} job={job} key={job.id} />
))}
</Col>
</Row>
Expand Down
11 changes: 8 additions & 3 deletions cvat-ui/src/components/jobs-page/jobs-page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (C) 2022 Intel Corporation
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import './styles.scss';
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { useHistory } from 'react-router';
import { useDispatch, useSelector } from 'react-redux';
import Spin from 'antd/lib/spin';
Expand All @@ -12,9 +13,10 @@ import Pagination from 'antd/lib/pagination';
import Empty from 'antd/lib/empty';
import Text from 'antd/lib/typography/Text';

import { Job } from 'cvat-core-wrapper';
import { updateHistoryFromQuery } from 'components/resource-sorting-filtering';
import { CombinedState, Indexable } from 'reducers';
import { getJobsAsync } from 'actions/jobs-actions';
import { getJobsAsync, updateJobAsync } from 'actions/jobs-actions';

import TopBarComponent from './top-bar';
import JobsContentComponent from './jobs-content';
Expand All @@ -26,6 +28,9 @@ function JobsPageComponent(): JSX.Element {
const query = useSelector((state: CombinedState) => state.jobs.query);
const fetching = useSelector((state: CombinedState) => state.jobs.fetching);
const count = useSelector((state: CombinedState) => state.jobs.count);
const onJobUpdate = useCallback((job: Job) => {
dispatch(updateJobAsync(job));
}, []);

const queryParams = new URLSearchParams(history.location.search);
const updatedQuery = { ...query };
Expand All @@ -51,7 +56,7 @@ function JobsPageComponent(): JSX.Element {

const content = count ? (
<>
<JobsContentComponent />
<JobsContentComponent onJobUpdate={onJobUpdate} />
<Row justify='space-around' about='middle'>
<Col md={22} lg={18} xl={16} xxl={16}>
<Pagination
Expand Down
Loading

0 comments on commit 10969ca

Please sign in to comment.