X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ffac6f1051efb642db49c4c4a5d2f3f477ca6d34..185beca2556c6a165f494ae941e06fec1c89fc74:/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 2654dd1b..63a57bbd 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -17,7 +17,7 @@ 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 { ProjectPanelMiddlewareService } from '../../store/project-panel/project-panel-middleware-service';
+import { restoreBranch } from '../../store/navigation/navigation-action';
 
 type CssRules = "toolbar" | "button";
 
@@ -48,6 +48,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: ProjectPanelColumnNames.NAME,
         selected: true,
+        configurable: true,
         sortDirection: SortDirection.ASC,
         render: renderName,
         width: "450px"
@@ -55,6 +56,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: "Status",
         selected: true,
+        configurable: true,
         filters: [
             {
                 name: ContainerRequestState.COMMITTED,
@@ -78,6 +80,7 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
     {
         name: ProjectPanelColumnNames.TYPE,
         selected: true,
+        configurable: true,
         filters: [
             {
                 name: resourceLabel(ResourceKind.COLLECTION),
@@ -101,32 +104,39 @@ 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"
     }
 ];
 
+export const PROJECT_PANEL_ID = "projectPanel";
+
 interface ProjectPanelDataProps {
     currentItemId: string;
+    isSidePanelOpen: boolean;
 }
 
 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;
 }
@@ -135,13 +145,13 @@ type ProjectPanelProps = ProjectPanelDataProps & ProjectPanelActionProps & Dispa
     & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
 export const ProjectPanel = withStyles(styles)(
-    connect((state: RootState) => ({ currentItemId: state.projects.currentItemId }))(
+    connect((state: RootState) => ({ currentItemId: state.projects.currentItemId, isSidePanelOpen: state.sidePanel[0].open }))(
         class extends React.Component<ProjectPanelProps> {
             render() {
                 const { classes } = this.props;
                 return <div>
                     <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}>
@@ -152,7 +162,8 @@ export const ProjectPanel = withStyles(styles)(
                         </Button>
                     </div>
                     <DataExplorer
-                        id={ProjectPanelMiddlewareService.getInstance().Id}
+                        id={PROJECT_PANEL_ID}
+                        columns={columns}
                         onRowClick={this.props.onItemClick}
                         onRowDoubleClick={this.props.onItemDoubleClick}
                         onContextMenu={this.props.onContextMenu}
@@ -161,13 +172,24 @@ export const ProjectPanel = withStyles(styles)(
             }
 
             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.isSidePanelOpen) {
+                    this.props.dispatch<any>(restoreBranch(this.props.match.params.id));
+                }
+            }
         }
     )
-);
\ No newline at end of file
+);
