From 08f35d9b26a06b70da6e54533782276617c5bed1 Mon Sep 17 00:00:00 2001 From: Janicki Artur Date: Thu, 9 Aug 2018 18:40:25 +0200 Subject: [PATCH] add default view component and use inside project and details panel Feature #13894 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- .../data-explorer/data-explorer.tsx | 109 +++++++++++------- src/components/default-view/default-view.tsx | 46 ++++++++ .../details-attribute/details-attribute.tsx | 21 ++-- .../details-panel/empty-details.tsx | 40 +------ src/views/project-panel/project-panel.tsx | 10 +- 5 files changed, 138 insertions(+), 88 deletions(-) create mode 100644 src/components/default-view/default-view.tsx diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx index 46d5fb50f3..4bd4a2374b 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -11,8 +11,10 @@ import { DataColumn } 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 { ProjectIcon } from '../icon/icon'; -type CssRules = "searchBox" | "toolbar"; +type CssRules = 'searchBox' | "toolbar" | 'defaultRoot' | 'defaultMessage' | 'defaultIcon'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ searchBox: { @@ -20,6 +22,18 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, toolbar: { paddingTop: theme.spacing.unit * 2 + }, + defaultRoot: { + position: 'absolute', + width: '100%', + top: '50%', + transform: 'translate(0%, -50%)' + }, + defaultMessage: { + fontSize: '1.75rem', + }, + defaultIcon: { + fontSize: '6rem' } }); @@ -31,6 +45,9 @@ interface DataExplorerDataProps { rowsPerPage: number; rowsPerPageOptions: number[]; page: number; +} + +interface DataExplorerActionProps { onSearch: (value: string) => void; onRowClick: (item: T) => void; onRowDoubleClick: (item: T) => void; @@ -43,48 +60,62 @@ interface DataExplorerDataProps { extractKey?: (item: T) => React.Key; } -type DataExplorerProps = DataExplorerDataProps & WithStyles; +type DataExplorerProps = DataExplorerDataProps & DataExplorerActionProps & WithStyles; export const DataExplorer = withStyles(styles)( class DataExplorerGeneric extends React.Component> { render() { - return - - -
- -
- -
-
- 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}/> - - {this.props.items.length > 0 && - - - } - -
; + const { + columns, onContextMenu, onFiltersChange, onSortToggle, extractKey, + rowsPerPage, rowsPerPageOptions, onColumnToggle, searchValue, onSearch, + items, itemsAvailable, onRowClick, onRowDoubleClick, classes + } = this.props; + return
+ { items.length > 0 ? ( + + + +
+ +
+ +
+
+ onRowClick(item)} + onContextMenu={onContextMenu} + onRowDoubleClick={(_, item: T) => onRowDoubleClick(item)} + onFiltersChange={onFiltersChange} + onSortToggle={onSortToggle} + extractKey={extractKey}/> + + + + + +
+ ) : ( + + )} +
; } changePage = (event: React.MouseEvent, page: number) => { diff --git a/src/components/default-view/default-view.tsx b/src/components/default-view/default-view.tsx new file mode 100644 index 0000000000..3bc3e5290d --- /dev/null +++ b/src/components/default-view/default-view.tsx @@ -0,0 +1,46 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from 'react'; +import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles'; +import { ArvadosTheme } from '../../common/custom-theme'; +import { Typography } from '@material-ui/core'; +import { IconType } from '../icon/icon'; +import * as classnames from "classnames"; + +type CssRules = 'root' | 'icon' | 'message'; + +const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ + root: { + textAlign: 'center' + }, + icon: { + color: theme.palette.grey["500"], + fontSize: '4.5rem' + }, + message: { + color: theme.palette.grey["500"] + } +}); + +export interface DefaultViewDataProps { + classRoot?: string; + messages: string[]; + classMessage?: string; + icon: IconType; + classIcon?: string; +} + +type DefaultViewProps = DefaultViewDataProps & WithStyles; + +export const DefaultView = withStyles(styles)( + ({ classes, classRoot, messages, classMessage, icon: Icon, classIcon }: DefaultViewProps) => + + + {messages.map((msg: string, index: number) => { + return {msg}; + })} + +); \ No newline at end of file diff --git a/src/components/details-attribute/details-attribute.tsx b/src/components/details-attribute/details-attribute.tsx index f9a5b05abf..9e58a3e4a0 100644 --- a/src/components/details-attribute/details-attribute.tsx +++ b/src/components/details-attribute/details-attribute.tsx @@ -45,14 +45,15 @@ interface DetailsAttributeDataProps { type DetailsAttributeProps = DetailsAttributeDataProps & WithStyles; -export const DetailsAttribute = withStyles(styles)(({ label, link, value, children, classes, classLabel, classValue }: DetailsAttributeProps) => - - {label} - { link - ? {value} - : - {value} - {children} - } - +export const DetailsAttribute = withStyles(styles)( + ({ label, link, value, children, classes, classLabel, classValue }: DetailsAttributeProps) => + + {label} + { link + ? {value} + : + {value} + {children} + } + ); diff --git a/src/views-components/details-panel/empty-details.tsx b/src/views-components/details-panel/empty-details.tsx index 51112ce571..47cb4030ed 100644 --- a/src/views-components/details-panel/empty-details.tsx +++ b/src/views-components/details-panel/empty-details.tsx @@ -3,44 +3,10 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { DefaultIcon, IconType, ProjectsIcon } from '../../components/icon/icon'; +import { DefaultIcon, ProjectsIcon } from '../../components/icon/icon'; import { EmptyResource } from '../../models/empty'; import { DetailsData } from "./details-data"; -import Typography from "@material-ui/core/Typography"; -import { StyleRulesCallback, WithStyles, withStyles } from "@material-ui/core/styles"; -import { ArvadosTheme } from "../../common/custom-theme"; -import Icon from "@material-ui/core/Icon/Icon"; - -type CssRules = 'container' | 'icon'; - -const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ - container: { - textAlign: 'center' - }, - icon: { - color: theme.palette.grey["500"], - fontSize: '72px' - } -}); - -export interface EmptyStateDataProps { - message: string; - icon: IconType; - details?: string; - children?: React.ReactNode; -} - -type EmptyStateProps = EmptyStateDataProps & WithStyles; - -const EmptyState = withStyles(styles)( - ({ classes, details, message, children, icon: Icon }: EmptyStateProps) => - - - {message} - {details && {details}} - {children && {children}} - -); +import { DefaultView } from '../../components/default-view/default-view'; export class EmptyDetails extends DetailsData { getIcon(className?: string) { @@ -48,6 +14,6 @@ export class EmptyDetails extends DetailsData { } getDetails() { - return ; + return ; } } diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index 0cd75ca3f8..991335dd7d 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -18,10 +18,16 @@ import { resourceLabel } from '../../common/labels'; import { ArvadosTheme } from '../../common/custom-theme'; import { renderName, renderStatus, renderType, renderOwner, renderFileSize, renderDate } from '../../views-components/data-explorer/renderers'; import { restoreBranch } from '../../store/navigation/navigation-action'; +import { relative } from 'path'; -type CssRules = "toolbar" | "button"; +type CssRules = 'root' | "toolbar" | "button"; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ + root: { + position: 'relative', + width: '100%', + height: '100%' + }, toolbar: { paddingBottom: theme.spacing.unit * 3, textAlign: "right" @@ -148,7 +154,7 @@ export const ProjectPanel = withStyles(styles)( class extends React.Component { render() { const { classes } = this.props; - return
+ return