Skip to content

Commit

Permalink
Merge branch 'develop' into bs/enable_webhooks_pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Aug 22, 2023
2 parents 37cc59a + 59ae3e5 commit db7a7f6
Show file tree
Hide file tree
Showing 20 changed files with 117 additions and 366 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- TBD
- Organization now opened immediately after it is created (<https://github.com/opencv/cvat/pull/6705>)

### Deprecated

Expand All @@ -25,7 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- TBD
- Removing job assignee (<https://github.com/opencv/cvat/pull/6712>)
- Fixed switching from organization to sandbox while getting a resource (<https://github.com/opencv/cvat/pull/6689>)

### Security

Expand Down
2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "11.0.1",
"version": "11.0.2",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "src/api.ts",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions cvat-core/src/server-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ Axios.interceptors.request.use((reqConfig) => {
});

Axios.interceptors.response.use((response) => {
if (isResourceURL(response.config.url)) {
const newOrg = response.data.organization;
if (newOrg && config.organization.organizationID !== newOrg) {
if (isResourceURL(response.config.url) &&
'organization' in (response.data || {})
) {
const newOrg: number | null = response.data.organization;
if (config.organization.organizationID !== newOrg) {
config?.onOrganizationChange(newOrg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function buildDuplicatedAPI(prototype) {
export class Session {}

export class Job extends Session {
public assignee: User;
public assignee: User | null;
public stage: JobStage;
public state: JobState;
public readonly id: number;
Expand Down
4 changes: 2 additions & 2 deletions cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.55.1",
"version": "1.55.3",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down Expand Up @@ -49,7 +49,7 @@
"lru-cache": "^9.1.1",
"moment": "^2.29.2",
"mousetrap": "^1.6.5",
"onnxruntime-web": "1.15.1",
"onnxruntime-web": "1.14.0",
"platform": "^1.3.6",
"prop-types": "^15.7.2",
"react": "^16.14.0",
Expand Down
6 changes: 2 additions & 4 deletions cvat-ui/src/actions/organization-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export enum OrganizationActionsTypes {
GET_ORGANIZATIONS_FAILED = 'GET_ORGANIZATIONS_FAILED',
ACTIVATE_ORGANIZATION_SUCCESS = 'ACTIVATE_ORGANIZATION_SUCCESS',
ACTIVATE_ORGANIZATION_FAILED = 'ACTIVATE_ORGANIZATION_FAILED',
CREATE_ORGANIZATION = 'CREATE_ORGANIZATION',
CREATE_ORGANIZATION_SUCCESS = 'CREATE_ORGANIZATION_SUCCESS',
CREATE_ORGANIZATION_FAILED = 'CREATE_ORGANIZATION_FAILED',
UPDATE_ORGANIZATION = 'UPDATE_ORGANIZATION',
Expand Down Expand Up @@ -46,7 +45,6 @@ const organizationActions = {
OrganizationActionsTypes.GET_ORGANIZATIONS_SUCCESS, { list },
),
getOrganizationsFailed: (error: any) => createAction(OrganizationActionsTypes.GET_ORGANIZATIONS_FAILED, { error }),
createOrganization: () => createAction(OrganizationActionsTypes.CREATE_ORGANIZATION),
createOrganizationSuccess: (organization: any) => createAction(
OrganizationActionsTypes.CREATE_ORGANIZATION_SUCCESS, { organization },
),
Expand Down Expand Up @@ -142,17 +140,17 @@ export function getOrganizationsAsync(): ThunkAction {
export function createOrganizationAsync(
organizationData: Store,
onCreateSuccess?: (createdSlug: string) => void,
onCreateFailed?: () => void,
): ThunkAction {
return async function (dispatch) {
const { slug } = organizationData;
const organization = new core.classes.Organization(organizationData);
dispatch(organizationActions.createOrganization());

try {
const createdOrganization = await organization.save();
dispatch(organizationActions.createOrganizationSuccess(createdOrganization));
if (onCreateSuccess) onCreateSuccess(createdOrganization.slug);
} catch (error) {
if (onCreateFailed) onCreateFailed();
dispatch(organizationActions.createOrganizationFailed(slug, error));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
//
// SPDX-License-Identifier: MIT

import React from 'react';
import React, { useState } from 'react';
import { useHistory } from 'react-router';
import { useDispatch, useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import Form from 'antd/lib/form';
import Input from 'antd/lib/input';
import Button from 'antd/lib/button';
import Space from 'antd/lib/space';
import { Store } from 'antd/lib/form/interface';
import { useForm } from 'antd/lib/form/Form';
import notification from 'antd/lib/notification';

import { createOrganizationAsync } from 'actions/organization-actions';
import validationPatterns from 'utils/validation-patterns';
import { CombinedState } from 'reducers';

function CreateOrganizationForm(): JSX.Element {
const [form] = useForm<Store>();
const dispatch = useDispatch();
const history = useHistory();
const creating = useSelector((state: CombinedState) => state.organizations.creating);
const [creating, setCreating] = useState(false);
const MAX_SLUG_LEN = 16;
const MAX_NAME_LEN = 64;

Expand All @@ -36,11 +34,12 @@ function CreateOrganizationForm(): JSX.Element {
...(location ? { location } : {}),
};

setCreating(true);
dispatch(
createOrganizationAsync(rest, (createdSlug: string): void => {
form.resetFields();
notification.info({ message: `Organization ${createdSlug} has been successfully created` });
}),
localStorage.setItem('currentOrganization', createdSlug);
(window as Window).location = '/organization';
}, () => setCreating(false)),
);
};

Expand Down
6 changes: 2 additions & 4 deletions cvat-ui/src/components/job-item/job-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ function JobItem(props: Props): JSX.Element {
value={job.assignee}
onSelect={(user: User | null): void => {
if (job?.assignee?.id === user?.id) return;
if (user) {
job.assignee = user;
onJobUpdate(job);
}
job.assignee = user;
onJobUpdate(job);
}}
/>
</Col>
Expand Down
10 changes: 6 additions & 4 deletions cvat-ui/src/components/watchers/organization-watcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ function OrganizationWatcher(): JSX.Element {
const organizationList = useSelector((state: CombinedState) => state.organizations.list);

useEffect(() => {
core.config.onOrganizationChange = (newOrgId: number) => {
const newOrganization = organizationList.find((org) => org.id === newOrgId);
if (newOrganization) {
core.config.onOrganizationChange = (newOrgId: number | null) => {
if (newOrgId === null) {
localStorage.removeItem('currentOrganization');
} else {
const newOrganization = organizationList.find((org) => org.id === newOrgId);
localStorage.setItem('currentOrganization', newOrganization.slug);
window.location.reload();
}
window.location.reload();
};
}, []);

Expand Down
1 change: 0 additions & 1 deletion cvat-ui/src/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,6 @@ export interface OrganizationState {
current?: Organization | null;
initialized: boolean;
fetching: boolean;
creating: boolean;
updating: boolean;
inviting: boolean;
leaving: boolean;
Expand Down
14 changes: 0 additions & 14 deletions cvat-ui/src/reducers/organizations-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const defaultState: OrganizationState = {
list: [],
initialized: false,
fetching: false,
creating: false,
updating: false,
inviting: false,
leaving: false,
Expand Down Expand Up @@ -55,23 +54,10 @@ export default function (
fetching: false,
};
}
case OrganizationActionsTypes.CREATE_ORGANIZATION: {
return {
...state,
creating: true,
};
}
case OrganizationActionsTypes.CREATE_ORGANIZATION_SUCCESS: {
return {
...state,
list: [...state.list, action.payload.organization],
creating: false,
};
}
case OrganizationActionsTypes.CREATE_ORGANIZATION_FAILED: {
return {
...state,
creating: false,
};
}
case OrganizationActionsTypes.UPDATE_ORGANIZATION: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.6.0",
"@istanbuljs/nyc-config-babel": "^1.0.1",
"@babel/register": "^7.22.5",
"@istanbuljs/nyc-config-babel": "^3.0.0",
"@types/mousetrap": "^1.6.5",
"@types/node": "^18.0.3",
"@typescript-eslint/eslint-plugin": "^5.30.5",
Expand All @@ -32,7 +33,6 @@
"babel-loader": "^8.0.6",
"babel-plugin-import": "^1.12.2",
"babel-plugin-istanbul": "^6.0.0",
"babel-register": "^6.26.0",
"bundle-declarations-webpack-plugin": "^3.1.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
Expand Down
2 changes: 2 additions & 0 deletions tests/cypress/e2e/actions_tasks2/fit_image_different_res.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ context('Correct behaviour of fit when navigating between frames with different
});

beforeEach(() => {
cy.intercept('GET', `/tasks/${taskID}/jobs/${jobID}`).as('visitAnnotationView');
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
cy.wait('@visitAnnotationView');
cy.get('.cvat-canvas-container').should('exist').and('be.visible');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ context('Multiple users. Assign task, job. Deactivating users.', () => {
cy.goToTaskList();
cy.openTask(taskName);
cy.assignTaskToUser(secondUserName);
cy.assignJobToUser(0, secondUserName);
cy.openJob();
// Getting the task and job id
cy.url().then((url) => {
Expand All @@ -140,6 +141,7 @@ context('Multiple users. Assign task, job. Deactivating users.', () => {
it('First user login and assign the job to the third user. Logout', () => {
cy.login();
cy.openTask(taskName);
cy.assignJobToUser(0, null);
cy.assignJobToUser(0, thirdUserName);
cy.logout();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ context('New organization pipeline.', () => {
describe(`Testing case "${caseId}"`, () => {
it('The first user creates an organization and activates it.', () => {
cy.createOrganization(organizationParams);
cy.activateOrganization(organizationParams.shortName);
});

it('Open the organization settings. Invite members.', () => {
Expand Down
1 change: 0 additions & 1 deletion tests/cypress/e2e/features/webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ context('Webhooks pipeline.', () => {
cy.visit('auth/login');
cy.login();
cy.createOrganization(organizationParams);
cy.activateOrganization(organizationParams.shortName);
cy.visit('/projects');
cy.createProjects(
project.name,
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/support/commands_organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Cypress.Commands.add('createOrganization', (organizationParams) => {
idWrapper.id = interception.response.body.id;
});
});

cy.get('.cvat-organization-page').should('exist').and('be.visible');
return cy.wrap(idWrapper);
});

Expand Down
19 changes: 12 additions & 7 deletions tests/cypress/support/commands_review_pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ Cypress.Commands.add('assignJobToUser', (jobID, user) => {
cy.get('.cvat-jobs-list')
.contains('a', `Job #${$job}`)
.parents('.cvat-job-item')
.find('.cvat-job-assignee-selector')
.click();
.find('.cvat-job-assignee-selector input')
.click()
.clear();
});

cy.intercept('PATCH', '/api/jobs/**').as('patchJobAssignee');
cy.get('.ant-select-dropdown')
.should('be.visible')
.not('.ant-select-dropdown-hidden')
.contains(new RegExp(`^${user}$`, 'g'))
.click();
if (user) {
cy.get('.ant-select-dropdown')
.should('be.visible')
.not('.ant-select-dropdown-hidden')
.contains(new RegExp(`^${user}$`, 'g'))
.click();
} else {
cy.get('body').type('{Enter}');
}

cy.wait('@patchJobAssignee').its('response.statusCode').should('equal', 200);
cy.get('.cvat-spinner').should('not.exist');
Expand Down
6 changes: 3 additions & 3 deletions tests/python/shared/fixtures/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def docker_restore_data_volumes():
CVAT_DB_DIR / "cvat_data.tar.bz2",
f"{PREFIX}_cvat_server_1:/tmp/cvat_data.tar.bz2",
)
docker_exec(Container.SERVER, "tar --strip 3 -xjf /tmp/cvat_data.tar.bz2 -C /home/django/data/")
docker_exec_cvat("tar --strip 3 -xjf /tmp/cvat_data.tar.bz2 -C /home/django/data/")


def kube_restore_data_volumes():
Expand Down Expand Up @@ -403,7 +403,7 @@ def local_start(start, stop, dumpdb, cleanup, rebuild, cvat_root_dir, cvat_db_di
docker_cp(cvat_db_dir / "data.json", f"{PREFIX}_cvat_server_1:/tmp/data.json")
wait_for_services()

docker_exec(Container.SERVER, "python manage.py loaddata /tmp/data.json")
docker_exec_cvat("python manage.py loaddata /tmp/data.json")
docker_exec(
Container.DB, "psql -U root -d postgres -v from=cvat -v to=test_db -f /tmp/restore.sql"
)
Expand Down Expand Up @@ -455,7 +455,7 @@ def session_finish(session):

docker_exec(Container.DB, "dropdb --if-exists cvat")
docker_exec(Container.DB, "createdb cvat")
docker_exec(Container.SERVER, "python manage.py migrate")
docker_exec_cvat("python manage.py migrate")


def collect_code_coverage_from_containers():
Expand Down
Loading

0 comments on commit db7a7f6

Please sign in to comment.