From: Lisa Knox Date: Fri, 15 Mar 2024 15:12:16 +0000 (-0400) Subject: 21224: created global current uuid property in store state Arvados-DCO-1.1-Signed... X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/92a147d8e4fd5b02264c06ec432255777cb942c7 21224: created global current uuid property in store state Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- diff --git a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx index 36b8199f30..7e462512f7 100644 --- a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx +++ b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx @@ -77,8 +77,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ export type MultiselectToolbarProps = { checkedList: TCheckedList; - singleSelectedUuid: string | null - inputSelectedUuid?: string + selectedResource: string | null; iconProps: IconProps user: User | null disabledButtons: Set @@ -97,9 +96,8 @@ export const MultiselectToolbar = connect( mapDispatchToProps )( withStyles(styles)((props: MultiselectToolbarProps & WithStyles) => { - const { classes, checkedList, inputSelectedUuid, iconProps, user, disabledButtons } = props; - const singleSelectedUuid = inputSelectedUuid ?? props.singleSelectedUuid - const singleResourceKind = singleSelectedUuid ? [resourceToMsResourceKind(singleSelectedUuid, iconProps.resources, user)] : null + const { classes, checkedList, iconProps, user, disabledButtons, selectedResource } = props; + const singleResourceKind = selectedResource ? [resourceToMsResourceKind(selectedResource, iconProps.resources, user)] : null const currentResourceKinds = singleResourceKind ? singleResourceKind : Array.from(selectedToKindSet(checkedList)); const currentPathIsTrash = window.location.pathname === "/trash"; const [isTransitioning, setIsTransitioning] = useState(false); @@ -124,7 +122,7 @@ export const MultiselectToolbar = connect( currentPathIsTrash && selectedToKindSet(checkedList).size ? [msToggleTrashAction] : selectActionsByKind(currentResourceKinds as string[], multiselectActionsFilters).filter((action) => - singleSelectedUuid === null ? action.isForMulti : true + selectedResource === null ? action.isForMulti : true ); return ( @@ -142,7 +140,7 @@ export const MultiselectToolbar = connect( @@ -150,10 +148,10 @@ export const MultiselectToolbar = connect( props.executeMulti(action, singleSelectedUuid, checkedList, iconProps.resources)} + onClick={() => props.executeMulti(action, selectedResource, checkedList, iconProps.resources)} className={classes.icon} > - {currentPathIsTrash || (useAlts && useAlts(singleSelectedUuid, iconProps)) ? altIcon && altIcon({}) : icon({})} + {currentPathIsTrash || (useAlts && useAlts(selectedResource, iconProps)) ? altIcon && altIcon({}) : icon({})} @@ -170,7 +168,7 @@ export const MultiselectToolbar = connect( data-cy='multiselect-button' onClick={() => { console.log('executing action', action.name, 'with checkedList', checkedList, 'and iconProps', iconProps.resources) - props.executeMulti(action, singleSelectedUuid, checkedList, iconProps.resources)}} + props.executeMulti(action, selectedResource, checkedList, iconProps.resources)}} className={classes.icon} > {action.icon({})} @@ -330,13 +328,13 @@ function selectActionsByKind(currentResourceKinds: Array, filterSet: TMu //--------------------------------------------------// -function mapStateToProps({auth, multiselect, resources, favorites, publicFavorites}: RootState) { +function mapStateToProps({auth, multiselect, resources, favorites, publicFavorites, selectedResource}: RootState) { return { checkedList: multiselect.checkedList as TCheckedList, - singleSelectedUuid: isExactlyOneSelected(multiselect.checkedList), user: auth && auth.user ? auth.user : null, disabledButtons: new Set(multiselect.disabledButtons), auth, + selectedResource, iconProps: { resources, favorites, diff --git a/services/workbench2/src/views-components/project-details-card/project-details-card.tsx b/services/workbench2/src/views-components/project-details-card/project-details-card.tsx index 063ea77cd9..0988d7c168 100644 --- a/services/workbench2/src/views-components/project-details-card/project-details-card.tsx +++ b/services/workbench2/src/views-components/project-details-card/project-details-card.tsx @@ -338,7 +338,7 @@ const ProjectCard: React.FC = ({ classes, currentResource, fro } action={ - + //
// void + toggleSidePanel: () => void, + setCurrentRouteUuid: (uuid: string) => void; } type MainPanelRootProps = MainPanelRootDataProps & MainPanelRootDispatchProps & WithStyles; @@ -46,7 +48,14 @@ type MainPanelRootProps = MainPanelRootDataProps & MainPanelRootDispatchProps & export const MainPanelRoot = withStyles(styles)( ({ classes, loading, working, user, buildInfo, uuidPrefix, isNotLinking, isLinkingPath, siteBanner, sessionIdleTimeout, - sidePanelIsCollapsed, isTransitioning, currentSideWidth}: MainPanelRootProps) =>{ + sidePanelIsCollapsed, isTransitioning, currentSideWidth, currentRoute, setCurrentRouteUuid}: MainPanelRootProps) =>{ + + useEffect(() => { + const splitRoute = currentRoute.split('/'); + const uuid = splitRoute[splitRoute.length - 1]; + setCurrentRouteUuid(uuid); + }, [currentRoute]); + return loading ? : <> diff --git a/services/workbench2/src/views/main-panel/main-panel.tsx b/services/workbench2/src/views/main-panel/main-panel.tsx index 264390a8b3..556ce0d75c 100644 --- a/services/workbench2/src/views/main-panel/main-panel.tsx +++ b/services/workbench2/src/views/main-panel/main-panel.tsx @@ -11,6 +11,7 @@ import { isWorkbenchLoading } from 'store/workbench/workbench-actions'; import { LinkAccountPanelStatus } from 'store/link-account-panel/link-account-panel-reducer'; import { matchLinkAccountRoute } from 'routes/routes'; import { toggleSidePanel } from "store/side-panel/side-panel-action"; +import { propertiesActions } from 'store/properties/properties-actions'; const mapStateToProps = (state: RootState): MainPanelRootDataProps => { return { @@ -25,7 +26,8 @@ const mapStateToProps = (state: RootState): MainPanelRootDataProps => { sessionIdleTimeout: parse(state.auth.config.clusterConfig.Workbench.IdleTimeout, 's') || 0, sidePanelIsCollapsed: state.sidePanel.collapsedState, isTransitioning: state.detailsPanel.isTransitioning, - currentSideWidth: state.sidePanel.currentSideWidth + currentSideWidth: state.sidePanel.currentSideWidth, + currentRoute: state.router.location ? state.router.location.pathname : '', }; }; @@ -33,7 +35,9 @@ const mapDispatchToProps = (dispatch) => { return { toggleSidePanel: (collapsedState)=>{ return dispatch(toggleSidePanel(collapsedState)) - } + }, + setCurrentRouteUuid: (uuid: string) => { + return dispatch(propertiesActions.SET_PROPERTY({key: 'currentRouteUuid', value: uuid}))} } };