[ARVADOS-WORKBENCH2] updated: 1.3.1-394-g1e5181ff

Git user git at public.curoverse.com
Fri Mar 8 05:17:42 EST 2019


Summary of changes:
 src/store/dialog/with-dialog.ts                    |  4 +++-
 src/views-components/context-menu/context-menu.tsx | 17 ++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

       via  1e5181ff623fd92942bc7bbaf5110e38dd7fdd9e (commit)
      from  291f9af579f6d32221a3307dfdf036ccdb7cf5f4 (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 1e5181ff623fd92942bc7bbaf5110e38dd7fdd9e
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Fri Mar 8 11:17:22 2019 +0100

    refs #
    Fix performance bug in with-dialog and context-menu components
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/dialog/with-dialog.ts b/src/store/dialog/with-dialog.ts
index 41dcd559..6eaee0d2 100644
--- a/src/store/dialog/with-dialog.ts
+++ b/src/store/dialog/with-dialog.ts
@@ -23,9 +23,11 @@ export const withDialog = (id: string) =>
     <T, P>(component: React.ComponentType<WithDialogProps<T> & any>) =>
         connect(mapStateToProps(id), mapDispatchToProps(id))(component);
 
+const emptyData = {};
+
 export const mapStateToProps = (id: string) => <T>(state: { dialog: DialogState }): WithDialogStateProps<T> => {
     const dialog = state.dialog[id];
-    return dialog ? dialog : { open: false, data: {} };
+    return dialog ? dialog : { open: false, data: emptyData };
 };
 
 export const mapDispatchToProps = (id: string) => (dispatch: Dispatch): WithDialogDispatchProps => ({
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index 4ce2f521..f6910290 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -9,7 +9,7 @@ import { ContextMenu as ContextMenuComponent, ContextMenuProps, ContextMenuItem
 import { createAnchorAt } from "~/components/popover/helpers";
 import { ContextMenuActionSet, ContextMenuAction } from "./context-menu-action-set";
 import { Dispatch } from "redux";
-
+import { memoize } from 'lodash';
 type DataProps = Pick<ContextMenuProps, "anchorEl" | "items" | "open"> & { resource?: ContextMenuResource };
 const mapStateToProps = (state: RootState): DataProps => {
     const { open, position, resource } = state.contextMenu;
@@ -34,14 +34,20 @@ const mapDispatchToProps = (dispatch: Dispatch): ActionProps => ({
     }
 });
 
+const handleItemClick = memoize(
+    (resource: DataProps['resource'], onItemClick: ActionProps['onItemClick']): ContextMenuProps['onItemClick'] =>
+        item => {
+            onItemClick(item, resource);
+        }
+);
+
 const mergeProps = ({ resource, ...dataProps }: DataProps, actionProps: ActionProps): ContextMenuProps => ({
     ...dataProps,
     ...actionProps,
-    onItemClick: item => {
-        actionProps.onItemClick(item, resource);
-    }
+    onItemClick: handleItemClick(resource, actionProps.onItemClick)
 });
 
+
 export const ContextMenu = connect(mapStateToProps, mapDispatchToProps, mergeProps)(ContextMenuComponent);
 
 const menuActionSets = new Map<string, ContextMenuActionSet>();
@@ -50,8 +56,9 @@ export const addMenuActionSet = (name: string, itemSet: ContextMenuActionSet) =>
     menuActionSets.set(name, itemSet);
 };
 
+const emptyActionSet: ContextMenuActionSet = [];
 const getMenuActionSet = (resource?: ContextMenuResource): ContextMenuActionSet => {
-    return resource ? menuActionSets.get(resource.menuKind) || [] : [];
+    return resource ? menuActionSets.get(resource.menuKind) || emptyActionSet : emptyActionSet;
 };
 
 export enum ContextMenuKind {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list