const currentPathIsTrash = window.location.pathname === "/trash";
- const buttons =
+ const actions =
currentPathIsTrash && selectedToKindSet(checkedList).size
? [msToggleTrashAction]
: selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
<React.Fragment>
<Toolbar
className={classes.root}
- style={{ width: `${buttons.length * 2.5}rem` }}
+ style={{ width: `${actions.length * 2.5}rem` }}
>
- {buttons.length ? (
- buttons.map((btn, i) =>
- btn.isDefault ? (
+ {actions.length ? (
+ actions.map((action, i) =>
+ action.isDefault ? (
<Tooltip
className={classes.button}
- title={btn.isDefault(selectedUuid, resources, favorites) ? btn.defaultText : btn.altText}
+ title={action.isDefault(selectedUuid, resources, favorites) ? action.name : action.altText}
key={i}
disableFocusListener
>
- <IconButton onClick={() => props.executeMulti(btn, checkedList, resources)}>
- {btn.isDefault(selectedUuid, resources, favorites) ? btn.icon && btn.icon({}) : btn.altIcon && btn.altIcon({})}
+ <IconButton onClick={() => props.executeMulti(action, checkedList, resources)}>
+ {action.isDefault(selectedUuid, resources, favorites) ? action.icon && action.icon({}) : action.altIcon && action.altIcon({})}
</IconButton>
</Tooltip>
) : (
<Tooltip
className={classes.button}
- title={btn.name}
+ title={action.name}
key={i}
disableFocusListener
>
- <IconButton onClick={() => props.executeMulti(btn, checkedList, resources)}>{btn.icon ? btn.icon({}) : <></>}</IconButton>
+ <IconButton onClick={() => props.executeMulti(action, checkedList, resources)}>{action.icon ? action.icon({}) : <></>}</IconButton>
</Tooltip>
)
)
});
const filteredNameSet = allFiltersArray.map(filterArray => {
- const resultSet = new Set();
- filterArray.forEach(action => resultSet.add(action.name || ""));
+ const resultSet = new Set<string>();
+ filterArray.forEach(action => resultSet.add(action.name as string || ""));
return resultSet;
});
const filteredResult = Array.from(rawResult).filter(action => {
for (let i = 0; i < filteredNameSet.length; i++) {
- if (!filteredNameSet[i].has(action.name)) return false;
+ if (!filteredNameSet[i].has(action.name as string)) return false;
}
return true;
});
export type TMultiselectActionsFilters = Record<string, [MultiSelectMenuActionSet, Set<string>]>;
-const { MOVE_TO, TOGGLE_TRASH_ACTION, TOGGLE_FAVORITE_ACTION, REMOVE, MAKE_A_COPY } = MultiSelectMenuActionNames;
+const { MOVE_TO, ADD_TO_TRASH: TOGGLE_TRASH_ACTION, ADD_TO_FAVORITES: TOGGLE_FAVORITE_ACTION, REMOVE, MAKE_A_COPY } = MultiSelectMenuActionNames;
//these sets govern what actions are on the ms toolbar for each resource kind
const projectMSActionsFilter = new Set([MOVE_TO, TOGGLE_TRASH_ACTION, TOGGLE_FAVORITE_ACTION]);
import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
import { toggleCollectionTrashed } from "store/trash/trash-actions";
import { ContextMenuResource } from "store/context-menu/context-menu-actions";
-import { MultiSelectMenuActionSet } from "./ms-menu-action-set";
+import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-action-set";
export const msCollectionActionSet: MultiSelectMenuActionSet = [
[
{
icon: CopyIcon,
- name: "Make a copy",
+ name: MultiSelectMenuActionNames.MAKE_A_COPY,
isForMulti: true,
execute: (dispatch, [...resources]) => {
if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
},
{
icon: MoveToIcon,
- name: "Move to",
+ name: MultiSelectMenuActionNames.MOVE_TO,
isForMulti: true,
execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
},
{
component: ToggleTrashAction,
- name: "ToggleTrashAction",
+ name: MultiSelectMenuActionNames.ADD_TO_TRASH,
isForMulti: true,
execute: (dispatch, resources: ContextMenuResource[]) => {
for (const resource of [...resources]) {
export const MultiSelectMenuActionNames = {
MAKE_A_COPY: "Make a copy",
MOVE_TO: "Move to",
- TOGGLE_TRASH_ACTION: "ToggleTrashAction",
- TOGGLE_FAVORITE_ACTION: "ToggleFavoriteAction",
+ ADD_TO_TRASH: "Add to Trash",
+ ADD_TO_FAVORITES: "Add to Favorites",
COPY_TO_CLIPBOARD: "Copy to clipboard",
COPY_AND_RERUN_PROCESS: "Copy and re-run process",
REMOVE: "Remove",
isForMulti: boolean;
}
-export type MultiSelectMenuActionSet = Array<Array<MultiSelectMenuAction>>;
+export type MultiSelectMenuActionSet = MultiSelectMenuAction[][];
import { openMoveProcessDialog } from "store/processes/process-move-actions";
import { openCopyProcessDialog } from "store/processes/process-copy-actions";
import { openRemoveProcessDialog } from "store/processes/processes-actions";
-import { MultiSelectMenuActionSet } from "./ms-menu-action-set";
+import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-action-set";
export const msProcessActionSet: MultiSelectMenuActionSet = [
[
{
icon: ReRunProcessIcon,
- name: "Copy and re-run process",
+ name: MultiSelectMenuActionNames.COPY_AND_RERUN_PROCESS,
isForMulti: true,
execute: (dispatch, resources) => {
for (const resource of [...resources]) {
},
{
icon: MoveToIcon,
- name: "Move to",
+ name: MultiSelectMenuActionNames.MOVE_TO,
isForMulti: true,
execute: (dispatch, resources) => {
dispatch<any>(openMoveProcessDialog(resources[0]));
},
},
{
- name: "Remove",
+ name: MultiSelectMenuActionNames.REMOVE,
icon: RemoveIcon,
isForMulti: true,
execute: (dispatch, resources) => {
import { checkFavorite } from "store/favorites/favorites-reducer";
export const msToggleFavoriteAction = {
- name: MultiSelectMenuActionNames.TOGGLE_FAVORITE_ACTION,
- defaultText: 'Add to Favorites',
+ name: MultiSelectMenuActionNames.ADD_TO_FAVORITES,
altText: 'Remove from Favorites',
icon: AddFavoriteIcon,
altIcon: RemoveFavoriteIcon,
};
export const msToggleTrashAction = {
- name: MultiSelectMenuActionNames.TOGGLE_TRASH_ACTION,
- defaultText: 'Add to Trash',
+ name: MultiSelectMenuActionNames.ADD_TO_TRASH,
altText: 'Restore from Trash',
icon: TrashIcon,
altIcon: RestoreFromTrashIcon,