Container req state up & properties removed
[arvados-workbench2.git] / src / views / project-panel / project-panel.tsx
index ab11593dd1a1f0d7da9447d49b0067c156ed5266..465178e7ffeca7b608bd13d594e749adb641901a 100644 (file)
@@ -17,10 +17,19 @@ import { SortDirection } from 'components/data-table/data-column';
 import { ResourceKind, Resource } from 'models/resource';
 import {
     ResourceFileSize,
+    ResourceFileCount,
+    ResourceCreatedAtDate,
     ResourceLastModifiedDate,
+    ResourceTrashDate,
+    ResourceDeleteDate,
     ProcessStatus,
     ResourceType,
-    ResourceOwner
+    ResourceUUID,
+    ResourceProcessState,
+    ResourcePortableDataHash,
+    ResourceVersion,
+    ResourceDescription,
+    ResourceOwnerWithName
 } from 'views-components/data-explorer/renderers';
 import { ProjectIcon } from 'components/icon/icon';
 import { ResourceName } from 'views-components/data-explorer/renderers';
@@ -36,7 +45,6 @@ import {
 import { navigateTo } from 'store/navigation/navigation-action';
 import { getProperty } from 'store/properties/properties';
 import { PROJECT_PANEL_CURRENT_UUID } from 'store/project-panel/project-panel-action';
-import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view';
 import { ArvadosTheme } from "common/custom-theme";
 import { createTree } from 'models/tree';
 import {
@@ -46,6 +54,7 @@ import {
 import { GroupContentsResource } from 'services/groups-service/groups-service';
 import { GroupClass, GroupResource } from 'models/group';
 import { CollectionResource } from 'models/collection';
+import { resourceIsFrozen } from 'common/frozen-resources';
 
 type CssRules = 'root' | "button";
 
@@ -64,7 +73,16 @@ export enum ProjectPanelColumnNames {
     TYPE = "Type",
     OWNER = "Owner",
     FILE_SIZE = "File size",
-    LAST_MODIFIED = "Last modified"
+    FILE_COUNT = "File count",
+    UUID = "UUID",
+    STATE = 'State',
+    CREATED_AT = "Date created",
+    LAST_MODIFIED = "Last modified",
+    TRASH_AT = "Trash at",
+    DELETE_AT = "Delete at",
+    DESCRIPTION = "Description",
+    PORTABLE_DATA_HASH = "Portable Data Hash",
+    VERSION = "Version"
 }
 
 export interface ProjectPanelFilter extends DataTableFilterItem {
@@ -100,7 +118,7 @@ export const projectPanelColumns: DataColumns<string> = [
         selected: false,
         configurable: true,
         filters: createTree(),
-        render: uuid => <ResourceOwner uuid={uuid} />
+        render: uuid => <ResourceOwnerWithName uuid={uuid} />
     },
     {
         name: ProjectPanelColumnNames.FILE_SIZE,
@@ -110,13 +128,79 @@ export const projectPanelColumns: DataColumns<string> = [
         render: uuid => <ResourceFileSize uuid={uuid} />
     },
     {
-        name: ProjectPanelColumnNames.LAST_MODIFIED,
+        name: ProjectPanelColumnNames.FILE_COUNT,
         selected: true,
         configurable: true,
+        filters: createTree(),
+        render: uuid =><ResourceFileCount uuid={uuid}/>
+    },
+    {
+        name: ProjectPanelColumnNames.UUID,
+        selected: true,
+        configurable: true,
+        filters: createTree(),
+        render: uuid => <ResourceUUID uuid={uuid}/>
+    },
+    {
+        name: ProjectPanelColumnNames.STATE,
+        selected: true,
+        configurable: true,
+        filters: createTree(),
+        render: uuid => <ResourceProcessState uuid={uuid}/>
+    },
+    {
+        name: ProjectPanelColumnNames.PORTABLE_DATA_HASH,
+        selected: true,
+        configurable: true,
+        filters: createTree(),
+        render: uuid => <ResourcePortableDataHash uuid={uuid}/>
+    },
+    {
+        name: ProjectPanelColumnNames.CREATED_AT,
+        selected: false,
+        configurable: true,
+        filters: createTree(),
+        render: uuid =><ResourceCreatedAtDate uuid={uuid}/>
+    },
+    {
+        name: ProjectPanelColumnNames.LAST_MODIFIED,
+        selected: false,
+        configurable: true,
         sortDirection: SortDirection.DESC,
         filters: createTree(),
         render: uuid => <ResourceLastModifiedDate uuid={uuid} />
+    },
+    {
+        name: ProjectPanelColumnNames.TRASH_AT,
+        selected: false,
+        configurable: true,
+        sortDirection: SortDirection.DESC,
+        filters: createTree(),
+        render: uuid => <ResourceTrashDate uuid={uuid} />
+    },
+    {
+        name: ProjectPanelColumnNames.DELETE_AT,
+        selected: false,
+        configurable: true,
+        sortDirection: SortDirection.DESC,
+        filters: createTree(),
+        render: uuid => <ResourceDeleteDate uuid={uuid} />
+    },
+    {
+        name: ProjectPanelColumnNames.DESCRIPTION,
+        selected: true,
+        configurable: true,
+        filters: createTree(),
+        render: uuid =><ResourceDescription uuid={uuid}/>
+    },
+    {
+        name: ProjectPanelColumnNames.VERSION,
+        selected: false,
+        configurable: true,
+        filters: createTree(),
+        render: uuid =><ResourceVersion uuid={uuid}/>
     }
+    
 ];
 
 export const PROJECT_PANEL_ID = "projectPanel";
@@ -137,41 +221,27 @@ interface ProjectPanelDataProps {
 type ProjectPanelProps = ProjectPanelDataProps & DispatchProp
     & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
-let data: any[] = [];
-let href: string = '';
 
 export const ProjectPanel = withStyles(styles)(
     connect((state: RootState) => ({
         currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties),
         resources: state.resources,
-        userUuid: state.auth.user!.uuid,
-        dataExplorerItems: state.dataExplorer?.projectPanel.items,
+        userUuid: state.auth.user!.uuid
     }))(
         class extends React.Component<ProjectPanelProps> {
             render() {
-                const { classes, dataExplorerItems } = this.props;
-                let loading = false;
-
-                if (dataExplorerItems.length > 0 && data === dataExplorerItems && href !== window.location.href) {
-                    loading = true
-                } else {
-                    href = window.location.href;
-                    data = dataExplorerItems;
-                }
+                const { classes } = this.props;
 
                 return <div data-cy='project-panel' className={classes.root}>
                     <DataExplorer
-                        working={loading}
                         id={PROJECT_PANEL_ID}
                         onRowClick={this.handleRowClick}
                         onRowDoubleClick={this.handleRowDoubleClick}
                         onContextMenu={this.handleContextMenu}
                         contextMenuColumn={true}
-                        dataTableDefaultView={
-                            <DataTableDefaultView
-                                icon={ProjectIcon}
-                                messages={DEFAULT_VIEW_MESSAGES} />
-                        } />
+                        defaultViewIcon={ProjectIcon}
+                        defaultViewMessages={DEFAULT_VIEW_MESSAGES}
+                    />
                 </div>;
             }
 
@@ -180,7 +250,7 @@ export const ProjectPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-                const { resources } = this.props;
+                const { resources, isAdmin } = this.props;
                 const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
                 // When viewing the contents of a filter group, all contents should be treated as read only.
                 let readonly = false;
@@ -195,11 +265,14 @@ export const ProjectPanel = withStyles(styles)(
                         name: resource.name,
                         uuid: resource.uuid,
                         ownerUuid: resource.ownerUuid,
-                        isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
+                        isTrashed: ('isTrashed' in resource) ? resource.isTrashed : false,
                         kind: resource.kind,
                         menuKind,
+                        isAdmin,
+                        isFrozen: resourceIsFrozen(resource, resources),
                         description: resource.description,
                         storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
+                        properties: ('properties' in resource) ? resource.properties : {},
                     }));
                 }
                 this.props.dispatch<any>(loadDetailsPanel(resourceUuid));