Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>
import { ArvadosTheme } from "common/custom-theme";
import { createTree } from 'models/tree';
import { DataTableFilters } from 'components/data-table-filters/data-table-filters-tree';
import { ArvadosTheme } from "common/custom-theme";
import { createTree } from 'models/tree';
import { DataTableFilters } from 'components/data-table-filters/data-table-filters-tree';
-import { CloseIcon, MoreOptionsIcon } from 'components/icon/icon';
+import { CloseIcon, MaximizeIcon, MoreOptionsIcon } from 'components/icon/icon';
import { PaperProps } from '@material-ui/core/Paper';
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';
type CssRules = 'searchBox' | "toolbar" | "toolbarUnderTitle" | "footer" | "root" | 'moreOptionsButton' | 'title';
paddingBottom: theme.spacing.unit * 2
},
toolbar: {
paddingBottom: theme.spacing.unit * 2
},
toolbar: {
- paddingTop: theme.spacing.unit * 2
+ paddingTop: theme.spacing.unit,
+ paddingRight: theme.spacing.unit * 2,
},
toolbarUnderTitle: {
paddingTop: 0
},
toolbarUnderTitle: {
paddingTop: 0
title?: React.ReactNode;
paperKey?: string;
currentItemUuid: string;
title?: React.ReactNode;
paperKey?: string;
currentItemUuid: string;
}
interface DataExplorerActionProps<T> {
}
interface DataExplorerActionProps<T> {
onChangeRowsPerPage: (rowsPerPage: number) => void;
onLoadMore: (page: number) => void;
extractKey?: (item: T) => React.Key;
onChangeRowsPerPage: (rowsPerPage: number) => void;
onLoadMore: (page: number) => void;
extractKey?: (item: T) => React.Key;
- doHidePanel?: () => void;
-type DataExplorerProps<T> = DataExplorerDataProps<T> & DataExplorerActionProps<T> & WithStyles<CssRules>;
+type DataExplorerProps<T> = DataExplorerDataProps<T> &
+ DataExplorerActionProps<T> & WithStyles<CssRules> & MPVPanelProps;
export const DataExplorer = withStyles(styles)(
class DataExplorerGeneric<T> extends React.Component<DataExplorerProps<T>> {
export const DataExplorer = withStyles(styles)(
class DataExplorerGeneric<T> extends React.Component<DataExplorerProps<T>> {
rowsPerPage, rowsPerPageOptions, onColumnToggle, searchLabel, searchValue, onSearch,
items, itemsAvailable, onRowClick, onRowDoubleClick, classes,
dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput,
rowsPerPage, rowsPerPageOptions, onColumnToggle, searchLabel, searchValue, onSearch,
items, itemsAvailable, onRowClick, onRowDoubleClick, classes,
dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput,
- paperKey, fetchMode, currentItemUuid, title, doHidePanel, panelName
+ paperKey, fetchMode, currentItemUuid, title,
+ doHidePanel, doMaximizePanel, panelName, panelMaximized
} = this.props;
return <Paper className={classes.root} {...paperProps} key={paperKey}>
{title && <div className={classes.title}>{title}</div>}
} = this.props;
return <Paper className={classes.root} {...paperProps} key={paperKey}>
{title && <div className={classes.title}>{title}</div>}
columns={columns}
onColumnToggle={onColumnToggle} />}
</Grid>
columns={columns}
onColumnToggle={onColumnToggle} />}
</Grid>
+ { doMaximizePanel && !!!panelMaximized &&
+ <Tooltip title={`Maximize ${panelName || 'panel'}`} disableFocusListener>
+ <IconButton onClick={doMaximizePanel}><MaximizeIcon /></IconButton>
+ </Tooltip> }
{ doHidePanel &&
<Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
{ doHidePanel &&
<Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
- <Button onClick={doHidePanel}><CloseIcon /></Button>
+ <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
</Tooltip> }
</Toolbar>}
<DataTable
</Tooltip> }
</Toolbar>}
<DataTable
// Import FontAwesome icons
import { library } from '@fortawesome/fontawesome-svg-core';
import { faPencilAlt, faSlash } from '@fortawesome/free-solid-svg-icons';
// Import FontAwesome icons
import { library } from '@fortawesome/fontawesome-svg-core';
import { faPencilAlt, faSlash } from '@fortawesome/free-solid-svg-icons';
+import { CropFreeSharp } from '@material-ui/icons';
library.add(
faPencilAlt,
faSlash,
library.add(
faPencilAlt,
faSlash,
export const KeyIcon: IconType = (props) => <VpnKey {...props} />;
export const LogIcon: IconType = (props) => <SettingsEthernet {...props} />;
export const MailIcon: IconType = (props) => <Mail {...props} />;
export const KeyIcon: IconType = (props) => <VpnKey {...props} />;
export const LogIcon: IconType = (props) => <SettingsEthernet {...props} />;
export const MailIcon: IconType = (props) => <Mail {...props} />;
+export const MaximizeIcon: IconType = (props) => <CropFreeSharp {...props} />;
export const MoreOptionsIcon: IconType = (props) => <MoreVert {...props} />;
export const MoveToIcon: IconType = (props) => <Input {...props} />;
export const NewProjectIcon: IconType = (props) => <CreateNewFolder {...props} />;
export const MoreOptionsIcon: IconType = (props) => <MoreVert {...props} />;
export const MoveToIcon: IconType = (props) => <Input {...props} />;
export const NewProjectIcon: IconType = (props) => <CreateNewFolder {...props} />;
interface MPVHideablePanelDataProps {
name: string;
visible: boolean;
interface MPVHideablePanelDataProps {
name: string;
visible: boolean;
children: ReactNode;
}
interface MPVHideablePanelActionProps {
doHidePanel: () => void;
children: ReactNode;
}
interface MPVHideablePanelActionProps {
doHidePanel: () => void;
+ doMaximizePanel: () => void;
}
type MPVHideablePanelProps = MPVHideablePanelDataProps & MPVHideablePanelActionProps;
}
type MPVHideablePanelProps = MPVHideablePanelDataProps & MPVHideablePanelActionProps;
-const MPVHideablePanel = ({doHidePanel, name, visible, ...props}: MPVHideablePanelProps) =>
+const MPVHideablePanel = ({doHidePanel, doMaximizePanel, name, visible, maximized, ...props}: MPVHideablePanelProps) =>
- {React.cloneElement((props.children as ReactElement), { doHidePanel, panelName: name })}
+ {React.cloneElement((props.children as ReactElement), { doHidePanel, doMaximizePanel,panelName: name, panelMaximized: maximized })}
</>
: null;
interface MPVPanelDataProps {
panelName?: string;
</>
: null;
interface MPVPanelDataProps {
panelName?: string;
+ panelMaximized?: boolean;
}
interface MPVPanelActionProps {
doHidePanel?: () => void;
}
interface MPVPanelActionProps {
doHidePanel?: () => void;
+ doMaximizePanel?: () => void;
}
// Props received by panel implementors
}
// Props received by panel implementors
type MPVPanelContentProps = {children: ReactElement} & MPVPanelProps & GridProps;
// Grid item compatible component for layout and MPV props passing
type MPVPanelContentProps = {children: ReactElement} & MPVPanelProps & GridProps;
// Grid item compatible component for layout and MPV props passing
-export const MPVPanelContent = ({doHidePanel, panelName, ...props}: MPVPanelContentProps) =>
+export const MPVPanelContent = ({doHidePanel, doMaximizePanel, panelName, panelMaximized, ...props}: MPVPanelContentProps) =>
- {React.cloneElement(props.children, { doHidePanel, panelName })}
+ {React.cloneElement(props.children, { doHidePanel, doMaximizePanel, panelName, panelMaximized })}
</Grid>;
export interface MPVPanelState {
</Grid>;
export interface MPVPanelState {
...panelVisibility.slice(idx+1)
])
};
...panelVisibility.slice(idx+1)
])
};
+ const maximizeFn = (idx: number) => () => {
+ // Maximize X == hide all but X
+ setPanelVisibility([
+ ...panelVisibility.slice(0, idx).map(() => false),
+ true,
+ ...panelVisibility.slice(idx+1).map(() => false),
+ ])
+ };
const toggleIcon = panelVisibility[idx]
? <VisibleIcon className={classNames(classes.buttonIcon)} />
: <InvisibleIcon className={classNames(classes.buttonIcon)}/>
const toggleIcon = panelVisibility[idx]
? <VisibleIcon className={classNames(classes.buttonIcon)} />
: <InvisibleIcon className={classNames(classes.buttonIcon)}/>
const toggleTooltip = panelVisibility[idx]
? `Hide ${panelName} panel`
: `Show ${panelName} panel`;
const toggleTooltip = panelVisibility[idx]
? `Hide ${panelName} panel`
: `Show ${panelName} panel`;
+ const panelIsMaximized = panelVisibility[idx] &&
+ panelVisibility.filter(e => e).length === 1;
- <MPVHideablePanel visible={panelVisibility[idx]} name={panelName} doHidePanel={toggleFn(idx)}>
+ <MPVHideablePanel visible={panelVisibility[idx]} name={panelName}
+ maximized={panelIsMaximized}
+ doHidePanel={toggleFn(idx)} doMaximizePanel={maximizeFn(idx)}>
{children[idx]}
</MPVHideablePanel>;
panels = [...panels, aPanel];
{children[idx]}
</MPVHideablePanel>;
panels = [...panels, aPanel];
import React from 'react';
import {
StyleRulesCallback, WithStyles, withStyles, Card,
import React from 'react';
import {
StyleRulesCallback, WithStyles, withStyles, Card,
- CardHeader, IconButton, CardContent, Grid, Chip, Typography, Tooltip, Button
+ CardHeader, IconButton, CardContent, Grid, Chip, Typography, Tooltip
} from '@material-ui/core';
import { ArvadosTheme } from 'common/custom-theme';
import { CloseIcon, MoreOptionsIcon, ProcessIcon } from 'components/icon/icon';
} from '@material-ui/core';
import { ArvadosTheme } from 'common/custom-theme';
import { CloseIcon, MoreOptionsIcon, ProcessIcon } from 'components/icon/icon';
</Tooltip>
{ doHidePanel &&
<Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
</Tooltip>
{ doHidePanel &&
<Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
- <Button onClick={doHidePanel}><CloseIcon /></Button>
+ <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
messages={DEFAULT_VIEW_MESSAGES} />
}
doHidePanel={props.doHidePanel}
messages={DEFAULT_VIEW_MESSAGES} />
}
doHidePanel={props.doHidePanel}
+ doMaximizePanel={props.doMaximizePanel}
+ panelMaximized={props.panelMaximized}
panelName={props.panelName} />;
};
\ No newline at end of file
panelName={props.panelName} />;
};
\ No newline at end of file