cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);
});
-})
\ No newline at end of file
+
+ it('navigates to the parent project after trashing the one being displayed', function() {
+ cy.createGroup(activeUser.token, {
+ name: `Test root project ${Math.floor(Math.random() * 999999)}`,
+ group_class: 'project',
+ }).as('testRootProject').then(function() {
+ cy.createGroup(activeUser.token, {
+ name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
+ group_class: 'project',
+ owner_uuid: this.testRootProject.uuid,
+ }).as('testSubProject');
+ });
+ cy.getAll('@testRootProject', '@testSubProject').then(function([testRootProject, testSubProject]) {
+ cy.loginAs(activeUser);
+
+ // Go to subproject and trash it.
+ cy.goToPath(`/projects/${testSubProject.uuid}`);
+ cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name);
+ cy.get('[data-cy=breadcrumb-last]')
+ .should('contain', testSubProject.name)
+ .rightclick();
+ cy.get('[data-cy=context-menu]').contains('Move to trash').click();
+
+ // Confirm that the parent project should be displayed.
+ cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
+ cy.url().should('contain', `/projects/${testRootProject.uuid}`);
+ cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
+
+ // Checks for bugfix #17637.
+ cy.get('[data-cy=not-found-content]').should('not.exist');
+ cy.get('[data-cy=not-found-page]').should('not.exist');
+ });
+ });
+
+ it('navigates to the root project after trashing the parent of the one being displayed', function() {
+ cy.createGroup(activeUser.token, {
+ name: `Test root project ${Math.floor(Math.random() * 999999)}`,
+ group_class: 'project',
+ }).as('testRootProject').then(function() {
+ cy.createGroup(activeUser.token, {
+ name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
+ group_class: 'project',
+ owner_uuid: this.testRootProject.uuid,
+ }).as('testSubProject').then(function() {
+ cy.createGroup(activeUser.token, {
+ name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
+ group_class: 'project',
+ owner_uuid: this.testSubProject.uuid,
+ }).as('testSubSubProject');
+ });
+ });
+ cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) {
+ cy.loginAs(activeUser);
+
+ // Go to innermost project and trash its parent.
+ cy.goToPath(`/projects/${testSubSubProject.uuid}`);
+ cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name);
+ cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name);
+ cy.get('[data-cy=side-panel-tree]')
+ .contains(testSubProject.name)
+ .rightclick();
+ cy.get('[data-cy=context-menu]').contains('Move to trash').click();
+
+ // Confirm that the trashed project's parent should be displayed.
+ cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
+ cy.url().should('contain', `/projects/${testRootProject.uuid}`);
+ cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
+ cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name);
+
+ // Checks for bugfix #17637.
+ cy.get('[data-cy=not-found-content]').should('not.exist');
+ cy.get('[data-cy=not-found-page]').should('not.exist');
+ });
+ });
+});
\ No newline at end of file
import { updateResources } from "~/store/resources/resources-actions";
import { getProperty } from "~/store/properties/properties";
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
-import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions.ts';
+import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { DataExplorer, getDataExplorer } from '~/store/data-explorer/data-explorer-reducer';
import { ListResults } from '~/services/common-service/common-service';
import { loadContainers } from '~/store/processes/processes-actions';
const node = treePicker ? getNode(projectUuid)(treePicker) : undefined;
if (projectUuid === SidePanelTreeCategory.SHARED_WITH_ME) {
await dispatch<any>(loadSharedRoot);
- } else if (node || projectUuid === '') {
+ } else if (node || projectUuid !== '') {
await dispatch<any>(loadProject(projectUuid));
}
};
import { activateSidePanelTreeItem, loadSidePanelTreeProjects } from "~/store/side-panel-tree/side-panel-tree-actions";
import { projectPanelActions } from "~/store/project-panel/project-panel-action";
import { ResourceKind } from "~/models/resource";
-import { navigateToTrash } from '~/store/navigation/navigation-action';
+import { navigateTo, navigateToTrash } from '~/store/navigation/navigation-action';
import { matchCollectionRoute } from '~/routes/routes';
export const toggleProjectTrashed = (uuid: string, ownerUuid: string, isTrashed: boolean) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
+ let errorMessage = '';
+ let successMessage = '';
try {
if (isTrashed) {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash...", kind: SnackbarKind.INFO }));
+ errorMessage = "Could not restore project from trash";
+ successMessage = "Restored from trash";
await services.groupsService.untrash(uuid);
+ dispatch<any>(navigateTo(uuid));
dispatch<any>(activateSidePanelTreeItem(uuid));
- dispatch(trashPanelActions.REQUEST_ITEMS());
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Restored from trash",
- hideDuration: 2000,
- kind: SnackbarKind.SUCCESS
- }));
} else {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash...", kind: SnackbarKind.INFO }));
+ errorMessage = "Could not move project to trash";
+ successMessage = "Added to trash";
await services.groupsService.trash(uuid);
- dispatch(projectPanelActions.REQUEST_ITEMS());
dispatch<any>(loadSidePanelTreeProjects(ownerUuid));
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Added to trash",
- hideDuration: 2000,
- kind: SnackbarKind.SUCCESS
- }));
+ dispatch<any>(navigateTo(ownerUuid));
}
} catch (e) {
dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Could not move project to trash",
+ message: errorMessage,
kind: SnackbarKind.ERROR
}));
}
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: successMessage,
+ hideDuration: 2000,
+ kind: SnackbarKind.SUCCESS
+ }));
};
export const toggleCollectionTrashed = (uuid: string, isTrashed: boolean) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
+ let errorMessage = '';
+ let successMessage = '';
try {
if (isTrashed) {
const { location } = getState().router;
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash...", kind: SnackbarKind.INFO }));
+ errorMessage = "Could not restore collection from trash";
+ successMessage = "Restored from trash";
await services.collectionService.untrash(uuid);
if (matchCollectionRoute(location ? location.pathname : '')) {
dispatch(navigateToTrash);
}
dispatch(trashPanelActions.REQUEST_ITEMS());
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Restored from trash",
- hideDuration: 2000,
- kind: SnackbarKind.SUCCESS
- }));
} else {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash...", kind: SnackbarKind.INFO }));
+ errorMessage = "Could not move collection to trash";
+ successMessage = "Added to trash";
await services.collectionService.trash(uuid);
dispatch(projectPanelActions.REQUEST_ITEMS());
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Added to trash",
- hideDuration: 2000,
- kind: SnackbarKind.SUCCESS
- }));
}
} catch (e) {
dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Could not move collection to trash",
+ message: errorMessage,
kind: SnackbarKind.ERROR
}));
}
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: successMessage,
+ hideDuration: 2000,
+ kind: SnackbarKind.SUCCESS
+ }));
};
export const toggleTrashed = (kind: ResourceKind, uuid: string, ownerUuid: string, isTrashed: boolean) =>
export const SidePanelTree = connect(undefined, mapDispatchToProps)(
(props: SidePanelTreeActionProps) =>
- <TreePicker {...props} render={renderSidePanelItem} pickerId={SIDE_PANEL_TREE} />);
+ <span data-cy="side-panel-tree">
+ <TreePicker {...props} render={renderSidePanelItem} pickerId={SIDE_PANEL_TREE} />
+ </span>);
const renderSidePanelItem = (item: TreeItem<ProjectResource>) => {
const name = typeof item.data === 'string' ? item.data : item.data.name;