Merge branch 'main' into 18692-frozen-projects-workbench-support
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 23 Jun 2022 12:36:25 +0000 (14:36 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 23 Jun 2022 12:36:25 +0000 (14:36 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

1  2 
cypress/integration/project.spec.js
src/index.tsx
src/store/context-menu/context-menu-actions.ts
src/views-components/context-menu/context-menu.tsx
src/views-components/data-explorer/renderers.tsx
src/views-components/side-panel-button/side-panel-button.tsx
src/views/project-panel/project-panel.tsx

index 520ad26aa7f3f624ad76ed2aaf5e895777ab4160,c4983e3e16bc5f135a0b6e4a29f24c3dad79bf58..0ad8da5622747231283946072b7b315418ed2972
@@@ -260,100 -278,4 +278,101 @@@ describe('Project tests', function() 
                  });
          });
      });
- });
 +
 +    describe('Frozen projects', () => {
 +        beforeEach(() => {  
 +            cy.createGroup(activeUser.token, {
 +                name: `Main project ${Math.floor(Math.random() * 999999)}`,
 +                group_class: 'project',
 +            }).as('mainProject');
 +    
 +            cy.createGroup(adminUser.token, {
 +                name: `Admin project ${Math.floor(Math.random() * 999999)}`,
 +                group_class: 'project',
 +            }).as('adminProject').then((mainProject) => {
 +                cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, 'can_write');
 +            });
 +
 +            cy.get('@mainProject').then((mainProject) => {
 +                cy.createGroup(adminUser.token, {
 +                    name : `Sub project ${Math.floor(Math.random() * 999999)}`,
 +                    group_class: 'project',
 +                    owner_uuid: mainProject.uuid,
 +                }).as('subProject');
 +
 +                cy.createCollection(adminUser.token, {
 +                    name: `Main collection ${Math.floor(Math.random() * 999999)}`,
 +                    owner_uuid: mainProject.uuid,
 +                    manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
 +                }).as('mainCollection');        
 +            });
 +        });
 +
 +        it('should be able to froze own project', () => {
 +            cy.getAll('@mainProject').then(([mainProject]) => {
 +                cy.loginAs(activeUser);
 +
 +                cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 +
 +                cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
 +            });
 +        });
 +
 +        it('should not be able to modify items within the frozen project', () => {
 +            cy.getAll('@mainProject', '@mainCollection').then(([mainProject, mainCollection]) => {
 +                cy.loginAs(activeUser);
 +
 +                cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 +
 +                cy.get('[data-cy=project-panel]').contains(mainProject.name).click();
 +
 +                cy.get('[data-cy=project-panel]').contains(mainCollection.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Move to trash').should('not.exist');
 +            });
 +        });
 +
 +        it('should not be able to froze not owned project', () => {
 +            cy.getAll('@adminProject').then(([adminProject]) => {
 +                cy.loginAs(activeUser);
 +
 +                cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
 +
 +                cy.get('main').contains(adminProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 +
 +                cy.get('main').contains(adminProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');
 +            });
 +        });
 +
 +        it('should be able to unfroze project if user is an admin', () => {
 +            cy.getAll('@adminProject').then(([adminProject]) => {
 +                cy.loginAs(adminUser);
 +
 +                cy.get('main').contains(adminProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Freeze').click();
 +
 +                cy.wait(1000);
 +
 +                cy.get('main').contains(adminProject.name).rightclick();
 +
 +                cy.get('[data-cy=context-menu]').contains('Unfreeze').click();
 +
 +                cy.get('main').contains(adminProject.name).rightclick();
 +                
 +                cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');
 +            });
 +        });
 +    });
+ });
++
diff --cc src/index.tsx
index 4dde654cbfe1c05f0579904414bce1a363810a80,03840d49ad232fe22d22a14c3762757690523894..066b520c9340be89f2da31a5cb204ca42d730a32
@@@ -100,14 -101,9 +101,15 @@@ addMenuActionSet(ContextMenuKind.GROUP_
  addMenuActionSet(ContextMenuKind.COLLECTION_ADMIN, collectionAdminActionSet);
  addMenuActionSet(ContextMenuKind.PROCESS_ADMIN, processResourceAdminActionSet);
  addMenuActionSet(ContextMenuKind.PROJECT_ADMIN, projectAdminActionSet);
 +addMenuActionSet(ContextMenuKind.FROZEN_PROJECT, [
 +    [
 +        ...frozenActionSet.reduce((prev, next) => prev.concat(next), []),
 +        ...readOnlyProjectActionSet.reduce((prev, next) => prev.concat(next), []),
 +    ]
 +]);
  addMenuActionSet(ContextMenuKind.FILTER_GROUP_ADMIN, filterGroupAdminActionSet);
  addMenuActionSet(ContextMenuKind.PERMISSION_EDIT, permissionEditActionSet);
+ addMenuActionSet(ContextMenuKind.WORKFLOW, workflowActionSet);
  
  storeRedirects();
  
index 245a6597af28581e1a3e953c6c3fd018237d2799,7822bdc6b4cd2411aaa37fc78a6a626200db35cf..c955ebec8faaa0f3db964e63dae08ef39251cbec
@@@ -755,9 -739,13 +762,13 @@@ const _resourceWithName 
              </Typography>;
          });
  
+ export const ResourceOwnerWithName = ownerFromResourceId(_resourceWithName);
+ export const ResourceWithName = userFromID(_resourceWithName);
  export const UserNameFromID =
      compose(userFromID)(
 -        (props: { uuid: string, userFullname: string, dispatch: Dispatch }) => {
 +        (props: { uuid: string, displayAsText?: string, userFullname: string, dispatch: Dispatch }) => {
              const { uuid, userFullname, dispatch } = props;
  
              if (userFullname === '') {
index f98f3a1aa2289c45c120035caad734dc6e802bfa,ccb40d53ba958b35645c14fb0af4a874e72f1b88..d9d14ae31c14252330be10990f8fb1eb7ad04e08
@@@ -184,11 -180,9 +181,11 @@@ export const ProjectPanel = withStyles(
                          name: resource.name,
                          uuid: resource.uuid,
                          ownerUuid: resource.ownerUuid,
-                         isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
+                         isTrashed: ('isTrashed' in resource) ? resource.isTrashed : false,
                          kind: resource.kind,
                          menuKind,
 +                        isAdmin,
 +                        isFrozen: resourceIsFrozen(resource, resources),
                          description: resource.description,
                          storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
                          properties: ('properties' in resource) ? resource.properties : {},