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

Open org immediately after it was created #6705

Merged
merged 6 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion 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 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.55.1",
"version": "1.55.2",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
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
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
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/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