X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/920ccdc45d7c3a8517b430ab17af53c3fc23cf6d..4b75b09d1c75d6796e75efc55e7b06917834b63e:/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 4175fbc6..051f5d34 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -2,42 +2,63 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +import React from 'react'; import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, WithStyles, TablePagination, IconButton, Tooltip, Button } from '@material-ui/core'; -import { ColumnSelector } from "~/components/column-selector/column-selector"; -import { DataTable, DataColumns } from "~/components/data-table/data-table"; -import { DataColumn, SortDirection } from "~/components/data-table/data-column"; -import { SearchInput } from '~/components/search-input/search-input'; -import { ArvadosTheme } from "~/common/custom-theme"; -import { createTree } from '~/models/tree'; -import { DataTableFilters } from '~/components/data-table-filters/data-table-filters-tree'; -import { MoreOptionsIcon } from '~/components/icon/icon'; +import { ColumnSelector } from "components/column-selector/column-selector"; +import { DataTable, DataColumns, DataTableFetchMode } from "components/data-table/data-table"; +import { DataColumn } from "components/data-table/data-column"; +import { SearchInput } from 'components/search-input/search-input'; +import { ArvadosTheme } from "common/custom-theme"; +import { createTree } from 'models/tree'; +import { DataTableFilters } from 'components/data-table-filters/data-table-filters-tree'; +import { CloseIcon, MaximizeIcon, MoreOptionsIcon } from 'components/icon/icon'; import { PaperProps } from '@material-ui/core/Paper'; +import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; -type CssRules = 'searchBox' | "toolbar" | "footer" | "root" | 'moreOptionsButton'; +type CssRules = 'searchBox' | 'headerMenu' | "toolbar" | "footer" | "root" | 'moreOptionsButton' | 'title' | 'dataTable' | 'container'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ searchBox: { paddingBottom: theme.spacing.unit * 2 }, toolbar: { - paddingTop: theme.spacing.unit * 2 + paddingTop: theme.spacing.unit, + paddingRight: theme.spacing.unit * 2, }, footer: { overflow: 'auto' }, root: { - height: '100%' + height: '100%', }, moreOptionsButton: { padding: 0 + }, + title: { + display: 'inline-block', + paddingLeft: theme.spacing.unit * 3, + paddingTop: theme.spacing.unit * 3, + fontSize: '18px' + }, + dataTable: { + height: '100%', + overflow: 'auto', + }, + container: { + height: '100%', + }, + headerMenu: { + float: 'right', + display: 'inline-block' } }); interface DataExplorerDataProps { + fetchMode: DataTableFetchMode; items: T[]; itemsAvailable: number; columns: DataColumns; + searchLabel?: string; searchValue: string; rowsPerPage: number; rowsPerPageOptions: number[]; @@ -49,6 +70,10 @@ interface DataExplorerDataProps { paperProps?: PaperProps; actions?: React.ReactNode; hideSearchInput?: boolean; + title?: React.ReactNode; + paperKey?: string; + currentItemUuid: string; + elementPath?: string; } interface DataExplorerActionProps { @@ -62,40 +87,67 @@ interface DataExplorerActionProps { onFiltersChange: (filters: DataTableFilters, column: DataColumn) => void; onChangePage: (page: number) => void; onChangeRowsPerPage: (rowsPerPage: number) => void; + onLoadMore: (page: number) => void; extractKey?: (item: T) => React.Key; } -type DataExplorerProps = DataExplorerDataProps & DataExplorerActionProps & WithStyles; +type DataExplorerProps = DataExplorerDataProps & + DataExplorerActionProps & WithStyles & MPVPanelProps; export const DataExplorer = withStyles(styles)( class DataExplorerGeneric extends React.Component> { + componentDidMount() { if (this.props.onSetColumns) { this.props.onSetColumns(this.props.columns); } } + render() { const { columns, onContextMenu, onFiltersChange, onSortToggle, working, extractKey, - rowsPerPage, rowsPerPageOptions, onColumnToggle, searchValue, onSearch, + rowsPerPage, rowsPerPageOptions, onColumnToggle, searchLabel, searchValue, onSearch, items, itemsAvailable, onRowClick, onRowDoubleClick, classes, - dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput + dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput, + paperKey, fetchMode, currentItemUuid, title, + doHidePanel, doMaximizePanel, panelName, panelMaximized, elementPath } = this.props; - return - - - {!hideSearchInput &&
- -
} - {actions} - {!hideColumnSelector && } -
-
- + +
+ {title && {title}} + { + (!hideColumnSelector || !hideSearchInput || !!actions) && + + + + {!hideSearchInput &&
+ {!hideSearchInput && } +
} + {actions} + {!hideColumnSelector && } +
+ { doMaximizePanel && !panelMaximized && + + + } + { doHidePanel && + + + } +
+
+ } +
+ onRowClick(item)} @@ -106,19 +158,35 @@ export const DataExplorer = withStyles(styles)( extractKey={extractKey} working={working} defaultView={dataTableDefaultView} - /> - - - + + { + elementPath && + + + {elementPath} + + + } + + {fetchMode === DataTableFetchMode.PAGINATED ? + // Disable next button on empty lists since that's not default behavior + nextIconButtonProps={(itemsAvailable > 0) ? {} : {disabled: true}} + component="div" /> : } - + +
; } @@ -130,6 +198,10 @@ export const DataExplorer = withStyles(styles)( this.props.onChangeRowsPerPage(parseInt(event.target.value, 10)); } + loadMore = () => { + this.props.onLoadMore(this.props.page + 1); + } + renderContextMenuTrigger = (item: T) => @@ -143,7 +215,6 @@ export const DataExplorer = withStyles(styles)( name: "Actions", selected: true, configurable: false, - sortDirection: SortDirection.NONE, filters: createTree(), key: "context-actions", render: this.renderContextMenuTrigger