});
}
-const isExactlyOneSelected = (checkedList: TCheckedList) => {
+export const isExactlyOneSelected = (checkedList: TCheckedList) => {
let tally = 0;
let current = '';
for (const uuid in checkedList) {
// SPDX-License-Identifier: AGPL-3.0
import { TCheckedList } from "components/data-table/data-table";
+import { isExactlyOneSelected } from "components/multiselect-toolbar/MultiselectToolbar";
export const multiselectActionContants = {
TOGGLE_VISIBLITY: "TOGGLE_VISIBLITY",
SET_CHECKEDLIST: "SET_CHECKEDLIST",
SELECT_ONE: 'SELECT_ONE',
DESELECT_ONE: "DESELECT_ONE",
- TOGGLE_ONE: 'TOGGLE_ONE'
+ TOGGLE_ONE: 'TOGGLE_ONE',
+ SET_SELECTED_UUID: 'SET_SELECTED_UUID'
};
export const toggleMSToolbar = (isVisible: boolean) => {
export const setCheckedListOnStore = (checkedList: TCheckedList) => {
return dispatch => {
+ dispatch(setSelectedUuid(isExactlyOneSelected(checkedList)))
dispatch({ type: multiselectActionContants.SET_CHECKEDLIST, payload: checkedList });
};
};
};
};
+export const setSelectedUuid = (uuid: string | null) => {
+ return dispatch => {
+ dispatch({ type: multiselectActionContants.SET_SELECTED_UUID, payload: uuid });
+ };
+};
+
export const multiselectActions = {
toggleMSToolbar,
setCheckedListOnStore,
selectOne,
deselectOne,
+ toggleOne,
+ setSelectedUuid
};
type MultiselectToolbarState = {
isVisible: boolean;
checkedList: TCheckedList;
+ selectedUuid: string;
};
const multiselectToolbarInitialState = {
isVisible: false,
checkedList: {},
+ selectedUuid: '',
};
-const { TOGGLE_VISIBLITY, SET_CHECKEDLIST, SELECT_ONE, DESELECT_ONE, TOGGLE_ONE } = multiselectActionContants;
+const { TOGGLE_VISIBLITY, SET_CHECKEDLIST, SELECT_ONE, DESELECT_ONE, TOGGLE_ONE, SET_SELECTED_UUID } = multiselectActionContants;
export const multiselectReducer = (state: MultiselectToolbarState = multiselectToolbarInitialState, action) => {
switch (action.type) {
return { ...state, checkedList: { ...state.checkedList, [action.payload]: false } };
case TOGGLE_ONE:
return { ...state, checkedList: { ...state.checkedList, [action.payload]: !state.checkedList[action.payload] } };
+ case SET_SELECTED_UUID:
+ return {...state, selectedUuid: action.payload || ''}
default:
return state;
}
const dataExplorerState = getDataExplorer(state.dataExplorer, id);
const currentRoute = state.router.location ? state.router.location.pathname : "";
const currentRefresh = localStorage.getItem(LAST_REFRESH_TIMESTAMP) || "";
- const currentItemUuid = currentRoute === "/workflows" ? state.properties.workflowPanelDetailsUuid : state.detailsPanel.resourceUuid;
+ const isDetailsResourceChecked = state.multiselect.checkedList[state.detailsPanel.resourceUuid]
+ const currentItemUuid = currentRoute === "/workflows" ? state.properties.workflowPanelDetailsUuid : isDetailsResourceChecked ? state.detailsPanel.resourceUuid : state.multiselect.selectedUuid;
const isMSToolbarVisible = state.multiselect.isVisible;
return {
...dataExplorerState,
}
};
-const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles }: RootState) => {
- const resource = getResource(detailsPanel.resourceUuid)(resources) as DetailsResource | undefined;
+const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles, multiselect, router }: RootState) => {
+ const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid]
+ const currentRoute = router.location ? router.location.pathname : "";
+ const currentItemUuid = isDetailsResourceChecked ? detailsPanel.resourceUuid : multiselect.selectedUuid || currentRoute.split('/')[2];
+ const resource = getResource(currentItemUuid)(resources) as DetailsResource | undefined || '';
const file = resource
? undefined
: getNode(detailsPanel.resourceUuid)(collectionPanelFiles);
import { getInitialProcessStatusFilters, getInitialProcessTypeFilters } from "store/resource-type-filters/resource-type-filters";
import { getProcess } from "store/processes/process";
import { ResourcesState } from "store/resources/resources";
+import { selectOne } from "store/multiselect/multiselect-actions";
type CssRules = "toolbar" | "button" | "root";
};
handleRowClick = (uuid: string) => {
+ this.props.dispatch<any>(selectOne(uuid))
this.props.dispatch<any>(loadDetailsPanel(uuid));
};
import { getProperty } from 'store/properties/properties';
import { PROJECT_PANEL_CURRENT_UUID } from 'store/project-panel/project-panel-action';
import { CollectionResource } from 'models/collection';
+import { selectOne } from 'store/multiselect/multiselect-actions';
type CssRules = "toolbar" | "button" | "root";
}
handleRowClick = (uuid: string) => {
+ this.props.dispatch<any>(selectOne(uuid))
this.props.dispatch<any>(loadDetailsPanel(uuid));
}
import { resourceIsFrozen } from 'common/frozen-resources';
import { ProjectResource } from 'models/project';
import { NotFoundView } from 'views/not-found-panel/not-found-panel';
+import { selectOne } from 'store/multiselect/multiselect-actions';
type CssRules = 'root' | 'button';
};
handleRowClick = (uuid: string) => {
+ this.props.dispatch<any>(selectOne(uuid))
this.props.dispatch<any>(loadDetailsPanel(uuid));
};
}
resourceUuidToContextMenuKind
} from 'store/context-menu/context-menu-actions';
import { GroupContentsResource } from 'services/groups-service/groups-service';
+import { selectOne } from 'store/multiselect/multiselect-actions';
type CssRules = "toolbar" | "button" | "root";
}
handleRowClick = (uuid: string) => {
+ this.props.dispatch<any>(selectOne(uuid))
this.props.dispatch<any>(loadDetailsPanel(uuid));
}
}
getTrashPanelTypeFilters
} from 'store/resource-type-filters/resource-type-filters';
import { CollectionResource } from 'models/collection';
+import { selectOne } from 'store/multiselect/multiselect-actions';
type CssRules = "toolbar" | "button" | "root";
}
handleRowClick = (uuid: string) => {
+ this.props.dispatch<any>(selectOne(uuid))
this.props.dispatch<any>(loadDetailsPanel(uuid));
}
}