X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ba0c5cf6838e36740881c4dd9639043b527bf82d..1d5fd6f8997bb6f06c8ed62dc01905566cbe135e:/src/components/multiselect-toolbar/MultiselectToolbar.tsx

diff --git a/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index db5739e978..a8a3f7a823 100644
--- a/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -13,12 +13,13 @@ import { ContextMenuResource } from "store/context-menu/context-menu-actions";
 import { Resource, extractUuidKind } from "models/resource";
 import { getResource } from "store/resources/resources";
 import { ResourcesState } from "store/resources/resources";
-import { ContextMenuAction, ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { ContextMenuAction, ContextMenuActionSet, DynamicContextMenuAction } from "views-components/context-menu/context-menu-action-set";
 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 { 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,8 +34,8 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         transition: "width 150ms",
     },
     button: {
-        width: "1rem",
-        margin: "auto 5px",
+        width: "2.5rem",
+        height: "2.5rem ",
     },
 });
 
@@ -62,15 +63,17 @@ export const MultiselectToolbar = connect(
             <React.Fragment>
                 <Toolbar
                     className={classes.root}
-                    style={{ width: `${buttons.length * 2.12}rem` }}>
+                    style={{ width: `${buttons.length * 2.5}rem` }}
+                >
                     {buttons.length ? (
                         buttons.map((btn, i) =>
-                            btn.name === "ToggleTrashAction" ? (
+                            btn.defaultText ? (
                                 <Tooltip
                                     className={classes.button}
-                                    title={currentPathIsTrash ? "Restore selected" : "Move to trash"}
+                                    title={!currentPathIsTrash ? btn.defaultText: btn.altText}
                                     key={i}
-                                    disableFocusListener>
+                                    disableFocusListener
+                                >
                                     <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
                                         {currentPathIsTrash ? <RestoreFromTrashIcon /> : <TrashIcon />}
                                     </IconButton>
@@ -80,10 +83,9 @@ export const MultiselectToolbar = connect(
                                     className={classes.button}
                                     title={btn.name}
                                     key={i}
-                                    disableFocusListener>
-                                    <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
-                                        {btn.icon ? btn.icon({}) : <></>}
-                                    </IconButton>
+                                    disableFocusListener
+                                >
+                                    <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>{btn.icon ? btn.icon({}) : <></>}</IconButton>
                                 </Tooltip>
                             )
                         )
@@ -92,7 +94,7 @@ export const MultiselectToolbar = connect(
                     )}
                 </Toolbar>
             </React.Fragment>
-        );
+        )
     })
 );
 
@@ -119,7 +121,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);
     });
@@ -131,9 +133,9 @@ function filterActions(actionArray: ContextMenuActionSet, filters: Set<string>):
 }
 
 function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMultiselectActionsFilters) {
-    const rawResult: Set<ContextMenuAction> = new Set();
+    const rawResult: Set<DynamicContextMenuAction> = new Set();
     const resultNames = new Set();
-    const allFiltersArray: ContextMenuAction[][] = [];
+    const allFiltersArray: DynamicContextMenuAction[][] = []
     currentResourceKinds.forEach(kind => {
         if (filterSet[kind]) {
             const actions = filterActions(...filterSet[kind]);
@@ -189,7 +191,7 @@ function mapDispatchToProps(dispatch: Dispatch) {
             switch (selectedAction.name) {
                 case contextMenuActionConsts.MOVE_TO:
                 case contextMenuActionConsts.REMOVE:
-                    const firstResource = getResource(selectedToArray(checkedList)[0])(resources) as Resource;
+                    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;
