[ARVADOS-WORKBENCH2] updated: 1.2.0-131-g1c0f11e

Git user git at public.curoverse.com
Fri Aug 24 12:49:30 EDT 2018


Summary of changes:
 src/components/breadcrumbs/breadcrumbs.tsx      |  2 +-
 src/views-components/breadcrumbs/breadcrumbs.ts | 54 +++++++++++++++++++++++++
 src/views/project-panel/project-panel.tsx       |  2 +
 src/views/workbench/workbench.tsx               |  2 +-
 4 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 src/views-components/breadcrumbs/breadcrumbs.ts

       via  1c0f11ed17dea5be97e8ca63385f979925f1fb08 (commit)
      from  d6d85de50096eb0053d58c5022fd4e949c830929 (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 1c0f11ed17dea5be97e8ca63385f979925f1fb08
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Fri Aug 24 18:49:14 2018 +0200

    Extract breadcrumbs view component
    
    Feature #14102
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/components/breadcrumbs/breadcrumbs.tsx b/src/components/breadcrumbs/breadcrumbs.tsx
index da549db..444ac75 100644
--- a/src/components/breadcrumbs/breadcrumbs.tsx
+++ b/src/components/breadcrumbs/breadcrumbs.tsx
@@ -25,7 +25,7 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     }
 });
 
-interface BreadcrumbsProps {
+export interface BreadcrumbsProps {
     items: Breadcrumb[];
     onClick: (breadcrumb: Breadcrumb) => void;
     onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
diff --git a/src/views-components/breadcrumbs/breadcrumbs.ts b/src/views-components/breadcrumbs/breadcrumbs.ts
new file mode 100644
index 0000000..306b29e
--- /dev/null
+++ b/src/views-components/breadcrumbs/breadcrumbs.ts
@@ -0,0 +1,54 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { connect } from "react-redux";
+import { Breadcrumbs as BreadcrumbsComponent, BreadcrumbsProps } from '~/components/breadcrumbs/breadcrumbs';
+import { RootState } from '~/store/store';
+import { Breadcrumb } from '~/components/breadcrumbs/breadcrumbs';
+import { matchProjectRoute } from '~/routes/routes';
+import { getTreePicker } from '~/store/tree-picker/tree-picker';
+import { SIDE_PANEL_TREE } from '~/store/side-panel-tree/side-panel-tree-actions';
+import { getNodeAncestors, getNode } from '~/models/tree';
+import { Dispatch } from 'redux';
+import { navigateToResource } from '~/store/navigation/navigation-action';
+
+interface ResourceBreadcrumb extends Breadcrumb {
+    uuid: string;
+}
+
+type BreadcrumbsDataProps = Pick<BreadcrumbsProps, 'items'>;
+type BreadcrumbsActionProps = Pick<BreadcrumbsProps, 'onClick' | 'onContextMenu'>;
+
+const memoizedMapStateToProps = () => {
+    let items: ResourceBreadcrumb[] = [];
+    return ({ router, treePicker }: RootState): BreadcrumbsDataProps => {
+        if (router.location) {
+            const projectMatch = matchProjectRoute(location.pathname);
+            const collectionMatch = matchProjectRoute(location.pathname);
+            const uuid = projectMatch && projectMatch.params.id
+                || collectionMatch && collectionMatch.params.id
+                || '';
+            const tree = getTreePicker(SIDE_PANEL_TREE)(treePicker);
+            if (tree) {
+                const ancestors = getNodeAncestors(uuid)(tree);
+                const node = getNode(uuid)(tree);
+                const nodes = node ? [...ancestors, node] : ancestors;
+                items = nodes.map(({ value }) =>
+                    typeof value.value === 'string'
+                        ? { label: value.value, uuid: value.nodeId }
+                        : { label: value.value.name, uuid: value.value.uuid });
+            }
+        }
+        return { items };
+    };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): BreadcrumbsActionProps => ({
+    onClick: ({ uuid }: ResourceBreadcrumb) => {
+        dispatch<any>(navigateToResource(uuid));
+    },
+    onContextMenu: () => { return; }
+});
+
+export const Breadcrumbs = connect(memoizedMapStateToProps(), mapDispatchToProps)(BreadcrumbsComponent);
\ No newline at end of file
diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index 37712c7..e1c9d83 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -31,6 +31,7 @@ import { collectionCreateActions } from '~/store/collections/creator/collection-
 import { navigateToResource } from '~/store/navigation/navigation-action';
 import { getProperty } from '~/store/properties/properties';
 import { PROJECT_PANEL_CURRENT_UUID } from '~/store/project-panel/project-panel-action';
+import { Breadcrumbs } from '~/views-components/breadcrumbs/breadcrumbs';
 
 type CssRules = 'root' | "toolbar" | "button";
 
@@ -181,6 +182,7 @@ export const ProjectPanel = withStyles(styles)(
                             New project
                         </Button>
                     </div>
+                    <Breadcrumbs />
                     <DataExplorer
                         id={PROJECT_PANEL_ID}
                         onRowClick={this.handleRowClick}
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 1c11e06..8d8d937 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -41,7 +41,7 @@ import { MoveProjectDialog } from '~/views-components/move-project-dialog/move-p
 import { MoveCollectionDialog } from '~/views-components/move-collection-dialog/move-collection-dialog';
 import { SidePanel } from '~/views-components/side-panel/side-panel';
 import { Routes } from '~/routes/routes';
-import { navigateToResource } from '../../store/navigation/navigation-action';
+import { navigateToResource } from '~/store/navigation/navigation-action';
 
 const APP_BAR_HEIGHT = 100;
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list