diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ba6b8a811b48fa151162f988743b9a5b8b79ba3..8b2858d08f811c147e15b825410bd0de940eb572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ non-ascii paths while adding files from "Connected file share" (issue #4428) - Job assignee can not resolve an issue () - Create manifest with cvat/server docker container command () - Cannot assign a resource to a user who has an organization () +- Logs and annotations are not saved when logout from a job page () - Occluded not applied on canvas instantly for a skeleton elements () - Oriented bounding boxes broken with COCO format ss() - Fixed upload resumption in production environments diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 28c4972577b5f06dfb0a170ee1965b2ec35f7966..0b01b76f1b02f1e99104e2e7005b79a4e2793018 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.43.1", + "version": "1.43.2", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index 7edaa6fbc67ff693ba14582832a523e300e7684c..7bc6663e56c7cbf982c2ecca673db9e7051bc17b 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -14,6 +14,7 @@ import Spin from 'antd/lib/spin'; import Text from 'antd/lib/typography/Text'; import 'antd/dist/antd.css'; +import LogoutComponent from 'components/logout-component'; import LoginPageContainer from 'containers/login-page/login-page'; import LoginWithTokenComponent from 'components/login-with-token/login-with-token'; import RegisterPageContainer from 'containers/register-page/register-page'; @@ -373,6 +374,7 @@ class CVATApplication extends React.PureComponent + @@ -447,7 +449,7 @@ class CVATApplication extends React.PureComponent 1 ? `/auth/login/?next=${location.pathname}` : '/auth/login'} + to={location.pathname.length > 1 ? `/auth/login?next=${location.pathname}` : '/auth/login'} /> diff --git a/cvat-ui/src/components/header/header.tsx b/cvat-ui/src/components/header/header.tsx index 03e97b76045c79d5b42ac50d1d78bab4172b8e94..0a187749fb1d8cfad71d9c249f027eea17dc6ba4 100644 --- a/cvat-ui/src/components/header/header.tsx +++ b/cvat-ui/src/components/header/header.tsx @@ -1,5 +1,5 @@ // Copyright (C) 2020-2022 Intel Corporation -// Copyright (C) 2022 CVAT.ai Corp +// Copyright (C) 2022 CVAT.ai Corporation // // SPDX-License-Identifier: MIT @@ -152,7 +152,6 @@ function HeaderContainer(props: Props): JSX.Element { changePasswordFetching, settingsDialogShown, switchSettingsShortcut, - onLogout, switchSettingsDialog, switchChangePasswordDialog, renderChangePasswordItem, @@ -364,7 +363,9 @@ function HeaderContainer(props: Props): JSX.Element { : } - onClick={onLogout} + onClick={() => { + history.push('/auth/logout'); + }} disabled={logoutFetching} > Logout diff --git a/cvat-ui/src/components/logout-component.tsx b/cvat-ui/src/components/logout-component.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a1d6838ba332e2eaf2f2a670752f4cd7e409d4e7 --- /dev/null +++ b/cvat-ui/src/components/logout-component.tsx @@ -0,0 +1,32 @@ +// Copyright (C) 2022 CVAT.ai Corporation +// +// SPDX-License-Identifier: MIT + +import Spin from 'antd/lib/spin'; +import React, { useEffect } from 'react'; +import { useDispatch } from 'react-redux'; +import { useHistory } from 'react-router'; + +import { saveLogsAsync } from 'actions/annotation-actions'; +import { logoutAsync } from 'actions/auth-actions'; + +function LogoutComponent(): JSX.Element { + const dispatch = useDispatch(); + const history = useHistory(); + + useEffect(() => { + dispatch(saveLogsAsync()).then(() => { + dispatch(logoutAsync()).then(() => { + history.goBack(); + }); + }); + }, []); + + return ( +
+ +
+ ); +} + +export default React.memo(LogoutComponent); diff --git a/cvat-ui/src/utils/redux.ts b/cvat-ui/src/utils/redux.ts index 4ed9abc909b38587f8d7afccff24bd2c7aa97213..7ba56c7d0d1eabf00b6cf02ca3519cfbf250b7b1 100644 --- a/cvat-ui/src/utils/redux.ts +++ b/cvat-ui/src/utils/redux.ts @@ -1,4 +1,5 @@ // Copyright (C) 2020-2022 Intel Corporation +// Copyright (C) 2022 CVAT.ai Corporation // // SPDX-License-Identifier: MIT @@ -18,6 +19,6 @@ export function createAction(type: T, payload?: P): Action< export type ActionUnion = ReturnType; -export type ThunkAction = _ThunkAction; +export type ThunkAction, A extends Action = AnyAction> = _ThunkAction; export type ThunkDispatch = _ThunkDispatch; diff --git a/tests/cypress/integration/actions_users/issue_1810_login_logout.js b/tests/cypress/integration/actions_users/issue_1810_login_logout.js index 476ce517e6864b3b30774401c5a51687f49f2880..8cd764b8149054c5eab31e523df342c479dfe746 100644 --- a/tests/cypress/integration/actions_users/issue_1810_login_logout.js +++ b/tests/cypress/integration/actions_users/issue_1810_login_logout.js @@ -1,4 +1,5 @@ // Copyright (C) 2020-2022 Intel Corporation +// Copyright (C) 2022 CVAT.ai Corporation // // SPDX-License-Identifier: MIT @@ -46,7 +47,7 @@ context('When clicking on the Logout button, get the user session closed.', () = .trigger('mouseover', { which: 1 }); }); cy.get('span[aria-label="logout"]').click(); - cy.url().should('include', `/auth/login/?next=/tasks/${taskId}`); + cy.url().should('include', `/auth/login?next=/tasks/${taskId}`); // login to task login(Cypress.env('user'), Cypress.env('password')); cy.url().should('include', `/tasks/${taskId}`).and('not.include', '/auth/login');