X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2a7fd99c212c33a1ec9911f8529fa5afc59a7bb2..3612a36e473bf1599180a9b3b90b03ca0aaafb45:/src/components/multiselect-toolbar/MultiselectToolbar.tsx

diff --git a/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index 22a9c7139c..3d8ae0c3d3 100644
--- a/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -17,8 +17,9 @@ import { ContextMenuAction, ContextMenuActionSet } from "views-components/contex
 import { RestoreFromTrashIcon, TrashIcon } from "components/icon/icon";
 import { multiselectActionsFilters, TMultiselectActionsFilters, contextMenuActionConsts } from "./ms-toolbar-action-filters";
 import { kindToActionSet, findActionByName } from "./ms-kind-action-differentiator";
-import { toggleTrashAction } from "views-components/context-menu/action-sets/project-action-set";
+import { msToggleTrashAction } from "views-components/multiselect-toolbar/ms-project-action-set";
 import { copyToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions";
+import { ContainerRequestResource } from "models/container-request";
 
 type CssRules = "root" | "button";
 
@@ -33,13 +34,12 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         transition: "width 150ms",
     },
     button: {
-        width: "1rem",
-        margin: "auto 5px",
+        width: "2.5rem",
+        height: "2.5rem ",
     },
 });
 
 export type MultiselectToolbarProps = {
-    isVisible: boolean;
     checkedList: TCheckedList;
     resources: ResourcesState;
     executeMulti: (action: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState) => void;
@@ -56,41 +56,46 @@ export const MultiselectToolbar = connect(
         const currentPathIsTrash = window.location.pathname === "/trash";
         const buttons =
             currentPathIsTrash && selectedToKindSet(checkedList).size
-                ? [toggleTrashAction]
+                ? [msToggleTrashAction]
                 : selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
 
         return (
-            <Toolbar
-                className={classes.root}
-                style={{ width: `${buttons.length * 2.12}rem` }}>
-                {buttons.length ? (
-                    buttons.map((btn, i) =>
-                        btn.name === "ToggleTrashAction" ? (
-                            <Tooltip
-                                className={classes.button}
-                                title={currentPathIsTrash ? "Restore selected" : "Move to trash"}
-                                key={i}
-                                disableFocusListener>
-                                <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
-                                    {currentPathIsTrash ? <RestoreFromTrashIcon /> : <TrashIcon />}
-                                </IconButton>
-                            </Tooltip>
-                        ) : (
-                            <Tooltip
-                                className={classes.button}
-                                title={btn.name}
-                                key={i}
-                                disableFocusListener>
-                                <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
-                                    {btn.icon ? btn.icon({}) : <></>}
-                                </IconButton>
-                            </Tooltip>
+            <React.Fragment>
+                <Toolbar
+                    className={classes.root}
+                    style={{ width: `${buttons.length * 2.5}rem` }}
+                >
+                    {buttons.length ? (
+                        buttons.map((btn, i) =>
+                            btn.name === "ToggleTrashAction" ? (
+                                <Tooltip
+                                    className={classes.button}
+                                    title={currentPathIsTrash ? "Restore selected" : "Move to trash"}
+                                    key={i}
+                                    disableFocusListener
+                                >
+                                    <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
+                                        {currentPathIsTrash ? <RestoreFromTrashIcon /> : <TrashIcon />}
+                                    </IconButton>
+                                </Tooltip>
+                            ) : (
+                                <Tooltip
+                                    className={classes.button}
+                                    title={btn.name}
+                                    key={i}
+                                    disableFocusListener
+                                >
+                                    <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
+                                        {btn.icon ? btn.icon({}) : <></>}
+                                    </IconButton>
+                                </Tooltip>
+                            )
                         )
-                    )
-                ) : (
-                    <></>
-                )}
-            </Toolbar>
+                    ) : (
+                        <></>
+                    )}
+                </Toolbar>
+            </React.Fragment>
         );
     })
 );
@@ -118,7 +123,7 @@ export function selectedToKindSet(checkedList: TCheckedList): Set<string> {
 function groupByKind(checkedList: TCheckedList, resources: ResourcesState): Record<string, ContextMenuResource[]> {
     const result = {};
     selectedToArray(checkedList).forEach(uuid => {
-        const resource = getResource(uuid)(resources) as Resource;
+        const resource = getResource(uuid)(resources) as ContainerRequestResource | Resource;
         if (!result[resource.kind]) result[resource.kind] = [];
         result[resource.kind].push(resource);
     });
@@ -175,10 +180,8 @@ function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMu
 //--------------------------------------------------//
 
 function mapStateToProps(state: RootState) {
-    const { isVisible, checkedList } = state.multiselect;
     return {
-        isVisible: isVisible,
-        checkedList: checkedList as TCheckedList,
+        checkedList: state.multiselect.checkedList as TCheckedList,
         resources: state.resources,
     };
 }
@@ -189,7 +192,8 @@ function mapDispatchToProps(dispatch: Dispatch) {
             const kindGroups = groupByKind(checkedList, resources);
             switch (selectedAction.name) {
                 case contextMenuActionConsts.MOVE_TO:
-                    const firstResource = getResource(selectedToArray(checkedList)[0])(resources) as Resource;
+                case contextMenuActionConsts.REMOVE:
+                    const firstResource = getResource(selectedToArray(checkedList)[0])(resources) as ContainerRequestResource | Resource;
                     const action = findActionByName(selectedAction.name as string, kindToActionSet[firstResource.kind]);
                     if (action) action.execute(dispatch, kindGroups[firstResource.kind]);
                     break;
