X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c952afae1af2fb31b68be04f70bd7ae6f9d52aba..765f6475a53ac7e635b737642ef375459324a117:/src/components/data-table/data-table.tsx

diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index 9a31cbfd..d942234d 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -3,13 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import React from 'react';
-import { Table, TableBody, TableRow, TableCell, TableHead, TableSortLabel, StyleRulesCallback, Theme, WithStyles, withStyles, IconButton, CircularProgress } from '@material-ui/core';
+import { Table, TableBody, TableRow, TableCell, TableHead, TableSortLabel, StyleRulesCallback, Theme, WithStyles, withStyles, IconButton } from '@material-ui/core';
 import classnames from 'classnames';
 import { DataColumn, SortDirection } from './data-column';
 import { DataTableDefaultView } from '../data-table-default-view/data-table-default-view';
 import { DataTableFilters } from '../data-table-filters/data-table-filters-tree';
 import { DataTableFiltersPopover } from '../data-table-filters/data-table-filters-popover';
-import { countNodes } from 'models/tree';
+import { countNodes, getTreeDirty } from 'models/tree';
+import { IconType, PendingIcon } from 'components/icon/icon';
 import { SvgIconProps } from '@material-ui/core/SvgIcon';
 import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward';
 
@@ -30,7 +31,8 @@ export interface DataTableDataProps<T> {
     onFiltersChange: (filters: DataTableFilters, column: DataColumn<T>) => void;
     extractKey?: (item: T) => React.Key;
     working?: boolean;
-    defaultView?: React.ReactNode;
+    defaultViewIcon?: IconType;
+    defaultViewMessages?: string[];
     currentItemUuid?: string;
     currentRoute?: string;
 }
@@ -49,10 +51,8 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
         background: theme.palette.background.paper
     },
     loader: {
-        top: '50%',
         left: '50%',
-        marginTop: '-15px',
-        marginLeft: '-15px',
+        marginLeft: '-84px',
         position: 'absolute'
     },
     noItemsInfo: {
@@ -87,7 +87,7 @@ type DataTableProps<T> = DataTableDataProps<T> & WithStyles<CssRules>;
 export const DataTable = withStyles(styles)(
     class Component<T> extends React.Component<DataTableProps<T>> {
         render() {
-            const { items, classes } = this.props;
+            const { items, classes, working } = this.props;
             return <div className={classes.root}>
                 <div className={classes.content}>
                     <Table>
@@ -97,24 +97,26 @@ export const DataTable = withStyles(styles)(
                             </TableRow>
                         </TableHead>
                         <TableBody className={classes.tableBody}>
-                            {
-                                this.props.working ? 
-                                    <div>
-                                        <CircularProgress className={classes.loader} size={30} />
-                                    </div> :
-                                    items.map(this.renderBodyRow)
-                            }
+                            { !working && items.map(this.renderBodyRow) }
                         </TableBody>
                     </Table>
-                    {items.length === 0 && this.props.working !== undefined && !this.props.working && this.renderNoItemsPlaceholder()}
+                    { !!working &&
+                        <div className={classes.loader}>
+                            <DataTableDefaultView
+                                icon={PendingIcon}
+                                messages={['Loading data, please wait.']} />
+                        </div> }
+                    {items.length === 0 && !working && this.renderNoItemsPlaceholder(this.props.columns)}
                 </div>
             </div>;
         }
 
-        renderNoItemsPlaceholder = () => {
-            return this.props.defaultView
-                ? this.props.defaultView
-                : <DataTableDefaultView />;
+        renderNoItemsPlaceholder = (columns: DataColumns<T>) => {
+            const dirty = columns.some((column) => getTreeDirty('')(column.filters));
+            return <DataTableDefaultView
+                icon={this.props.defaultViewIcon}
+                messages={this.props.defaultViewMessages}
+                filtersApplied={dirty} />;
         }
 
         renderHeadCell = (column: DataColumn<T>, index: number) => {
