X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/699f7cebc3057ddf22ca3c43c3d3534d605972ec..10ce16c28de952f6533ca3cc9df909269e3d2a53:/src/components/data-explorer/data-explorer.tsx

diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx
index 1073ddd8b5..4699fd6de0 100644
--- a/src/components/data-explorer/data-explorer.tsx
+++ b/src/components/data-explorer/data-explorer.tsx
@@ -3,15 +3,27 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, Theme, WithStyles, TablePagination, IconButton } from '@material-ui/core';
+import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, WithStyles, TablePagination, IconButton } from '@material-ui/core';
 import MoreVertIcon from "@material-ui/icons/MoreVert";
-import ColumnSelector from "../column-selector/column-selector";
-import DataTable, { DataColumns } from "../data-table/data-table";
+import { ColumnSelector } from "../column-selector/column-selector";
+import { DataTable, DataColumns } from "../data-table/data-table";
 import { DataColumn } from "../data-table/data-column";
 import { DataTableFilterItem } from '../data-table-filters/data-table-filters';
-import SearchInput from '../search-input/search-input';
+import { SearchInput } from '../search-input/search-input';
+import { ArvadosTheme } from "../../common/custom-theme";
 
-interface DataExplorerProps<T> {
+type CssRules = "searchBox" | "toolbar";
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    searchBox: {
+        paddingBottom: theme.spacing.unit * 2
+    },
+    toolbar: {
+        paddingTop: theme.spacing.unit * 2
+    }
+});
+
+interface DataExplorerDataProps<T> {
     items: T[];
     itemsAvailable: number;
     columns: DataColumns<T>;
@@ -31,33 +43,35 @@ interface DataExplorerProps<T> {
     extractKey?: (item: T) => React.Key;
 }
 
-class DataExplorer<T> extends React.Component<DataExplorerProps<T> & WithStyles<CssRules>> {
+type DataExplorerProps<T> = DataExplorerDataProps<T> & WithStyles<CssRules>;
 
-    render() {
-        return <Paper>
-            <Toolbar className={this.props.classes.toolbar}>
-                <Grid container justify="space-between" wrap="nowrap" alignItems="center">
-                    <div className={this.props.classes.searchBox}>
-                        <SearchInput
-                            value={this.props.searchValue}
-                            onSearch={this.props.onSearch} />
-                    </div>
-                    <ColumnSelector
-                        columns={this.props.columns}
-                        onColumnToggle={this.props.onColumnToggle} />
-                </Grid>
-            </Toolbar>
-            <DataTable
-                columns={[...this.props.columns, this.contextMenuColumn]}
-                items={this.props.items}
-                onRowClick={(_, item: T) => this.props.onRowClick(item)}
-                onContextMenu={this.props.onContextMenu}
-                onRowDoubleClick={(_, item: T) => this.props.onRowDoubleClick(item)}
-                onFiltersChange={this.props.onFiltersChange}
-                onSortToggle={this.props.onSortToggle}
-                extractKey={this.props.extractKey} />
-            <Toolbar>
-                {this.props.items.length > 0 &&
+export const DataExplorer = withStyles(styles)(
+    class DataExplorerGeneric<T> extends React.Component<DataExplorerProps<T>> {
+        render() {
+            return <Paper>
+                <Toolbar className={this.props.classes.toolbar}>
+                    <Grid container justify="space-between" wrap="nowrap" alignItems="center">
+                        <div className={this.props.classes.searchBox}>
+                            <SearchInput
+                                value={this.props.searchValue}
+                                onSearch={this.props.onSearch}/>
+                        </div>
+                        <ColumnSelector
+                            columns={this.props.columns}
+                            onColumnToggle={this.props.onColumnToggle}/>
+                    </Grid>
+                </Toolbar>
+                <DataTable
+                    columns={[...this.props.columns, this.contextMenuColumn]}
+                    items={this.props.items}
+                    onRowClick={(_, item: T) => this.props.onRowClick(item)}
+                    onContextMenu={this.props.onContextMenu}
+                    onRowDoubleClick={(_, item: T) => this.props.onRowDoubleClick(item)}
+                    onFiltersChange={this.props.onFiltersChange}
+                    onSortToggle={this.props.onSortToggle}
+                    extractKey={this.props.extractKey}/>
+                <Toolbar>
+                    {this.props.items.length > 0 &&
                     <Grid container justify="flex-end">
                         <TablePagination
                             count={this.props.itemsAvailable}
@@ -69,45 +83,32 @@ class DataExplorer<T> extends React.Component<DataExplorerProps<T> & WithStyles<
                             component="div"
                         />
                     </Grid>}
-            </Toolbar>
-        </Paper>;
-    }
+                </Toolbar>
+            </Paper>;
+        }
 
-    changePage = (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => {
-        this.props.onChangePage(page);
-    }
+        changePage = (event: React.MouseEvent<HTMLButtonElement>, page: number) => {
+            this.props.onChangePage(page);
+        }
 
-    changeRowsPerPage: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement> = (event) => {
-        this.props.onChangeRowsPerPage(parseInt(event.target.value, 10));
-    }
+        changeRowsPerPage: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement> = (event) => {
+            this.props.onChangeRowsPerPage(parseInt(event.target.value, 10));
+        }
 
-    renderContextMenuTrigger = (item: T) =>
-        <Grid container justify="flex-end">
-            <IconButton onClick={event => this.props.onContextMenu(event, item)}>
-                <MoreVertIcon />
-            </IconButton>
-        </Grid>
+        renderContextMenuTrigger = (item: T) =>
+            <Grid container justify="flex-end">
+                <IconButton onClick={event => this.props.onContextMenu(event, item)}>
+                    <MoreVertIcon/>
+                </IconButton>
+            </Grid>
 
-    contextMenuColumn = {
-        name: "Actions",
-        selected: true,
-        key: "context-actions",
-        renderHeader: () => null,
-        render: this.renderContextMenuTrigger,
-        width: "auto"
-    };
-
-}
-
-type CssRules = "searchBox" | "toolbar";
-
-const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
-    searchBox: {
-        paddingBottom: theme.spacing.unit * 2
-    },
-    toolbar: {
-        paddingTop: theme.spacing.unit * 2
+        contextMenuColumn = {
+            name: "Actions",
+            selected: true,
+            key: "context-actions",
+            renderHeader: () => null,
+            render: this.renderContextMenuTrigger,
+            width: "auto"
+        };
     }
-});
-
-export default withStyles(styles)(DataExplorer);
+);
