[arvados-workbench2] created: 2.4.0-159-g7eb16e13

git repository hosting git at public.arvados.org
Wed Jul 27 02:43:02 UTC 2022


        at  7eb16e136a720bdfda5a4d4782d9cce1d00f5ded (commit)


commit 7eb16e136a720bdfda5a4d4782d9cce1d00f5ded
Author: Stephen Smith <stephen at curii.com>
Date:   Tue Jul 26 19:42:09 2022 -0400

    19079: Add search results context menu with clipboard and new tab options
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

diff --git a/src/index.tsx b/src/index.tsx
index 03840d49..5d939d36 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -66,6 +66,7 @@ import { workflowActionSet } from 'views-components/context-menu/action-sets/wor
 import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
 import { openNotFoundDialog } from './store/not-found-panel/not-found-panel-action';
 import { storeRedirects } from './common/redirect-to';
+import { searchResultsActionSet } from 'views-components/context-menu/action-sets/search-results-action-set';
 
 console.log(`Starting arvados [${getBuildInfo()}]`);
 
@@ -104,6 +105,7 @@ addMenuActionSet(ContextMenuKind.PROJECT_ADMIN, projectAdminActionSet);
 addMenuActionSet(ContextMenuKind.FILTER_GROUP_ADMIN, filterGroupAdminActionSet);
 addMenuActionSet(ContextMenuKind.PERMISSION_EDIT, permissionEditActionSet);
 addMenuActionSet(ContextMenuKind.WORKFLOW, workflowActionSet);
+addMenuActionSet(ContextMenuKind.SEARCH_RESULTS, searchResultsActionSet);
 
 storeRedirects();
 
diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts
index 3e239fee..e00b65b3 100644
--- a/src/store/context-menu/context-menu-actions.ts
+++ b/src/store/context-menu/context-menu-actions.ts
@@ -10,7 +10,7 @@ import { RootState } from 'store/store';
 import { getResource, getResourceWithEditableStatus } from '../resources/resources';
 import { UserResource } from 'models/user';
 import { isSidePanelTreeCategory } from 'store/side-panel-tree/side-panel-tree-actions';
-import { extractUuidKind, ResourceKind, EditableResource } from 'models/resource';
+import { extractUuidKind, ResourceKind, EditableResource, Resource } from 'models/resource';
 import { Process } from 'store/processes/process';
 import { RepositoryResource } from 'models/repositories';
 import { SshKeyResource } from 'models/ssh-key';
@@ -267,3 +267,17 @@ export const resourceUuidToContextMenuKind = (uuid: string, readonly = false) =>
                 return;
         }
     };
+
+export const openSearchResultsContextMenu = (event: React.MouseEvent<HTMLElement>, uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState) => {
+        const res = getResource<Resource>(uuid)(getState().resources);
+        if (res) {
+            dispatch<any>(openContextMenu(event, {
+                name: '',
+                uuid: res.uuid,
+                ownerUuid: '',
+                kind: res.kind,
+                menuKind: ContextMenuKind.SEARCH_RESULTS,
+            }));
+        }
+    };
diff --git a/src/store/open-in-new-tab/open-in-new-tab.actions.ts b/src/store/open-in-new-tab/open-in-new-tab.actions.ts
index 94aec140..a363bc03 100644
--- a/src/store/open-in-new-tab/open-in-new-tab.actions.ts
+++ b/src/store/open-in-new-tab/open-in-new-tab.actions.ts
@@ -3,25 +3,11 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import copy from 'copy-to-clipboard';
-import { ResourceKind } from 'models/resource';
+import { getResourceUrl } from 'routes/routes';
 import { getClipboardUrl } from 'views-components/context-menu/actions/helpers';
 
-const getUrl = (resource: any) => {
-    let url: string | null = null;
-    const { uuid, kind } = resource;
-
-    if (kind === ResourceKind.COLLECTION) {
-        url = `/collections/${uuid}`;
-    }
-    if (kind === ResourceKind.PROJECT) {
-        url = `/projects/${uuid}`;
-    }
-
-    return url;
-};
-
 export const openInNewTabAction = (resource: any) => () => {
-    const url = getUrl(resource);
+    const url = getResourceUrl(resource.uuid);
 
     if (url) {
         window.open(`${window.location.origin}${url}`, '_blank');
@@ -29,9 +15,9 @@ export const openInNewTabAction = (resource: any) => () => {
 };
 
 export const copyToClipboardAction = (resource: any) => () => {
-    const url = getUrl(resource);
+    const url = getResourceUrl(resource.uuid);
 
     if (url) {
         copy(getClipboardUrl(url, false));
     }
-};
\ No newline at end of file
+};
diff --git a/src/views-components/context-menu/action-sets/search-results-action-set.ts b/src/views-components/context-menu/action-sets/search-results-action-set.ts
new file mode 100644
index 00000000..e916a105
--- /dev/null
+++ b/src/views-components/context-menu/action-sets/search-results-action-set.ts
@@ -0,0 +1,42 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "../context-menu-action-set";
+import { DetailsIcon, AdvancedIcon, OpenIcon, Link } from 'components/icon/icon';
+import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
+import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
+import { copyToClipboardAction, openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
+
+export const searchResultsActionSet: ContextMenuActionSet = [
+    [
+        {
+            icon: OpenIcon,
+            name: "Open in new tab",
+            execute: (dispatch, resource) => {
+                dispatch<any>(openInNewTabAction(resource));
+            }
+        },
+        {
+            icon: Link,
+            name: "Copy to clipboard",
+            execute: (dispatch, resource) => {
+                dispatch<any>(copyToClipboardAction(resource));
+            }
+        },
+        {
+            icon: DetailsIcon,
+            name: "View details",
+            execute: dispatch => {
+                dispatch<any>(toggleDetailsPanel());
+            }
+        },
+        {
+            icon: AdvancedIcon,
+            name: "Advanced",
+            execute: (dispatch, resource) => {
+                dispatch<any>(openAdvancedTabDialog(resource.uuid));
+            }
+        },
+    ]
+];
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index 4766259a..a8e7fd02 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -111,4 +111,5 @@ export enum ContextMenuKind {
     PERMISSION_EDIT = "PermissionEdit",
     LINK = "Link",
     WORKFLOW = "Workflow",
+    SEARCH_RESULTS = "SearchResults"
 }
diff --git a/src/views/search-results-panel/search-results-panel.tsx b/src/views/search-results-panel/search-results-panel.tsx
index d25682f6..0902f15b 100644
--- a/src/views/search-results-panel/search-results-panel.tsx
+++ b/src/views/search-results-panel/search-results-panel.tsx
@@ -5,8 +5,7 @@
 import { Dispatch } from "redux";
 import { connect } from "react-redux";
 import { navigateTo } from 'store/navigation/navigation-action';
-// import { openContextMenu, resourceKindToContextMenuKind } from 'store/context-menu/context-menu-actions';
-// import { ResourceKind } from 'models/resource';
+import { openSearchResultsContextMenu } from 'store/context-menu/context-menu-actions';
 import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
 import { SearchResultsPanelView } from 'views/search-results-panel/search-results-panel-view';
 import { RootState } from 'store/store';
@@ -42,7 +41,9 @@ const mapStateToProps = (rootState: RootState) => {
 };
 
 const mapDispatchToProps = (dispatch: Dispatch): SearchResultsPanelActionProps => ({
-    onContextMenu: (event, resourceUuid) => { return; },
+    onContextMenu: (event, resourceUuid) => {
+        dispatch<any>(openSearchResultsContextMenu(event, resourceUuid));
+    },
     onDialogOpen: (ownerUuid: string) => { return; },
     onItemClick: (resourceUuid: string) => {
         dispatch<any>(loadDetailsPanel(resourceUuid));

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list