extractKey?: (item: T) => React.Key;
toggleMSToolbar: (isVisible: boolean) => void;
setCheckedListOnStore: (checkedList: TCheckedList) => void;
+ setSelectedUuid: (checkedList: TCheckedList) => void;
}
type DataExplorerProps<T> = DataExplorerDataProps<T> & DataExplorerActionProps<T> & WithStyles<CssRules> & MPVPanelProps;
toggleMSToolbar={toggleMSToolbar}
setCheckedListOnStore={setCheckedListOnStore}
checkedList={checkedList}
+ setSelectedUuid={this.props.setSelectedUuid}
/>
</Grid>
<Grid
import ArrowDownwardIcon from "@material-ui/icons/ArrowDownward";
import { createTree } from "models/tree";
import { DataTableMultiselectOption } from "../data-table-multiselect-popover/data-table-multiselect-popover";
+import { isExactlyOneSelected } from "store/multiselect/multiselect-actions";
export type DataColumns<I, R> = Array<DataColumn<I, R>>;
toggleMSToolbar: (isVisible: boolean) => void;
setCheckedListOnStore: (checkedList: TCheckedList) => void;
checkedList: TCheckedList;
+ setSelectedUuid: (checkedList: TCheckedList) => void;
}
type CssRules =
if (prevProps.currentRoute !== this.props.currentRoute) {
this.initializeCheckedList([])
}
+ if (isExactlyOneSelected(prevProps.checkedList) !== isExactlyOneSelected(this.props.checkedList)) {
+ this.props.setSelectedUuid(this.props.checkedList)
+ }
}
componentWillUnmount(): void {
import { OrderBuilder } from 'services/api/order-builder';
import { CollectionResource } from 'models/collection';
import { extractUuidKind, ResourceKind } from 'models/resource';
+import { CLOSE_DRAWER } from 'views-components/details-panel/details-panel';
export const SLIDE_TIMEOUT = 500;
};
export const toggleDetailsPanel = (uuid: string = '') => (dispatch: Dispatch, getState: () => RootState) => {
- const { detailsPanel, router }= getState()
- // because of material-ui issue resizing details panel breaks tabs.
- // triggering window resize event fixes that.
- if(uuid !== detailsPanel.resourceUuid && detailsPanel.isOpened){
+ const { detailsPanel }= getState()
+ const isTargetUuidNew = uuid !== detailsPanel.resourceUuid
+ if(isTargetUuidNew && uuid !== CLOSE_DRAWER && detailsPanel.isOpened){
dispatch<any>(loadDetailsPanel(uuid));
} else {
+ // because of material-ui issue resizing details panel breaks tabs.
+ // triggering window resize event fixes that.
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, SLIDE_TIMEOUT);
startDetailsPanelTransition(dispatch)
dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
if (getState().detailsPanel.isOpened) {
- dispatch<any>(loadDetailsPanel(getState().detailsPanel.resourceUuid));
+ dispatch<any>(loadDetailsPanel(isTargetUuidNew ? uuid : detailsPanel.resourceUuid));
}
}
};
import { multiselectActionConstants } from "./multiselect-actions";
import { TCheckedList } from "components/data-table/data-table";
-type MultiselectToolbarState = {
+export type MultiselectToolbarState = {
isVisible: boolean;
checkedList: TCheckedList;
selectedUuid: string;
import { DataColumns, TCheckedList } from "components/data-table/data-table";
import { DataTableFilters } from "components/data-table-filters/data-table-filters-tree";
import { LAST_REFRESH_TIMESTAMP } from "components/refresh-button/refresh-button";
-import { toggleMSToolbar, setCheckedListOnStore } from "store/multiselect/multiselect-actions";
+import { toggleMSToolbar, setCheckedListOnStore, setSelectedUuid, isExactlyOneSelected } from "store/multiselect/multiselect-actions";
+import { DetailsPanelState } from "store/details-panel/details-panel-reducer";
interface Props {
id: string;
extractKey?: (item: any) => React.Key;
}
+const getCurrentItemUuid = (
+ currentRoute: string,
+ workflowPanelDetailsUuid: string,
+ isDetailsResourceChecked: boolean,
+ isOnlyOneSelected: boolean,
+ detailsPanel: DetailsPanelState,
+ multiselectSelectedUuid: string
+) => {
+ if(currentRoute === '/workflows') {
+ return workflowPanelDetailsUuid;
+ }
+ if(isDetailsResourceChecked && isOnlyOneSelected) {
+ return detailsPanel.resourceUuid;
+ }
+ if(!detailsPanel.isOpened){
+ return multiselectSelectedUuid;
+ }
+ return detailsPanel.resourceUuid;
+};
+
const mapStateToProps = ({ progressIndicator, dataExplorer, router, multiselect, detailsPanel, properties}: RootState, { id }: Props) => {
const progress = progressIndicator.find(p => p.id === id);
const dataExplorerState = getDataExplorer(dataExplorer, id);
const currentRefresh = localStorage.getItem(LAST_REFRESH_TIMESTAMP) || "";
const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid]
const isOnlyOneSelected = Object.values(multiselect.checkedList).filter(x => x === true).length === 1;
- const currentItemUuid =
- currentRoute === '/workflows' ? properties.workflowPanelDetailsUuid : isDetailsResourceChecked && isOnlyOneSelected ? detailsPanel.resourceUuid : multiselect.selectedUuid;
+ const currentItemUuid = getCurrentItemUuid(currentRoute, properties.workflowPanelDetailsUuid, isDetailsResourceChecked, isOnlyOneSelected, detailsPanel, multiselect.selectedUuid);
const isMSToolbarVisible = multiselect.isVisible;
return {
...dataExplorerState,
dispatch<any>(setCheckedListOnStore(checkedList));
},
+ setSelectedUuid: (checkedList: TCheckedList) => {
+ dispatch<any>(setSelectedUuid(isExactlyOneSelected(checkedList)))
+ },
+
+
onRowClick,
onRowDoubleClick,
import { FileDetails } from 'views-components/details-panel/file-details';
import { getNode } from 'models/tree';
import { resourceIsFrozen } from 'common/frozen-resources';
+import { DetailsPanelState } from 'store/details-panel/details-panel-reducer';
+import { MultiselectToolbarState } from 'store/multiselect/multiselect-reducer';
type CssRules = 'root' | 'container' | 'opened' | 'headerContainer' | 'headerIcon' | 'tabContainer';
}
};
+const getCurrentItemUuid = (
+ isDetailsResourceChecked: boolean,
+ currentRoute: string,
+ detailsPanel: DetailsPanelState,
+ multiselect: MultiselectToolbarState,
+ currentRouteSplit: string[]
+) => {
+ if (isDetailsResourceChecked || currentRoute.includes('collections') || detailsPanel.isOpened) {
+ return detailsPanel.resourceUuid;
+ }
+ if (!!multiselect.selectedUuid) {
+ return multiselect.selectedUuid;
+ }
+ return currentRouteSplit[currentRouteSplit.length - 1];
+};
+
const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles, multiselect, router }: RootState) => {
- const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid]
+ const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid] === true;
const currentRoute = router.location ? router.location.pathname : "";
- const currentItemUuid = isDetailsResourceChecked || currentRoute.includes('collections') ? detailsPanel.resourceUuid : multiselect.selectedUuid ? multiselect.selectedUuid : currentRoute.split('/')[2];
+ const currentRouteSplit = currentRoute.split('/');
+ const currentItemUuid = getCurrentItemUuid(isDetailsResourceChecked, currentRoute, detailsPanel, multiselect, currentRouteSplit);
const resource = getResource(currentItemUuid)(resources) as DetailsResource | undefined;
const file = resource
? undefined
};
};
+export const CLOSE_DRAWER = 'CLOSE_DRAWER'
+
const mapDispatchToProps = (dispatch: Dispatch) => ({
onCloseDrawer: (currentItemId) => {
dispatch<any>(toggleDetailsPanel(currentItemId));
}
renderContent() {
- const { classes, onCloseDrawer, res, tabNr, authConfig, currentItemUuid } = this.props;
+ const { classes, onCloseDrawer, res, tabNr, authConfig } = this.props;
let shouldShowInlinePreview = false;
if (!('kind' in res)) {
</Tooltip>
</Grid>
<Grid item>
- <IconButton color="inherit" onClick={()=>onCloseDrawer(currentItemUuid)}>
+ <IconButton color="inherit" onClick={()=>onCloseDrawer(CLOSE_DRAWER)}>
<CloseIcon />
</IconButton>
</Grid>