import { collectionFilesActionSet } from './views-components/context-menu/action-sets/collection-files-action-set';
import { collectionFilesItemActionSet } from './views-components/context-menu/action-sets/collection-files-item-action-set';
import { collectionActionSet } from './views-components/context-menu/action-sets/collection-action-set';
+import { collectionResourceActionSet } from './views-components/context-menu/action-sets/collection-resource-action-set';
addMenuActionSet(ContextMenuKind.ROOT_PROJECT, rootProjectActionSet);
addMenuActionSet(ContextMenuKind.PROJECT, projectActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
+addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
fetchConfig()
.then(config => {
import { CollectionResource } from '../../../models/collection';
import { initialize } from 'redux-form';
import { collectionPanelActions } from "../../collection-panel/collection-panel-action";
+import { ContextMenuResource } from "../../context-menu/context-menu-reducer";
export const collectionUpdaterActions = unionize({
OPEN_COLLECTION_UPDATER: ofType<{ uuid: string }>(),
export const COLLECTION_FORM_NAME = 'collectionEditDialog';
-export const openUpdater = (uuid: string) =>
+export const openUpdater = (item: ContextMenuResource) =>
(dispatch: Dispatch, getState: () => RootState) => {
- dispatch(collectionUpdaterActions.OPEN_COLLECTION_UPDATER({ uuid }));
- const item = getState().collectionPanel.item;
- if(item) {
+ if (item) {
+ dispatch(collectionUpdaterActions.OPEN_COLLECTION_UPDATER({ uuid: item.uuid }));
dispatch(initialize(COLLECTION_FORM_NAME, { name: item.name, description: item.description }));
}
};
export const collectionUpdaterReducer = (state: CollectionUpdaterState = initialState, action: CollectionUpdaterAction) => {
return collectionUpdaterActions.match(action, {
OPEN_COLLECTION_UPDATER: ({ uuid }) => updateCollection(state, { uuid, opened: true }),
- CLOSE_COLLECTION_UPDATER: () => updateCollection(state, { opened: false }),
+ CLOSE_COLLECTION_UPDATER: () => updateCollection(state, { opened: false, uuid: "" }),
UPDATE_COLLECTION_SUCCESS: () => updateCollection(state, { opened: false, uuid: "" }),
default: () => state
});
uuid: string;
kind: string;
name: string;
+ description?: string;
}
const initialState = {
icon: RenameIcon,
name: "Edit collection",
execute: (dispatch, resource) => {
- dispatch<any>(openUpdater(resource.uuid));
+ dispatch<any>(openUpdater(resource));
}
},
{
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "../context-menu-action-set";
+import { ToggleFavoriteAction } from "../actions/favorite-action";
+import { toggleFavorite } from "../../../store/favorites/favorites-actions";
+import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "../../../components/icon/icon";
+import { openUpdater } from "../../../store/collections/updater/collection-updater-action";
+import { favoritePanelActions } from "../../../store/favorite-panel/favorite-panel-action";
+
+export const collectionResourceActionSet: ContextMenuActionSet = [[
+ {
+ icon: RenameIcon,
+ name: "Edit collection",
+ execute: (dispatch, resource) => {
+ dispatch<any>(openUpdater(resource));
+ }
+ },
+ {
+ icon: ShareIcon,
+ name: "Share",
+ execute: (dispatch, resource) => {
+ // add code
+ }
+ },
+ {
+ icon: MoveToIcon,
+ name: "Move to",
+ execute: (dispatch, resource) => {
+ // add code
+ }
+ },
+ {
+ component: ToggleFavoriteAction,
+ execute: (dispatch, resource) => {
+ dispatch<any>(toggleFavorite(resource)).then(() => {
+ dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
+ });
+ }
+ },
+ {
+ icon: CopyIcon,
+ name: "Copy to project",
+ execute: (dispatch, resource) => {
+ // add code
+ }
+ },
+ {
+ icon: DetailsIcon,
+ name: "View details",
+ execute: (dispatch, resource) => {
+ // add code
+ }
+ },
+ {
+ icon: RemoveIcon,
+ name: "Remove",
+ execute: (dispatch, resource) => {
+ // add code
+ }
+ }
+]];
FAVORITE = "Favorite",
COLLECTION_FILES = "CollectionFiles",
COLLECTION_FILES_ITEM = "CollectionFilesItem",
- COLLECTION = 'Collection'
+ COLLECTION = 'Collection',
+ COLLECTION_RESOURCE = 'CollectionResource'
}
export const RENAME_FILE_DIALOG = 'renameFileDialog';
-export const openRenameFileDialog = (originalName: string, ) =>
+export const openRenameFileDialog = (originalName: string) =>
(dispatch: Dispatch) => {
dispatch(reset(RENAME_FILE_DIALOG));
dispatch(dialogActions.OPEN_DIALOG({ id: RENAME_FILE_DIALOG, data: originalName }));
export interface ProjectPanelItem {
uuid: string;
name: string;
+ description?: string;
kind: string;
url: string;
owner: string;
return {
uuid: r.uuid,
name: r.name,
+ description: r.description,
kind: r.kind,
url: "",
owner: r.ownerUuid,
this.openContextMenu(event, {
uuid: item.uuid,
name: item.name,
+ description: item.description,
kind: ContextMenuKind.COLLECTION
});
}}
renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
onItemRouteChange={itemId => this.props.dispatch(setProjectItem(itemId, ItemMode.ACTIVE))}
onContextMenu={(event, item) => {
+ let kind: ContextMenuKind;
- const kind = item.kind === ResourceKind.PROJECT ? ContextMenuKind.PROJECT : ContextMenuKind.RESOURCE;
+ if (item.kind === ResourceKind.PROJECT) {
+ kind = ContextMenuKind.PROJECT;
+ } else if (item.kind === ResourceKind.COLLECTION) {
+ kind = ContextMenuKind.COLLECTION_RESOURCE;
+ } else {
+ kind = ContextMenuKind.RESOURCE;
+ }
+
this.openContextMenu(event, {
uuid: item.uuid,
name: item.name,
+ description: item.description,
kind
});
}}
this.props.dispatch(collectionCreateActions.OPEN_COLLECTION_CREATOR({ ownerUuid: itemUuid }));
}
- openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: { name: string; uuid: string; kind: ContextMenuKind; }) => {
+ openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: { name: string; uuid: string; description?: string; kind: ContextMenuKind; }) => {
event.preventDefault();
this.props.dispatch(
contextMenuActions.OPEN_CONTEXT_MENU({