[ARVADOS-WORKBENCH2] created: 2.1.0-357-gbeacdc4d

Git user git at public.arvados.org
Wed Apr 28 22:15:54 UTC 2021


        at  beacdc4d38efb1880aaa14e8b3985e683d14e457 (commit)


commit beacdc4d38efb1880aaa14e8b3985e683d14e457
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Wed Apr 28 19:15:30 2021 -0300

    17289: Adds test.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js
index 5bad87b3..15170076 100644
--- a/cypress/integration/collection.spec.js
+++ b/cypress/integration/collection.spec.js
@@ -53,7 +53,7 @@ describe('Collection panel tests', function () {
                     const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find('dict')[0].children);
                     const map = {};
                     let i, j = 2;
-                    
+
                     for (i=0; i < childrenCollection.length; i += j) {
                       map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
                     }
@@ -116,6 +116,7 @@ describe('Collection panel tests', function () {
             // on this loop may pass an assertion from the first iteration by looking
             // for the same file name.
             const fileName = isWritable ? 'bar' : 'foo';
+            const subDirName = 'subdir';
             cy.createGroup(adminUser.token, {
                 name: 'Shared project',
                 group_class: 'project',
@@ -126,7 +127,7 @@ describe('Collection panel tests', function () {
                     name: 'Test collection',
                     owner_uuid: this.sharedGroup.uuid,
                     properties: { someKey: 'someValue' },
-                    manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
+                    manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
                 })
                     .as('testCollection').then(function () {
                         // Share the group with active user.
@@ -184,6 +185,7 @@ describe('Collection panel tests', function () {
                                     .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
                             }
                         });
+                        // Test context menus
                         cy.get('[data-cy=collection-files-panel]')
                             .contains(fileName).rightclick({ force: true });
                         cy.get('[data-cy=context-menu]')
@@ -193,6 +195,15 @@ describe('Collection panel tests', function () {
                             .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
                             .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
                         cy.get('body').click(); // Collapse the menu
+                        cy.get('[data-cy=collection-files-panel]')
+                            .contains(subDirName).rightclick({ force: true });
+                        cy.get('[data-cy=context-menu]')
+                            .should('not.contain', 'Download')
+                            .and('contain', 'Open in new tab')
+                            .and('contain', 'Copy to clipboard')
+                            .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
+                            .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
+                        cy.get('body').click(); // Collapse the menu
                         // Hamburger 'more options' menu button
                         cy.get('[data-cy=collection-files-panel-options-btn]')
                             .click()
@@ -202,16 +213,8 @@ describe('Collection panel tests', function () {
                         cy.get('[data-cy=collection-files-panel-options-btn]')
                             .click()
                         cy.get('[data-cy=context-menu]')
-                            // .should('contain', 'Download selected')
                             .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
                         cy.get('body').click(); // Collapse the menu
-                        // File item 'more options' button
-                        cy.get('[data-cy=file-item-options-btn')
-                            .click()
-                        cy.get('[data-cy=context-menu]')
-                            .should('contain', 'Download')
-                            .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
-                        cy.get('body').click(); // Collapse the menu
                     })
             })
         })

commit c3560cceb44003550d1f991c7d7d64de33625001
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Wed Apr 28 18:31:34 2021 -0300

    17289: Splits context menu actions set to avoid showing 'Download' on dirs.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/index.tsx b/src/index.tsx
index e691c5d2..7803c6b7 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -25,7 +25,7 @@ import { filterGroupActionSet, projectActionSet, readOnlyProjectActionSet } from
 import { resourceActionSet } from '~/views-components/context-menu/action-sets/resource-action-set';
 import { favoriteActionSet } from "~/views-components/context-menu/action-sets/favorite-action-set";
 import { collectionFilesActionSet, readOnlyCollectionFilesActionSet } from '~/views-components/context-menu/action-sets/collection-files-action-set';
-import { collectionFilesItemActionSet, readOnlyCollectionFilesItemActionSet } from '~/views-components/context-menu/action-sets/collection-files-item-action-set';
+import { collectionDirectoryItemActionSet, collectionFileItemActionSet, readOnlyCollectionDirectoryItemActionSet, readOnlyCollectionFileItemActionSet } from '~/views-components/context-menu/action-sets/collection-files-item-action-set';
 import { collectionFilesNotSelectedActionSet } from '~/views-components/context-menu/action-sets/collection-files-not-selected-action-set';
 import { collectionActionSet, collectionAdminActionSet, oldCollectionVersionActionSet, readOnlyCollectionActionSet } from '~/views-components/context-menu/action-sets/collection-action-set';
 import { processActionSet } from '~/views-components/context-menu/action-sets/process-action-set';
@@ -74,8 +74,10 @@ addMenuActionSet(ContextMenuKind.FAVORITE, favoriteActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
 addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILES, readOnlyCollectionFilesActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_FILES_NOT_SELECTED, collectionFilesNotSelectedActionSet);
-addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
-addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILES_ITEM, readOnlyCollectionFilesItemActionSet);
+addMenuActionSet(ContextMenuKind.COLLECTION_DIRECTORY_ITEM, collectionDirectoryItemActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM, readOnlyCollectionDirectoryItemActionSet);
+addMenuActionSet(ContextMenuKind.COLLECTION_FILE_ITEM, collectionFileItemActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILE_ITEM, readOnlyCollectionFileItemActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
 addMenuActionSet(ContextMenuKind.READONLY_COLLECTION, readOnlyCollectionActionSet);
 addMenuActionSet(ContextMenuKind.OLD_VERSION_COLLECTION, oldCollectionVersionActionSet);
diff --git a/src/views-components/collection-panel-files/collection-panel-files.ts b/src/views-components/collection-panel-files/collection-panel-files.ts
index 91420edb..ddd59ea6 100644
--- a/src/views-components/collection-panel-files/collection-panel-files.ts
+++ b/src/views-components/collection-panel-files/collection-panel-files.ts
@@ -55,12 +55,17 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick<CollectionPanelFilesProps,
         dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_SELECTION({ id: item.id }));
     },
     onItemMenuOpen: (event, item, isWritable) => {
+        const isDirectory = item.data.type === 'directory';
         dispatch<any>(openContextMenu(
             event,
             {
                 menuKind: isWritable
-                    ? ContextMenuKind.COLLECTION_FILES_ITEM
-                    : ContextMenuKind.READONLY_COLLECTION_FILES_ITEM,
+                    ? isDirectory
+                        ? ContextMenuKind.COLLECTION_DIRECTORY_ITEM
+                        : ContextMenuKind.COLLECTION_FILE_ITEM
+                    : isDirectory
+                        ? ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM
+                        : ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
                 kind: ResourceKind.COLLECTION,
                 name: item.data.name,
                 uuid: item.id,
diff --git a/src/views-components/context-menu/action-sets/collection-files-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-action-set.ts
index 7e885615..03cfdb9b 100644
--- a/src/views-components/context-menu/action-sets/collection-files-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-action-set.ts
@@ -5,8 +5,8 @@
 import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
 import { collectionPanelFilesAction, openMultipleFilesRemoveDialog } from "~/store/collection-panel/collection-panel-files/collection-panel-files-actions";
 import { openCollectionPartialCopyDialog, openCollectionPartialCopyToSelectedCollectionDialog } from '~/store/collections/collection-partial-copy-actions';
-// import { DownloadCollectionFileAction } from "~/views-components/context-menu/actions/download-collection-file-action";
 
+// These action sets are used on the multi-select actions button.
 export const readOnlyCollectionFilesActionSet: ContextMenuActionSet = [[
     {
         name: "Select all",
@@ -20,10 +20,6 @@ export const readOnlyCollectionFilesActionSet: ContextMenuActionSet = [[
             dispatch(collectionPanelFilesAction.UNSELECT_ALL_COLLECTION_FILES());
         }
     },
-    // { // Disabled for now as we need to create backend version of this feature which will be less buggy
-    //     component: DownloadCollectionFileAction,
-    //     execute: () => { return; }
-    // },
     {
         name: "Create a new collection with selected",
         execute: dispatch => {
diff --git a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
index bfbdec61..64b29e43 100644
--- a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
@@ -9,11 +9,7 @@ import { openFileRemoveDialog, openRenameFileDialog } from '~/store/collection-p
 import { CollectionFileViewerAction } from '~/views-components/context-menu/actions/collection-file-viewer-action';
 import { CollectionCopyToClipboardAction } from "../actions/collection-copy-to-clipboard-action";
 
-export const readOnlyCollectionFilesItemActionSet: ContextMenuActionSet = [[
-    {
-        component: DownloadCollectionFileAction,
-        execute: () => { return; }
-    },
+export const readOnlyCollectionDirectoryItemActionSet: ContextMenuActionSet = [[
     {
         component: CollectionFileViewerAction,
         execute: () => { return; },
@@ -24,7 +20,15 @@ export const readOnlyCollectionFilesItemActionSet: ContextMenuActionSet = [[
     }
 ]];
 
-export const collectionFilesItemActionSet: ContextMenuActionSet = readOnlyCollectionFilesItemActionSet.concat([[
+export const readOnlyCollectionFileItemActionSet: ContextMenuActionSet = [[
+    {
+        component: DownloadCollectionFileAction,
+        execute: () => { return; }
+    },
+    ...readOnlyCollectionDirectoryItemActionSet.reduce((prev, next) => prev.concat(next), []),
+]];
+
+const writableActionSet: ContextMenuActionSet = [[
     {
         name: "Rename",
         icon: RenameIcon,
@@ -42,4 +46,19 @@ export const collectionFilesItemActionSet: ContextMenuActionSet = readOnlyCollec
             dispatch<any>(openFileRemoveDialog(resource.uuid));
         }
     }
-]]);
\ No newline at end of file
+]];
+
+export const collectionDirectoryItemActionSet: ContextMenuActionSet = readOnlyCollectionDirectoryItemActionSet.concat(writableActionSet);
+
+// export const collectionDirectoryItemActionSet: ContextMenuActionSet = [[
+//     ...readOnlyCollectionDirectoryItemActionSet.reduce((prev, next) => prev.concat(next), []),
+//     ...writableActionSet.reduce((prev, next) => prev.concat(next), []),
+// ]];
+
+// export const collectionFileItemActionSet: ContextMenuActionSet = [[
+//     ...readOnlyCollectionFileItemActionSet.reduce((prev, next) => prev.concat(next), []),
+//     ...writableActionSet.reduce((prev, next) => prev.concat(next), []),
+// ]];
+
+
+export const collectionFileItemActionSet: ContextMenuActionSet = readOnlyCollectionFileItemActionSet.concat(writableActionSet);
\ No newline at end of file
diff --git a/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx b/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
index 4fc11fb2..e8518d1f 100644
--- a/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
+++ b/src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
@@ -12,9 +12,11 @@ const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
     const { keepWebServiceUrl } = state.auth.config;
-    if (resource && (
-        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
-        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
+    if (resource && [
+        ContextMenuKind.COLLECTION_FILE_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+        ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
diff --git a/src/views-components/context-menu/actions/collection-file-viewer-action.tsx b/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
index aba35534..7d25f1cf 100644
--- a/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
+++ b/src/views-components/context-menu/actions/collection-file-viewer-action.tsx
@@ -12,9 +12,11 @@ import { getInlineFileUrl, sanitizeToken } from "./helpers";
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
-    if (resource && (
-        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
-        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
+    if (resource && [
+        ContextMenuKind.COLLECTION_FILE_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+        ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             const fileUrl = sanitizeToken(getInlineFileUrl(
diff --git a/src/views-components/context-menu/actions/download-collection-file-action.tsx b/src/views-components/context-menu/actions/download-collection-file-action.tsx
index e1986d3c..3af98c4e 100644
--- a/src/views-components/context-menu/actions/download-collection-file-action.tsx
+++ b/src/views-components/context-menu/actions/download-collection-file-action.tsx
@@ -13,9 +13,11 @@ import { sanitizeToken } from "./helpers";
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
-    if (resource && (
-        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
-        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
+    if (resource && [
+        ContextMenuKind.COLLECTION_FILE_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+        ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index ee87d71a..26e38f19 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -76,8 +76,10 @@ export enum ContextMenuKind {
     TRASH = "Trash",
     COLLECTION_FILES = "CollectionFiles",
     READONLY_COLLECTION_FILES = "ReadOnlyCollectionFiles",
-    COLLECTION_FILES_ITEM = "CollectionFilesItem",
-    READONLY_COLLECTION_FILES_ITEM = "ReadOnlyCollectionFilesItem",
+    COLLECTION_FILE_ITEM = "CollectionFileItem",
+    COLLECTION_DIRECTORY_ITEM = "CollectionDirectoryItem",
+    READONLY_COLLECTION_FILE_ITEM = "ReadOnlyCollectionFileItem",
+    READONLY_COLLECTION_DIRECTORY_ITEM = "ReadOnlyCollectionDirectoryItem",
     COLLECTION_FILES_NOT_SELECTED = "CollectionFilesNotSelected",
     COLLECTION = 'Collection',
     COLLECTION_ADMIN = 'CollectionAdmin',

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list