[arvados-workbench2] updated: 2.6.0-44-gf7a4118c
git repository hosting
git at public.arvados.org
Fri Jun 23 15:50:26 UTC 2023
Summary of changes:
.../multiselectToolbar/MultiselectToolbar.tsx | 107 ++++-----------------
1 file changed, 19 insertions(+), 88 deletions(-)
via f7a4118c87ae1df4a42efdad3695e6fcb5d60854 (commit)
from b80db2511622b7600fa7a03e7db4c5c82cf61d39 (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 f7a4118c87ae1df4a42efdad3695e6fcb5d60854
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Fri Jun 23 11:50:22 2023 -0400
15768: set up button filter, minor cleanup Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/src/components/multiselectToolbar/MultiselectToolbar.tsx b/src/components/multiselectToolbar/MultiselectToolbar.tsx
index 606c8ff2..d2796322 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -2,25 +2,21 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import React, { ReactElement } from 'react';
+import React from 'react';
import { connect } from 'react-redux';
-import { StyleRulesCallback, withStyles, WithStyles, Toolbar, Button, Tooltip, IconButton } from '@material-ui/core';
+import { StyleRulesCallback, withStyles, WithStyles, Toolbar, Tooltip, IconButton } from '@material-ui/core';
import { ArvadosTheme } from 'common/custom-theme';
import { RootState } from 'store/store';
import { Dispatch } from 'redux';
-import { CopyToClipboardSnackbar } from 'components/copy-to-clipboard-snackbar/copy-to-clipboard-snackbar';
import { TCheckedList } from 'components/data-table/data-table';
import { openRemoveProcessDialog, openRemoveManyProcessesDialog } from 'store/processes/processes-actions';
import { processResourceActionSet } from '../../views-components/context-menu/action-sets/process-resource-action-set';
import { ContextMenuResource } from 'store/context-menu/context-menu-actions';
-import { ResourceKind, extractUuidKind } from 'models/resource';
+import { extractUuidKind } from 'models/resource';
import { openMoveProcessDialog } from 'store/processes/process-move-actions';
import { openCopyProcessDialog, openCopyManyProcessesDialog } from 'store/processes/process-copy-actions';
import { getResource } from 'store/resources/resources';
-import { ResourceName } from 'views-components/data-explorer/renderers';
-import { ProcessResource } from 'models/process';
import { ResourcesState } from 'store/resources/resources';
-import { Resource } from 'models/resource';
import { getProcess } from 'store/processes/process';
import { CopyProcessDialog, CopyManyProcessesDialog } from 'views-components/dialog-forms/copy-process-dialog';
import { collectionActionSet } from 'views-components/context-menu/action-sets/collection-action-set';
@@ -49,59 +45,23 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
},
});
-// type MultiselectToolbarAction = {
-// name: string;
-// funcName: string;
-// relevantKinds: Set<ResourceKind>;
-// };
-
-//gleaned from src/views-components/context-menu/action-sets
-// export const defaultActions: Array<MultiselectToolbarAction> = [
-// // {
-// // name: 'copy and re-run',
-// // funcName: 'copySelected',
-// // relevantKinds: new Set([ResourceKind.PROCESS]),
-// // },
-// {
-// name: 'copy',
-// funcName: 'copyCollections',
-// relevantKinds: new Set([ResourceKind.COLLECTION]),
-// },
-// {
-// name: 'move',
-// funcName: 'moveSelected',
-// relevantKinds: new Set([ResourceKind.PROCESS, ResourceKind.PROJECT]),
-// },
-// {
-// name: 'remove',
-// funcName: 'removeSelected',
-// relevantKinds: new Set([ResourceKind.PROCESS, ResourceKind.COLLECTION]),
-// },
-// {
-// name: 'favorite',
-// funcName: 'favoriteSelected',
-// relevantKinds: new Set([ResourceKind.PROCESS, ResourceKind.PROJECT, ResourceKind.COLLECTION]),
-// },
-// ];
-
export type MultiselectToolbarProps = {
- // actions: Array<MultiselectToolbarAction>;
isVisible: boolean;
checkedList: TCheckedList;
resources: ResourcesState;
- // copySelected: (checkedList: TCheckedList, resources: ResourcesState) => void;
- // copyCollections: (fn, resource: Resource) => void;
- // moveSelected: (resource) => void;
- // removeSelected: (checkedList: TCheckedList) => void;
executeMulti: (fn, checkedList: TCheckedList, resources: ResourcesState) => void;
};
-const CollectionMSActionsFilter = {
+const collectionMSActionsFilter = {
MAKE_A_COPY: 'Make a copy',
MOVE_TO: 'Move to',
TOGGLE_TRASH_ACTION: 'ToggleTrashAction',
};
+const multiselectActionsFilters = {
+ 'arvados#collection': [collectionActionSet, collectionMSActionsFilter],
+};
+
export const MultiselectToolbar = connect(
mapStateToProps,
mapDispatchToProps
@@ -110,25 +70,14 @@ export const MultiselectToolbar = connect(
const { classes, isVisible, checkedList, resources } = props;
const currentResourceKinds = Array.from(selectedToKindSet(checkedList));
- const buttons = filterActions(collectionActionSet, CollectionMSActionsFilter);
- console.log(selectedToArray(props.checkedList));
+ const buttons = selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
return (
- <Toolbar className={classes.root} style={{ width: `${buttons.length * 5.5}rem` }}>
+ <Toolbar className={classes.root} style={{ width: `${buttons.length * 3.5}rem` }}>
{buttons.length ? (
- buttons.map((btn) => (
- <Tooltip title={btn.name} disableFocusListener>
- <IconButton
- onClick={() =>
- props.executeMulti(
- btn.execute,
- checkedList,
- props.resources
- // getResource('tordo-4zz18-2dkyrfnrsjdda5v')(props.resources) as Resource
- )
- }
- >
- {/* {console.log(btn.component && btn.component)} */}
+ buttons.map((btn, i) => (
+ <Tooltip title={btn.name} key={i} disableFocusListener>
+ <IconButton onClick={() => props.executeMulti(btn.execute, checkedList, props.resources)}>
{btn.icon ? (
btn.icon({ className: 'foo' })
) : btn.name === 'ToggleTrashAction' ? (
@@ -172,6 +121,12 @@ function filterActions(actionArray: ContextMenuActionSet, filters: Record<string
return actionArray[0].filter((action) => Object.values(filters).includes(action.name as string));
}
+function selectActionsByKind(resourceKinds: Array<string>, filterSet: any) {
+ const result: Array<ContextMenuAction> = [];
+ resourceKinds.forEach((kind) => result.push(...filterActions(filterSet[kind][0], filterSet[kind][1])));
+ return result;
+}
+
//--------------------------------------------------//
function mapStateToProps(state: RootState) {
@@ -185,10 +140,6 @@ function mapStateToProps(state: RootState) {
function mapDispatchToProps(dispatch: Dispatch) {
return {
- // copySelected: (checkedList: TCheckedList, resources: ResourcesState) => copyMoveMany(dispatch, checkedList),
- // copyCollections: (fn, resource) => fn(dispatch, resource),
- // moveSelected: (checkedList: TCheckedList) => {},
- // removeSelected: (checkedList: TCheckedList) => removeMultiProcesses(dispatch, checkedList),
executeMulti: (fn, checkedList: TCheckedList, resources: ResourcesState) =>
selectedToArray(checkedList).forEach((uuid) => {
console.log(uuid);
@@ -196,23 +147,3 @@ function mapDispatchToProps(dispatch: Dispatch) {
}),
};
}
-
-// function copyMoveMany(dispatch: Dispatch, checkedList: TCheckedList) {
-// const selectedList: Array<string> = selectedToArray(checkedList);
-// const uuid = selectedList[0];
-// dispatch<any>(openCopyManyProcessesDialog(selectedList));
-// }
-
-// const RemoveFunctions = {
-// ONE_PROCESS: (uuid: string) => openRemoveProcessDialog(uuid),
-// MANY_PROCESSES: (list: Array<string>) => openRemoveManyProcessesDialog(list),
-// };
-
-// function removeMultiProcesses(dispatch: Dispatch, checkedList: TCheckedList): void {
-// const selectedList: Array<string> = selectedToArray(checkedList);
-// dispatch<any>(
-// selectedList.length === 1
-// ? RemoveFunctions.ONE_PROCESS(selectedList[0])
-// : RemoveFunctions.MANY_PROCESSES(selectedList)
-// );
-// }
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list