[ARVADOS-WORKBENCH2] updated: 2.1.0-104-g306d28fe

Git user git at public.arvados.org
Tue Nov 24 20:03:30 UTC 2020


Summary of changes:
 cypress/integration/collection-panel.spec.js       | 15 +++++++++++
 .../details-panel/collection-details.tsx           | 29 ++++++++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)

       via  306d28fed8af239094ca8eaf956d3410fafc031b (commit)
      from  f40add991a9557c2cb692f59a78ab3f2bd98121f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 306d28fed8af239094ca8eaf956d3410fafc031b
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Nov 24 17:02:54 2020 -0300

    13494: Adds context menu support to collection versions browser.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js
index 2b9957a3..377f11d9 100644
--- a/cypress/integration/collection-panel.spec.js
+++ b/cypress/integration/collection-panel.spec.js
@@ -381,6 +381,21 @@ describe('Collection panel tests', function() {
                 .should('not.contain', 'foo').and('contain', 'bar');
             cy.get('[data-cy=collection-version-browser-select-3]')
                 .should('contain', '3').and('contain', '3 B');
+
+            // Check context menus on version browser
+            cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
+            cy.get('[data-cy=context-menu]')
+                .should('contain', 'Add to favorites')
+                .and('contain', 'Make a copy')
+                .and('contain', 'Edit collection');
+            cy.get('body').click();
+            // (and now an old version...)
+            cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
+            cy.get('[data-cy=context-menu]')
+                .should('contain', 'Add to favorites')
+                .and('contain', 'Make a copy')
+                .and('not.contain', 'Edit collection');
+            cy.get('body').click();
         });
     });
 })
diff --git a/src/views-components/details-panel/collection-details.tsx b/src/views-components/details-panel/collection-details.tsx
index b0449bff..6066a588 100644
--- a/src/views-components/details-panel/collection-details.tsx
+++ b/src/views-components/details-panel/collection-details.tsx
@@ -14,6 +14,8 @@ import { Grid, ListItem, StyleRulesCallback, Typography, withStyles, WithStyles
 import { formatDate, formatFileSize } from '~/common/formatters';
 import { Dispatch } from 'redux';
 import { navigateTo } from '~/store/navigation/navigation-action';
+import { resourceKindToContextMenuKind, openContextMenu } from '~/store/context-menu/context-menu-actions';
+import { ContextMenuKind } from '../context-menu/context-menu';
 
 export type CssRules = 'versionBrowserHeader' | 'versionBrowserItem';
 
@@ -60,30 +62,45 @@ export class CollectionDetails extends DetailsData<CollectionResource> {
 interface CollectionVersionBrowserProps {
     currentCollection: CollectionResource | undefined;
     versions: CollectionResource[];
+    isAdmin: boolean;
 }
 
 interface CollectionVersionBrowserDispatchProps {
     showVersion: (c: CollectionResource) => void;
+    handleContextMenu: (event: React.MouseEvent<HTMLElement>, collection: CollectionResource, menuKind: ContextMenuKind | undefined) => void;
 }
 
 const mapStateToProps = (state: RootState): CollectionVersionBrowserProps => {
     const currentCollection = getResource<CollectionResource>(state.detailsPanel.resourceUuid)(state.resources);
+    const isAdmin = state.auth.user!.isAdmin;
     const versions = currentCollection
         && filterResources(rsc =>
             (rsc as CollectionResource).currentVersionUuid === currentCollection.currentVersionUuid)(state.resources)
                 .sort((a: CollectionResource, b: CollectionResource) => b.version - a.version) as CollectionResource[]
         || [];
-    return { currentCollection, versions };
+    return { currentCollection, versions, isAdmin };
 };
 
 const mapDispatchToProps = () =>
     (dispatch: Dispatch): CollectionVersionBrowserDispatchProps => ({
         showVersion: (collection) => dispatch<any>(navigateTo(collection.uuid)),
+        handleContextMenu: (event: React.MouseEvent<HTMLElement>, collection: CollectionResource, menuKind: ContextMenuKind) => {
+            if (collection && menuKind) {
+                dispatch<any>(openContextMenu(event, {
+                    name: collection.name,
+                    uuid: collection.uuid,
+                    ownerUuid: collection.ownerUuid,
+                    isTrashed: collection.isTrashed,
+                    kind: collection.kind,
+                    menuKind
+                }));
+            }
+        },
     });
 
 const CollectionVersionBrowser = withStyles(styles)(
     connect(mapStateToProps, mapDispatchToProps)(
-        ({ currentCollection, versions, showVersion, classes }: CollectionVersionBrowserProps & CollectionVersionBrowserDispatchProps & WithStyles<CssRules>) => {
+        ({ currentCollection, versions, isAdmin, showVersion, handleContextMenu, classes }: CollectionVersionBrowserProps & CollectionVersionBrowserDispatchProps & WithStyles<CssRules>) => {
             return <div data-cy="collection-version-browser">
                 <Grid container>
                     <Grid item xs={2}>
@@ -108,6 +125,14 @@ const CollectionVersionBrowser = withStyles(styles)(
                             data-cy={`collection-version-browser-select-${item.version}`}
                             key={item.version}
                             onClick={e => showVersion(item)}
+                            onContextMenu={event => handleContextMenu(
+                                event,
+                                item,
+                                resourceKindToContextMenuKind(
+                                    item.uuid,
+                                    isAdmin,
+                                    (item.uuid === item.currentVersionUuid))
+                            )}
                             selected={isSelectedVersion}>
                             <Grid item xs={2}>
                                 <Typography variant="caption" className={classes.versionBrowserItem}>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list