interface AttributeDataProps {
label: string;
+ value?: string;
+ link?: string;
}
type AttributeProps = AttributeDataProps & WithStyles<CssRules>;
class Attribute extends React.Component<AttributeProps> {
+ hasLink() {
+ return !!this.props.link;
+ }
+
render() {
- const { label, children, classes } = this.props;
+ const { label, link, value, children, classes } = this.props;
return <Typography component="div" className={classes.attribute}>
- <span className={classes.label}>{label}</span>
- <span className={classes.value}>{children}</span>
- </Typography>;
+ <Typography component="span" className={classes.label}>{label}</Typography>
+ { this.hasLink() ? (
+ <a href='{link}' className={classes.link} target='_blank'>{value}</a>
+ ) : (
+ <Typography component="span" className={classes.value}>
+ {value}
+ {children}
+ </Typography>
+ )}
+ </Typography>;
}
}
-type CssRules = 'attribute' | 'label' | 'value';
+type CssRules = 'attribute' | 'label' | 'value' | 'link';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
attribute: {
+ height: '24px',
display: 'flex',
alignItems: 'center',
marginBottom: theme.spacing.unit
value: {
display: 'flex',
alignItems: 'center'
+ },
+ link: {
+ color: theme.palette.primary.main,
+ textDecoration: 'none'
}
});
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import Typography from '@material-ui/core/Typography';
+import { WithStyles, withStyles, StyleRulesCallback } from '@material-ui/core/styles';
+import { ArvadosTheme } from 'src/common/custom-theme';
+import IconBase, { IconTypes } from '../icon/icon';
+
+export interface EmptyStateDataProps {
+ message: string;
+ icon: IconTypes;
+ details?: string;
+}
+
+type EmptyStateProps = EmptyStateDataProps & WithStyles<CssRules>;
+
+class EmptyState extends React.Component<EmptyStateProps, {}> {
+
+ render() {
+ const { classes, message, details, icon, children } = this.props;
+ return (
+ <Typography className={classes.container} component="div">
+ <IconBase icon={icon} className={classes.icon} />
+ <Typography variant="body1" gutterBottom>{message}</Typography>
+ { details && <Typography gutterBottom>{details}</Typography> }
+ { children && <Typography gutterBottom>{children}</Typography> }
+ </Typography>
+ );
+ }
+
+}
+
+type CssRules = 'container' | 'icon';
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ container: {
+ textAlign: 'center'
+ },
+ icon: {
+ color: theme.palette.grey["500"],
+ fontSize: '72px'
+ }
+});
+
+export default withStyles(styles)(EmptyState);
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import * as classnames from "classnames";
+import CloseAnnouncement from '@material-ui/icons/Announcement';
+import CloseIcon from '@material-ui/icons/Close';
+import FolderIcon from '@material-ui/icons/Folder';
+
+export enum IconTypes {
+ ANNOUNCEMENT = 'announcement',
+ FOLDER = 'folder',
+ CLOSE = 'close',
+ PROJECT = 'project',
+ COLLECTION = 'collection',
+ PROCESS = 'process'
+}
+
+interface IconBaseDataProps {
+ icon: IconTypes;
+ className?: string;
+}
+
+type IconBaseProps = IconBaseDataProps;
+
+interface IconBaseState {
+ icon: IconTypes;
+}
+
+const getSpecificIcon = (props: any) => ({
+ announcement: <CloseAnnouncement className={props.className} />,
+ folder: <FolderIcon className={props.className} />,
+ close: <CloseIcon className={props.className} />,
+ project: <i className={classnames([props.className, 'fas fa-folder fa-lg'])} />,
+ collection: <i className={classnames([props.className, 'fas fa-archive fa-lg'])} />,
+ process: <i className={classnames([props.className, 'fas fa-cogs fa-lg'])} />
+});
+
+class IconBase extends React.Component<IconBaseProps, IconBaseState> {
+ state = {
+ icon: IconTypes.FOLDER,
+ };
+
+ render() {
+ return getSpecificIcon(this.props)[this.props.icon];
+ }
+}
+
+export default IconBase;
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { unionize, ofType, UnionOf } from "unionize";
+import CommonResourceService, { Resource } from "../../common/api/common-resource-service";
+import { ResourceKind } from "../../models/kinds";
+import { Dispatch } from "redux";
+import { groupsService } from "../../services/services";
+import { serverApi } from "../../common/api/server-api";
+
+const actions = unionize({
+ TOGGLE_DETAILS_PANEL: ofType<{}>(),
+ LOAD_DETAILS: ofType<{ uuid: string, kind: ResourceKind }>(),
+ LOAD_DETAILS_SUCCESS: ofType<{ item: Resource }>(),
+}, { tag: 'type', value: 'payload' });
+
+export default actions;
+
+export type DetailsPanelAction = UnionOf<typeof actions>;
+
+export const loadDetails = (uuid: string, kind: ResourceKind) =>
+ (dispatch: Dispatch) => {
+ dispatch(actions.LOAD_DETAILS({ uuid, kind }));
+ getService(kind)
+ .get(uuid)
+ .then(project => {
+ dispatch(actions.LOAD_DETAILS_SUCCESS({ item: project }));
+ });
+ };
+
+const getService = (kind: ResourceKind) => {
+ switch (kind) {
+ case ResourceKind.Project:
+ return new CommonResourceService(serverApi, "groups");
+ case ResourceKind.Collection:
+ return new CommonResourceService(serverApi, "collections");
+ default:
+ return new CommonResourceService(serverApi, "");
+ }
+};
+
+
+
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Resource } from "../../common/api/common-resource-service";
+import actions, { DetailsPanelAction } from "./details-panel-action";
+
+export interface DetailsPanelState {
+ item: Resource | null;
+ isOpened: boolean;
+}
+
+const initialState = {
+ item: null,
+ isOpened: false
+};
+
+const reducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) =>
+ actions.match(action, {
+ default: () => state,
+ LOAD_DETAILS: () => state,
+ LOAD_DETAILS_SUCCESS: ({ item }) => ({ ...state, item }),
+ TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened })
+ });
+
+export default reducer;
import { push } from "react-router-redux";
import { TreeItemStatus } from "../../components/tree/tree";
import { findTreeItem } from "../project/project-reducer";
-import { Resource, ResourceKind } from "../../models/resource";
+import { Resource, ResourceKind as R } from "../../models/resource";
import sidePanelActions from "../side-panel/side-panel-action";
import dataExplorerActions from "../data-explorer/data-explorer-action";
import { PROJECT_PANEL_ID } from "../../views/project-panel/project-panel";
import { RootState } from "../store";
import { sidePanelData } from "../side-panel/side-panel-reducer";
+import { loadDetails } from "../details-panel/details-panel-action";
+import { ResourceKind } from "../../models/kinds";
export const getResourceUrl = (resource: Resource): string => {
switch (resource.kind) {
- case ResourceKind.PROJECT: return `/projects/${resource.uuid}`;
- case ResourceKind.COLLECTION: return `/collections/${resource.uuid}`;
+ case R.PROJECT: return `/projects/${resource.uuid}`;
+ case R.COLLECTION: return `/collections/${resource.uuid}`;
default: return "";
}
};
import dataExplorerReducer, { DataExplorerState } from './data-explorer/data-explorer-reducer';
import collectionsReducer, { CollectionState } from "./collection/collection-reducer";
import { projectPanelMiddleware } from '../store/project-panel/project-panel-middleware';
+import detailsPanelReducer, { DetailsPanelState } from './details-panel/details-panel-reducer';
const composeEnhancers =
(process.env.NODE_ENV === 'development' &&
router: RouterState;
dataExplorer: DataExplorerState;
sidePanel: SidePanelState;
+ detailsPanel: DetailsPanelState;
}
const rootReducer = combineReducers({
collections: collectionsReducer,
router: routerReducer,
dataExplorer: dataExplorerReducer,
- sidePanel: sidePanelReducer
+ sidePanel: sidePanelReducer,
+ detailsPanel: detailsPanelReducer
});
import * as React from 'react';
import Drawer from '@material-ui/core/Drawer';
import IconButton from "@material-ui/core/IconButton";
-import CloseIcon from '@material-ui/icons/Close';
-import FolderIcon from '@material-ui/icons/Folder';
import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
import { ArvadosTheme } from '../../common/custom-theme';
import Attribute from '../../components/attribute/attribute';
import Typography from '@material-ui/core/Typography';
import Grid from '@material-ui/core/Grid';
import * as classnames from "classnames";
+import { connect, Dispatch } from 'react-redux';
+import EmptyState from '../../components/empty-state/empty-state';
+import { RootState } from '../../store/store';
+import actions from "../../store/details-panel/details-panel-action";
+import { Resource } from '../../common/api/common-resource-service';
+import { ResourceKind } from '../../models/kinds';
+import { ProjectResource } from '../../models/project';
+import { CollectionResource } from '../../models/collection';
+import IconBase, { IconTypes } from '../../components/icon/icon';
+import { ProcessResource } from '../../models/process';
-export interface DetailsPanelProps {
+export interface DetailsPanelDataProps {
onCloseDrawer: () => void;
isOpened: boolean;
+ icon: IconTypes;
+ title: string;
+ details: React.ReactElement<any>;
}
-class DetailsPanel extends React.Component<DetailsPanelProps & WithStyles<CssRules>, {}> {
- state = {
- tabsValue: 0,
- };
+type DetailsPanelProps = DetailsPanelDataProps & WithStyles<CssRules>;
- handleChange = (event: any, value: boolean) => {
- this.setState({ tabsValue: value });
- }
-
- renderTabContainer = (children: React.ReactElement<any>) =>
+class DetailsPanel extends React.Component<DetailsPanelProps, {}> {
+ state = {
+ tabsValue: 0
+ };
+
+ handleChange = (event: any, value: boolean) => {
+ this.setState({ tabsValue: value });
+ }
+
+ renderTabContainer = (children: React.ReactElement<any>) =>
<Typography className={this.props.classes.tabContainer} component="div">
{children}
</Typography>
- render() {
- const { classes, onCloseDrawer, isOpened } = this.props;
- const { tabsValue } = this.state;
+ render() {
+ const { classes, onCloseDrawer, isOpened, icon, title, details } = this.props;
+ const { tabsValue } = this.state;
return (
- <div className={classnames([classes.container, { [classes.opened]: isOpened }])}>
+ <Typography component="div" className={classnames([classes.container, { [classes.opened]: isOpened }])}>
<Drawer variant="permanent" anchor="right" classes={{ paper: classes.drawerPaper }}>
- <Typography component="div" className={classes.headerContainer}>
- <Grid container alignItems='center' justify='space-around'>
- <i className="fas fa-cogs fa-lg" />
- <Typography variant="title">
- Tutorial pipeline
- </Typography>
+ <Typography component="div" className={classes.headerContainer}>
+ <Grid container alignItems='center' justify='space-around'>
+ <IconBase className={classes.headerIcon} icon={icon} />
+ <Typography variant="title">
+ {title}
+ </Typography>
<IconButton color="inherit" onClick={onCloseDrawer}>
- <CloseIcon />
- </IconButton>
- </Grid>
- </Typography>
- <Tabs value={tabsValue} onChange={this.handleChange}>
- <Tab disableRipple label="Details" />
- <Tab disableRipple label="Activity" />
- </Tabs>
+ <IconBase icon={IconTypes.CLOSE} />
+ </IconButton>
+ </Grid>
+ </Typography>
+ <Tabs value={tabsValue} onChange={this.handleChange}>
+ <Tab disableRipple label="Details" />
+ <Tab disableRipple label="Activity" />
+ </Tabs>
{tabsValue === 0 && this.renderTabContainer(
<Grid container direction="column">
- <Attribute label="Type">Process</Attribute>
- <Attribute label="Size">---</Attribute>
- <Attribute label="Location">
- <FolderIcon />
- Projects
- </Attribute>
- <Attribute label="Owner">me</Attribute>
- </Grid>
- )}
- {tabsValue === 1 && this.renderTabContainer(
- <Grid container direction="column">
- <Attribute label="Type">Process</Attribute>
- <Attribute label="Size">---</Attribute>
- <Attribute label="Location">
- <FolderIcon />
- Projects
- </Attribute>
- <Attribute label="Owner">me</Attribute>
+ {details}
</Grid>
- )}
+ )}
+ {tabsValue === 1 && this.renderTabContainer(
+ <Grid container direction="column" />
+ )}
</Drawer>
- </div>
+ </Typography>
);
}
}
-type CssRules = 'drawerPaper' | 'container' | 'opened' | 'headerContainer' | 'tabContainer';
+type CssRules = 'drawerPaper' | 'container' | 'opened' | 'headerContainer' | 'headerIcon' | 'tabContainer';
const drawerWidth = 320;
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
- container: {
+ container: {
width: 0,
- position: 'relative',
+ position: 'relative',
height: 'auto',
transition: 'width 0.5s ease',
'&$opened': {
drawerPaper: {
position: 'relative',
width: drawerWidth
- },
- headerContainer: {
+ },
+ headerContainer: {
color: theme.palette.grey["600"],
- margin: `${theme.spacing.unit}px 0`,
- '& .fa-cogs': {
- fontSize: "24px"
- }
- },
- tabContainer: {
- padding: theme.spacing.unit * 3
- }
+ margin: `${theme.spacing.unit}px 0`
+ },
+ headerIcon: {
+ fontSize: "34px"
+ },
+ tabContainer: {
+ padding: theme.spacing.unit * 3
+ }
+});
+
+type DetailsPanelResource = ProjectResource | CollectionResource | ProcessResource;
+
+const getIcon = (res: DetailsPanelResource) => {
+ switch (res.kind) {
+ case ResourceKind.Project:
+ return IconTypes.FOLDER;
+ case ResourceKind.Collection:
+ return IconTypes.COLLECTION;
+ case ResourceKind.Process:
+ return IconTypes.PROCESS;
+ default:
+ return IconTypes.FOLDER;
+ }
+};
+
+const getDetails = (res: DetailsPanelResource) => {
+ switch (res.kind) {
+ case ResourceKind.Project:
+ return <div>
+ <Attribute label='Type' value='Project' />
+ <Attribute label='Size' value='---' />
+ <Attribute label="Location">
+ <IconBase icon={IconTypes.FOLDER} />
+ Projects
+ </Attribute>
+ <Attribute label='Owner' value='me' />
+ <Attribute label='Last modified' value='5:25 PM 5/23/2018' />
+ <Attribute label='Created at' value='1:25 PM 5/23/2018' />
+ <Attribute label='File size' value='1.4 GB' />
+ </div>;
+ case ResourceKind.Collection:
+ return <div>
+ <Attribute label='Type' value='Data Collection' />
+ <Attribute label='Size' value='---' />
+ <Attribute label="Location">
+ <IconBase icon={IconTypes.FOLDER} />
+ Projects
+ </Attribute>
+ <Attribute label='Owner' value='me' />
+ <Attribute label='Last modified' value='5:25 PM 5/23/2018' />
+ <Attribute label='Created at' value='1:25 PM 5/23/2018' />
+ <Attribute label='Number of files' value='20' />
+ <Attribute label='Content size' value='54 MB' />
+ <Attribute label='Collection UUID' link='http://www.google.pl' value='nfnz05wp63ibf8w' />
+ <Attribute label='Content address' link='http://www.google.pl' value='nfnz05wp63ibf8w' />
+ <Attribute label='Creator' value='Chrystian' />
+ <Attribute label='Used by' value='---' />
+ </div>;
+ case ResourceKind.Process:
+ return <div>
+ <Attribute label='Type' value='Process' />
+ <Attribute label='Size' value='---' />
+ <Attribute label="Location">
+ <IconBase icon={IconTypes.FOLDER} />
+ Projects
+ </Attribute>
+ <Attribute label='Owner' value='me' />
+ <Attribute label='Last modified' value='5:25 PM 5/23/2018' />
+ <Attribute label='Created at' value='1:25 PM 5/23/2018' />
+ <Attribute label='Finished at' value='1:25 PM 5/23/2018' />
+ <Attribute label='Outputs' link='http://www.google.pl' value='Container Output' />
+ <Attribute label='UUID' link='http://www.google.pl' value='nfnz05wp63ibf8w' />
+ <Attribute label='Container UUID' link='http://www.google.pl' value='nfnz05wp63ibf8w' />
+ <Attribute label='Priority' value='1' />
+ <Attribute label='Runtime constrains' value='1' />
+ <Attribute label='Docker image locator' link='http://www.google.pl' value='3838388226321' />
+ </div>;
+ default:
+ return getEmptyState();
+ }
+};
+
+const getEmptyState = () => {
+ return <EmptyState icon={ IconTypes.ANNOUNCEMENT }
+ message='Select a file or folder to view its details.' />;
+};
+
+const mapStateToProps = ({ detailsPanel }: RootState) => {
+ const { isOpened, item } = detailsPanel;
+ return {
+ isOpened,
+ title: item ? (item as DetailsPanelResource).name : 'Projects',
+ icon: item ? getIcon(item as DetailsPanelResource) : IconTypes.FOLDER,
+ details: item ? getDetails(item as DetailsPanelResource) : getEmptyState()
+ };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch) => ({
+ onCloseDrawer: () => {
+ dispatch(actions.TOGGLE_DETAILS_PANEL());
+ }
});
-export default withStyles(styles)(DetailsPanel);
\ No newline at end of file
+const DetailsPanelContainer = connect(mapStateToProps, mapDispatchToProps)(DetailsPanel);
+
+export default withStyles(styles)(DetailsPanelContainer);
\ No newline at end of file
import configureStore from "../../store/store";
import createBrowserHistory from "history/createBrowserHistory";
import { ConnectedRouter } from "react-router-redux";
-import { MuiThemeProvider } from '@material-ui/core';
+import { MuiThemeProvider } from '@material-ui/core/styles';
import { CustomTheme } from '../../common/custom-theme';
const history = createBrowserHistory();
import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import { connect, DispatchProp } from "react-redux";
-import { Route, Switch, RouteComponentProps, withRouter } from "react-router";
+import { Route, Switch, RouteComponentProps } from "react-router";
import authActions from "../../store/auth/auth-action";
-import dataExplorerActions from "../../store/data-explorer/data-explorer-action";
import { User } from "../../models/user";
import { RootState } from "../../store/store";
import MainAppBar, {
import ProjectTree from '../../views-components/project-tree/project-tree';
import { TreeItem } from "../../components/tree/tree";
import { Project } from "../../models/project";
-import { getTreePath, findTreeItem } from '../../store/project/project-reducer';
+import { getTreePath } from '../../store/project/project-reducer';
import sidePanelActions from '../../store/side-panel/side-panel-action';
import SidePanel, { SidePanelItem } from '../../components/side-panel/side-panel';
-import { ResourceKind } from "../../models/resource";
import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
import projectActions from "../../store/project/project-action";
import ProjectPanel from "../project-panel/project-panel";
-import { sidePanelData } from '../../store/side-panel/side-panel-reducer';
import DetailsPanel from '../../views-components/details-panel/details-panel';
import { ArvadosTheme } from '../../common/custom-theme';
+import detailsPanelActions, { loadDetails } from "../../store/details-panel/details-panel-action";
+import { ResourceKind } from '../../models/kinds';
const drawerWidth = 240;
const appBarHeight = 100;
helpMenu: NavMenuItem[],
anonymousMenu: NavMenuItem[]
};
- isDetailsPanelOpened: boolean;
}
+
class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
state = {
anchorEl: null,
action: () => this.props.dispatch(authActions.LOGIN())
}
]
- },
- isDetailsPanelOpened: false
+ }
};
mainAppBarActions: MainAppBarActionProps = {
},
onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action(),
onDetailsPanelToggle: () => {
- this.setState(prev => ({ isDetailsPanelOpened: !prev.isDetailsPanelOpened }));
+ this.props.dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
}
};
<Route path="/projects/:id" render={this.renderProjectPanel} />
</Switch>
</div>
- <DetailsPanel
- isOpened={this.state.isDetailsPanelOpened}
- onCloseDrawer={this.mainAppBarActions.onDetailsPanelToggle} />
+ <DetailsPanel/>
</main>
</div>
);
renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
onItemRouteChange={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
- onItemClick={item => this.props.dispatch<any>(setProjectItem(item.uuid, ItemMode.ACTIVE))}
+ onItemClick={item => {
+ this.props.dispatch<any>(setProjectItem(item.uuid, ItemMode.ACTIVE));
+ this.props.dispatch<any>(loadDetails(item.uuid, item.kind as ResourceKind));
+ }}
{...props} />
}