import { Resource, extractUuidKind } from "models/resource";
import { getResource } from "store/resources/resources";
import { ResourcesState } from "store/resources/resources";
-import { ContextMenuAction, ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { ContextMenuAction, ContextMenuActionSet, DynamicContextMenuAction } from "views-components/context-menu/context-menu-action-set";
import { RestoreFromTrashIcon, TrashIcon } from "components/icon/icon";
import { multiselectActionsFilters, TMultiselectActionsFilters, contextMenuActionConsts } from "./ms-toolbar-action-filters";
import { kindToActionSet, findActionByName } from "./ms-kind-action-differentiator";
>
{buttons.length ? (
buttons.map((btn, i) =>
- btn.name === "ToggleTrashAction" ? (
+ btn.defaultText ? (
<Tooltip
className={classes.button}
- title={currentPathIsTrash ? "Restore selected" : "Move to trash"}
+ title={!currentPathIsTrash ? btn.defaultText: btn.altText}
key={i}
disableFocusListener
>
key={i}
disableFocusListener
>
- <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
- {btn.icon ? btn.icon({}) : <></>}
- </IconButton>
+ <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>{btn.icon ? btn.icon({}) : <></>}</IconButton>
</Tooltip>
)
)
)}
</Toolbar>
</React.Fragment>
- );
+ )
})
);
}
function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMultiselectActionsFilters) {
- const rawResult: Set<ContextMenuAction> = new Set();
+ const rawResult: Set<DynamicContextMenuAction> = new Set();
const resultNames = new Set();
- const allFiltersArray: ContextMenuAction[][] = [];
+ const allFiltersArray: DynamicContextMenuAction[][] = []
currentResourceKinds.forEach(kind => {
if (filterSet[kind]) {
const actions = filterActions(...filterSet[kind]);
// SPDX-License-Identifier: AGPL-3.0
import { ResourceKind } from "models/resource";
-import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { DynamicContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
import { msCollectionActionSet } from "views-components/multiselect-toolbar/ms-collection-action-set";
import { msProjectActionSet } from "views-components/multiselect-toolbar/ms-project-action-set";
import { msProcessActionSet } from "views-components/multiselect-toolbar/ms-process-action-set";
-export function findActionByName(name: string, actionSet: ContextMenuActionSet) {
+export function findActionByName(name: string, actionSet: DynamicContextMenuActionSet) {
return actionSet[0].find(action => action.name === name);
}
const { COLLECTION, PROJECT, PROCESS } = ResourceKind;
-export const kindToActionSet: Record<string, ContextMenuActionSet> = {
+export const kindToActionSet: Record<string, DynamicContextMenuActionSet> = {
[COLLECTION]: msCollectionActionSet,
[PROJECT]: msProjectActionSet,
[PROCESS]: msProcessActionSet,
// SPDX-License-Identifier: AGPL-3.0
import { ResourceKind } from "models/resource";
-import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { DynamicContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
import { msCollectionActionSet } from "views-components/multiselect-toolbar/ms-collection-action-set";
import { msProjectActionSet } from "views-components/multiselect-toolbar/ms-project-action-set";
import { msProcessActionSet } from "views-components/multiselect-toolbar/ms-process-action-set";
-export type TMultiselectActionsFilters = Record<string, [ContextMenuActionSet, Set<string>]>;
+export type TMultiselectActionsFilters = Record<string, [DynamicContextMenuActionSet, Set<string>]>;
export const contextMenuActionConsts = {
MAKE_A_COPY: "Make a copy",
import { Dispatch } from "redux";
import { ContextMenuItem } from "components/context-menu/context-menu";
import { ContextMenuResource } from "store/context-menu/context-menu-actions";
+import { IconType } from "components/icon/icon";
export interface ContextMenuAction extends ContextMenuItem {
execute(dispatch: Dispatch, resources: ContextMenuResource[], state?: any): void;
}
+export interface DynamicContextMenuAction extends ContextMenuAction {
+ defaultText?: string
+ defaultIcon?: IconType
+ altText?: string
+ altIcon?: IconType
+}
+
export type ContextMenuActionSet = Array<Array<ContextMenuAction>>;
+export type DynamicContextMenuActionSet = Array<Array<DynamicContextMenuAction>>;
//
// SPDX-License-Identifier: AGPL-3.0
-import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { DynamicContextMenuActionSet, DynamicContextMenuAction } from "views-components/context-menu/context-menu-action-set";
import { MoveToIcon, Link } from "components/icon/icon";
import { openMoveProjectDialog } from "store/projects/project-move-actions";
import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
import { ToggleFavoriteAction } from "views-components/context-menu/actions/favorite-action";
import { toggleFavorite } from "store/favorites/favorites-actions";
import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
+import { AddFavoriteIcon, RemoveFavoriteIcon } from "components/icon/icon";
+import { RestoreFromTrashIcon, TrashIcon } from "components/icon/icon";
-export const msToggleFavoriteAction = {
- component: ToggleFavoriteAction,
+
+export const msToggleFavoriteAction: DynamicContextMenuAction = {
name: "ToggleFavoriteAction",
+ defaultText: 'Add to Favorites',
+ altText: 'Remove from Favorites',
+ defaultIcon: AddFavoriteIcon,
+ altIcon: RemoveFavoriteIcon,
+
execute: (dispatch, resources) => {
- dispatch(toggleFavorite(resources[0])).then(() => {
+ dispatch<any>(toggleFavorite(resources[0])).then(() => {
dispatch(favoritePanelActions.REQUEST_ITEMS());
});
},
},
};
-export const msToggleTrashAction = {
- component: ToggleTrashAction,
+export const msToggleTrashAction: DynamicContextMenuAction = {
name: "ToggleTrashAction",
+ defaultText: 'Add to Trash',
+ altText: 'Restore from Trash',
+ defaultIcon: TrashIcon,
+ altIcon: RestoreFromTrashIcon,
execute: (dispatch, resources) => {
for (const resource of [...resources]) {
- dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
+ dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
}
},
};
-export const msProjectActionSet: ContextMenuActionSet = [[msCopyToClipboardMenuAction, msMoveToAction, msToggleTrashAction, msToggleFavoriteAction]];
+export const msProjectActionSet: DynamicContextMenuAction[][] = [[msCopyToClipboardMenuAction, msMoveToAction, msToggleTrashAction, msToggleFavoriteAction]];