X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/3eba091748f10f981d48f44eed14115b4fcee0ce..876e5e2f31a218255845977489ea70aacc0211cd:/src/views/project-panel/project-panel.tsx

diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index c7138c30..e9179a11 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -5,22 +5,29 @@
 import * as React from 'react';
 import { ProjectPanelItem } from './project-panel-item';
 import { Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { DataExplorer } from "../../views-components/data-explorer/data-explorer";
+import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
 import { DispatchProp, connect } from 'react-redux';
-import { DataColumns } from '../../components/data-table/data-table';
+import { DataColumns } from '~/components/data-table/data-table';
 import { RouteComponentProps } from 'react-router';
-import { RootState } from '../../store/store';
-import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters';
-import { ContainerRequestState } from '../../models/container-request';
-import { SortDirection } from '../../components/data-table/data-column';
-import { ResourceKind } from '../../models/resource';
-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 { RootState } from '~/store/store';
+import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
+import { ContainerRequestState } from '~/models/container-request';
+import { SortDirection } from '~/components/data-table/data-column';
+import { ResourceKind } from '~/models/resource';
+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 { ProjectIcon } from '~/components/icon/icon';
 
-type CssRules = "toolbar" | "button";
+type CssRules = 'root' | "toolbar" | "button";
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    root: {
+        position: 'relative',
+        width: '100%',
+        height: '100%'
+    },
     toolbar: {
         paddingBottom: theme.spacing.unit * 3,
         textAlign: "right"
@@ -47,6 +54,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: ProjectPanelColumnNames.NAME,
         selected: true,
+        configurable: true,
         sortDirection: SortDirection.ASC,
         render: renderName,
         width: "450px"
@@ -54,6 +62,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: "Status",
         selected: true,
+        configurable: true,
         filters: [
             {
                 name: ContainerRequestState.COMMITTED,
@@ -77,6 +86,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: ProjectPanelColumnNames.TYPE,
         selected: true,
+        configurable: true,
         filters: [
             {
                 name: resourceLabel(ResourceKind.COLLECTION),
@@ -100,18 +110,21 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: ProjectPanelColumnNames.OWNER,
         selected: true,
+        configurable: true,
         render: item => renderOwner(item.owner),
         width: "200px"
     },
     {
         name: ProjectPanelColumnNames.FILE_SIZE,
         selected: true,
+        configurable: true,
         render: item => renderFileSize(item.fileSize),
         width: "50px"
     },
     {
         name: ProjectPanelColumnNames.LAST_MODIFIED,
         selected: true,
+        configurable: true,
         sortDirection: SortDirection.NONE,
         render: item => renderDate(item.lastModified),
         width: "150px"
@@ -127,7 +140,8 @@ interface ProjectPanelDataProps {
 interface ProjectPanelActionProps {
     onItemClick: (item: ProjectPanelItem) => void;
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: ProjectPanelItem) => void;
-    onDialogOpen: (ownerUuid: string) => void;
+    onProjectCreationDialogOpen: (ownerUuid: string) => void;
+    onCollectionCreationDialogOpen: (ownerUuid: string) => void;
     onItemDoubleClick: (item: ProjectPanelItem) => void;
     onItemRouteChange: (itemId: string) => void;
 }
@@ -140,9 +154,9 @@ export const ProjectPanel = withStyles(styles)(
         class extends React.Component<ProjectPanelProps> {
             render() {
                 const { classes } = this.props;
-                return <div>
+                return <div className={classes.root}>
                     <div className={classes.toolbar}>
-                        <Button color="primary" variant="raised" className={classes.button}>
+                        <Button color="primary" onClick={this.handleNewCollectionClick} variant="raised" className={classes.button}>
                             Create a collection
                         </Button>
                         <Button color="primary" variant="raised" className={classes.button}>
@@ -154,21 +168,35 @@ export const ProjectPanel = withStyles(styles)(
                     </div>
                     <DataExplorer
                         id={PROJECT_PANEL_ID}
+                        columns={columns}
                         onRowClick={this.props.onItemClick}
                         onRowDoubleClick={this.props.onItemDoubleClick}
                         onContextMenu={this.props.onContextMenu}
-                        extractKey={(item: ProjectPanelItem) => item.uuid} />
+                        extractKey={(item: ProjectPanelItem) => item.uuid}
+                        defaultIcon={ProjectIcon}
+                        defaultMessages={['Your project is empty.', 'Please create a project or create a collection and upload a data.']} />
                 </div>;
             }
 
             handleNewProjectClick = () => {
-                this.props.onDialogOpen(this.props.currentItemId);
+                this.props.onProjectCreationDialogOpen(this.props.currentItemId);
+            }
+
+            handleNewCollectionClick = () => {
+                this.props.onCollectionCreationDialogOpen(this.props.currentItemId);
             }
+
             componentWillReceiveProps({ match, currentItemId, onItemRouteChange }: ProjectPanelProps) {
                 if (match.params.id !== currentItemId) {
                     onItemRouteChange(match.params.id);
                 }
             }
+
+            componentDidMount() {
+                if (this.props.match.params.id && this.props.currentItemId === '') {
+                    this.props.dispatch<any>(restoreBranch(this.props.match.params.id));
+                }
+            }
         }
     )
-);
\ No newline at end of file
+);
