X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/7ae86efd9905582df4191910528c3803a68ba81b..d842372e4f45ee06315e511529e65ae1d3f319a0:/src/views/favorite-panel/favorite-panel.tsx

diff --git a/src/views/favorite-panel/favorite-panel.tsx b/src/views/favorite-panel/favorite-panel.tsx
index 36a34107..125ea27d 100644
--- a/src/views/favorite-panel/favorite-panel.tsx
+++ b/src/views/favorite-panel/favorite-panel.tsx
@@ -4,21 +4,21 @@
 
 import * as React from 'react';
 import { FavoritePanelItem } from './favorite-panel-item';
-import { Grid, Typography, Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { formatDate, formatFileSize } from '../../common/formatters';
-import { DataExplorer } from "../../views-components/data-explorer/data-explorer";
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
 import { DispatchProp, connect } from 'react-redux';
-import { DataColumns } from '../../components/data-table/data-table';
+import { DataColumns } from '~/components/data-table/data-table';
 import { RouteComponentProps } from 'react-router';
-import { RootState } from '../../store/store';
-import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters';
-import { ContainerRequestState } from '../../models/container-request';
-import { SortDirection } from '../../components/data-table/data-column';
-import { ResourceKind } from '../../models/resource';
-import { resourceLabel } from '../../common/labels';
-import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon } from '../../components/icon/icon';
-import { ArvadosTheme } from '../../common/custom-theme';
-import { FavoriteStar } from "../../views-components/favorite-star/favorite-star";
+import { RootState } from '~/store/store';
+import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
+import { ContainerRequestState } from '~/models/container-request';
+import { SortDirection } from '~/components/data-table/data-column';
+import { ResourceKind } from '~/models/resource';
+import { resourceLabel } from '~/common/labels';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { renderName, renderStatus, renderType, renderOwner, renderFileSize, renderDate } from '~/views-components/data-explorer/renderers';
+import { FAVORITE_PANEL_ID } from "~/store/favorite-panel/favorite-panel-action";
+import { FavoriteIcon } from '~/components/icon/icon';
 
 type CssRules = "toolbar" | "button";
 
@@ -32,61 +32,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     },
 });
 
-const renderName = (item: FavoritePanelItem) =>
-    <Grid container alignItems="center" wrap="nowrap" spacing={16}>
-        <Grid item>
-            {renderIcon(item)}
-        </Grid>
-        <Grid item>
-            <Typography color="primary">
-                {item.name}
-            </Typography>
-        </Grid>
-        <Grid item>
-            <Typography variant="caption">
-                <FavoriteStar resourceUuid={item.uuid} />
-            </Typography>
-        </Grid>
-    </Grid>;
-
-
-const renderIcon = (item: FavoritePanelItem) => {
-    switch (item.kind) {
-        case ResourceKind.PROJECT:
-            return <ProjectIcon />;
-        case ResourceKind.COLLECTION:
-            return <CollectionIcon />;
-        case ResourceKind.PROCESS:
-            return <ProcessIcon />;
-        default:
-            return <DefaultIcon />;
-    }
-};
-
-const renderDate = (date: string) => {
-    return <Typography noWrap>{formatDate(date)}</Typography>;
-};
-
-const renderFileSize = (fileSize?: number) =>
-    <Typography noWrap>
-        {formatFileSize(fileSize)}
-    </Typography>;
-
-const renderOwner = (owner: string) =>
-    <Typography noWrap color="primary" >
-        {owner}
-    </Typography>;
-
-const renderType = (type: string) =>
-    <Typography noWrap>
-        {resourceLabel(type)}
-    </Typography>;
-
-const renderStatus = (item: FavoritePanelItem) =>
-    <Typography noWrap align="center" >
-        {item.status || "-"}
-    </Typography>;
-
 export enum FavoritePanelColumnNames {
     NAME = "Name",
     STATUS = "Status",
@@ -104,13 +49,17 @@ export const columns: DataColumns<FavoritePanelItem, FavoritePanelFilter> = [
     {
         name: FavoritePanelColumnNames.NAME,
         selected: true,
+        configurable: true,
         sortDirection: SortDirection.ASC,
+        filters: [],
         render: renderName,
         width: "450px"
     },
     {
         name: "Status",
         selected: true,
+        configurable: true,
+        sortDirection: SortDirection.NONE,
         filters: [
             {
                 name: ContainerRequestState.COMMITTED,
@@ -134,6 +83,8 @@ export const columns: DataColumns<FavoritePanelItem, FavoritePanelFilter> = [
     {
         name: FavoritePanelColumnNames.TYPE,
         selected: true,
+        configurable: true,
+        sortDirection: SortDirection.NONE,
         filters: [
             {
                 name: resourceLabel(ResourceKind.COLLECTION),
@@ -157,26 +108,32 @@ export const columns: DataColumns<FavoritePanelItem, FavoritePanelFilter> = [
     {
         name: FavoritePanelColumnNames.OWNER,
         selected: true,
+        configurable: true,
+        sortDirection: SortDirection.NONE,
+        filters: [],
         render: item => renderOwner(item.owner),
         width: "200px"
     },
     {
         name: FavoritePanelColumnNames.FILE_SIZE,
         selected: true,
+        configurable: true,
+        sortDirection: SortDirection.NONE,
+        filters: [],
         render: item => renderFileSize(item.fileSize),
         width: "50px"
     },
     {
         name: FavoritePanelColumnNames.LAST_MODIFIED,
         selected: true,
+        configurable: true,
         sortDirection: SortDirection.NONE,
+        filters: [],
         render: item => renderDate(item.lastModified),
         width: "150px"
     }
 ];
 
-export const FAVORITE_PANEL_ID = "favoritePanel";
-
 interface FavoritePanelDataProps {
     currentItemId: string;
 }
@@ -198,10 +155,13 @@ export const FavoritePanel = withStyles(styles)(
             render() {
                 return <DataExplorer
                     id={FAVORITE_PANEL_ID}
+                    columns={columns}
                     onRowClick={this.props.onItemClick}
                     onRowDoubleClick={this.props.onItemDoubleClick}
                     onContextMenu={this.props.onContextMenu}
-                    extractKey={(item: FavoritePanelItem) => item.uuid} />
+                    extractKey={(item: FavoritePanelItem) => item.uuid}
+                    defaultIcon={FavoriteIcon}
+                    defaultMessages={['Your favorites list is empty.']}/>
                 ;
             }
 
