Merge branch 'master' into 13765-information-inside-details-panel
authorJanicki Artur <artur.janicki@contractors.roche.com>
Tue, 10 Jul 2018 11:54:09 +0000 (13:54 +0200)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Tue, 10 Jul 2018 11:54:09 +0000 (13:54 +0200)
refs #13765

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

src/components/attribute/attribute.tsx
src/components/empty-state/empty-state.tsx [new file with mode: 0644]
src/components/icon/icon.tsx [new file with mode: 0644]
src/store/details-panel/details-panel-action.ts [new file with mode: 0644]
src/store/details-panel/details-panel-reducer.ts [new file with mode: 0644]
src/store/navigation/navigation-action.ts
src/store/store.ts
src/views-components/details-panel/details-panel.tsx
src/views/workbench/workbench.test.tsx
src/views/workbench/workbench.tsx

index 131d629ab6e9fdef4a12437bf7de6f9f45ee93bc..6d1c3bc37a79d1db36f38b87c52b4cd07cdbe836 100644 (file)
@@ -9,26 +9,40 @@ import { ArvadosTheme } from 'src/common/custom-theme';
 
 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
@@ -40,6 +54,10 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     value: {
         display: 'flex',
         alignItems: 'center'
+    },
+    link: {
+        color: theme.palette.primary.main,
+        textDecoration: 'none'
     }
 });
 
diff --git a/src/components/empty-state/empty-state.tsx b/src/components/empty-state/empty-state.tsx
new file mode 100644 (file)
index 0000000..205053b
--- /dev/null
@@ -0,0 +1,46 @@
+// 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
diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx
new file mode 100644 (file)
index 0000000..c420a19
--- /dev/null
@@ -0,0 +1,50 @@
+// 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
diff --git a/src/store/details-panel/details-panel-action.ts b/src/store/details-panel/details-panel-action.ts
new file mode 100644 (file)
index 0000000..ffa66b6
--- /dev/null
@@ -0,0 +1,44 @@
+// 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, "");
+    }
+};
+
+
+
diff --git a/src/store/details-panel/details-panel-reducer.ts b/src/store/details-panel/details-panel-reducer.ts
new file mode 100644 (file)
index 0000000..73fc604
--- /dev/null
@@ -0,0 +1,26 @@
+// 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;
index 5fb6b7296997a578162f8d6e28f1fadd79354a1b..1cab7349da8399e020b629fae853941357827886 100644 (file)
@@ -7,17 +7,19 @@ import projectActions, { getProjectList } from "../project/project-action";
 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 "";
     }
 };
index 00c2ad75e422b074e53ab7cba5f90742c8a781be..f74b87737ed14c6b94b751145f2e258006c81f45 100644 (file)
@@ -13,6 +13,7 @@ import authReducer, { AuthState } from "./auth/auth-reducer";
 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' &&
@@ -26,6 +27,7 @@ export interface RootState {
     router: RouterState;
     dataExplorer: DataExplorerState;
     sidePanel: SidePanelState;
+    detailsPanel: DetailsPanelState;
 }
 
 const rootReducer = combineReducers({
@@ -34,7 +36,8 @@ const rootReducer = combineReducers({
     collections: collectionsReducer,
     router: routerReducer,
     dataExplorer: dataExplorerReducer,
-    sidePanel: sidePanelReducer
+    sidePanel: sidePanelReducer,
+    detailsPanel: detailsPanelReducer
 });
 
 
index 9d25d9200859bc7fd1a1c36e8971dee930157a43..138c91a58312bfcb817af5293ddb2abbc3e0931c 100644 (file)
@@ -5,8 +5,6 @@
 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';
@@ -15,83 +13,84 @@ import Tab from '@material-ui/core/Tab';
 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': {
@@ -102,17 +101,112 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     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
index 71bc915c5ed155f26c677997f0ae6e2eb7f1ba96..79a98ad60b172191a509bff635b3079eb7fc1ddb 100644 (file)
@@ -9,7 +9,7 @@ import { Provider } from "react-redux";
 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();
index 8cc5fc22700571a207395746390d8e778ad4e1f8..11f36948dcb21707df604ab27c3c021b01161090 100644 (file)
@@ -6,9 +6,8 @@ import * as React from 'react';
 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, {
@@ -20,16 +19,16 @@ import { push } from 'react-router-redux';
 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;
@@ -100,9 +99,9 @@ interface WorkbenchState {
         helpMenu: NavMenuItem[],
         anonymousMenu: NavMenuItem[]
     };
-    isDetailsPanelOpened: boolean;
 }
 
+
 class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
     state = {
         anchorEl: null,
@@ -131,8 +130,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                     action: () => this.props.dispatch(authActions.LOGIN())
                 }
             ]
-        },
-        isDetailsPanelOpened: false
+        }
     };
 
     mainAppBarActions: MainAppBarActionProps = {
@@ -145,7 +143,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
         },
         onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action(),
         onDetailsPanelToggle: () => {
-            this.setState(prev => ({ isDetailsPanelOpened: !prev.isDetailsPanelOpened }));
+            this.props.dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
         }
     };
 
@@ -202,9 +200,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                             <Route path="/projects/:id" render={this.renderProjectPanel} />
                         </Switch>
                     </div>
-                    <DetailsPanel 
-                        isOpened={this.state.isDetailsPanelOpened} 
-                        onCloseDrawer={this.mainAppBarActions.onDetailsPanelToggle} />
+                    <DetailsPanel/>
                 </main>
             </div>
         );
@@ -212,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} />
 
 }