X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e2041e819042f1051fc026aaee2c73823824fc56..31f0010ed0833ff91600cd8ce31d4df1847882cc:/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx diff --git a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx index 5b39e925bf..194950b134 100644 --- a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx +++ b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import React, { useEffect, useState } from "react"; +import React from "react"; import { connect } from "react-redux"; import { StyleRulesCallback, withStyles, WithStyles, Toolbar, Tooltip, IconButton } from "@material-ui/core"; import { ArvadosTheme } from "common/custom-theme"; @@ -34,12 +34,9 @@ import { Process } from "store/processes/process"; import { PublicFavoritesState } from "store/public-favorites/public-favorites-reducer"; import { isExactlyOneSelected } from "store/multiselect/multiselect-actions"; import { IntersectionObserverWrapper } from "./ms-toolbar-overflow-wrapper"; -import { ContextMenuKind, sortMenuItems } from 'views-components/context-menu/menu-item-sort'; -import { sortByProperty } from "common/array-utils"; +import { ContextMenuKind, sortMenuItems, menuDirection } from 'views-components/context-menu/menu-item-sort'; -const WIDTH_TRANSITION = 150 - -type CssRules = "root" | "transition" | "button" | "iconContainer" | "icon"; +type CssRules = "root" | "button" | "iconContainer" | "icon" | "divider"; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { @@ -49,17 +46,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ height: '2.7rem', padding: 0, margin: "1rem auto auto 0.3rem", - transition: `width ${WIDTH_TRANSITION}ms`, - overflow: 'hidden', - }, - transition: { - display: "flex", - flexDirection: "row", - height: '2.7rem', - padding: 0, - margin: "1rem auto auto 0.3rem", overflow: 'hidden', - transition: `width ${WIDTH_TRANSITION}ms`, }, button: { width: "2.5rem", @@ -72,7 +59,11 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, icon: { marginLeft: '-0.5rem', - } + }, + divider: { + display: "flex", + alignItems: "center", + }, }); export type MultiselectToolbarProps = { @@ -97,21 +88,8 @@ export const MultiselectToolbar = connect( withStyles(styles)((props: MultiselectToolbarProps & WithStyles) => { const { classes, checkedList, singleSelectedUuid, iconProps, user, disabledButtons } = props; const singleResourceKind = singleSelectedUuid ? [resourceToMsResourceKind(singleSelectedUuid, iconProps.resources, user)] : null - console.log(singleResourceKind) const currentResourceKinds = singleResourceKind ? singleResourceKind : Array.from(selectedToKindSet(checkedList)); const currentPathIsTrash = window.location.pathname === "/trash"; - const [isTransitioning, setIsTransitioning] = useState(false); - - const handleTransition = () => { - setIsTransitioning(true) - setTimeout(() => { - setIsTransitioning(false) - }, WIDTH_TRANSITION); - } - - useEffect(()=>{ - handleTransition() - }, [checkedList]) const rawActions = currentPathIsTrash && selectedToKindSet(checkedList).size @@ -120,13 +98,16 @@ export const MultiselectToolbar = connect( singleSelectedUuid === null ? action.isForMulti : true ); - const actions = - singleResourceKind && singleResourceKind.length ? sortMenuItems(singleResourceKind[0] as ContextMenuKind, rawActions) : rawActions.sort(sortByProperty('name')); + const actions: ContextMenuAction[] | MultiSelectMenuAction[] = sortMenuItems( + singleResourceKind && singleResourceKind.length ? (singleResourceKind[0] as ContextMenuKind) : ContextMenuKind.MULTI, + rawActions, + menuDirection.HORIZONTAL + ); return ( @@ -134,14 +115,24 @@ export const MultiselectToolbar = connect( {actions.map((action, i) =>{ const { hasAlts, useAlts, name, altName, icon, altIcon } = action; - return hasAlts ? ( + return action.name === ContextMenuActionNames.DIVIDER ? ( + action.component && ( +
+ +
+ ) + ) : hasAlts ? ( + > + > getResource(uuid)(resources)); dispatch(copyToClipboardAction(selectedResources)); break;