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

Fixed UI crash on project page when task is creating in the project #8187

Merged
merged 4 commits into from
Jul 18, 2024
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
4 changes: 4 additions & 0 deletions changelog.d/20240718_085228_boris_fixed_undefined_value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- User interface crashed if there are active creating task requests on a project page
(<https://github.com/cvat-ai/cvat/pull/8187>)
20 changes: 5 additions & 15 deletions cvat-ui/src/components/project-page/project-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import notification from 'antd/lib/notification';
import { getCore, Project, Task } from 'cvat-core-wrapper';
import { CombinedState, Indexable } from 'reducers';
import { getProjectTasksAsync } from 'actions/projects-actions';
import { cancelInferenceAsync } from 'actions/models-actions';
import CVATLoadingSpinner from 'components/common/loading-spinner';
import TaskItem from 'components/tasks-page/task-item';
import TaskItem from 'containers/tasks-page/task-item';
import MoveTaskModal from 'components/move-task-modal/move-task-modal';
import ModelRunnerDialog from 'components/model-runner-modal/model-runner-dialog';
import {
Expand Down Expand Up @@ -60,10 +59,7 @@ export default function ProjectPageComponent(): JSX.Element {
const [updatingProject, setUpdatingProject] = useState(false);
const mounted = useRef(false);

const ribbonPlugins = useSelector((state: CombinedState) => state.plugins.components.taskItem.ribbon);
const deletes = useSelector((state: CombinedState) => state.projects.activities.deletes);
const taskDeletes = useSelector((state: CombinedState) => state.tasks.activities.deletes);
const tasksActiveInferences = useSelector((state: CombinedState) => state.models.inferences);
const tasks = useSelector((state: CombinedState) => state.tasks.current);
const tasksCount = useSelector((state: CombinedState) => state.tasks.count);
const tasksQuery = useSelector((state: CombinedState) => state.projects.tasksGettingQuery);
Expand Down Expand Up @@ -120,12 +116,12 @@ export default function ProjectPageComponent(): JSX.Element {
}, [tasksQuery]);

useEffect(() => {
if (projectInstance && id in deletes && deletes[id]) {
if (deletes[id]) {
history.push('/projects');
}
}, [deletes]);

if (fechingProject) {
if (fechingProject || id in deletes) {
return <Spin size='large' className='cvat-spinner' />;
}

Expand Down Expand Up @@ -153,14 +149,8 @@ export default function ProjectPageComponent(): JSX.Element {
.map((task: Task) => (
<TaskItem
key={task.id}
ribbonPlugins={ribbonPlugins}
deleted={task.id in taskDeletes ? taskDeletes[task.id] : false}
hidden={false}
activeInference={tasksActiveInferences[task.id] || null}
cancelAutoAnnotation={() => {
dispatch(cancelInferenceAsync(task.id));
}}
taskInstance={task}
taskID={task.id}
idx={tasks.indexOf(task)}
/>
))}
</React.Fragment>
Expand Down
22 changes: 7 additions & 15 deletions cvat-ui/src/reducers/projects-reducer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
// Copyright (C) 2022-2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import { AnyAction } from 'redux';
import { omit } from 'lodash';

import { ProjectsActionTypes } from 'actions/projects-actions';
import { BoundariesActionTypes } from 'actions/boundaries-actions';
Expand Down Expand Up @@ -117,49 +118,40 @@ export default (state: ProjectsState = defaultState, action: AnyAction): Project
}
case ProjectsActionTypes.DELETE_PROJECT: {
const { projectId } = action.payload;
const { deletes } = state.activities;

deletes[projectId] = false;

return {
...state,
activities: {
...state.activities,
deletes: {
...deletes,
...state.activities.deletes,
[projectId]: false,
},
},
};
}
case ProjectsActionTypes.DELETE_PROJECT_SUCCESS: {
const { projectId } = action.payload;
const { deletes } = state.activities;

deletes[projectId] = true;

return {
...state,
activities: {
...state.activities,
deletes: {
...deletes,
...state.activities.deletes,
[projectId]: true,
},
},
};
}
case ProjectsActionTypes.DELETE_PROJECT_FAILED: {
const { projectId } = action.payload;
const { deletes } = state.activities;

delete deletes[projectId];

return {
...state,
activities: {
...state.activities,
deletes: {
...deletes,
},
deletes: omit(state.activities.deletes, projectId),
},
};
}
Expand Down
Loading