X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9cbd6231837df8564953330fc63ce0fb9b9454cc..519b431a41a9ab4815a1e4180ee78395b74a85de:/src/components/data-explorer/data-explorer.tsx?ds=sidebyside

diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx
index af14db9c..cb979c7b 100644
--- a/src/components/data-explorer/data-explorer.tsx
+++ b/src/components/data-explorer/data-explorer.tsx
@@ -3,18 +3,17 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, WithStyles, TablePagination, IconButton } from '@material-ui/core';
-import MoreVertIcon from "@material-ui/icons/MoreVert";
+import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, WithStyles, TablePagination, IconButton, Tooltip } from '@material-ui/core';
 import { ColumnSelector } from "../column-selector/column-selector";
 import { DataTable, DataColumns } from "../data-table/data-table";
 import { DataColumn, SortDirection } from "../data-table/data-column";
-import { DataTableFilterItem } from '../data-table-filters/data-table-filters';
 import { SearchInput } from '../search-input/search-input';
 import { ArvadosTheme } from "~/common/custom-theme";
-import { DefaultView } from '../default-view/default-view';
-import { IconType } from '../icon/icon';
+import { createTree } from '~/models/tree';
+import { DataTableFilters } from '../data-table-filters/data-table-filters-tree';
+import { MoreOptionsIcon } from '~/components/icon/icon';
 
-type CssRules = 'searchBox' | "toolbar" | 'defaultRoot' | 'defaultMessage' | 'defaultIcon';
+type CssRules = 'searchBox' | "toolbar" | "footer" | "root" | 'moreOptionsButton';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     searchBox: {
@@ -23,18 +22,14 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     toolbar: {
         paddingTop: theme.spacing.unit * 2
     },
-    defaultRoot: {
-        position: 'absolute',
-        width: '80%',
-        left: '50%',
-        top: '50%',
-        transform: 'translate(-50%, -50%)'
+    footer: {
+        overflow: 'auto'
     },
-    defaultMessage: {
-        fontSize: '1.75rem',
+    root: {
+        height: '100%'
     },
-    defaultIcon: {
-        fontSize: '6rem'
+    moreOptionsButton: {
+        padding: 0
     }
 });
 
@@ -46,8 +41,9 @@ interface DataExplorerDataProps<T> {
     rowsPerPage: number;
     rowsPerPageOptions: number[];
     page: number;
-    defaultIcon: IconType;
-    defaultMessages: string[];
+    contextMenuColumn: boolean;
+    dataTableDefaultView?: React.ReactNode;
+    working?: boolean;
 }
 
 interface DataExplorerActionProps<T> {
@@ -58,7 +54,7 @@ interface DataExplorerActionProps<T> {
     onColumnToggle: (column: DataColumn<T>) => void;
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: T) => void;
     onSortToggle: (column: DataColumn<T>) => void;
-    onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn<T>) => void;
+    onFiltersChange: (filters: DataTableFilters, column: DataColumn<T>) => void;
     onChangePage: (page: number) => void;
     onChangeRowsPerPage: (rowsPerPage: number) => void;
     extractKey?: (item: T) => React.Key;
@@ -75,56 +71,49 @@ export const DataExplorer = withStyles(styles)(
         }
         render() {
             const {
-                columns, onContextMenu, onFiltersChange, onSortToggle, extractKey,
+                columns, onContextMenu, onFiltersChange, onSortToggle, working, extractKey,
                 rowsPerPage, rowsPerPageOptions, onColumnToggle, searchValue, onSearch,
-                items, itemsAvailable, onRowClick, onRowDoubleClick, defaultIcon, defaultMessages, classes
+                items, itemsAvailable, onRowClick, onRowDoubleClick, classes,
+                dataTableDefaultView
             } = this.props;
-            return <div>
-                { items.length > 0 ? (
-                    <Paper>
-                        <Toolbar className={classes.toolbar}>
-                            <Grid container justify="space-between" wrap="nowrap" alignItems="center">
-                                <div className={classes.searchBox}>
-                                    <SearchInput
-                                        value={searchValue}
-                                        onSearch={onSearch}/>
-                                </div>
-                                <ColumnSelector
-                                    columns={columns}
-                                    onColumnToggle={onColumnToggle}/>
-                            </Grid>
-                        </Toolbar>
-                        <DataTable
-                            columns={[...columns, this.contextMenuColumn]}
-                            items={items}
-                            onRowClick={(_, item: T) => onRowClick(item)}
-                            onContextMenu={onContextMenu}
-                            onRowDoubleClick={(_, item: T) => onRowDoubleClick(item)}
-                            onFiltersChange={onFiltersChange}
-                            onSortToggle={onSortToggle}
-                            extractKey={extractKey}/>
-                        <Toolbar>
-                            <Grid container justify="flex-end">
-                                <TablePagination
-                                    count={itemsAvailable}
-                                    rowsPerPage={rowsPerPage}
-                                    rowsPerPageOptions={rowsPerPageOptions}
-                                    page={this.props.page}
-                                    onChangePage={this.changePage}
-                                    onChangeRowsPerPage={this.changeRowsPerPage}
-                                    component="div" />
-                            </Grid>
-                        </Toolbar>
-                    </Paper>
-                ) : (
-                    <DefaultView
-                        classRoot={classes.defaultRoot}
-                        icon={defaultIcon}
-                        classIcon={classes.defaultIcon}
-                        messages={defaultMessages}
-                        classMessage={classes.defaultMessage} />
-                )}
-            </div>;
+            return <Paper className={classes.root}>
+                <Toolbar className={classes.toolbar}>
+                    <Grid container justify="space-between" wrap="nowrap" alignItems="center">
+                        <div className={classes.searchBox}>
+                            <SearchInput
+                                value={searchValue}
+                                onSearch={onSearch} />
+                        </div>
+                        <ColumnSelector
+                            columns={columns}
+                            onColumnToggle={onColumnToggle} />
+                    </Grid>
+                </Toolbar>
+                <DataTable
+                    columns={this.props.contextMenuColumn ? [...columns, this.contextMenuColumn] : columns}
+                    items={items}
+                    onRowClick={(_, item: T) => onRowClick(item)}
+                    onContextMenu={onContextMenu}
+                    onRowDoubleClick={(_, item: T) => onRowDoubleClick(item)}
+                    onFiltersChange={onFiltersChange}
+                    onSortToggle={onSortToggle}
+                    extractKey={extractKey}
+                    working={working}
+                    defaultView={dataTableDefaultView}
+                />
+                <Toolbar className={classes.footer}>
+                    <Grid container justify="flex-end">
+                        <TablePagination
+                            count={itemsAvailable}
+                            rowsPerPage={rowsPerPage}
+                            rowsPerPageOptions={rowsPerPageOptions}
+                            page={this.props.page}
+                            onChangePage={this.changePage}
+                            onChangeRowsPerPage={this.changeRowsPerPage}
+                            component="div" />
+                    </Grid>
+                </Toolbar>
+            </Paper>;
         }
 
         changePage = (event: React.MouseEvent<HTMLButtonElement>, page: number) => {
@@ -136,21 +125,22 @@ export const DataExplorer = withStyles(styles)(
         }
 
         renderContextMenuTrigger = (item: T) =>
-            <Grid container justify="flex-end">
-                <IconButton onClick={event => this.props.onContextMenu(event, item)}>
-                    <MoreVertIcon/>
-                </IconButton>
+            <Grid container justify="center">
+                <Tooltip title="More options" disableFocusListener>
+                    <IconButton className={this.props.classes.moreOptionsButton} onClick={event => this.props.onContextMenu(event, item)}>
+                        <MoreOptionsIcon />
+                    </IconButton>
+                </Tooltip>
             </Grid>
 
-        contextMenuColumn = {
+        contextMenuColumn: DataColumn<any> = {
             name: "Actions",
             selected: true,
             configurable: false,
             sortDirection: SortDirection.NONE,
-            filters: [],
+            filters: createTree(),
             key: "context-actions",
-            render: this.renderContextMenuTrigger,
-            width: "auto"
+            render: this.renderContextMenuTrigger
         };
     }
 );
