Merge branch '17306-Favorites-in-copy-dialog-is-different-to-favorite-list'
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 18 Feb 2021 21:12:08 +0000 (22:12 +0100)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 18 Feb 2021 21:12:14 +0000 (22:12 +0100)
closes #17306

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

12 files changed:
cypress/integration/favorites.js [deleted file]
cypress/integration/favorites.spec.js [new file with mode: 0644]
cypress/support/commands.js
src/services/favorite-service/favorite-service.ts
src/store/collections/collection-partial-copy-actions.ts
src/store/tree-picker/tree-picker-actions.ts
src/views-components/projects-tree-picker/favorites-tree-picker.tsx
src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
src/views-components/projects-tree-picker/projects-tree-picker.tsx
src/views-components/projects-tree-picker/tree-picker-field.tsx
src/views-components/sharing-dialog/sharing-dialog-component.tsx
src/views-components/sharing-dialog/sharing-invitation-form-component.tsx

diff --git a/cypress/integration/favorites.js b/cypress/integration/favorites.js
deleted file mode 100644 (file)
index 0855c94..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-describe('Favorites tests', function() {
-    let activeUser;
-    let adminUser;
-
-    before(function() {
-        // Only set up common users once. These aren't set up as aliases because
-        // aliases are cleaned up after every test. Also it doesn't make sense
-        // to set the same users on beforeEach() over and over again, so we
-        // separate a little from Cypress' 'Best Practices' here.
-        cy.getUser('admin', 'Admin', 'User', true, true)
-            .as('adminUser').then(function() {
-                adminUser = this.adminUser;
-            }
-        );
-        cy.getUser('collectionuser1', 'Collection', 'User', false, true)
-            .as('activeUser').then(function() {
-                activeUser = this.activeUser;
-            }
-        );
-    })
-
-    beforeEach(function() {
-        cy.clearCookies()
-        cy.clearLocalStorage()
-    })
-
-    it('checks that Public favorites does not appear under shared with me', function() {
-        cy.loginAs(adminUser);
-        cy.contains('Shared with me').click();
-        cy.get('main').contains('Public favorites').should('not.exist');
-    })
-
-    it('creates and removes a public favorite', function() {
-        cy.loginAs(adminUser);
-            cy.createGroup(adminUser.token, {
-                name: `my-favorite-project`,
-                group_class: 'project',
-            }).as('myFavoriteProject').then(function() {
-                cy.contains('Refresh').click();
-                cy.get('main').contains('my-favorite-project').rightclick();
-                cy.contains('Add to public favorites').click();
-                cy.contains('Public Favorites').click();
-                cy.get('main').contains('my-favorite-project').rightclick();
-                cy.contains('Remove from public favorites').click();
-                cy.get('main').contains('my-favorite-project').should('not.exist');
-                cy.trashGroup(adminUser.token, this.myFavoriteProject.uuid);
-            });
-    })
-})
diff --git a/cypress/integration/favorites.spec.js b/cypress/integration/favorites.spec.js
new file mode 100644 (file)
index 0000000..eca35bc
--- /dev/null
@@ -0,0 +1,222 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+describe('Favorites tests', function () {
+    let activeUser;
+    let adminUser;
+
+    before(function () {
+        // Only set up common users once. These aren't set up as aliases because
+        // aliases are cleaned up after every test. Also it doesn't make sense
+        // to set the same users on beforeEach() over and over again, so we
+        // separate a little from Cypress' 'Best Practices' here.
+        cy.getUser('admin', 'Admin', 'User', true, true)
+            .as('adminUser').then(function () {
+                adminUser = this.adminUser;
+            }
+            );
+        cy.getUser('collectionuser1', 'Collection', 'User', false, true)
+            .as('activeUser').then(function () {
+                activeUser = this.activeUser;
+            }
+            );
+    })
+
+    beforeEach(function () {
+        cy.clearCookies()
+        cy.clearLocalStorage()
+    })
+
+    it('checks that Public favorites does not appear under shared with me', function () {
+        cy.loginAs(adminUser);
+        cy.contains('Shared with me').click();
+        cy.get('main').contains('Public favorites').should('not.exist');
+    });
+
+    it('creates and removes a public favorite', function () {
+        cy.loginAs(adminUser);
+        cy.createGroup(adminUser.token, {
+            name: `my-favorite-project`,
+            group_class: 'project',
+        }).as('myFavoriteProject').then(function () {
+            cy.contains('Refresh').click();
+            cy.get('main').contains('my-favorite-project').rightclick();
+            cy.contains('Add to public favorites').click();
+            cy.contains('Public Favorites').click();
+            cy.get('main').contains('my-favorite-project').rightclick();
+            cy.contains('Remove from public favorites').click();
+            cy.get('main').contains('my-favorite-project').should('not.exist');
+            cy.trashGroup(adminUser.token, this.myFavoriteProject.uuid);
+        });
+    });
+
+    it('can copy collection to favorites', () => {
+        cy.loginAs(adminUser);
+
+        cy.createGroup(adminUser.token, {
+            name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
+            group_class: 'project',
+        }).as('mySharedWritableProject').then(function (mySharedWritableProject) {
+            cy.contains('Refresh').click();
+            cy.get('main').contains(mySharedWritableProject.name).rightclick();
+            cy.get('[data-cy=context-menu]').within(() => {
+                cy.contains('Share').click();
+            });
+            cy.get('[id="select-permissions"]').as('selectPermissions');
+            cy.get('@selectPermissions').click();
+            cy.contains('Write').click();
+            cy.get('.sharing-dialog').as('sharingDialog');
+            cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
+            cy.get('[role=tooltip]').click();
+            cy.get('@sharingDialog').contains('Save').click();
+        });
+
+        cy.createGroup(adminUser.token, {
+            name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
+            group_class: 'project',
+        }).as('mySharedReadonlyProject').then(function (mySharedReadonlyProject) {
+            cy.contains('Refresh').click();
+            cy.get('main').contains(mySharedReadonlyProject.name).rightclick();
+            cy.get('[data-cy=context-menu]').within(() => {
+                cy.contains('Share').click();
+            });
+            cy.get('.sharing-dialog').as('sharingDialog');
+            cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
+            cy.get('[role=tooltip]').click();
+            cy.get('@sharingDialog').contains('Save').click();
+        });
+
+        cy.createGroup(activeUser.token, {
+            name: `my-project ${Math.floor(Math.random() * 999999)}`,
+            group_class: 'project',
+        }).as('myProject1');
+
+        cy.createCollection(adminUser.token, {
+            name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+            owner_uuid: activeUser.user.uuid,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        })
+            .as('testCollection');
+
+        cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject', '@myProject1', '@testCollection')
+            .then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1, testCollection]) {
+                cy.loginAs(activeUser);
+
+                cy.contains('Shared with me').click();
+
+                cy.get('main').contains(mySharedWritableProject.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.get('main').contains(mySharedReadonlyProject.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.doSearch(`${activeUser.user.uuid}`);
+
+                cy.get('main').contains(myProject1.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.contains(testCollection.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Move to').click();
+                });
+
+                cy.get('[data-cy=form-dialog]').within(function () {
+                    cy.get('[data-cy=projects-tree-favourites-tree-picker]').find('i').click();
+                    cy.contains(myProject1.name);
+                    cy.contains(mySharedWritableProject.name);
+                    cy.get('[data-cy=projects-tree-favourites-tree-picker]')
+                        .should('not.contain', mySharedReadonlyProject.name);
+                    cy.contains(mySharedWritableProject.name).click();
+                    cy.get('[data-cy=form-submit-btn]').click();
+                });
+
+                cy.doSearch(`${mySharedWritableProject.uuid}`);
+                cy.get('main').contains(testCollection.name);
+            });
+    });
+
+    it('can copy selected into the collection', () => {
+        cy.loginAs(adminUser);
+
+        cy.createCollection(adminUser.token, {
+            name: `Test source collection ${Math.floor(Math.random() * 999999)}`,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        })
+            .as('testSourceCollection').then(function (testSourceCollection) {
+                cy.contains('Refresh').click();
+                cy.get('main').contains(testSourceCollection.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Share').click();
+                });
+                cy.get('[id="select-permissions"]').as('selectPermissions');
+                cy.get('@selectPermissions').click();
+                cy.contains('Write').click();
+                cy.get('.sharing-dialog').as('sharingDialog');
+                cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
+                cy.get('[role=tooltip]').click();
+                cy.get('@sharingDialog').contains('Save').click();
+            });
+
+        cy.createCollection(adminUser.token, {
+            name: `Test target collection ${Math.floor(Math.random() * 999999)}`,
+        })
+            .as('testTargetCollection').then(function (testTargetCollection) {
+                cy.contains('Refresh').click();
+                cy.get('main').contains(testTargetCollection.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Share').click();
+                });
+                cy.get('[id="select-permissions"]').as('selectPermissions');
+                cy.get('@selectPermissions').click();
+                cy.contains('Write').click();
+                cy.get('.sharing-dialog').as('sharingDialog');
+                cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
+                cy.get('[role=tooltip]').click();
+                cy.get('@sharingDialog').contains('Save').click();
+            });
+
+        cy.getAll('@testSourceCollection', '@testTargetCollection')
+            .then(function ([testSourceCollection, testTargetCollection]) {
+                cy.loginAs(activeUser);
+
+                cy.get('.layout-pane-primary')
+                    .contains('Projects').click();
+
+                cy.get('main').contains(testTargetCollection.name).rightclick();
+                cy.get('[data-cy=context-menu]').within(() => {
+                    cy.contains('Add to favorites').click();
+                });
+
+                cy.get('main').contains(testSourceCollection.name).click();
+                cy.get('[data-cy=collection-files-panel]').contains('bar');
+                cy.get('[data-cy=collection-files-panel]').find('input[type=checkbox]').click({ force: true });
+                cy.get('[data-cy=collection-files-panel-options-btn]').click();
+                cy.get('[data-cy=context-menu]')
+                    .contains('Copy selected into the collection').click();
+
+                cy.get('[data-cy=projects-tree-favourites-tree-picker]')
+                    .find('i')
+                    .click();
+
+                cy.get('[data-cy=projects-tree-favourites-tree-picker]')
+                    .contains(testTargetCollection.name)
+                    .click();
+
+                cy.get('[data-cy=form-submit-btn]').click();
+
+                cy.get('.layout-pane-primary')
+                    .contains('Projects').click();
+
+                cy.get('main').contains(testTargetCollection.name).click();
+
+                cy.get('[data-cy=collection-files-panel]').contains('bar');
+            });
+    });
+});
\ No newline at end of file
index bba04ba85977bf9a95d34e9792a3fcb435902f5a..24e4b73a3265962f6dec09cdf68025d28d63b03c 100644 (file)
@@ -32,17 +32,17 @@ const controllerURL = Cypress.env('controller_url');
 const systemToken = Cypress.env('system_token');
 
 Cypress.Commands.add(
-    "doRequest", (method='GET', path='', data=null, qs=null,
-                   token=systemToken, auth=false, followRedirect=true) => {
-        return cy.request({
-            method: method,
-            url: `${controllerURL}/${path}`,
-            body: data,
-            qs: auth ? qs : Object.assign({api_token: token}, qs),
-            auth: auth ? {bearer: `${token}`} : undefined,
-            followRedirect: followRedirect
-        })
-    }
+    "doRequest", (method = 'GET', path = '', data = null, qs = null,
+        token = systemToken, auth = false, followRedirect = true) => {
+    return cy.request({
+        method: method,
+        url: `${controllerURL}/${path}`,
+        body: data,
+        qs: auth ? qs : Object.assign({ api_token: token }, qs),
+        auth: auth ? { bearer: `${token}` } : undefined,
+        followRedirect: followRedirect
+    })
+}
 )
 
 // This resets the DB removing all content and seeding it with the fixtures.
@@ -54,7 +54,7 @@ Cypress.Commands.add(
 )
 
 Cypress.Commands.add(
-    "getUser", (username, first_name='', last_name='', is_admin=false, is_active=true) => {
+    "getUser", (username, first_name = '', last_name = '', is_admin = false, is_active = true) => {
         // Create user if not already created
         return cy.doRequest('POST', '/auth/controller/callback', {
             auth_info: JSON.stringify({
@@ -66,30 +66,30 @@ Cypress.Commands.add(
             }),
             return_to: ',https://example.local'
         }, null, systemToken, true, false) // Don't follow redirects so we can catch the token
-        .its('headers.location').as('location')
-        // Get its token and set the account up as admin and/or active
-        .then(function() {
-            this.userToken = this.location.split("=")[1]
-            assert.isString(this.userToken)
-            return cy.doRequest('GET', '/arvados/v1/users', null, {
-                filters: `[["username", "=", "${username}"]]`
-            })
-            .its('body.items.0')
-            .as('aUser')
-            .then(function() {
-                cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, {
-                    user: {
-                        is_admin: is_admin,
-                        is_active: is_active
-                    }
-                })
-                .its('body')
-                .as('theUser')
-                .then(function() {
-                    return {user: this.theUser, token: this.userToken};
+            .its('headers.location').as('location')
+            // Get its token and set the account up as admin and/or active
+            .then(function () {
+                this.userToken = this.location.split("=")[1]
+                assert.isString(this.userToken)
+                return cy.doRequest('GET', '/arvados/v1/users', null, {
+                    filters: `[["username", "=", "${username}"]]`
                 })
+                    .its('body.items.0')
+                    .as('aUser')
+                    .then(function () {
+                        cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, {
+                            user: {
+                                is_admin: is_admin,
+                                is_active: is_active
+                            }
+                        })
+                            .its('body')
+                            .as('theUser')
+                            .then(function () {
+                                return { user: this.theUser, token: this.userToken };
+                            })
+                    })
             })
-        })
     }
 )
 
@@ -145,31 +145,31 @@ Cypress.Commands.add(
 
 Cypress.Commands.add(
     "createResource", (token, suffix, data) => {
-        return cy.doRequest('POST', '/arvados/v1/'+suffix, data, null, token, true)
-        .its('body').as('resource')
-        .then(function() {
-            return this.resource;
-        })
+        return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true)
+            .its('body').as('resource')
+            .then(function () {
+                return this.resource;
+            })
     }
 )
 
 Cypress.Commands.add(
     "deleteResource", (token, suffix, uuid) => {
-        return cy.doRequest('DELETE', '/arvados/v1/'+suffix+'/'+uuid)
-        .its('body').as('resource')
-        .then(function() {
-            return this.resource;
-        })
+        return cy.doRequest('DELETE', '/arvados/v1/' + suffix + '/' + uuid)
+            .its('body').as('resource')
+            .then(function () {
+                return this.resource;
+            })
     }
 )
 
 Cypress.Commands.add(
     "updateResource", (token, suffix, uuid, data) => {
-        return cy.doRequest('PUT', '/arvados/v1/'+suffix+'/'+uuid, data, null, token, true)
-        .its('body').as('resource')
-        .then(function() {
-            return this.resource;
-        })
+        return cy.doRequest('PUT', '/arvados/v1/' + suffix + '/' + uuid, data, null, token, true)
+            .its('body').as('resource')
+            .then(function () {
+                return this.resource;
+            })
     }
 )
 
@@ -186,4 +186,14 @@ Cypress.Commands.add(
     "doSearch", (searchTerm) => {
         cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);
     }
-)
\ No newline at end of file
+)
+
+Cypress.Commands.add('getAll', (...elements) => {
+    const promise = cy.wrap([], { log: false })
+
+    for (let element of elements) {
+        promise.then(arr => cy.get(element).then(got => cy.wrap([...arr, got])))
+    }
+
+    return promise
+})
\ No newline at end of file
index fbb2a52f448920e8b34cccaac6219709193534c7..fce81004afbc359e912ec64c867143064c0e26d9 100644 (file)
@@ -45,7 +45,7 @@ export class FavoriteService {
                 results.items.map(item => this.linkService.delete(item.uuid))));
     }
 
-    list(userUuid: string, { filters, limit, offset, linkOrder, contentOrder }: FavoriteListArguments = {}): Promise<ListResults<GroupContentsResource>> {
+    list(userUuid: string, { filters, limit, offset, linkOrder, contentOrder }: FavoriteListArguments = {}, showOnlyOwned: boolean = true): Promise<ListResults<GroupContentsResource>> {
         const listFilters = new FilterBuilder()
             .addEqual('owner_uuid', userUuid)
             .addEqual('link_class', LinkClass.STAR)
@@ -60,7 +60,7 @@ export class FavoriteService {
             })
             .then(results => {
                 const uuids = results.items.map(item => item.headUuid);
-                return this.groupsService.contents(userUuid, {
+                return this.groupsService.contents(showOnlyOwned ? userUuid : '', {
                     limit,
                     offset,
                     order: contentOrder,
index 74fa17b35cf47dc5d42d2e6dbd0871809ea15fbb..09c6bb66686384d219a1d9b3c08dd6ce1fecbc4e 100644 (file)
@@ -112,6 +112,13 @@ export const copyCollectionPartialToSelectedCollection = ({ collectionUuid }: Co
         dispatch(startSubmit(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
         const state = getState();
         const currentCollection = state.collectionPanel.item;
+
+        if (currentCollection && !currentCollection.manifestText) {
+            const fetchedCurrentCollection = await services.collectionService.get(currentCollection.uuid);
+            currentCollection.manifestText = fetchedCurrentCollection.manifestText;
+            currentCollection.unsignedManifestText = fetchedCurrentCollection.unsignedManifestText;
+        }
+
         if (currentCollection) {
             try {
                 dispatch(progressIndicatorActions.START_WORKING(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
@@ -127,10 +134,10 @@ export const copyCollectionPartialToSelectedCollection = ({ collectionUuid }: Co
                     }
                 });
                 const diffPathToRemove = _.difference(paths, pathsToRemove);
-                await services.collectionService.deleteFiles(selectedCollection.uuid, pathsToRemove);
+                await services.collectionService.deleteFiles(selectedCollection.uuid, pathsToRemove.map(path => path.replace(currentCollection.uuid, collectionUuid)));
                 const collectionWithDeletedFiles = await services.collectionService.get(collectionUuid);
-                await services.collectionService.update(collectionUuid, { manifestText: `${collectionWithDeletedFiles.manifestText}${currentCollection.manifestText ? currentCollection.manifestText : currentCollection.unsignedManifestText}` });
-                await services.collectionService.deleteFiles(collectionWithDeletedFiles.uuid, diffPathToRemove);
+                await services.collectionService.update(collectionUuid, { manifestText: `${collectionWithDeletedFiles.manifestText}${(currentCollection.manifestText ? currentCollection.manifestText : currentCollection.unsignedManifestText) || ''}` });
+                await services.collectionService.deleteFiles(collectionWithDeletedFiles.uuid, diffPathToRemove.map(path => path.replace(currentCollection.uuid, collectionUuid)));
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION }));
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'Files has been copied to selected collection.',
index 3fa5187a3dcf0b9e7eb7be39bdec1ea2d0fb5e7f..d11f7527b4e0d7d18a1e6e9d1a0ecbddfae67e35 100644 (file)
@@ -21,6 +21,7 @@ import { mapTree } from '../../models/tree';
 import { LinkResource, LinkClass } from "~/models/link";
 import { mapTreeValues } from "~/models/tree";
 import { sortFilesTree } from "~/services/collection-service/collection-service-files-response";
+import { GroupResource } from "~/models/group";
 
 export const treePickerActions = unionize({
     LOAD_TREE_PICKER_NODE: ofType<{ id: string, pickerId: string }>(),
@@ -236,7 +237,8 @@ interface LoadFavoritesProjectParams {
     includeFiles?: boolean;
 }
 
-export const loadFavoritesProject = (params: LoadFavoritesProjectParams) =>
+export const loadFavoritesProject = (params: LoadFavoritesProjectParams,
+    options: { showOnlyOwned: boolean, showOnlyWritable: boolean } = { showOnlyOwned: true, showOnlyWritable: false }) =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
         const { pickerId, includeCollections = false, includeFiles = false } = params;
         const uuid = getUserUuid(getState());
@@ -248,12 +250,18 @@ export const loadFavoritesProject = (params: LoadFavoritesProjectParams) =>
                 fb => fb.getFilters(),
             )(new FilterBuilder());
 
-            const { items } = await services.favoriteService.list(uuid, { filters });
+            const { items } = await services.favoriteService.list(uuid, { filters }, options.showOnlyOwned);
 
             dispatch<any>(receiveTreePickerData<GroupContentsResource>({
                 id: 'Favorites',
                 pickerId,
-                data: items,
+                data: items.filter((item) => {
+                    if (options.showOnlyWritable && (item as GroupResource).writableBy && (item as GroupResource).writableBy.indexOf(uuid) === -1) {
+                        return false;
+                    }
+
+                    return true;
+                }),
                 extractNodeData: item => ({
                     id: item.uuid,
                     value: item,
index 09704066a17d4a4d50a8030bede397942fb8678e..2f149f4a86be412de6e082ac947b9b536bf87fc2 100644 (file)
@@ -11,7 +11,7 @@ import { loadFavoritesProject } from '~/store/tree-picker/tree-picker-actions';
 export const FavoritesTreePicker = connect(() => ({
     rootItemIcon: FavoriteIcon,
 }), (dispatch: Dispatch): Pick<ProjectsTreePickerProps, 'loadRootItem'> => ({
-    loadRootItem: (_, pickerId, includeCollections, includeFiles) => {
-        dispatch<any>(loadFavoritesProject({ pickerId, includeCollections, includeFiles }));
+    loadRootItem: (_, pickerId, includeCollections, includeFiles, options) => {
+        dispatch<any>(loadFavoritesProject({ pickerId, includeCollections, includeFiles }, options));
     },
 }))(ProjectsTreePicker);
\ No newline at end of file
index 07b1ad816a6d0475469e5438e08b7351b777282f..eb756d727449722ebddbd03b7e351a6d72dc254d 100644 (file)
@@ -33,7 +33,9 @@ export interface ProjectsTreePickerDataProps {
     showSelection?: boolean;
     relatedTreePickers?: string[];
     disableActivation?: string[];
-    loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string, includeCollections?: boolean, includeFiles?: boolean) => void;
+    options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
+    loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string,
+         includeCollections?: boolean, includeFiles?: boolean, options?: { showOnlyOwned: boolean, showOnlyWritable: boolean }) => void;
 }
 
 export type ProjectsTreePickerProps = ProjectsTreePickerDataProps & Partial<PickedTreePickerProps>;
@@ -43,7 +45,7 @@ const mapStateToProps = (_: any, { rootItemIcon, showSelection }: ProjectsTreePi
     showSelection: isSelectionVisible(showSelection),
 });
 
-const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, relatedTreePickers, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
+const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, relatedTreePickers, options, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
     onContextMenu: () => { return; },
     toggleItemActive: (event, item, pickerId) => {
 
@@ -67,7 +69,7 @@ const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollectio
                         : loadProject({ id, pickerId, includeCollections, includeFiles })
                 );
             } else if (!('type' in data) && loadRootItem) {
-                loadRootItem(item as TreeItem<ProjectsTreePickerRootItem>, pickerId, includeCollections, includeFiles);
+                loadRootItem(item as TreeItem<ProjectsTreePickerRootItem>, pickerId, includeCollections, includeFiles, options);
             }
         } else if (status === TreeItemStatus.LOADED) {
             dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ id, pickerId }));
index 10bb5eb822c411a4236cd6b80cbb052612d555d5..f28d173e86a93ca06041f9c1e43f43700524ff57 100644 (file)
@@ -17,6 +17,7 @@ export interface ProjectsTreePickerProps {
     includeCollections?: boolean;
     includeFiles?: boolean;
     showSelection?: boolean;
+    options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
     toggleItemActive?: (event: React.MouseEvent<HTMLElement>, item: TreeItem<ProjectsTreePickerItem>, pickerId: string) => void;
     toggleItemSelection?: (event: React.MouseEvent<HTMLElement>, item: TreeItem<ProjectsTreePickerItem>, pickerId: string) => void;
 }
@@ -33,7 +34,9 @@ export const ProjectsTreePicker = ({ pickerId, ...props }: ProjectsTreePickerPro
         <HomeTreePicker pickerId={home} {...p} />
         <SharedTreePicker pickerId={shared} {...p} />
         <PublicFavoritesTreePicker pickerId={publicFavorites} {...p} />
-        <FavoritesTreePicker pickerId={favorites} {...p} />  
+        <div data-cy="projects-tree-favourites-tree-picker">
+            <FavoritesTreePicker pickerId={favorites} {...p} />  
+        </div>
     </div>;
 };
 
index a8ab05f699145b296ab0e8afd96d5d9f2463d8a8..436a3e45922259ae63fbc18e56da6c763eda6c99 100644 (file)
@@ -14,7 +14,8 @@ export const ProjectTreePickerField = (props: WrappedFieldProps & PickerIdProp)
     <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
         <ProjectsTreePicker
             pickerId={props.pickerId}
-            toggleItemActive={handleChange(props)} />
+            toggleItemActive={handleChange(props)}
+            options={{ showOnlyOwned: false, showOnlyWritable: true }} />
         {props.meta.dirty && props.meta.error &&
             <Typography variant='caption' color='error'>
                 {props.meta.error}
@@ -30,6 +31,7 @@ export const CollectionTreePickerField = (props: WrappedFieldProps & PickerIdPro
         <ProjectsTreePicker
             pickerId={props.pickerId}
             toggleItemActive={handleChange(props)}
+            options={{ showOnlyOwned: false, showOnlyWritable: true }}
             includeCollections />
         {props.meta.dirty && props.meta.error &&
             <Typography variant='caption' color='error'>
index 1792bd67d7f929c513f1a014549c76cd78bd6f44..2038ad964bbc5e09ce1b7c1a1a78508cfdc4bf56 100644 (file)
@@ -25,6 +25,7 @@ export default (props: SharingDialogDataProps & SharingDialogActionProps) => {
     const { children, open, loading, advancedEnabled, saveEnabled, onAdvanced, onClose, onExited, onSave } = props;
     return <Dialog
         {...{ open, onClose, onExited }}
+        className="sharing-dialog"
         fullWidth
         maxWidth='sm'
         disableBackdropClick
index 59456fb3f046119b22d8e0d3b00a668e1690b21f..b23ee6b6b42ce3839153e493cf133339d0c11f06 100644 (file)
@@ -10,10 +10,10 @@ import { ParticipantSelect, Participant } from './participant-select';
 
 export default () =>
     <Grid container spacing={8}>
-        <Grid item xs={8}>
+        <Grid data-cy="invite-people-field" item xs={8}>
             <InvitedPeopleField />
         </Grid>
-        <Grid item xs={4}>
+        <Grid data-cy="permission-select-field" item xs={4}>
             <PermissionSelectField />
         </Grid>
     </Grid>;