[arvados-workbench2] updated: 2.6.0-50-g76fe6edc
git repository hosting
git at public.arvados.org
Sat Jul 1 23:09:26 UTC 2023
Summary of changes:
.../multiselectToolbar/MultiselectToolbar.tsx | 95 +++++++++++++++-------
.../ms-kind-action-differentiator.ts | 21 +++++
.../ms-toolbar-action-filters.ts | 26 +++++-
3 files changed, 109 insertions(+), 33 deletions(-)
create mode 100644 src/components/multiselectToolbar/ms-kind-action-differentiator.ts
via 76fe6edc8d158f67c600f75c6bb351d7a679b71e (commit)
via 38da1ff0a3990e643cbfbd5fa548597a1618055a (commit)
via 171267ba19481f363e35332eb3a7fac3c63cbbcb (commit)
via 781c06ee0633709137ba3a4d305eb6e1db2a6dfb (commit)
from e9c6bbebe8d9a3e22d239a51b1a0fae575b3dacb (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 76fe6edc8d158f67c600f75c6bb351d7a679b71e
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Mon Jun 26 10:48:03 2023 -0400
15768: notations for algo revisions 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 e6b5d29f..3fc4e81d 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -121,9 +121,13 @@ function filterActions(actionArray: ContextMenuActionSet, filters: Array<string>
//this might be the least efficient algorithm I've ever written
function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMultiselectActionsFilters) {
const result: Array<ContextMenuAction> = [];
+ //start at currentResourceKinds
currentResourceKinds.forEach((kind) => {
+ //if there is a matching filter set
if (filterSet[kind]) {
+ //filter actions that apply to current kind
const actions = filterActions(...filterSet[kind]);
+ //if action name isn't in result, push name
actions.forEach((action) => {
if (!result.some((item) => item.name === action.name)) {
result.push(action);
@@ -131,6 +135,7 @@ function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMu
});
}
});
+ //return sorted array of actions
return result.sort((a, b) => {
a.name = a.name || '';
b.name = b.name || '';
commit 38da1ff0a3990e643cbfbd5fa548597a1618055a
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Sun Jun 25 16:47:22 2023 -0400
15768: ms toolbar now filters duplicate buttons 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 88fd23b8..e6b5d29f 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -52,7 +52,7 @@ export type MultiselectToolbarProps = {
isVisible: boolean;
checkedList: TCheckedList;
resources: ResourcesState;
- executeMulti: (fn, actionName: string, checkedList: TCheckedList, resources: ResourcesState) => void;
+ executeMulti: (action: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState) => void;
};
export const MultiselectToolbar = connect(
@@ -71,31 +71,13 @@ export const MultiselectToolbar = connect(
buttons.map((btn, i) =>
btn.name === 'ToggleTrashAction' ? (
<Tooltip className={classes.button} title={'Move to trash'} key={i} disableFocusListener>
- <IconButton
- onClick={() =>
- props.executeMulti(
- btn.execute,
- btn.name as string,
- checkedList,
- props.resources
- )
- }
- >
+ <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
<TrashIcon />
</IconButton>
</Tooltip>
) : (
<Tooltip className={classes.button} title={btn.name} key={i} disableFocusListener>
- <IconButton
- onClick={() =>
- props.executeMulti(
- btn.execute,
- btn.name as string,
- checkedList,
- props.resources
- )
- }
- >
+ <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
{btn.icon ? btn.icon({}) : <></>}
</IconButton>
</Tooltip>
@@ -131,17 +113,35 @@ function selectedToKindSet(checkedList: TCheckedList): Set<string> {
}
//num of currentResourceKinds * num of actions (in ContextMenuActionSet) * num of filters
-//worst case: 14 * x * x -oof
+//worst case: 14 * n * n -oof
function filterActions(actionArray: ContextMenuActionSet, filters: Array<string>): Array<ContextMenuAction> {
return actionArray[0].filter((action) => filters.includes(action.name as string));
}
+//this might be the least efficient algorithm I've ever written
function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMultiselectActionsFilters) {
const result: Array<ContextMenuAction> = [];
currentResourceKinds.forEach((kind) => {
- if (filterSet[kind]) result.push(...filterActions(...filterSet[kind]));
+ if (filterSet[kind]) {
+ const actions = filterActions(...filterSet[kind]);
+ actions.forEach((action) => {
+ if (!result.some((item) => item.name === action.name)) {
+ result.push(action);
+ }
+ });
+ }
+ });
+ return result.sort((a, b) => {
+ a.name = a.name || '';
+ b.name = b.name || '';
+ if (a.name < b.name) {
+ return -1;
+ }
+ if (a.name > b.name) {
+ return 1;
+ }
+ return 0;
});
- return result;
}
//--------------------------------------------------//
@@ -157,16 +157,16 @@ function mapStateToProps(state: RootState) {
function mapDispatchToProps(dispatch: Dispatch) {
return {
- executeMulti: (fn, actionName: string, checkedList: TCheckedList, resources: ResourcesState) => {
+ executeMulti: (action: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState) => {
selectedToArray(checkedList).forEach((uuid) => {
const resource = getResource(uuid)(resources);
- resource ? executeSpecific(dispatch, actionName, resource) : fn(dispatch, resource);
+ executeSpecific(dispatch, action.name, resource);
});
},
};
}
-function executeSpecific(dispatch: Dispatch, actionName: string, resource) {
+function executeSpecific(dispatch: Dispatch, actionName, resource) {
const actionSet = kindToActionSet[resource.kind];
const action = findActionByName(actionName, actionSet);
if (action) action.execute(dispatch, resource);
commit 171267ba19481f363e35332eb3a7fac3c63cbbcb
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Sun Jun 25 16:01:05 2023 -0400
15768: different resource kinds can now do the same operation with the same button 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 98144a54..88fd23b8 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -12,7 +12,7 @@ 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 { extractUuidKind } from 'models/resource';
+import { Resource, 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';
@@ -22,7 +22,12 @@ import { CopyProcessDialog, CopyManyProcessesDialog } from 'views-components/dia
import { collectionActionSet } from 'views-components/context-menu/action-sets/collection-action-set';
import { ContextMenuAction, ContextMenuActionSet } from 'views-components/context-menu/context-menu-action-set';
import { TrashIcon } from 'components/icon/icon';
-import { multiselectActionsFilters, TMultiselectActionsFilters } from './ms-toolbar-action-filters';
+import {
+ multiselectActionsFilters,
+ TMultiselectActionsFilters,
+ contextMenuActionConsts,
+} from './ms-toolbar-action-filters';
+import { kindToActionSet, findActionByName } from './ms-kind-action-differentiator';
type CssRules = 'root' | 'button';
@@ -47,7 +52,7 @@ export type MultiselectToolbarProps = {
isVisible: boolean;
checkedList: TCheckedList;
resources: ResourcesState;
- executeMulti: (fn, checkedList: TCheckedList, resources: ResourcesState) => void;
+ executeMulti: (fn, actionName: string, checkedList: TCheckedList, resources: ResourcesState) => void;
};
export const MultiselectToolbar = connect(
@@ -67,7 +72,14 @@ export const MultiselectToolbar = connect(
btn.name === 'ToggleTrashAction' ? (
<Tooltip className={classes.button} title={'Move to trash'} key={i} disableFocusListener>
<IconButton
- onClick={() => props.executeMulti(btn.execute, checkedList, props.resources)}
+ onClick={() =>
+ props.executeMulti(
+ btn.execute,
+ btn.name as string,
+ checkedList,
+ props.resources
+ )
+ }
>
<TrashIcon />
</IconButton>
@@ -75,9 +87,16 @@ export const MultiselectToolbar = connect(
) : (
<Tooltip className={classes.button} title={btn.name} key={i} disableFocusListener>
<IconButton
- onClick={() => props.executeMulti(btn.execute, checkedList, props.resources)}
+ onClick={() =>
+ props.executeMulti(
+ btn.execute,
+ btn.name as string,
+ checkedList,
+ props.resources
+ )
+ }
>
- {btn.icon ? btn.icon({}) : <>error</>}
+ {btn.icon ? btn.icon({}) : <></>}
</IconButton>
</Tooltip>
)
@@ -138,9 +157,17 @@ function mapStateToProps(state: RootState) {
function mapDispatchToProps(dispatch: Dispatch) {
return {
- executeMulti: (fn, checkedList: TCheckedList, resources: ResourcesState) =>
+ executeMulti: (fn, actionName: string, checkedList: TCheckedList, resources: ResourcesState) => {
selectedToArray(checkedList).forEach((uuid) => {
- fn(dispatch, getResource(uuid)(resources));
- }),
+ const resource = getResource(uuid)(resources);
+ resource ? executeSpecific(dispatch, actionName, resource) : fn(dispatch, resource);
+ });
+ },
};
}
+
+function executeSpecific(dispatch: Dispatch, actionName: string, resource) {
+ const actionSet = kindToActionSet[resource.kind];
+ const action = findActionByName(actionName, actionSet);
+ if (action) action.execute(dispatch, resource);
+}
diff --git a/src/components/multiselectToolbar/ms-kind-action-differentiator.ts b/src/components/multiselectToolbar/ms-kind-action-differentiator.ts
new file mode 100644
index 00000000..609f273c
--- /dev/null
+++ b/src/components/multiselectToolbar/ms-kind-action-differentiator.ts
@@ -0,0 +1,21 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ResourceKind } from 'models/resource';
+import { ContextMenuActionSet } from 'views-components/context-menu/context-menu-action-set';
+import { collectionActionSet } from 'views-components/context-menu/action-sets/collection-action-set';
+import { projectActionSet } from 'views-components/context-menu/action-sets/project-action-set';
+import { processResourceActionSet } from 'views-components/context-menu/action-sets/process-resource-action-set';
+
+export function findActionByName(name: string, actionSet: ContextMenuActionSet) {
+ return actionSet[0].find((action) => action.name === name);
+}
+
+const { COLLECTION, PROJECT, PROCESS } = ResourceKind;
+
+export const kindToActionSet: Record<string, ContextMenuActionSet> = {
+ [COLLECTION]: collectionActionSet,
+ [PROJECT]: projectActionSet,
+ [PROCESS]: processResourceActionSet,
+};
commit 781c06ee0633709137ba3a4d305eb6e1db2a6dfb
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Sun Jun 25 13:50:34 2023 -0400
15768: Starting differentiation 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 e6e8c62e..98144a54 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -35,14 +35,11 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
margin: '1rem auto auto 0.5rem',
overflow: 'hidden',
transition: 'width 150ms',
+ borderBottom: '1px solid gray',
},
button: {
- backgroundColor: '#017ead',
- color: 'white',
- fontSize: '0.75rem',
- width: 'auto',
- margin: 'auto',
- padding: '1px',
+ width: '1rem',
+ margin: 'auto 5px',
},
});
@@ -64,21 +61,27 @@ export const MultiselectToolbar = connect(
const buttons = selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
return (
- <Toolbar className={classes.root} style={{ width: `${buttons.length * 3.5}rem` }}>
+ <Toolbar className={classes.root} style={{ width: `${buttons.length * 2.12}rem` }}>
{buttons.length ? (
- 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' ? (
+ buttons.map((btn, i) =>
+ btn.name === 'ToggleTrashAction' ? (
+ <Tooltip className={classes.button} title={'Move to trash'} key={i} disableFocusListener>
+ <IconButton
+ onClick={() => props.executeMulti(btn.execute, checkedList, props.resources)}
+ >
<TrashIcon />
- ) : (
- <>error</>
- )}
- </IconButton>
- </Tooltip>
- ))
+ </IconButton>
+ </Tooltip>
+ ) : (
+ <Tooltip className={classes.button} title={btn.name} key={i} disableFocusListener>
+ <IconButton
+ onClick={() => props.executeMulti(btn.execute, checkedList, props.resources)}
+ >
+ {btn.icon ? btn.icon({}) : <>error</>}
+ </IconButton>
+ </Tooltip>
+ )
+ )
) : (
<></>
)}
@@ -108,13 +111,15 @@ function selectedToKindSet(checkedList: TCheckedList): Set<string> {
return setifiedList;
}
+//num of currentResourceKinds * num of actions (in ContextMenuActionSet) * num of filters
+//worst case: 14 * x * x -oof
function filterActions(actionArray: ContextMenuActionSet, filters: Array<string>): Array<ContextMenuAction> {
return actionArray[0].filter((action) => filters.includes(action.name as string));
}
-function selectActionsByKind(resourceKinds: Array<string>, filterSet: TMultiselectActionsFilters) {
+function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMultiselectActionsFilters) {
const result: Array<ContextMenuAction> = [];
- resourceKinds.forEach((kind) => {
+ currentResourceKinds.forEach((kind) => {
if (filterSet[kind]) result.push(...filterActions(...filterSet[kind]));
});
return result;
diff --git a/src/components/multiselectToolbar/ms-toolbar-action-filters.ts b/src/components/multiselectToolbar/ms-toolbar-action-filters.ts
index 7d997496..1d8f24cc 100644
--- a/src/components/multiselectToolbar/ms-toolbar-action-filters.ts
+++ b/src/components/multiselectToolbar/ms-toolbar-action-filters.ts
@@ -2,16 +2,34 @@
//
// SPDX-License-Identifier: AGPL-3.0
+import { ResourceKind } from 'models/resource';
import { ContextMenuActionSet } from 'views-components/context-menu/context-menu-action-set';
import { collectionActionSet } from 'views-components/context-menu/action-sets/collection-action-set';
import { projectActionSet } from 'views-components/context-menu/action-sets/project-action-set';
+import { processResourceActionSet } from 'views-components/context-menu/action-sets/process-resource-action-set';
export type TMultiselectActionsFilters = Record<string, [ContextMenuActionSet, Array<string>]>;
-const collectionMSActionsFilter = ['Make a copy', 'Move to', 'ToggleTrashAction'];
-const projectMSActionsFilter = ['Copy to clipboard', 'Move to', 'ToggleTrashAction'];
+export const contextMenuActionConsts = {
+ MAKE_A_COPY: 'Make a copy',
+ MOVE_TO: 'Move to',
+ TOGGLE_TRASH_ACTION: 'ToggleTrashAction',
+ COPY_TO_CLIPBOARD: 'Copy to clipboard',
+ COPY_AND_RERUN_PROCESS: 'Copy and re-run process',
+ REMOVE: 'Remove',
+} as const;
+
+const { MAKE_A_COPY, MOVE_TO, TOGGLE_TRASH_ACTION, COPY_TO_CLIPBOARD, COPY_AND_RERUN_PROCESS, REMOVE } =
+ contextMenuActionConsts;
+
+const collectionMSActionsFilter = [MAKE_A_COPY, MOVE_TO, TOGGLE_TRASH_ACTION];
+const projectMSActionsFilter = [COPY_TO_CLIPBOARD, MOVE_TO, TOGGLE_TRASH_ACTION];
+const processResourceMSActionsFilter = [COPY_AND_RERUN_PROCESS, MOVE_TO, REMOVE];
+
+const { COLLECTION, PROJECT, PROCESS } = ResourceKind;
export const multiselectActionsFilters: TMultiselectActionsFilters = {
- 'arvados#collection': [collectionActionSet, collectionMSActionsFilter],
- 'arvados#group': [projectActionSet, projectMSActionsFilter],
+ [COLLECTION]: [collectionActionSet, collectionMSActionsFilter],
+ [PROJECT]: [projectActionSet, projectMSActionsFilter],
+ [PROCESS]: [processResourceActionSet, processResourceMSActionsFilter],
};
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list