[ARVADOS-WORKBENCH2] updated: 1.1.4-229-g0e3c4c5
Git user
git at public.curoverse.com
Tue Jul 10 07:17:37 EDT 2018
Summary of changes:
src/store/details-panel/details-panel-action.ts | 27 ++--
src/store/navigation/navigation-action.ts | 2 -
.../details-panel/details-panel.tsx | 145 ++++++++++++++-------
src/views/workbench/workbench.tsx | 8 +-
4 files changed, 119 insertions(+), 63 deletions(-)
via 0e3c4c507b9d3ec37b808b7a38cf111722659403 (commit)
from d8c787ee061c3953628362f5eb6c37123f5ca0f5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 0e3c4c507b9d3ec37b808b7a38cf111722659403
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date: Tue Jul 10 13:17:30 2018 +0200
load item to panelDetails and display data
Feature #13765
Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>
diff --git a/src/store/details-panel/details-panel-action.ts b/src/store/details-panel/details-panel-action.ts
index e2d2479..ffa66b6 100644
--- a/src/store/details-panel/details-panel-action.ts
+++ b/src/store/details-panel/details-panel-action.ts
@@ -3,10 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0
import { unionize, ofType, UnionOf } from "unionize";
-import { Resource } from "../../common/api/common-resource-service";
+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<{}>(),
@@ -21,15 +22,23 @@ export type DetailsPanelAction = UnionOf<typeof actions>;
export const loadDetails = (uuid: string, kind: ResourceKind) =>
(dispatch: Dispatch) => {
dispatch(actions.LOAD_DETAILS({ uuid, kind }));
- if (kind === ResourceKind.Project) {
- groupsService
- .get(uuid)
- .then(project => {
- dispatch(actions.LOAD_DETAILS_SUCCESS({ item: project }));
- });
- }
-
+ 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, "");
+ }
+};
+
diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts
index 034cdac..1cab734 100644
--- a/src/store/navigation/navigation-action.ts
+++ b/src/store/navigation/navigation-action.ts
@@ -36,8 +36,6 @@ export const setProjectItem = (itemId: string, itemMode: ItemMode) =>
const treeItem = findTreeItem(projects.items, itemId);
if (treeItem) {
- // TODO: Get correct resource kind
- dispatch<any>(loadDetails(treeItem.data.uuid, ResourceKind.Project));
dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY());
const projectsItem = sidePanelData[0];
diff --git a/src/views-components/details-panel/details-panel.tsx b/src/views-components/details-panel/details-panel.tsx
index b29e190..138c91a 100644
--- a/src/views-components/details-panel/details-panel.tsx
+++ b/src/views-components/details-panel/details-panel.tsx
@@ -22,13 +22,14 @@ 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 DetailsPanelDataProps {
onCloseDrawer: () => void;
isOpened: boolean;
- header: React.ReactElement<any>;
- renderDetails?: React.ComponentType<{}>;
- renderActivity?: React.ComponentType<{}>;
+ icon: IconTypes;
+ title: string;
+ details: React.ReactElement<any>;
}
type DetailsPanelProps = DetailsPanelDataProps & WithStyles<CssRules>;
@@ -48,14 +49,17 @@ class DetailsPanel extends React.Component<DetailsPanelProps, {}> {
</Typography>
render() {
- const { classes, onCloseDrawer, isOpened, header, renderDetails, renderActivity } = this.props;
+ const { classes, onCloseDrawer, isOpened, icon, title, details } = this.props;
const { tabsValue } = this.state;
return (
<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'>
- {header}
+ <IconBase className={classes.headerIcon} icon={icon} />
+ <Typography variant="title">
+ {title}
+ </Typography>
<IconButton color="inherit" onClick={onCloseDrawer}>
<IconBase icon={IconTypes.CLOSE} />
</IconButton>
@@ -67,24 +71,11 @@ class DetailsPanel extends React.Component<DetailsPanelProps, {}> {
</Tabs>
{tabsValue === 0 && this.renderTabContainer(
<Grid container direction="column">
- {renderDetails}
- <EmptyState icon={IconTypes.ANNOUNCEMENT}
- message='Select a file or folder to view its details.' />
- <Attribute label='Type' value='Process' />
- <Attribute label='Size' value='---' />
- <Attribute label="Location">
- <IconBase icon={IconTypes.FOLDER} />
- Projects
- </Attribute>
- <Attribute label='Outputs' link='http://www.google.pl' value='New output as link' />
- <Attribute label='Owner' value='me' />
+ {details}
</Grid>
)}
{tabsValue === 1 && this.renderTabContainer(
- <Grid container direction="column">
- {renderActivity}
- <EmptyState icon={IconTypes.ANNOUNCEMENT} message='Select a file or folder to view its details.' />
- </Grid>
+ <Grid container direction="column" />
)}
</Drawer>
</Typography>
@@ -93,7 +84,7 @@ class DetailsPanel extends React.Component<DetailsPanelProps, {}> {
}
-type CssRules = 'drawerPaper' | 'container' | 'opened' | 'headerContainer' | 'tabContainer';
+type CssRules = 'drawerPaper' | 'container' | 'opened' | 'headerContainer' | 'headerIcon' | 'tabContainer';
const drawerWidth = 320;
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
@@ -113,48 +104,102 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
},
headerContainer: {
color: theme.palette.grey["600"],
- margin: `${theme.spacing.unit}px 0`,
- '& .fa-cogs': {
- fontSize: "24px",
- color: theme.customs.colors.green700
- }
+ margin: `${theme.spacing.unit}px 0`
+ },
+ headerIcon: {
+ fontSize: "34px"
},
tabContainer: {
padding: theme.spacing.unit * 3
}
});
-const renderCollectionHeader = (collection: CollectionResource) =>
- <>
- <IconBase icon={IconTypes.COLLECTION} />
- <Typography variant="title">
- {collection.name}
- </Typography>
- </>;
+type DetailsPanelResource = ProjectResource | CollectionResource | ProcessResource;
-const renderProjectHeader = (project: ProjectResource) =>
- <>
- <IconBase icon={IconTypes.FOLDER} />
- <Typography variant="title">
- {project.name}
- </Typography>
- </>;
+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 renderHeader = (resource: Resource) => {
- switch(resource.kind) {
+const getDetails = (res: DetailsPanelResource) => {
+ switch (res.kind) {
case ResourceKind.Project:
- return renderProjectHeader(resource as ProjectResource);
+ 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 renderCollectionHeader(resource as CollectionResource);
- default:
- return null;
+ 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 mapStateToProps = ({detailsPanel}: RootState) => ({
- isOpened: detailsPanel.isOpened,
- header: detailsPanel.item ? renderHeader(detailsPanel.item) : null
-});
+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: () => {
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index e848784..11f3694 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -27,7 +27,8 @@ import projectActions from "../../store/project/project-action";
import ProjectPanel from "../project-panel/project-panel";
import DetailsPanel from '../../views-components/details-panel/details-panel';
import { ArvadosTheme } from '../../common/custom-theme';
-import detailsPanelActions from "../../store/details-panel/details-panel-action";
+import detailsPanelActions, { loadDetails } from "../../store/details-panel/details-panel-action";
+import { ResourceKind } from '../../models/kinds';
const drawerWidth = 240;
const appBarHeight = 100;
@@ -207,7 +208,10 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
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} />
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list