Merge branch '16971-Issues-with-Project-and-Collection-name-description-not-being... 2.2.1
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Wed, 7 Jul 2021 15:34:09 +0000 (17:34 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Wed, 7 Jul 2021 15:34:13 +0000 (17:34 +0200)
closes #16971

Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/collection.spec.js
cypress/integration/favorites.spec.js
cypress/integration/sharing.spec.js
cypress/integration/side-panel.spec.js
cypress/support/commands.js
src/store/context-menu/context-menu-actions.ts
src/views/favorite-panel/favorite-panel.tsx
src/views/project-panel/project-panel.tsx
src/views/public-favorites-panel/public-favorites-panel.tsx
src/views/shared-with-me-panel/shared-with-me-panel.tsx

index 797a9d49fedf4838a8dfdc2619600a644dcbbe40..f3b63218de0901d39472368429bd9c2df51e6072 100644 (file)
@@ -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,
index 6e9091e1b76e63e3329df636af5279cabd9d47a1..9f4e2b84c1444812cf8715a2ecc83216b9b7ef86 100644 (file)
@@ -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,
index 5786c41d563b6d9b68035095958a23404db040a5..c5664e3b89e272518c6591e204d6dc474d3323be 100644 (file)
@@ -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
index 8882494bf81c69e501d3a50092b558c502d2c5ac..912e68ebfe229c394fdb7287226060f39956202f 100644 (file)
@@ -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);
+            });
+    });
+
 })
index dbb9cd0b1f9a82b33118d8cad630d8c87789128b..069ed96dcf3631afec10e55478f6f635f96b6d4b 100644 (file)
@@ -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}`);
index 1997b2a64894b3aba3baa7c3666ea394dd93614c..bda1136caf7f45e9121a670e1a47a91e315644d2 100644 (file)
@@ -65,6 +65,7 @@ export const openCollectionFilesContextMenu = (event: React.MouseEvent<HTMLEleme
             name: '',
             uuid: '',
             ownerUuid: '',
+            description: '',
             kind: ResourceKind.COLLECTION,
             menuKind: isCollectionFileSelected
                 ? isWritable
@@ -166,6 +167,7 @@ export const openProjectContextMenu = (event: React.MouseEvent<HTMLElement>, res
                 uuid: res.uuid,
                 kind: res.kind,
                 menuKind,
+                description: res.description,
                 ownerUuid: res.ownerUuid,
                 isTrashed: ('isTrashed' in res) ? res.isTrashed : false,
             }));
index 48a9e33029d679ec90a4ebe4d35ee966c7cbfad8..dcae68074aeb9f6561d841f14028c25e5095e8a6 100644 (file)
@@ -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<string> = [
 ];
 
 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<FavoritePanelProps> {
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-                const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
-                if (menuKind) {
+                const { resources } = this.props;
+                const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
+                
+                let readonly = false;
+                const project = getResource<GroupResource>(this.props.currentItemId)(resources);
+                
+                if (project && project.groupClass === GroupClass.FILTER) {
+                    readonly = true;
+                }
+
+                const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid, readonly));
+
+                if (menuKind&& resource) {
                     this.props.dispatch<any>(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<any>(loadDetailsPanel(resourceUuid));
index 35a7f9c16068e87296db695cf0b63f0e0fbae722..4327d1b7bf005ff0785f9f6e60504b3a94ccf5fd 100644 (file)
@@ -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<any>(loadDetailsPanel(resourceUuid));
index 800e5e599fcedff1ec7578106fc3f74a9c8f688e..7e845d6cc8a5ebb71f40e930bda85a7eafa65dc9 100644 (file)
@@ -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<string> = [
 
 interface PublicFavoritePanelDataProps {
     publicFavorites: PublicFavoritesState;
+    resources: ResourcesState;
 }
 
 interface PublicFavoritePanelActionProps {
     onItemClick: (item: string) => void;
-    onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
+    onContextMenu: (resources: ResourcesState) => (event: React.MouseEvent<HTMLElement>, 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<GroupContentsResource>(resourceUuid)(resources);
         const kind = dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
-        if (kind) {
+        if (kind && resource) {
             dispatch<any>(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={
                         <DataTableDefaultView
index 76a314ae306bd41ff9f56b6118e5c8ba7f45bac8..2bc72ba41e5c529d6dd0e8cd2b2890ef0c1ae98b 100644 (file)
@@ -61,8 +61,9 @@ export const SharedWithMePanel = withStyles(styles)(
                 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
                 if (menuKind && resource) {
                     this.props.dispatch<any>(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,