17098: Avoids offering the 'Add to favorites' action on old versions.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 25 Nov 2020 16:08:19 +0000 (13:08 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 25 Nov 2020 16:08:19 +0000 (13:08 -0300)
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/action-sets/collection-action-set.ts

index a44edd7eaf137d3feb5cdcbf6c62fb603bc64d46..0a127db7ad26823a4a6ebc8bc33ba2bb71f83583 100644 (file)
@@ -352,9 +352,11 @@ describe('Collection panel tests', function() {
             cy.get('[data-cy=collection-files-panel]')
                 .should('contain', 'foo').and('contain', 'bar');
 
-            // Check that old collection action is available on context menu
-            cy.get('[data-cy=collection-panel-options-btn]').click()
-            cy.get('[data-cy=context-menu]').should('contain', 'Recover version')
+            // Check that only old collection action are available on context menu
+            cy.get('[data-cy=collection-panel-options-btn]').click();
+            cy.get('[data-cy=context-menu]')
+                .should('contain', 'Recover version')
+                .and('not.contain', 'Add to favorites');
             cy.get('body').click(); // Collapse the menu avoiding details panel expansion
 
             // Click on "head version" link, confirm that it's the latest version.
index 7e4c7b98ca7700d83f12ca20eb21f30172b43880..a870a813df80497750ac75b1d17bbf0a04be888a 100644 (file)
@@ -2,10 +2,23 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { ContextMenuActionSet } from "../context-menu-action-set";
+import {
+    ContextMenuAction,
+    ContextMenuActionSet
+} from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "~/store/favorites/favorites-actions";
-import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, AdvancedIcon, OpenIcon, Link, RecoverVersionIcon } from "~/components/icon/icon";
+import {
+    RenameIcon,
+    ShareIcon,
+    MoveToIcon,
+    CopyIcon,
+    DetailsIcon,
+    AdvancedIcon,
+    OpenIcon,
+    Link,
+    RecoverVersionIcon
+} from "~/components/icon/icon";
 import { openCollectionUpdateDialog } from "~/store/collections/collection-update-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
 import { openMoveCollectionDialog } from '~/store/collections/collection-move-actions';
@@ -21,16 +34,17 @@ import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
 import { togglePublicFavorite } from "~/store/public-favorites/public-favorites-actions";
 import { publicFavoritePanelActions } from "~/store/public-favorites-panel/public-favorites-action";
 
-export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
-    {
-        component: ToggleFavoriteAction,
-        name: 'ToggleFavoriteAction',
-        execute: (dispatch, resource) => {
-            dispatch<any>(toggleFavorite(resource)).then(() => {
-                dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
-            });
-        }
-    },
+const toggleFavoriteAction: ContextMenuAction = {
+    component: ToggleFavoriteAction,
+    name: 'ToggleFavoriteAction',
+    execute: (dispatch, resource) => {
+        dispatch<any>(toggleFavorite(resource)).then(() => {
+            dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
+        });
+    }
+};
+
+const commonActionSet: ContextMenuActionSet = [[
     {
         icon: OpenIcon,
         name: "Open in new tab",
@@ -69,6 +83,11 @@ export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
     },
 ]];
 
+export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
+    ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
+    toggleFavoriteAction,
+]];
+
 export const collectionActionSet: ContextMenuActionSet = [
     [
         ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
@@ -118,7 +137,7 @@ export const collectionAdminActionSet: ContextMenuActionSet = [
 
 export const oldCollectionVersionActionSet: ContextMenuActionSet = [
     [
-        ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
+        ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
         {
             icon: RecoverVersionIcon,
             name: 'Recover version',