[arvados-workbench2] updated: 2.7.0-199-g64677607
git repository hosting
git at public.arvados.org
Tue Nov 14 21:00:19 UTC 2023
Summary of changes:
.../multiselect-toolbar/MultiselectToolbar.tsx | 36 +++++++++++++++-------
.../multiselect-toolbar/ms-menu-action-set.ts | 3 +-
.../multiselect-toolbar/ms-project-action-set.ts | 11 +++++--
3 files changed, 36 insertions(+), 14 deletions(-)
via 64677607790ab4d196de3d848dbd411c731a2f7b (commit)
from 87c6fcfb9a3b4fc7db82549c51c81393e9737b4a (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 64677607790ab4d196de3d848dbd411c731a2f7b
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Tue Nov 14 15:59:54 2023 -0500
21128: icon toggles in place Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index 185f8e0f..2d9f3c44 100644
--- a/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -41,8 +41,10 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
export type MultiselectToolbarProps = {
checkedList: TCheckedList;
+ selectedUuid: string | null
resources: ResourcesState;
executeMulti: (action: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState) => void;
+ favorites: any
};
export const MultiselectToolbar = connect(
@@ -50,15 +52,13 @@ export const MultiselectToolbar = connect(
mapDispatchToProps
)(
withStyles(styles)((props: MultiselectToolbarProps & WithStyles<CssRules>) => {
- const { classes, checkedList } = props;
+ const { classes, checkedList, resources, selectedUuid, favorites } = props;
const currentResourceKinds = Array.from(selectedToKindSet(checkedList));
- const currentPathIsTrash = window.location.pathname === "/trash";
- const buttons =
- currentPathIsTrash && selectedToKindSet(checkedList).size
- ? [msToggleTrashAction]
- : selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
+ const buttons = selectedToKindSet(checkedList).size
+ ? selectActionsByKind(currentResourceKinds, multiselectActionsFilters) : []
+console.log(buttons)
return (
<React.Fragment>
<Toolbar
@@ -67,15 +67,15 @@ export const MultiselectToolbar = connect(
>
{buttons.length ? (
buttons.map((btn, i) =>
- btn.defaultText ? (
+ btn.isDefault ? (
<Tooltip
className={classes.button}
- title={!currentPathIsTrash ? btn.defaultText : btn.altText}
+ title={btn.isDefault(selectedUuid, resources, favorites) ? btn.defaultText : btn.altText}
key={i}
disableFocusListener
>
- <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
- {!currentPathIsTrash ? btn.icon({}) : btn.altIcon({})}
+ <IconButton onClick={() => props.executeMulti(btn, checkedList, resources)}>
+ {btn.isDefault(selectedUuid, resources, favorites) ? btn.icon && btn.icon({}) : btn.altIcon && btn.altIcon({})}
</IconButton>
</Tooltip>
) : (
@@ -85,7 +85,7 @@ export const MultiselectToolbar = connect(
key={i}
disableFocusListener
>
- <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>{btn.icon ? btn.icon({}) : <></>}</IconButton>
+ <IconButton onClick={() => props.executeMulti(btn, checkedList, resources)}>{btn.icon ? btn.icon({}) : <></>}</IconButton>
</Tooltip>
)
)
@@ -175,12 +175,26 @@ function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMu
});
}
+const isExactlyOneSelected = (checkedList: TCheckedList) => {
+ let tally = 0;
+ let current = '';
+ for (const uuid in checkedList) {
+ if (checkedList[uuid] === true) {
+ tally++;
+ current = uuid;
+ }
+ }
+ return tally === 1 ? current : null
+};
+
//--------------------------------------------------//
function mapStateToProps(state: RootState) {
return {
checkedList: state.multiselect.checkedList as TCheckedList,
+ selectedUuid: isExactlyOneSelected(state.multiselect.checkedList),
resources: state.resources,
+ favorites: state.favorites
};
}
diff --git a/src/views-components/multiselect-toolbar/ms-menu-action-set.ts b/src/views-components/multiselect-toolbar/ms-menu-action-set.ts
index c34df023..1cc3c12e 100644
--- a/src/views-components/multiselect-toolbar/ms-menu-action-set.ts
+++ b/src/views-components/multiselect-toolbar/ms-menu-action-set.ts
@@ -4,6 +4,7 @@
import { IconType } from "components/icon/icon";
import { ContextMenuAction } from "../context-menu/context-menu-action-set";
+import { ResourcesState } from "store/resources/resources";
export const MultiSelectMenuActionNames = {
MAKE_A_COPY: "Make a copy",
@@ -19,7 +20,7 @@ export interface MultiSelectMenuAction extends ContextMenuAction {
defaultText?: string;
altText?: string;
altIcon?: IconType;
- isDefault?: () => boolean;
+ isDefault?: (uuid: string | null, resources: ResourcesState, favorites) => boolean;
}
export type MultiSelectMenuActionSet = Array<Array<MultiSelectMenuAction>>;
diff --git a/src/views-components/multiselect-toolbar/ms-project-action-set.ts b/src/views-components/multiselect-toolbar/ms-project-action-set.ts
index 61e89b1c..de328a7d 100644
--- a/src/views-components/multiselect-toolbar/ms-project-action-set.ts
+++ b/src/views-components/multiselect-toolbar/ms-project-action-set.ts
@@ -11,8 +11,9 @@ import { toggleFavorite } from "store/favorites/favorites-actions";
import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
import { AddFavoriteIcon, RemoveFavoriteIcon } from "components/icon/icon";
import { RestoreFromTrashIcon, TrashIcon } from "components/icon/icon";
-
-
+import { getResource } from "store/resources/resources";
+import { ContextMenuResource } from "store/context-menu/context-menu-actions";
+import { checkFavorite } from "store/favorites/favorites-reducer";
export const msToggleFavoriteAction = {
name: MultiSelectMenuActionNames.TOGGLE_FAVORITE_ACTION,
@@ -20,6 +21,9 @@ export const msToggleFavoriteAction = {
altText: 'Remove from Favorites',
icon: AddFavoriteIcon,
altIcon: RemoveFavoriteIcon,
+ isDefault: (uuid, resources, favorites)=>{
+ return !checkFavorite(uuid, favorites);
+ },
execute: (dispatch, resources) => {
dispatch(toggleFavorite(resources[0])).then(() => {
dispatch(favoritePanelActions.REQUEST_ITEMS());
@@ -49,6 +53,9 @@ export const msToggleTrashAction = {
altText: 'Restore from Trash',
icon: TrashIcon,
altIcon: RestoreFromTrashIcon,
+ isDefault: (uuid, resources, favorites = []) => {
+ return uuid ? !(getResource(uuid)(resources) as any).isTrashed : true;
+ },
execute: (dispatch, resources) => {
for (const resource of [...resources]) {
dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list