[ARVADOS-WORKBENCH2] updated: 1.1.4-153-gc3efa27

Git user git at public.curoverse.com
Tue Jun 26 09:14:46 EDT 2018


Summary of changes:
 .../project-explorer/project-explorer.tsx          | 11 +++-----
 src/views/project-panel/project-panel.tsx          | 29 +++++++++++++++-------
 2 files changed, 23 insertions(+), 17 deletions(-)

       via  c3efa27ba09323568c2b7d2cd27911fe4937ccbc (commit)
      from  c3945a12b21445b157cfe3ea77f88134c670d88c (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 c3efa27ba09323568c2b7d2cd27911fe4937ccbc
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Jun 26 15:14:31 2018 +0200

    Implement filtering in project-panel
    
    Feature #13683
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views-components/project-explorer/project-explorer.tsx b/src/views-components/project-explorer/project-explorer.tsx
index e982553..556b23b 100644
--- a/src/views-components/project-explorer/project-explorer.tsx
+++ b/src/views-components/project-explorer/project-explorer.tsx
@@ -26,6 +26,7 @@ interface ProjectExplorerProps {
     items: ProjectExplorerItem[];
     onRowClick: (item: ProjectExplorerItem) => void;
     onToggleSort: (toggledColumn: DataColumn<ProjectExplorerItem>) => void;
+    onChangeFilters: (filters: DataTableFilterItem[]) => void;
 }
 
 interface ProjectExplorerState {
@@ -49,13 +50,6 @@ class ProjectExplorer extends React.Component<ProjectExplorerProps, ProjectExplo
         }, {
             name: "Status",
             selected: true,
-            filters: [{
-                name: "In progress",
-                selected: true
-            }, {
-                name: "Complete",
-                selected: true
-            }],
             render: renderStatus,
             width: "75px"
         }, {
@@ -65,7 +59,7 @@ class ProjectExplorer extends React.Component<ProjectExplorerProps, ProjectExplo
                 name: "Collection",
                 selected: true
             }, {
-                name: "Group",
+                name: "Project",
                 selected: true
             }],
             render: item => renderType(item.kind),
@@ -162,6 +156,7 @@ class ProjectExplorer extends React.Component<ProjectExplorerProps, ProjectExplo
                     : column
             )
         });
+        this.props.onChangeFilters(filters);
     }
 
     executeAction = (action: ContextMenuAction, item: ProjectExplorerItem) => {
diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index d44053d..df9721f 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -14,6 +14,7 @@ import { projectExplorerItems } from "./project-panel-selectors";
 import { ProjectExplorerItem } from "../../views-components/project-explorer/project-explorer-item";
 import { Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
 import { DataColumn, SortDirection } from '../../components/data-table/data-column';
+import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters';
 
 interface ProjectPanelDataProps {
     projects: ProjectState;
@@ -27,6 +28,7 @@ interface ProjectPanelState {
         columnName: string;
         direction: SortDirection;
     };
+    filters: string[];
 }
 
 class ProjectPanel extends React.Component<ProjectPanelProps & WithStyles<CssRules>, ProjectPanelState> {
@@ -34,7 +36,8 @@ class ProjectPanel extends React.Component<ProjectPanelProps & WithStyles<CssRul
         sort: {
             columnName: "Name",
             direction: "desc"
-        }
+        },
+        filters: ['collection', 'project']
     };
 
     render() {
@@ -44,7 +47,8 @@ class ProjectPanel extends React.Component<ProjectPanelProps & WithStyles<CssRul
             this.props.collections
         );
         const [goBackItem, ...otherItems] = items;
-        const sortedItems = sortItems(this.state.sort, otherItems);
+        const filteredItems = otherItems.filter(i => this.state.filters.some(f => f === i.kind));
+        const sortedItems = sortItems(this.state.sort, filteredItems);
         return (
             <div>
                 <div className={this.props.classes.toolbar}>
@@ -59,9 +63,10 @@ class ProjectPanel extends React.Component<ProjectPanelProps & WithStyles<CssRul
                     </Button>
                 </div>
                 <ProjectExplorer
-                    items={goBackItem ? [goBackItem, ...sortedItems] : sortedItems }
+                    items={goBackItem ? [goBackItem, ...sortedItems] : sortedItems}
                     onRowClick={this.goToItem}
                     onToggleSort={this.toggleSort}
+                    onChangeFilters={this.changeFilters}
                 />
             </div>
         );
@@ -72,18 +77,24 @@ class ProjectPanel extends React.Component<ProjectPanelProps & WithStyles<CssRul
     }
 
     toggleSort = (column: DataColumn<ProjectExplorerItem>) => {
-        this.setState({sort: {
-            columnName: column.name,
-            direction: column.sortDirection || "none"
-        }});
+        this.setState({
+            sort: {
+                columnName: column.name,
+                direction: column.sortDirection || "none"
+            }
+        });
+    }
+
+    changeFilters = (filters: DataTableFilterItem[]) => {
+        this.setState({ filters: filters.filter(f => f.selected).map(f => f.name.toLowerCase()) });
     }
 }
 
-const sortItems = (sort: {columnName: string, direction: SortDirection}, items: ProjectExplorerItem[]) => {
+const sortItems = (sort: { columnName: string, direction: SortDirection }, items: ProjectExplorerItem[]) => {
     const sortedItems = items.slice(0);
     const direction = sort.direction === "asc" ? -1 : 1;
     sortedItems.sort((a, b) => {
-        if(sort.columnName === "Last modified") {
+        if (sort.columnName === "Last modified") {
             return ((new Date(a.lastModified)).getTime() - (new Date(b.lastModified)).getTime()) * direction;
         } else {
             return a.name.localeCompare(b.name) * direction;

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list