},
expanded: {
transition: 'width 150ms',
- transitionTimingFunction: 'ease-in',
},
button: {
backgroundColor: '#017ead',
{
name: 'remove',
action: 'removeSelected',
- relevantKinds: [ResourceKind.COLLECTION],
+ relevantKinds: [ResourceKind.COLLECTION, ResourceKind.PROCESS, ResourceKind.PROJECT],
+ },
+ {
+ name: 'foo',
+ action: 'barSelected',
+ relevantKinds: [ResourceKind.COLLECTION, ResourceKind.PROJECT],
},
];
checkedList: TCheckedList;
copySelected: () => void;
moveSelected: () => void;
+ barSelected: () => void;
removeSelected: (selectedList: TCheckedList) => void;
};
// console.log(props);
const { classes, actions, isVisible, checkedList } = props;
- //include any action that can be applied to all selected elements
+ const currentResourceKinds = selectedToArray(checkedList).map((element) => extractUuidKind(element));
+
+ const buttons = actions.filter(
+ (action) => currentResourceKinds.length && currentResourceKinds.every((kind) => action.relevantKinds.includes(kind as ResourceKind))
+ );
- const currentResourceKinds = new Set(selectedToArray(checkedList).map((element) => extractUuidKind(element) as string));
- console.log('CURRENT_KINDS', currentResourceKinds);
- const buttons = actions.filter((action) => {
- // console.log('ACTION.KINDS', action.relevantKinds);
- return action.relevantKinds.every((kind) => {
- // console.log('KIND', kind);
- // console.log('setHasKind', currentResourceKinds.has(kind));
- return currentResourceKinds.has(kind);
- });
- });
- // console.log('BUTTONS', buttons);
return (
- <Toolbar className={isVisible && buttons.length ? `${classes.root} ${classes.expanded}` : classes.root} style={{ width: `${buttons.length * 5.8}rem` }}>
+ <Toolbar className={isVisible && buttons.length ? `${classes.root} ${classes.expanded}` : classes.root} style={{ width: `${buttons.length * 5.5}rem` }}>
{buttons.length ? (
buttons.map((btn) => (
<Button key={btn.name} className={`${classes.button} ${classes.expanded}`} onClick={() => props[btn.action](checkedList)}>
}
function mapStateToProps(state: RootState) {
- // console.log(state.resources, state.multiselect.checkedList);
const { isVisible, checkedList } = state.multiselect;
return {
isVisible: isVisible,
checkedList: checkedList as TCheckedList,
- // selectedList: state.multiselect.checkedList.forEach(processUUID=>containerRequestUUID)
};
}
return {
copySelected: () => {},
moveSelected: () => {},
+ barSelected: () => {},
removeSelected: (checkedList: TCheckedList) => removeMulti(dispatch, checkedList),
};
}