X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/953fa9de6f70c1de6e875d86b47d5bf3ac40830c..bead3b2896eaaceb9b9a3c805d40e8048c93b218:/src/components/multiselect-toolbar/MultiselectToolbar.tsx?ds=sidebyside

diff --git a/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index 1256c541..72d375ff 100644
--- a/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -31,7 +31,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         width: 0,
         padding: 0,
         margin: "1rem auto auto 0.5rem",
-        overflow: "hidden",
+        overflowY: 'scroll',
         transition: "width 150ms",
     },
     button: {
@@ -43,25 +43,30 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 export type MultiselectToolbarProps = {
     checkedList: TCheckedList;
     selectedUuid: string | null
-    resources: ResourcesState;
+    iconProps: IconProps
     executeMulti: (action: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState) => void;
-    favorites: FavoritesState
 };
 
+type IconProps = {
+    resources: ResourcesState;
+    favorites: FavoritesState
+}
+
 export const MultiselectToolbar = connect(
     mapStateToProps,
     mapDispatchToProps
 )(
     withStyles(styles)((props: MultiselectToolbarProps & WithStyles<CssRules>) => {
-        const { classes, checkedList, resources, selectedUuid, favorites } = props;
+        const { classes, checkedList, selectedUuid: singleSelectedUuid, iconProps } = props;
         const currentResourceKinds = Array.from(selectedToKindSet(checkedList));
 
         const currentPathIsTrash = window.location.pathname === "/trash";
 
         const actions =
-            currentPathIsTrash && selectedToKindSet(checkedList).size 
-            ? [msToggleTrashAction] 
-            : selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
+            currentPathIsTrash && selectedToKindSet(checkedList).size
+                ? [msToggleTrashAction]
+                : selectActionsByKind(currentResourceKinds, multiselectActionsFilters)
+                .filter((action) => (singleSelectedUuid === null ? action.isForMulti : true));
 
         return (
             <React.Fragment>
@@ -71,15 +76,15 @@ export const MultiselectToolbar = connect(
                 >
                     {actions.length ? (
                         actions.map((action, i) =>
-                            action.isDefault ? (
+                            action.hasAlts ? (
                                 <Tooltip
                                     className={classes.button}
-                                    title={action.isDefault(selectedUuid, resources, favorites) ? action.name : action.altText}
+                                    title={currentPathIsTrash || action.useAlts(singleSelectedUuid, iconProps) ? action.altName : action.name}
                                     key={i}
                                     disableFocusListener
                                 >
-                                    <IconButton onClick={() => props.executeMulti(action, checkedList, resources)}>
-                                        {action.isDefault(selectedUuid, resources, favorites) ? action.icon({}) : action.altIcon && action.altIcon({})}
+                                    <IconButton onClick={() => props.executeMulti(action, checkedList, iconProps.resources)}>
+                                        {currentPathIsTrash || action.useAlts(singleSelectedUuid, iconProps) ? action.altIcon && action.altIcon({}) :  action.icon({})}
                                     </IconButton>
                                 </Tooltip>
                             ) : (
@@ -89,7 +94,7 @@ export const MultiselectToolbar = connect(
                                     key={i}
                                     disableFocusListener
                                 >
-                                    <IconButton onClick={() => props.executeMulti(action, checkedList, resources)}>{action.icon({})}</IconButton>
+                                    <IconButton onClick={() => props.executeMulti(action, checkedList, iconProps.resources)}>{action.icon({})}</IconButton>
                                 </Tooltip>
                             )
                         )
@@ -179,7 +184,7 @@ function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMu
     });
 }
 
-const isExactlyOneSelected = (checkedList: TCheckedList) => {
+export const isExactlyOneSelected = (checkedList: TCheckedList) => {
     let tally = 0;
     let current = '';
     for (const uuid in checkedList) {
@@ -193,13 +198,15 @@ const isExactlyOneSelected = (checkedList: TCheckedList) => {
 
 //--------------------------------------------------//
 
-function mapStateToProps(state: RootState) {
+function mapStateToProps({multiselect, resources, favorites}: RootState) {
     return {
-        checkedList: state.multiselect.checkedList as TCheckedList,
-        selectedUuid: isExactlyOneSelected(state.multiselect.checkedList),
-        resources: state.resources,
-        favorites: state.favorites
-    };
+        checkedList: multiselect.checkedList as TCheckedList,
+        selectedUuid: isExactlyOneSelected(multiselect.checkedList),
+        iconProps: {
+            resources,
+            favorites
+        }
+    }
 }
 
 function mapDispatchToProps(dispatch: Dispatch) {
