X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/7ef76c77956b9938322e23e8981bbf2cee2acff6..5e9c2244747eff9fc02ff3c0d140bdde5e0b6845:/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 d3d26708..c7a296a6 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -11,22 +11,25 @@ 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 { + CloseIcon, + IconType, + MaximizeIcon, + UnMaximizeIcon, + 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" | "toolbarUnderTitle" | "footer" | "root" | 'moreOptionsButton' | 'title' | 'dataTable' | 'container'; +type CssRules = 'searchBox' | 'headerMenu' | "toolbar" | "footer" | "root" | 'moreOptionsButton' | 'title' | 'dataTable' | 'container'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ searchBox: { - paddingBottom: theme.spacing.unit * 2 + paddingBottom: 0, }, toolbar: { - paddingTop: theme.spacing.unit, - paddingRight: theme.spacing.unit * 2, - }, - toolbarUnderTitle: { - paddingTop: 0 + paddingTop: 0, + paddingRight: theme.spacing.unit, }, footer: { overflow: 'auto' @@ -38,8 +41,9 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ padding: 0 }, title: { - paddingLeft: theme.spacing.unit * 3, - paddingTop: theme.spacing.unit * 3, + display: 'inline-block', + paddingLeft: theme.spacing.unit * 2, + paddingTop: theme.spacing.unit * 2, fontSize: '18px' }, dataTable: { @@ -49,6 +53,10 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ container: { height: '100%', }, + headerMenu: { + float: 'right', + display: 'inline-block', + } }); interface DataExplorerDataProps { @@ -62,8 +70,11 @@ interface DataExplorerDataProps { rowsPerPageOptions: number[]; page: number; contextMenuColumn: boolean; - dataTableDefaultView?: React.ReactNode; + defaultViewIcon?: IconType; + defaultViewMessages?: string[]; working?: boolean; + currentRefresh?: string; + currentRoute?: string; hideColumnSelector?: boolean; paperProps?: PaperProps; actions?: React.ReactNode; @@ -71,6 +82,7 @@ interface DataExplorerDataProps { title?: React.ReactNode; paperKey?: string; currentItemUuid: string; + elementPath?: string; } interface DataExplorerActionProps { @@ -93,45 +105,97 @@ type DataExplorerProps = DataExplorerDataProps & export const DataExplorer = withStyles(styles)( class DataExplorerGeneric extends React.Component> { + state = { + showLoading: false, + prevRefresh: '', + prevRoute: '', + }; + + componentDidUpdate(prevProps: DataExplorerProps) { + const currentRefresh = this.props.currentRefresh || ''; + const currentRoute = this.props.currentRoute || ''; + + if (currentRoute !== this.state.prevRoute) { + // Component already mounted, but the user comes from a route change, + // like browsing through a project hierarchy. + this.setState({ + showLoading: this.props.working, + prevRoute: currentRoute, + }); + } + + if (currentRefresh !== this.state.prevRefresh) { + // Component already mounted, but the user just clicked the + // refresh button. + this.setState({ + showLoading: this.props.working, + prevRefresh: currentRefresh, + }); + } + if (this.state.showLoading && !this.props.working) { + this.setState({ + showLoading: false, + }); + } + } + componentDidMount() { if (this.props.onSetColumns) { this.props.onSetColumns(this.props.columns); } + // Component just mounted, so we need to show the loading indicator. + this.setState({ + showLoading: this.props.working, + prevRefresh: this.props.currentRefresh || '', + prevRoute: this.props.currentRoute || '', + }); } + render() { const { - columns, onContextMenu, onFiltersChange, onSortToggle, working, extractKey, + columns, onContextMenu, onFiltersChange, onSortToggle, extractKey, rowsPerPage, rowsPerPageOptions, onColumnToggle, searchLabel, searchValue, onSearch, items, itemsAvailable, onRowClick, onRowDoubleClick, classes, - dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput, + defaultViewIcon, defaultViewMessages, hideColumnSelector, actions, paperProps, hideSearchInput, paperKey, fetchMode, currentItemUuid, title, - doHidePanel, doMaximizePanel, panelName, panelMaximized + doHidePanel, doMaximizePanel, doUnMaximizePanel, panelName, panelMaximized, elementPath } = this.props; - return + + return - {title && {title}} - {(!hideColumnSelector || !hideSearchInput) && - -
- {!hideSearchInput && } -
- {actions} - {!hideColumnSelector && } -
- { doMaximizePanel && !panelMaximized && - - - } - { doHidePanel && - - - } -
} +
+ {title && {title}} + { + (!hideColumnSelector || !hideSearchInput || !!actions) && + + + {!hideSearchInput &&
+ {!hideSearchInput && } +
} + {actions} + {!hideColumnSelector && } + { doUnMaximizePanel && panelMaximized && + + + } + { doMaximizePanel && !panelMaximized && + + + } + { doHidePanel && + + + } +
+
+ } +
- + { + elementPath && + + + {elementPath} + + + } + {fetchMode === DataTableFetchMode.PAGINATED ?