From: Daniel Kutyła Date: Wed, 7 Jul 2021 15:34:09 +0000 (+0200) Subject: Merge branch '16971-Issues-with-Project-and-Collection-name-description-not-being... X-Git-Tag: 2.2.1^0 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/7edd5a7c86af0814f8a2282aa266a9d1a604a45f?hp=9cde730be1dcabd9fc9bcbe59fcfb60acf59f9fd Merge branch '16971-Issues-with-Project-and-Collection-name-description-not-being-saved-shown' into main closes #16971 Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js index 797a9d49..f3b63218 100644 --- a/cypress/integration/collection.spec.js +++ b/cypress/integration/collection.spec.js @@ -586,7 +586,7 @@ describe('Collection panel tests', function () { cy.get('[data-cy=breadcrumb-last]').should('contain', collName); }); - it.only('shows responsible person for collection if available', () => { + it('shows responsible person for collection if available', () => { cy.createCollection(adminUser.token, { name: `Test collection ${Math.floor(Math.random() * 999999)}`, owner_uuid: activeUser.user.uuid, diff --git a/cypress/integration/favorites.spec.js b/cypress/integration/favorites.spec.js index 6e9091e1..9f4e2b84 100644 --- a/cypress/integration/favorites.spec.js +++ b/cypress/integration/favorites.spec.js @@ -132,7 +132,50 @@ describe('Favorites tests', function () { }); }); - it('can view favourites in workflow', () => { + it('can edit project and collections in favorites', () => { + cy.createProject({ + owningUser: adminUser, + projectName: 'mySharedWritableProject', + canWrite: true, + addToFavorites: true + }); + + cy.createCollection(adminUser.token, { + owner_uuid: adminUser.user.uuid, + name: `Test target collection ${Math.floor(Math.random() * 999999)}`, + }).as('testTargetCollection').then(function (testTargetCollection) { + cy.addToFavorites(adminUser.token, adminUser.user.uuid, testTargetCollection.uuid); + }); + + cy.getAll('@mySharedWritableProject', '@testTargetCollection') + .then(function ([mySharedWritableProject, testTargetCollection]) { + cy.loginAs(adminUser); + + cy.get('[data-cy=side-panel-tree]').contains('My Favorites').click(); + + const newProjectName = `New project name ${mySharedWritableProject.name}`; + const newProjectDescription = `New project description ${mySharedWritableProject.name}`; + const newCollectionName = `New collection name ${testTargetCollection.name}`; + const newCollectionDescription = `New collection description ${testTargetCollection.name}`; + + cy.testEditProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription); + cy.testEditProjectOrCollection('main', testTargetCollection.name, newCollectionName, newCollectionDescription, false); + + cy.get('[data-cy=side-panel-tree]').contains('Projects').click(); + + cy.get('main').contains(newProjectName).rightclick(); + cy.contains('Add to public favorites').click(); + cy.get('main').contains(newCollectionName).rightclick(); + cy.contains('Add to public favorites').click(); + + cy.get('[data-cy=side-panel-tree]').contains('Public Favorites').click(); + + cy.testEditProjectOrCollection('main', newProjectName, mySharedWritableProject.name, 'newProjectDescription'); + cy.testEditProjectOrCollection('main', newCollectionName, testTargetCollection.name, 'newCollectionDescription', false); + }); + }); + + it('can view favorites in workflow', () => { cy.createProject({ owningUser: adminUser, targetUser: activeUser, diff --git a/cypress/integration/sharing.spec.js b/cypress/integration/sharing.spec.js index 5786c41d..c5664e3b 100644 --- a/cypress/integration/sharing.spec.js +++ b/cypress/integration/sharing.spec.js @@ -78,4 +78,26 @@ describe('Sharing tests', function () { cy.get('[data-cy=context-menu]').should('not.contain', 'Move to trash'); }); }); + + it('can edit project in shared with me', () => { + cy.createProject({ + owningUser: adminUser, + targetUser: activeUser, + projectName: 'mySharedWritableProject', + canWrite: true, + addToFavorites: true + }); + + cy.getAll('@mySharedWritableProject') + .then(function ([mySharedWritableProject]) { + cy.loginAs(activeUser); + + cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click(); + + const newProjectName = `New project name ${mySharedWritableProject.name}`; + const newProjectDescription = `New project description ${mySharedWritableProject.name}`; + + cy.testEditProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription); + }); + }); }); \ No newline at end of file diff --git a/cypress/integration/side-panel.spec.js b/cypress/integration/side-panel.spec.js index 8882494b..912e68eb 100644 --- a/cypress/integration/side-panel.spec.js +++ b/cypress/integration/side-panel.spec.js @@ -92,4 +92,26 @@ describe('Side panel tests', function() { }) }) + it('can edit project in side panel', () => { + cy.createProject({ + owningUser: activeUser, + targetUser: activeUser, + projectName: 'mySharedWritableProject', + canWrite: true, + addToFavorites: false + }); + + cy.getAll('@mySharedWritableProject') + .then(function ([mySharedWritableProject]) { + cy.loginAs(activeUser); + + cy.get('[data-cy=side-panel-tree]').contains('Projects').click(); + + const newProjectName = `New project name ${mySharedWritableProject.name}`; + const newProjectDescription = `New project description ${mySharedWritableProject.name}`; + + cy.testEditProjectOrCollection('[data-cy=side-panel-tree]', mySharedWritableProject.name, newProjectName, newProjectDescription); + }); + }); + }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index dbb9cd0b..069ed96d 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -192,6 +192,32 @@ Cypress.Commands.add( } ) +Cypress.Commands.add( + "testEditProjectOrCollection", (container, oldName, newName, newDescription, isProject = true) => { + cy.get(container).contains(oldName).rightclick(); + cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click(); + cy.get('[data-cy=form-dialog]').within(() => { + cy.get('input[name=name]').clear().type(newName); + cy.get(isProject ? 'div[contenteditable=true]' : 'input[name=description]').clear().type(newDescription); + cy.get('[data-cy=form-submit-btn]').click(); + }); + + cy.get(container).contains(newName).rightclick(); + cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click(); + cy.get('[data-cy=form-dialog]').within(() => { + cy.get('input[name=name]').should('have.value', newName); + + if (isProject) { + cy.get('span[data-text=true]').contains(newDescription); + } else { + cy.get('input[name=description]').should('have.value', newDescription); + } + + cy.get('[data-cy=form-cancel-btn]').click(); + }); + } +) + Cypress.Commands.add( "doSearch", (searchTerm) => { cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`); diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts index 1997b2a6..bda1136c 100644 --- a/src/store/context-menu/context-menu-actions.ts +++ b/src/store/context-menu/context-menu-actions.ts @@ -65,6 +65,7 @@ export const openCollectionFilesContextMenu = (event: React.MouseEvent, res uuid: res.uuid, kind: res.kind, menuKind, + description: res.description, ownerUuid: res.ownerUuid, isTrashed: ('isTrashed' in res) ? res.isTrashed : false, })); diff --git a/src/views/favorite-panel/favorite-panel.tsx b/src/views/favorite-panel/favorite-panel.tsx index 48a9e330..dcae6807 100644 --- a/src/views/favorite-panel/favorite-panel.tsx +++ b/src/views/favorite-panel/favorite-panel.tsx @@ -34,7 +34,11 @@ import { RootState } from '~/store/store'; import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view'; import { createTree } from '~/models/tree'; import { getSimpleObjectTypeFilters } from '~/store/resource-type-filters/resource-type-filters'; -import { ResourcesState } from '~/store/resources/resources'; +import { getResource, ResourcesState } from '~/store/resources/resources'; +import { GroupContentsResource } from '~/services/groups-service/groups-service'; +import { GroupClass, GroupResource } from '~/models/group'; +import { getProperty } from '~/store/properties/properties'; +import { PROJECT_PANEL_CURRENT_UUID } from '~/store/project-panel/project-panel-action'; type CssRules = "toolbar" | "button"; @@ -109,6 +113,7 @@ export const favoritePanelColumns: DataColumns = [ ]; interface FavoritePanelDataProps { + currentItemId: any; favorites: FavoritesState; resources: ResourcesState; userUuid: string; @@ -123,6 +128,7 @@ const mapStateToProps = (state : RootState): FavoritePanelDataProps => ({ favorites: state.favorites, resources: state.resources, userUuid: state.auth.user!.uuid, + currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties), }); type FavoritePanelProps = FavoritePanelDataProps & FavoritePanelActionProps & DispatchProp @@ -133,14 +139,27 @@ export const FavoritePanel = withStyles(styles)( class extends React.Component { handleContextMenu = (event: React.MouseEvent, resourceUuid: string) => { - const menuKind = this.props.dispatch(resourceUuidToContextMenuKind(resourceUuid)); - if (menuKind) { + const { resources } = this.props; + const resource = getResource(resourceUuid)(resources); + + let readonly = false; + const project = getResource(this.props.currentItemId)(resources); + + if (project && project.groupClass === GroupClass.FILTER) { + readonly = true; + } + + const menuKind = this.props.dispatch(resourceUuidToContextMenuKind(resourceUuid, readonly)); + + if (menuKind&& resource) { this.props.dispatch(openContextMenu(event, { - name: '', - uuid: resourceUuid, - ownerUuid: '', - kind: ResourceKind.NONE, - menuKind + name: resource.name, + uuid: resource.uuid, + ownerUuid: resource.ownerUuid, + isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false, + kind: resource.kind, + menuKind, + description: resource.description, })); } this.props.dispatch(loadDetailsPanel(resourceUuid)); diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index 35a7f9c1..4327d1b7 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -183,7 +183,8 @@ export const ProjectPanel = withStyles(styles)( ownerUuid: resource.ownerUuid, isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false, kind: resource.kind, - menuKind + menuKind, + description: resource.description, })); } this.props.dispatch(loadDetailsPanel(resourceUuid)); diff --git a/src/views/public-favorites-panel/public-favorites-panel.tsx b/src/views/public-favorites-panel/public-favorites-panel.tsx index 800e5e59..7e845d6c 100644 --- a/src/views/public-favorites-panel/public-favorites-panel.tsx +++ b/src/views/public-favorites-panel/public-favorites-panel.tsx @@ -35,6 +35,8 @@ import { createTree } from '~/models/tree'; import { getSimpleObjectTypeFilters } from '~/store/resource-type-filters/resource-type-filters'; import { PUBLIC_FAVORITE_PANEL_ID } from '~/store/public-favorites-panel/public-favorites-action'; import { PublicFavoritesState } from '~/store/public-favorites/public-favorites-reducer'; +import { getResource, ResourcesState } from '~/store/resources/resources'; +import { GroupContentsResource } from '~/services/groups-service/groups-service'; type CssRules = "toolbar" | "button"; @@ -110,24 +112,28 @@ export const publicFavoritePanelColumns: DataColumns = [ interface PublicFavoritePanelDataProps { publicFavorites: PublicFavoritesState; + resources: ResourcesState; } interface PublicFavoritePanelActionProps { onItemClick: (item: string) => void; - onContextMenu: (event: React.MouseEvent, item: string) => void; + onContextMenu: (resources: ResourcesState) => (event: React.MouseEvent, item: string) => void; onDialogOpen: (ownerUuid: string) => void; onItemDoubleClick: (item: string) => void; } -const mapStateToProps = ({ publicFavorites }: RootState): PublicFavoritePanelDataProps => ({ - publicFavorites +const mapStateToProps = ({ publicFavorites, resources }: RootState): PublicFavoritePanelDataProps => ({ + publicFavorites, + resources, }); const mapDispatchToProps = (dispatch: Dispatch): PublicFavoritePanelActionProps => ({ - onContextMenu: (event, resourceUuid) => { + onContextMenu: (resources: ResourcesState) => (event, resourceUuid) => { + const resource = getResource(resourceUuid)(resources); const kind = dispatch(resourceUuidToContextMenuKind(resourceUuid)); - if (kind) { + if (kind && resource) { dispatch(openContextMenu(event, { - name: '', + name: resource.name, + description: resource.description, uuid: resourceUuid, ownerUuid: '', kind: ResourceKind.NONE, @@ -156,7 +162,7 @@ export const PublicFavoritePanel = withStyles(styles)( id={PUBLIC_FAVORITE_PANEL_ID} onRowClick={this.props.onItemClick} onRowDoubleClick={this.props.onItemDoubleClick} - onContextMenu={this.props.onContextMenu} + onContextMenu={this.props.onContextMenu(this.props.resources)} contextMenuColumn={true} dataTableDefaultView={ (resourceUuidToContextMenuKind(resourceUuid)); if (menuKind && resource) { this.props.dispatch(openContextMenu(event, { - name: '', + name: resource.name, uuid: resource.uuid, + description: resource.description, ownerUuid: resource.ownerUuid, isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false, kind: resource.kind,