Merge branch '17018-readonly-file-actions-fix'
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 5 Nov 2020 22:51:28 +0000 (19:51 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 5 Nov 2020 22:51:28 +0000 (19:51 -0300)
Closes #17018

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

cypress/integration/collection-panel.spec.js
src/views-components/context-menu/actions/collection-copy-to-clipboard-action.tsx
src/views-components/context-menu/actions/collection-file-viewer-action.tsx
src/views-components/context-menu/actions/copy-to-clipboard-action.tsx
src/views-components/context-menu/actions/download-collection-file-action.tsx

index 414d7e3ed40d12e91ba8155e888e4eab700a74ed..404d1c5b04f7ec2b2a17729908b0e6f0130dc60e 100644 (file)
@@ -64,8 +64,8 @@ describe('Collection panel tests', function() {
                         .click()
                     cy.get('[data-cy=context-menu]')
                         .should('contain', 'Add to favorites')
-                        .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection')
-                        .type('{esc}'); // Collapse the options menu
+                        .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
+                    cy.get('body').click(); // Collapse the menu avoiding details panel expansion
                     cy.get('[data-cy=collection-properties-panel]')
                         .should('contain', 'someKey')
                         .and('contain', 'someValue')
@@ -95,6 +95,15 @@ describe('Collection panel tests', function() {
                         cy.get('[data-cy=upload-button]')
                             .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
                     });
+                    cy.get('[data-cy=collection-files-panel]')
+                        .contains('bar').rightclick();
+                    cy.get('[data-cy=context-menu]')
+                        .should('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()
@@ -106,14 +115,14 @@ describe('Collection panel tests', function() {
                     cy.get('[data-cy=context-menu]')
                         // .should('contain', 'Download selected')
                         .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
-                        .type('{esc}'); // Collapse the options menu
+                    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')
-                        .type('{esc}'); // Collapse
+                        .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
+                    cy.get('body').click(); // Collapse the menu
                 })
             })
         })
index f6038b80103d9e8b96bf5c63cd0a572298303492..4fc11fb25902388b48950e5a9e8138372967b6b9 100644 (file)
@@ -12,7 +12,9 @@ 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) {
+    if (resource && (
+        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
+        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
@@ -21,10 +23,8 @@ const mapStateToProps = (state: RootState) => {
                 currentCollectionUuid
             };
         }
-    } else {
-        return ;
     }
-    return ;
+    return {};
 };
 
 export const CollectionCopyToClipboardAction = connect(mapStateToProps)(CopyToClipboardAction);
index f75da23869666e248fe1f04d91cd0e500f0e1a21..dfc9d14acd7e5552e5daa23e9256b04ab819f764 100644 (file)
@@ -11,7 +11,9 @@ import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 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) {
+    if (resource && (
+        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
+        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
@@ -20,10 +22,8 @@ const mapStateToProps = (state: RootState) => {
                 currentCollectionUuid
             };
         }
-    } else {
-        return;
     }
-    return;
+    return {};
 };
 
 export const CollectionFileViewerAction = connect(mapStateToProps)(FileViewerAction);
index 31ef4b9750b66ddcd8e80f2556b74d6fac463d60..fffcc19b185fbc7e25b1d7d00bd2ff7cf80d2ccf 100644 (file)
@@ -27,7 +27,7 @@ export const CopyToClipboardAction = (props: { href?: any, download?: any, onCli
             </ListItemIcon>
             <ListItemText>
                 Copy to clipboard
-                </ListItemText>
+            </ListItemText>
         </ListItem>
         : null;
 };
\ No newline at end of file
index 3e4e4a0ba7929418ebc80694768716eb072d4c4d..e1986d3cd338454551cc46b9563405d097257ab2 100644 (file)
@@ -13,7 +13,9 @@ 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) {
+    if (resource && (
+        resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM ||
+        resource.menuKind === ContextMenuKind.READONLY_COLLECTION_FILES_ITEM)) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {