X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4b4ef8d9e7c3d65e4d65b8aafb68b294c30e2e28..a781af5eae4f4e7f6e07a2b205ad4e54e9e8ec7a:/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 2cdb671261..e34ea1ecda 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -4,20 +4,18 @@
 
 import * as React from 'react';
 import { ProjectPanelItem } from './project-panel-item';
-import { Grid, Typography, Button, Toolbar, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import { Grid, Typography, Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
 import { formatDate, formatFileSize } from '../../common/formatters';
 import DataExplorer from "../../views-components/data-explorer/data-explorer";
-import { ContextMenuAction } from '../../components/context-menu/context-menu';
 import { DispatchProp, connect } from 'react-redux';
 import { DataColumns } from '../../components/data-table/data-table';
 import { RouteComponentProps } from 'react-router';
 import { RootState } from '../../store/store';
-import { ResourceKind } from '../../models/kinds';
 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 DialogProjectCreate from '../../components/dialog-create/dialog-project-create';
-import { mockAnchorFromMouseEvent } from "../../components/popover/helpers";
+import { ResourceKind } from '../../models/resource';
+import { resourceLabel } from '../../common/labels';
 
 export const PROJECT_PANEL_ID = "projectPanel";
 
@@ -25,33 +23,19 @@ export interface ProjectPanelFilter extends DataTableFilterItem {
     type: ResourceKind | ContainerRequestState;
 }
 
-interface DataExplorerState<T> {
-    contextMenu: {
-        anchorEl?: HTMLElement;
-        item?: T;
-    };
-    open?: boolean;
-}
-
 type ProjectPanelProps = {
     currentItemId: string,
     onItemClick: (item: ProjectPanelItem) => void,
-    onItemRouteChange: (itemId: string) => void,
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: ProjectPanelItem) => void;
-    handleCreationDialogOpen: () => void;
-    handleCreationDialogClose: () => void;
-    isCreationDialogOpen: boolean;
+    onDialogOpen: (ownerUuid: string) => void;
+    onItemDoubleClick: (item: ProjectPanelItem) => void,
+    onItemRouteChange: (itemId: string) => void
 }
     & DispatchProp
     & WithStyles<CssRules>
     & RouteComponentProps<{ id: string }>;
 
-class ProjectPanel extends React.Component<ProjectPanelProps, DataExplorerState<any>> {
-    state: DataExplorerState<any> = {
-        contextMenu: {},
-        open: false,
-    };
-    
+class ProjectPanel extends React.Component<ProjectPanelProps> {
     render() {
         return <div>
             <div className={this.props.classes.toolbar}>
@@ -61,15 +45,16 @@ class ProjectPanel extends React.Component<ProjectPanelProps, DataExplorerState<
                 <Button color="primary" variant="raised" className={this.props.classes.button}>
                     Run a process
                 </Button>
-                <Button color="primary" onClick={this.props.handleCreationDialogOpen} variant="raised" className={this.props.classes.button}>
+                <Button color="primary" onClick={() => this.props.onDialogOpen(this.props.currentItemId)} variant="raised" className={this.props.classes.button}>
                     New project
                 </Button>
-                <DialogProjectCreate open={this.props.isCreationDialogOpen} handleClose={this.props.handleCreationDialogClose}/>
             </div>
             <DataExplorer
                 id={PROJECT_PANEL_ID}
                 onRowClick={this.props.onItemClick}
-                onContextMenu={this.props.onContextMenu} />;
+                onRowDoubleClick={this.props.onItemDoubleClick}
+                onContextMenu={this.props.onContextMenu}
+                extractKey={(item: ProjectPanelItem) => item.uuid} />
         </div>;
     }
 
@@ -78,26 +63,6 @@ class ProjectPanel extends React.Component<ProjectPanelProps, DataExplorerState<
             this.props.onItemRouteChange(match.params.id);
         }
     }
-
-    executeAction = (action: ContextMenuAction, item: ProjectPanelItem) => {
-        alert(`Executing ${action.name} on ${item.name}`);
-    }
-
-    openContextMenu = (event: React.MouseEvent<HTMLElement>, item: any) => {
-        event.preventDefault();
-        event.stopPropagation();
-        this.setState({
-            contextMenu: {
-                anchorEl: mockAnchorFromMouseEvent(event),
-                item
-            }
-        });
-    }
-
-    closeContextMenu = () => {
-        this.setState({ contextMenu: {} });
-    }
-
 }
 
 type CssRules = "toolbar" | "button";
@@ -157,24 +122,9 @@ const renderOwner = (owner: string) =>
         {owner}
     </Typography>;
 
-
-
-const typeToLabel = (type: string) => {
-    switch (type) {
-        case ResourceKind.Collection:
-            return "Data collection";
-        case ResourceKind.Project:
-            return "Project";
-        case ResourceKind.Process:
-            return "Process";
-        default:
-            return "Unknown";
-    }
-};
-
 const renderType = (type: string) => {
     return <Typography noWrap>
-        {typeToLabel(type)}
+        {resourceLabel(type)}
     </Typography>;
 };
 
@@ -221,15 +171,15 @@ export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [{
     name: ProjectPanelColumnNames.Type,
     selected: true,
     filters: [{
-        name: typeToLabel(ResourceKind.Collection),
+        name: resourceLabel(ResourceKind.Collection),
         selected: true,
         type: ResourceKind.Collection
     }, {
-        name: typeToLabel(ResourceKind.Process),
+        name: resourceLabel(ResourceKind.Process),
         selected: true,
         type: ResourceKind.Process
     }, {
-        name: typeToLabel(ResourceKind.Project),
+        name: resourceLabel(ResourceKind.Project),
         selected: true,
         type: ResourceKind.Project
     }],
