export type MultiselectToolbarProps = {
checkedList: TCheckedList;
- singleSelectedUuid: string | null
- inputSelectedUuid?: string
+ selectedResource: string | null;
iconProps: IconProps
user: User | null
disabledButtons: Set<string>
mapDispatchToProps
)(
withStyles(styles)((props: MultiselectToolbarProps & WithStyles<CssRules>) => {
- 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);
currentPathIsTrash && selectedToKindSet(checkedList).size
? [msToggleTrashAction]
: selectActionsByKind(currentResourceKinds as string[], multiselectActionsFilters).filter((action) =>
- singleSelectedUuid === null ? action.isForMulti : true
+ selectedResource === null ? action.isForMulti : true
);
return (
<Tooltip
className={classes.button}
data-targetid={name}
- title={currentPathIsTrash || (useAlts && useAlts(singleSelectedUuid, iconProps)) ? altName : name}
+ title={currentPathIsTrash || (useAlts && useAlts(selectedResource, iconProps)) ? altName : name}
key={i}
disableFocusListener
>
<IconButton
data-cy='multiselect-button'
disabled={disabledButtons.has(name)}
- onClick={() => 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({})}
</IconButton>
</span>
</Tooltip>
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({})}
//--------------------------------------------------//
-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<string>(multiselect.disabledButtons),
auth,
+ selectedResource,
iconProps: {
resources,
favorites,
//
// SPDX-License-Identifier: AGPL-3.0
-import React from 'react';
+import React, { useEffect } from 'react';
import { StyleRulesCallback, WithStyles, withStyles, Grid, LinearProgress } from '@material-ui/core';
import { User } from "models/user";
import { ArvadosTheme } from 'common/custom-theme';
sidePanelIsCollapsed: boolean;
isTransitioning: boolean;
currentSideWidth: number;
+ currentRoute: string;
}
interface MainPanelRootDispatchProps {
- toggleSidePanel: () => void
+ toggleSidePanel: () => void,
+ setCurrentRouteUuid: (uuid: string) => void;
}
type MainPanelRootProps = MainPanelRootDataProps & MainPanelRootDispatchProps & WithStyles<CssRules>;
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
? <WorkbenchLoadingScreen />
: <>
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 {
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 : '',
};
};
return {
toggleSidePanel: (collapsedState)=>{
return dispatch(toggleSidePanel(collapsedState))
- }
+ },
+ setCurrentRouteUuid: (uuid: string) => {
+ return dispatch(propertiesActions.SET_PROPERTY({key: 'currentRouteUuid', value: uuid}))}
}
};