[ARVADOS-WORKBENCH2] updated: 1.1.4-207-g5c513f2

Git user git at public.curoverse.com
Thu Jul 5 08:43:46 EDT 2018


Summary of changes:
 src/components/data-table/data-column.ts           | 14 ++++++++-----
 src/components/data-table/data-table.tsx           |  4 ++--
 .../project-panel/project-panel-middleware.ts      | 15 +++++++-------
 src/views/project-panel/project-panel.tsx          | 23 +++++++++++++++-------
 4 files changed, 35 insertions(+), 21 deletions(-)

       via  5c513f2c78337482da4cc6055706fd022c26c007 (commit)
      from  e9b57c9d6025168cc29442c85fd784902007052a (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 5c513f2c78337482da4cc6055706fd022c26c007
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Jul 5 14:43:18 2018 +0200

    Add SortDirection and ProjectColumnName enums
    
    Feature #13703
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/components/data-table/data-column.ts b/src/components/data-table/data-column.ts
index 0440fe2..06744c3 100644
--- a/src/components/data-table/data-column.ts
+++ b/src/components/data-table/data-column.ts
@@ -16,7 +16,11 @@ export interface DataColumn<T, F extends DataTableFilterItem = DataTableFilterIt
     width?: string;
 }
 
-export type SortDirection = "asc" | "desc" | "none";
+export enum SortDirection {
+    Asc = "asc",
+    Desc = "desc",
+    None = "none"
+}
 
 export const isColumnConfigurable = <T>(column: DataColumn<T>) => {
     return column.configurable === undefined || column.configurable;
@@ -24,12 +28,12 @@ export const isColumnConfigurable = <T>(column: DataColumn<T>) => {
 
 export const toggleSortDirection = <T>(column: DataColumn<T>): DataColumn<T> => {
     return column.sortDirection
-        ? column.sortDirection === "asc"
-            ? { ...column, sortDirection: "desc" }
-            : { ...column, sortDirection: "asc" }
+        ? column.sortDirection === SortDirection.Asc
+            ? { ...column, sortDirection: SortDirection.Desc }
+            : { ...column, sortDirection: SortDirection.Asc }
         : column;
 };
 
 export const resetSortDirection = <T>(column: DataColumn<T>): DataColumn<T> => {
-    return column.sortDirection ? { ...column, sortDirection: "none" } : column;
+    return column.sortDirection ? { ...column, sortDirection: SortDirection.None } : column;
 };
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index 22ecf4f..5372128 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -54,8 +54,8 @@ class DataTable<T extends DataItem> extends React.Component<DataTableProps<T> &
                     </DataTableFilters>
                     : sortDirection
                         ? <TableSortLabel
-                            active={sortDirection !== "none"}
-                            direction={sortDirection !== "none" ? sortDirection : undefined}
+                            active={sortDirection !== SortDirection.None}
+                            direction={sortDirection !== SortDirection.None ? sortDirection : undefined}
                             onClick={() =>
                                 onSortToggle &&
                                 onSortToggle(column)}>
diff --git a/src/views/project-panel/project-panel-middleware.ts b/src/views/project-panel/project-panel-middleware.ts
index a6a7256..0e1e764 100644
--- a/src/views/project-panel/project-panel-middleware.ts
+++ b/src/views/project-panel/project-panel-middleware.ts
@@ -4,7 +4,7 @@
 
 import { Middleware } from "redux";
 import actions from "../../store/data-explorer/data-explorer-action";
-import { PROJECT_PANEL_ID, columns, ProjectPanelFilter } from "./project-panel";
+import { PROJECT_PANEL_ID, columns, ProjectPanelFilter, ProjectPanelColumnNames } from "./project-panel";
 import { groupsService } from "../../services/services";
 import { RootState } from "../../store/store";
 import { getDataExplorer, DataExplorerState } from "../../store/data-explorer/data-explorer-reducer";
@@ -15,6 +15,7 @@ import { ProcessResource } from "../../models/process";
 import { CollectionResource } from "../../models/collection";
 import OrderBuilder from "../../common/api/order-builder";
 import { GroupContentsResource, GroupContentsResourcePrefix } from "../../services/groups-service/groups-service";
+import { SortDirection } from "../../components/data-table/data-column";
 
 export const projectPanelMiddleware: Middleware = store => next => {
     next(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns }));
@@ -51,17 +52,17 @@ export const projectPanelMiddleware: Middleware = store => next => {
                 const state = store.getState() as RootState;
                 const dataExplorer = getDataExplorer(state.dataExplorer, PROJECT_PANEL_ID);
                 const columns = dataExplorer.columns as DataColumns<ProjectPanelItem, ProjectPanelFilter>;
-                const typeFilters = getColumnFilters(columns, "Type");
-                const statusFilters = getColumnFilters(columns, "Status");
+                const typeFilters = getColumnFilters(columns, ProjectPanelColumnNames.Type);
+                const statusFilters = getColumnFilters(columns, ProjectPanelColumnNames.Status);
                 const sortColumn = dataExplorer.columns.find(({ sortDirection }) => Boolean(sortDirection && sortDirection !== "none"));
-                const sortDirection = sortColumn && sortColumn.sortDirection === "asc" ? "asc" : "desc";
+                const sortDirection = sortColumn && sortColumn.sortDirection === SortDirection.Asc ? SortDirection.Asc : SortDirection.Desc;
                 if (typeFilters.length > 0) {
                     groupsService
                         .contents(state.projects.currentItemId, {
                             limit: dataExplorer.rowsPerPage,
                             offset: dataExplorer.page * dataExplorer.rowsPerPage,
                             order: sortColumn
-                                ? sortColumn.name === "Name"
+                                ? sortColumn.name === ProjectPanelColumnNames.Name
                                     ? getOrder("name", sortDirection)
                                     : getOrder("createdAt", sortDirection)
                                 : OrderBuilder.create(),
@@ -104,13 +105,13 @@ const getColumnFilters = (columns: DataColumns<ProjectPanelItem, ProjectPanelFil
     return column && column.filters ? column.filters.filter(f => f.selected) : [];
 };
 
-const getOrder = (attribute: "name" | "createdAt", direction: "asc" | "desc") =>
+const getOrder = (attribute: "name" | "createdAt", direction: SortDirection) =>
     [
         OrderBuilder.create<GroupContentsResource>(GroupContentsResourcePrefix.Collection),
         OrderBuilder.create<GroupContentsResource>(GroupContentsResourcePrefix.Process),
         OrderBuilder.create<GroupContentsResource>(GroupContentsResourcePrefix.Project)
     ].reduce((acc, b) =>
-        acc.concat(direction === "asc"
+        acc.concat(direction === SortDirection.Asc
             ? b.addAsc(attribute)
             : b.addDesc(attribute)), OrderBuilder.create());
 
diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index 2c895ee..3c8c79c 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -15,6 +15,7 @@ import { RootState } from '../../store/store';
 import { ResourceKind } from '../../models/kinds';
 import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters';
 import { ContainerRequestState } from '../../models/container-request';
+import { SortDirection } from '../../components/data-table/data-column';
 
 export const PROJECT_PANEL_ID = "projectPanel";
 
@@ -148,12 +149,20 @@ const renderStatus = (item: ProjectPanelItem) =>
         {item.status || "-"}
     </Typography>;
 
+export enum ProjectPanelColumnNames {
+    Name = "Name",
+    Status = "Status",
+    Type = "Type",
+    Owner = "Owner",
+    FileSize = "File size",
+    LastModified = "Last modified"
 
+}
 
 export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [{
-    name: "Name",
+    name: ProjectPanelColumnNames.Name,
     selected: true,
-    sortDirection: "desc",
+    sortDirection: SortDirection.Asc,
     render: renderName,
     width: "450px"
 }, {
@@ -175,7 +184,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [{
     render: renderStatus,
     width: "75px"
 }, {
-    name: "Type",
+    name: ProjectPanelColumnNames.Type,
     selected: true,
     filters: [{
         name: typeToLabel(ResourceKind.Collection),
@@ -193,19 +202,19 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [{
     render: item => renderType(item.kind),
     width: "125px"
 }, {
-    name: "Owner",
+    name: ProjectPanelColumnNames.Owner,
     selected: true,
     render: item => renderOwner(item.owner),
     width: "200px"
 }, {
-    name: "File size",
+    name: ProjectPanelColumnNames.FileSize,
     selected: true,
     render: item => renderFileSize(item.fileSize),
     width: "50px"
 }, {
-    name: "Last modified",
+    name: ProjectPanelColumnNames.LastModified,
     selected: true,
-    sortDirection: "none",
+    sortDirection: SortDirection.None,
     render: item => renderDate(item.lastModified),
     width: "150px"
 }];

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list