[ARVADOS-WORKBENCH2] updated: 1.1.4-292-ge7253b5
Git user
git at public.curoverse.com
Fri Jul 13 09:02:52 EDT 2018
Summary of changes:
src/store/context-menu/context-menu-reducer.ts | 8 +-
src/views-components/context-menu/context-menu.tsx | 87 ++++++++++++++--------
src/views/workbench/workbench.tsx | 14 ++--
3 files changed, 72 insertions(+), 37 deletions(-)
via e7253b56d761c939f1bc890a6b8c4087eab1410d (commit)
from 99d2472afc89ca78a4fef46ac08ce520b3bcf17b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit e7253b56d761c939f1bc890a6b8c4087eab1410d
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Fri Jul 13 15:02:33 2018 +0200
Implement base distinction between context menu kind
Feature #13805
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/context-menu/context-menu-reducer.ts b/src/store/context-menu/context-menu-reducer.ts
index 69f9c9a..129c2af 100644
--- a/src/store/context-menu/context-menu-reducer.ts
+++ b/src/store/context-menu/context-menu-reducer.ts
@@ -17,7 +17,13 @@ export interface ContextMenuPosition {
export interface ContextMenuResource {
uuid: string;
- kind: ResourceKind;
+ kind: ContextMenuKind;
+}
+
+export enum ContextMenuKind {
+ RootProject = "RootProject",
+ Project = "Project",
+ Collection = "Collection"
}
const initialState = {
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index 21d851d..bfd833a 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -8,7 +8,7 @@ import actions from "../../store/context-menu/context-menu-actions";
import ContextMenu, { ContextMenuAction, ContextMenuProps } from "../../components/context-menu/context-menu";
import { createAnchorAt } from "../../components/popover/helpers";
import projectActions from "../../store/project/project-action";
-import { ContextMenuResource } from "../../store/context-menu/context-menu-reducer";
+import { ContextMenuResource, ContextMenuKind } from "../../store/context-menu/context-menu-reducer";
type DataProps = Pick<ContextMenuProps, "anchorEl" | "actions"> & { resource?: ContextMenuResource };
@@ -16,12 +16,12 @@ const mapStateToProps = (state: RootState): DataProps => {
const { position, resource } = state.contextMenu;
return {
anchorEl: resource ? createAnchorAt(position) : undefined,
- actions: contextMenuActions,
+ actions: resource ? menuActions[resource.kind] : [],
resource
};
};
-type ActionProps = Pick<ContextMenuProps, "onClose"> & {onActionClick: (action: ContextMenuAction, resource?: ContextMenuResource) => void};
+type ActionProps = Pick<ContextMenuProps, "onClose"> & { onActionClick: (action: ContextMenuAction, resource?: ContextMenuResource) => void };
const mapDispatchToProps = (dispatch: Dispatch): ActionProps => ({
onClose: () => {
dispatch(actions.CLOSE_CONTEXT_MENU());
@@ -46,29 +46,58 @@ const mergeProps = ({ resource, ...dataProps }: DataProps, actionProps: ActionPr
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(ContextMenu);
-const contextMenuActions = [[{
- icon: "fas fa-plus fa-fw",
- name: "New project"
-}, {
- icon: "fas fa-users fa-fw",
- name: "Share"
-}, {
- icon: "fas fa-sign-out-alt fa-fw",
- name: "Move to"
-}, {
- icon: "fas fa-star fa-fw",
- name: "Add to favourite"
-}, {
- icon: "fas fa-edit fa-fw",
- name: "Rename"
-}, {
- icon: "fas fa-copy fa-fw",
- name: "Make a copy"
-}, {
- icon: "fas fa-download fa-fw",
- name: "Download"
-}], [{
- icon: "fas fa-trash-alt fa-fw",
- name: "Remove"
-}
-]];
\ No newline at end of file
+const menuActions = {
+ [ContextMenuKind.RootProject]: [[{
+ icon: "fas fa-plus fa-fw",
+ name: "New project"
+ }]],
+ [ContextMenuKind.Project]: [[{
+ icon: "fas fa-plus fa-fw",
+ name: "New project"
+ }, {
+ icon: "fas fa-users fa-fw",
+ name: "Share"
+ }, {
+ icon: "fas fa-sign-out-alt fa-fw",
+ name: "Move to"
+ }, {
+ icon: "fas fa-star fa-fw",
+ name: "Add to favourite"
+ }, {
+ icon: "fas fa-edit fa-fw",
+ name: "Rename"
+ }, {
+ icon: "fas fa-copy fa-fw",
+ name: "Make a copy"
+ }, {
+ icon: "fas fa-download fa-fw",
+ name: "Download"
+ }], [{
+ icon: "fas fa-trash-alt fa-fw",
+ name: "Remove"
+ }
+ ]],
+ [ContextMenuKind.Collection]: [[{
+ icon: "fas fa-users fa-fw",
+ name: "Share"
+ }, {
+ icon: "fas fa-sign-out-alt fa-fw",
+ name: "Move to"
+ }, {
+ icon: "fas fa-star fa-fw",
+ name: "Add to favourite"
+ }, {
+ icon: "fas fa-edit fa-fw",
+ name: "Rename"
+ }, {
+ icon: "fas fa-copy fa-fw",
+ name: "Make a copy"
+ }, {
+ icon: "fas fa-download fa-fw",
+ name: "Download"
+ }], [{
+ icon: "fas fa-trash-alt fa-fw",
+ name: "Remove"
+ }
+ ]]
+};
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index afd9dfd..52332e8 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -35,6 +35,7 @@ import contextMenuActions from "../../store/context-menu/context-menu-actions";
import { SidePanelIdentifiers } from '../../store/side-panel/side-panel-reducer';
import { ProjectResource } from '../../models/project';
import { ResourceKind } from '../../models/resource';
+import { ContextMenuKind } from '../../store/context-menu/context-menu-reducer';
const drawerWidth = 240;
const appBarHeight = 100;
@@ -154,7 +155,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
this.props.dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
},
onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: NavBreadcrumb) => {
- this.openContextMenu(event, breadcrumb.itemId);
+ this.openContextMenu(event, breadcrumb.itemId, ContextMenuKind.Project);
}
};
@@ -172,13 +173,12 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
this.props.dispatch(projectActions.OPEN_PROJECT_CREATOR({ ownerUuid: itemUuid }));
}
-
- openContextMenu = (event: React.MouseEvent<HTMLElement>, itemUuid: string) => {
+ openContextMenu = (event: React.MouseEvent<HTMLElement>, itemUuid: string, kind: ContextMenuKind) => {
event.preventDefault();
this.props.dispatch(
contextMenuActions.OPEN_CONTEXT_MENU({
position: { x: event.clientX, y: event.clientY },
- resource: { uuid: itemUuid, kind: ResourceKind.Project }
+ resource: { uuid: itemUuid, kind }
})
);
}
@@ -213,11 +213,11 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
toggleOpen={this.toggleSidePanelOpen}
toggleActive={this.toggleSidePanelActive}
sidePanelItems={this.props.sidePanelItems}
- onContextMenu={(event) => this.openContextMenu(event, authService.getUuid() || "")}>
+ onContextMenu={(event) => this.openContextMenu(event, authService.getUuid() || "", ContextMenuKind.RootProject)}>
<ProjectTree
projects={this.props.projects}
toggleOpen={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.OPEN))}
- onContextMenu={(event, item) => this.openContextMenu(event, item.data.uuid)}
+ onContextMenu={(event, item) => this.openContextMenu(event, item.data.uuid, ContextMenuKind.Project)}
toggleActive={itemId => {
this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE));
this.props.dispatch<any>(loadDetails(itemId, ResourceKind.Project));
@@ -241,7 +241,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
onItemRouteChange={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
- onContextMenu={(event, item) => this.openContextMenu(event, item.uuid)}
+ onContextMenu={(event, item) => this.openContextMenu(event, item.uuid, ContextMenuKind.Project)}
onDialogOpen={this.handleCreationDialogOpen}
onItemClick={item => {
this.props.dispatch<any>(loadDetails(item.uuid, item.kind as ResourceKind));
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list