X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9e4aa2fd44835698c0a3e6f321a2cf88b6f11939..c918b794f369e2d38f85e2c2ca7bb11fc69555fe:/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 44868800..9cc1cc95 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -3,23 +3,31 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { Grid, Paper, Toolbar } from '@material-ui/core'; +import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, Theme, WithStyles, TablePagination, Table, IconButton } from '@material-ui/core'; +import MoreVertIcon from "@material-ui/icons/MoreVert"; import ContextMenu, { ContextMenuActionGroup, ContextMenuAction } from "../../components/context-menu/context-menu"; import ColumnSelector from "../../components/column-selector/column-selector"; -import DataTable from "../../components/data-table/data-table"; +import DataTable, { DataColumns } from "../../components/data-table/data-table"; import { mockAnchorFromMouseEvent } from "../../components/popover/helpers"; -import { DataColumn, toggleSortDirection } from "../../components/data-table/data-column"; +import { DataColumn } from "../../components/data-table/data-column"; import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters'; +import SearchInput from '../search-input/search-input'; interface DataExplorerProps { items: T[]; - columns: Array>; + columns: DataColumns; contextActions: ContextMenuActionGroup[]; + searchValue: string; + rowsPerPage: number; + page: number; + onSearch: (value: string) => void; onRowClick: (item: T) => void; onColumnToggle: (column: DataColumn) => void; onContextAction: (action: ContextMenuAction, item: T) => void; onSortToggle: (column: DataColumn) => void; onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn) => void; + onChangePage: (page: number) => void; + onChangeRowsPerPage: (rowsPerPage: number) => void; } interface DataExplorerState { @@ -29,7 +37,7 @@ interface DataExplorerState { }; } -class DataExplorer extends React.Component, DataExplorerState> { +class DataExplorer extends React.Component & WithStyles, DataExplorerState> { state: DataExplorerState = { contextMenu: {} }; @@ -41,21 +49,42 @@ class DataExplorer extends React.Component, DataExplorer actions={this.props.contextActions} onActionClick={this.callAction} onClose={this.closeContextMenu} /> - - - - + + {this.props.items.length > 0 && + +
+ +
+ +
} +
this.props.onRowClick(item)} onRowContextMenu={this.openContextMenu} onFiltersChange={this.props.onFiltersChange} onSortToggle={this.props.onSortToggle} /> - + + {this.props.items.length > 0 && + + + } + ; } @@ -81,6 +110,50 @@ class DataExplorer extends React.Component, DataExplorer } } + changePage = (event: React.MouseEvent | null, page: number) => { + this.props.onChangePage(page); + } + + changeRowsPerPage: React.ChangeEventHandler = (event) => { + this.props.onChangeRowsPerPage(parseInt(event.target.value, 10)); + } + + renderContextMenuTrigger = (item: T) => + + this.openContextMenuWithTrigger(event, item)}> + + + + + openContextMenuWithTrigger = (event: React.MouseEvent, item: T) => { + event.preventDefault(); + this.setState({ + contextMenu: { + anchorEl: event.currentTarget, + item + } + }); + } + + contextMenuColumn = { + name: "Actions", + selected: true, + key: "context-actions", + renderHeader: () => null, + render: this.renderContextMenuTrigger + }; + } -export default DataExplorer; +type CssRules = "searchBox" | "toolbar"; + +const styles: StyleRulesCallback = (theme: Theme) => ({ + searchBox: { + paddingBottom: theme.spacing.unit * 2 + }, + toolbar: { + paddingTop: theme.spacing.unit * 2 + } +}); + +export default withStyles(styles)(DataExplorer);