Init collection-panel-files hoc
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 30 Jul 2018 10:58:04 +0000 (12:58 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 30 Jul 2018 10:58:04 +0000 (12:58 +0200)
Feature #13855

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/components/collection-panel-files/collection-panel-files.tsx
src/views-components/collection-panel-files/collection-panel-files.ts [new file with mode: 0644]
src/views/workbench/workbench.tsx

index af2c19a05d0388f17abf390ebe1038649673830c..fb1ee0513b23dcb44119380f3b19d6c6bbac97c7 100644 (file)
@@ -47,44 +47,3 @@ export const CollectionPanelFiles = withStyles(styles)(
             <FileTree onMenuOpen={onItemMenuOpen} {...treeProps} />
         </div>);
 
-export const collectionPanelItems: Array<TreeItem<FileTreeData>> = [{
-    active: false,
-    data: {
-        name: "Directory 1",
-        type: "directory"
-    },
-    id: "Directory 1",
-    open: true,
-    status: TreeItemStatus.LOADED,
-    items: [{
-        active: false,
-        data: {
-            name: "Directory 1.1",
-            type: "directory"
-        },
-        id: "Directory 1.1",
-        open: false,
-        status: TreeItemStatus.LOADED,
-        items: []
-    }, {
-        active: false,
-        data: {
-            name: "File 1.1",
-            type: "file",
-            size: 20033
-        },
-        id: "File 1.1",
-        open: false,
-        status: TreeItemStatus.LOADED,
-        items: []
-    }]
-}, {
-    active: false,
-    data: {
-        name: "Directory 2",
-        type: "directory"
-    },
-    id: "Directory 2",
-    open: false,
-    status: TreeItemStatus.LOADED
-}]; 
diff --git a/src/views-components/collection-panel-files/collection-panel-files.ts b/src/views-components/collection-panel-files/collection-panel-files.ts
new file mode 100644 (file)
index 0000000..e61007a
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { connect } from "react-redux";
+import { CollectionPanelFiles as Component, CollectionPanelFilesProps } from "../../components/collection-panel-files/collection-panel-files";
+import { RootState } from "../../store/store";
+import { TreeItemStatus } from "../../components/tree/tree";
+
+const mapStateToProps = (state: RootState): Pick<CollectionPanelFilesProps, "items"> => ({
+    items: [{
+        active: false,
+        data: {
+            name: "Directory 1",
+            type: "directory"
+        },
+        id: "Directory 1",
+        open: true,
+        status: TreeItemStatus.LOADED,
+        items: [{
+            active: false,
+            data: {
+                name: "Directory 1.1",
+                type: "directory"
+            },
+            id: "Directory 1.1",
+            open: false,
+            status: TreeItemStatus.LOADED,
+            items: []
+        }, {
+            active: false,
+            data: {
+                name: "File 1.1",
+                type: "file",
+                size: 20033
+            },
+            id: "File 1.1",
+            open: false,
+            status: TreeItemStatus.LOADED,
+            items: []
+        }]
+    }, {
+        active: false,
+        data: {
+            name: "Directory 2",
+            type: "directory"
+        },
+        id: "Directory 2",
+        open: false,
+        status: TreeItemStatus.LOADED
+    }]
+});
+
+
+export const CollectionPanelFiles = connect(mapStateToProps)(Component);
index 1b6e05dabbe032113d62aaa3892766e0961d88ad..75e926593953e45ae59fbb4f96680457284b2e3b 100644 (file)
@@ -36,7 +36,7 @@ import { FavoritePanel, FAVORITE_PANEL_ID } from "../favorite-panel/favorite-pan
 import { CurrentTokenDialog } from '../../views-components/current-token-dialog/current-token-dialog';
 import { dataExplorerActions } from '../../store/data-explorer/data-explorer-action';
 import { Snackbar } from '../../views-components/snackbar/snackbar';
-import { CollectionPanelFiles, collectionPanelItems } from '../../components/collection-panel-files/collection-panel-files';
+import { CollectionPanelFiles } from '../../views-components/collection-panel-files/collection-panel-files';
 
 const drawerWidth = 240;
 const appBarHeight = 100;
@@ -215,7 +215,6 @@ export const Workbench = withStyles(styles)(
                                     <Route path="/favorites" render={this.renderFavoritePanel} />
                                     <Route path="/" render={() => 
                                     <CollectionPanelFiles 
-                                        items={collectionPanelItems} 
                                         onCollapseToggle={console.log}
                                         onSelectionToggle={console.log}
                                         onItemMenuOpen={console.log}