X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/80fdf9603c057f1e41915e7c8890c942d240b36e..3971518483964a5c789eea29f7a199ebd99bdce3:/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 2483c5166f..4a3f60a619 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -2,41 +2,56 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import withStyles from "@material-ui/core/styles/withStyles";
 import { DispatchProp, connect } from 'react-redux';
 import { RouteComponentProps } from 'react-router';
 import { StyleRulesCallback, WithStyles } from "@material-ui/core";
 
-import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
-import { DataColumns } from '~/components/data-table/data-table';
-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, Resource } from '~/models/resource';
-import { ResourceFileSize, ResourceLastModifiedDate, ProcessStatus, ResourceType, ResourceOwner } from '~/views-components/data-explorer/renderers';
-import { ProjectIcon } from '~/components/icon/icon';
-import { ResourceName } from '~/views-components/data-explorer/renderers';
-import { ResourcesState, getResource } from '~/store/resources/resources';
-import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
-import { resourceKindToContextMenuKind, openContextMenu } from '~/store/context-menu/context-menu-actions';
-import { ProjectResource } from '~/models/project';
-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 { getInitialResourceTypeFilters } from '~/store/resource-type-filters/resource-type-filters';
+import { DataExplorer } from "views-components/data-explorer/data-explorer";
+import { DataColumns } from 'components/data-table/data-table';
+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, Resource } from 'models/resource';
+import {
+    ResourceFileSize,
+    ResourceLastModifiedDate,
+    ProcessStatus,
+    ResourceType,
+    ResourceOwner
+} from 'views-components/data-explorer/renderers';
+import { ProjectIcon } from 'components/icon/icon';
+import { ResourceName } from 'views-components/data-explorer/renderers';
+import {
+    ResourcesState,
+    getResource
+} from 'store/resources/resources';
+import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
+import {
+    openContextMenu,
+    resourceUuidToContextMenuKind
+} from 'store/context-menu/context-menu-actions';
+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 {
+    getInitialResourceTypeFilters,
+    getInitialProcessStatusFilters
+} from 'store/resource-type-filters/resource-type-filters';
+import { GroupContentsResource } from 'services/groups-service/groups-service';
+import { GroupClass, GroupResource } from 'models/group';
+import { CollectionResource } from 'models/collection';
 
 type CssRules = 'root' | "button";
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
-        position: 'relative',
         width: '100%',
-        height: '100%'
     },
     button: {
         marginLeft: theme.spacing.unit
@@ -69,7 +84,8 @@ export const projectPanelColumns: DataColumns<string> = [
         name: "Status",
         selected: true,
         configurable: true,
-        filters: createTree(),
+        mutuallyExclusiveFilters: true,
+        filters: getInitialProcessStatusFilters(),
         render: uuid => <ProcessStatus uuid={uuid} />,
     },
     {
@@ -81,7 +97,7 @@ export const projectPanelColumns: DataColumns<string> = [
     },
     {
         name: ProjectPanelColumnNames.OWNER,
-        selected: true,
+        selected: false,
         configurable: true,
         filters: createTree(),
         render: uuid => <ResourceOwner uuid={uuid} />
@@ -105,7 +121,7 @@ export const projectPanelColumns: DataColumns<string> = [
 
 export const PROJECT_PANEL_ID = "projectPanel";
 
-const DEFAUL_VIEW_MESSAGES = [
+const DEFAULT_VIEW_MESSAGES = [
     'Your project is empty.',
     'Please create a project or create a collection and upload a data.',
 ];
@@ -114,6 +130,7 @@ interface ProjectPanelDataProps {
     currentItemId: string;
     resources: ResourcesState;
     isAdmin: boolean;
+    userUuid: string;
 }
 
 type ProjectPanelProps = ProjectPanelDataProps & DispatchProp
@@ -123,12 +140,12 @@ export const ProjectPanel = withStyles(styles)(
     connect((state: RootState) => ({
         currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties),
         resources: state.resources,
-        isAdmin: state.auth.user!.isAdmin
+        userUuid: state.auth.user!.uuid,
     }))(
         class extends React.Component<ProjectPanelProps> {
             render() {
                 const { classes } = this.props;
-                return <div className={classes.root}>
+                return <div data-cy='project-panel' className={classes.root}>
                     <DataExplorer
                         id={PROJECT_PANEL_ID}
                         onRowClick={this.handleRowClick}
@@ -138,7 +155,7 @@ export const ProjectPanel = withStyles(styles)(
                         dataTableDefaultView={
                             <DataTableDefaultView
                                 icon={ProjectIcon}
-                                messages={DEFAUL_VIEW_MESSAGES} />
+                                messages={DEFAULT_VIEW_MESSAGES} />
                         } />
                 </div>;
             }
@@ -148,16 +165,26 @@ export const ProjectPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-                const menuKind = resourceKindToContextMenuKind(resourceUuid, this.props.isAdmin);
-                const resource = getResource<ProjectResource>(resourceUuid)(this.props.resources);
+                const { resources } = 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;
+                const project = getResource<GroupResource>(this.props.currentItemId)(resources);
+                if (project && project.groupClass === GroupClass.FILTER) {
+                    readonly = true;
+                }
+
+                const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid, readonly));
                 if (menuKind && resource) {
                     this.props.dispatch<any>(openContextMenu(event, {
                         name: resource.name,
                         uuid: resource.uuid,
                         ownerUuid: resource.ownerUuid,
-                        isTrashed: resource.isTrashed,
+                        isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
                         kind: resource.kind,
-                        menuKind
+                        menuKind,
+                        description: resource.description,
+                        storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
                     }));
                 }
                 this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
@@ -168,7 +195,7 @@ export const ProjectPanel = withStyles(styles)(
             }
 
             handleRowClick = (uuid: string) => {
-                this.props.dispatch(loadDetailsPanel(uuid));
+                this.props.dispatch<any>(loadDetailsPanel(uuid));
             }
 
         }
