import { resourceIsFrozen } from "common/frozen-resources";
import { ProjectResource } from "models/project";
import { getProcess } from "store/processes/process";
+import { filterCollectionFilesBySelection } from "store/collection-panel/collection-panel-files/collection-panel-files-state";
export const contextMenuActions = unionize({
OPEN_CONTEXT_MENU: ofType<{ position: ContextMenuPosition; resource: ContextMenuResource }>(),
isFrozen?: boolean;
storageClassesDesired?: string[];
properties?: { [key: string]: string | string[] };
+ isMulti?: boolean;
+ fromContextMenu?: boolean;
};
export const isKeyboardClick = (event: React.MouseEvent<HTMLElement>) => event.nativeEvent.detail === 0;
export const openCollectionFilesContextMenu =
(event: React.MouseEvent<HTMLElement>, isWritable: boolean) => (dispatch: Dispatch, getState: () => RootState) => {
const isCollectionFileSelected = JSON.stringify(getState().collectionPanelFiles).includes('"selected":true');
+ const selectedCount = filterCollectionFilesBySelection(getState().collectionPanelFiles, true).length;
+ const multiple = selectedCount > 1;
dispatch<any>(
openContextMenu(event, {
name: "",
ownerUuid: "",
description: "",
kind: ResourceKind.COLLECTION,
- menuKind: isCollectionFileSelected
- ? isWritable
- ? ContextMenuKind.COLLECTION_FILES
- : ContextMenuKind.READONLY_COLLECTION_FILES
- : ContextMenuKind.COLLECTION_FILES_NOT_SELECTED,
+ menuKind:
+ selectedCount > 0
+ ? isWritable
+ ? multiple
+ ? ContextMenuKind.COLLECTION_FILES_MULTIPLE
+ : ContextMenuKind.COLLECTION_FILES
+ : multiple
+ ? ContextMenuKind.READONLY_COLLECTION_FILES_MULTIPLE
+ : ContextMenuKind.READONLY_COLLECTION_FILES
+ : ContextMenuKind.COLLECTION_FILES_NOT_SELECTED,
})
);
};
case ResourceKind.LINK:
return ContextMenuKind.LINK;
case ResourceKind.WORKFLOW:
- return ContextMenuKind.WORKFLOW;
+ return isEditable ? ContextMenuKind.WORKFLOW : ContextMenuKind.READONLY_WORKFLOW;
default:
return;
}