[ARVADOS-WORKBENCH2] updated: 1.1.4-365-g3787043

Git user git at public.curoverse.com
Mon Jul 23 17:48:30 EDT 2018


Summary of changes:
 src/components/context-menu/context-menu.tsx       | 12 ++++++-----
 .../context-menu/action-sets/favorite-action.tsx   | 23 ++++++++++++++++++++++
 .../context-menu/action-sets/project-action-set.ts |  9 +++++----
 .../action-sets/root-project-action-set.ts         |  1 +
 4 files changed, 36 insertions(+), 9 deletions(-)
 create mode 100644 src/views-components/context-menu/action-sets/favorite-action.tsx

       via  37870430486b96966f874bb507c2511d679f7721 (commit)
       via  c1b2cf95d7b5e1da32e59e43b745b625120e16cf (commit)
      from  c16ed46210ea3c7f29442b4a1622239ff3641f29 (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 37870430486b96966f874bb507c2511d679f7721
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Jul 23 23:48:16 2018 +0200

    Create component for favorite management menu item
    
    Feature #13784
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views-components/context-menu/action-sets/favorite-action.tsx b/src/views-components/context-menu/action-sets/favorite-action.tsx
new file mode 100644
index 0000000..7976eb5
--- /dev/null
+++ b/src/views-components/context-menu/action-sets/favorite-action.tsx
@@ -0,0 +1,23 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { ListItemIcon, ListItemText } from "@material-ui/core";
+import { FavoriteIcon, AddFavoriteIcon, RemoveFavoriteIcon } from "../../../components/icon/icon";
+import { connect } from "react-redux";
+import { RootState } from "../../../store/store";
+
+const mapStateToProps = (state: RootState) => ({
+    isFavorite: state.contextMenu.resource && state.favorites[state.contextMenu.resource.uuid] === true
+});
+
+export const FavoriteActionText = connect(mapStateToProps)((props: { isFavorite: boolean }) =>
+    props.isFavorite
+        ? <>Remove from favorites</>
+        : <>Add to favorites</>);
+
+export const FavoriteActionIcon = connect(mapStateToProps)((props: { isFavorite: boolean }) =>
+    props.isFavorite
+        ? <RemoveFavoriteIcon />
+        : <AddFavoriteIcon />);
diff --git a/src/views-components/context-menu/action-sets/project-action-set.ts b/src/views-components/context-menu/action-sets/project-action-set.ts
index 66dbd4d..2b33649 100644
--- a/src/views-components/context-menu/action-sets/project-action-set.ts
+++ b/src/views-components/context-menu/action-sets/project-action-set.ts
@@ -4,7 +4,8 @@
 
 import { ContextMenuActionSet } from "../context-menu-action-set";
 import { projectActions } from "../../../store/project/project-action";
-import { ShareIcon, NewProjectIcon  } from "../../../components/icon/icon";
+import { ShareIcon, NewProjectIcon } from "../../../components/icon/icon";
+import { FavoriteActionText, FavoriteActionIcon } from "./favorite-action";
 
 export const projectActionSet: ContextMenuActionSet = [[{
     icon: NewProjectIcon,
@@ -13,7 +14,7 @@ export const projectActionSet: ContextMenuActionSet = [[{
         dispatch(projectActions.OPEN_PROJECT_CREATOR({ ownerUuid: resource.uuid }));
     }
 }, {
-    icon: ShareIcon,
-    name: "Share",
-    execute: () => { return; }
+    name: FavoriteActionText,
+    icon: FavoriteActionIcon,
+    execute: (dispatch, resource) => { alert(resource); }
 }]];
diff --git a/src/views-components/context-menu/action-sets/root-project-action-set.ts b/src/views-components/context-menu/action-sets/root-project-action-set.ts
index 139bd26..8d3d035 100644
--- a/src/views-components/context-menu/action-sets/root-project-action-set.ts
+++ b/src/views-components/context-menu/action-sets/root-project-action-set.ts
@@ -5,6 +5,7 @@
 import { ContextMenuActionSet } from "../context-menu-action-set";
 import { projectActions } from "../../../store/project/project-action";
 import { NewProjectIcon } from "../../../components/icon/icon";
+import { FavoriteActionText, FavoriteActionIcon } from "./favorite-action";
 
 export const rootProjectActionSet: ContextMenuActionSet =  [[{
     icon: NewProjectIcon,

commit c1b2cf95d7b5e1da32e59e43b745b625120e16cf
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Jul 23 23:47:31 2018 +0200

    Update ContextMenu to accept name and icon components
    
    Feature #13784
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/components/context-menu/context-menu.tsx b/src/components/context-menu/context-menu.tsx
index 2103a2a..67fbb82 100644
--- a/src/components/context-menu/context-menu.tsx
+++ b/src/components/context-menu/context-menu.tsx
@@ -7,8 +7,8 @@ import { DefaultTransformOrigin } from "../popover/helpers";
 import { IconType } from "../icon/icon";
 
 export interface ContextMenuItem {
-    name: string;
-    icon: IconType;
+    name: string | React.ComponentType;
+    icon: React.ComponentType<any>;
 }
 
 export type ContextMenuItemGroup = ContextMenuItem[];
@@ -22,7 +22,7 @@ export interface ContextMenuProps {
 
 export class ContextMenu extends React.PureComponent<ContextMenuProps> {
     render() {
-        const { anchorEl, items, onClose, onItemClick} = this.props;
+        const { anchorEl, items, onClose, onItemClick } = this.props;
         return <Popover
             anchorEl={anchorEl}
             open={!!anchorEl}
@@ -39,10 +39,12 @@ export class ContextMenu extends React.PureComponent<ContextMenuProps> {
                                 key={actionIndex}
                                 onClick={() => onItemClick(item)}>
                                 <ListItemIcon>
-                                    <item.icon/>
+                                    <item.icon />
                                 </ListItemIcon>
                                 <ListItemText>
-                                    {item.name}
+                                    {typeof item.name === "string"
+                                        ? item.name
+                                        : <item.name />}
                                 </ListItemText>
                             </ListItem>)}
                         {groupIndex < items.length - 1 && <Divider />}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list