From: Lucas Di Pentima Date: Wed, 25 Nov 2020 16:08:19 +0000 (-0300) Subject: 17098: Avoids offering the 'Add to favorites' action on old versions. X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/c345c171d74d5855d400a8559620f69a87fdb04c 17098: Avoids offering the 'Add to favorites' action on old versions. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js index a44edd7eaf..0a127db7ad 100644 --- a/cypress/integration/collection-panel.spec.js +++ b/cypress/integration/collection-panel.spec.js @@ -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. diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts index 7e4c7b98ca..a870a813df 100644 --- a/src/views-components/context-menu/action-sets/collection-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-action-set.ts @@ -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(toggleFavorite(resource)).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); - } - }, +const toggleFavoriteAction: ContextMenuAction = { + component: ToggleFavoriteAction, + name: 'ToggleFavoriteAction', + execute: (dispatch, resource) => { + dispatch(toggleFavorite(resource)).then(() => { + dispatch(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',