X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/670d92f78e9af2390b93e5d984f5fabf59a16071..8489fb1669592f46853a3c793ad211fa919c30b7:/src/views-components/details-panel/project-details.tsx

diff --git a/src/views-components/details-panel/project-details.tsx b/src/views-components/details-panel/project-details.tsx
index c3c3d68e33..7dc6709da5 100644
--- a/src/views-components/details-panel/project-details.tsx
+++ b/src/views-components/details-panel/project-details.tsx
@@ -16,9 +16,12 @@ import { withStyles, StyleRulesCallback, WithStyles, Button } from '@material-ui
 import { ArvadosTheme } from 'common/custom-theme';
 import { Dispatch } from 'redux';
 import { getPropertyChip } from '../resource-properties-form/property-chip';
-import { ResourceOwnerWithName } from '../data-explorer/renderers';
+import { ResourceWithName } from '../data-explorer/renderers';
 import { GroupClass } from "models/group";
 import { openProjectUpdateDialog, ProjectUpdateFormDialogData } from 'store/projects/project-update-actions';
+import { RootState } from 'store/store';
+import { ResourcesState } from 'store/resources/resources';
+import { resourceIsFrozen } from 'common/frozen-resources';
 
 export class ProjectDetails extends DetailsData<ProjectResource> {
     getIcon(className?: string) {
@@ -33,17 +36,22 @@ export class ProjectDetails extends DetailsData<ProjectResource> {
     }
 }
 
-type CssRules = 'tag' | 'editIcon';
+type CssRules = 'tag' | 'editIcon' | 'editButton';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     tag: {
-        marginRight: theme.spacing.unit,
-        marginBottom: theme.spacing.unit
+        marginRight: theme.spacing.unit / 2,
+        marginBottom: theme.spacing.unit / 2,
     },
     editIcon: {
-        paddingRight: theme.spacing.unit/2,
+        paddingRight: theme.spacing.unit / 2,
         fontSize: '1.125rem',
-    }
+    },
+    editButton: {
+        boxShadow: 'none',
+        padding: '2px 10px 2px 5px',
+        fontSize: '0.75rem'
+    },
 });
 
 interface ProjectDetailsComponentDataProps {
@@ -54,6 +62,12 @@ interface ProjectDetailsComponentActionProps {
     onClick: (prj: ProjectUpdateFormDialogData) => () => void;
 }
 
+const mapStateToProps = (state: RootState): { resources: ResourcesState } => {
+    return {
+        resources: state.resources
+    };
+};
+
 const mapDispatchToProps = (dispatch: Dispatch) => ({
     onClick: (prj: ProjectUpdateFormDialogData) =>
         () => dispatch<any>(openProjectUpdateDialog(prj)),
@@ -61,23 +75,26 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
 
 type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
 
-const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
+const ProjectDetailsComponent = connect(mapStateToProps, mapDispatchToProps)(
     withStyles(styles)(
-        ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
+        ({ classes, project, resources, onClick }: ProjectDetailsComponentProps & { resources: ResourcesState }) => <div>
             {project.groupClass !== GroupClass.FILTER ?
-                    <Button onClick={onClick({
-                        uuid: project.uuid,
-                        name: project.name,
-                        description: project.description,
-                        properties: project.properties,
-                    })}>
-                        <RenameIcon className={classes.editIcon} /> Edit
-                    </Button>
-                    : ''
-                }
+                <Button onClick={onClick({
+                    uuid: project.uuid,
+                    name: project.name,
+                    description: project.description,
+                    properties: project.properties,
+                })}
+                    disabled={resourceIsFrozen(project, resources)}
+                    className={classes.editButton} variant='contained'
+                    data-cy='details-panel-edit-btn' color='primary' size='small'>
+                    <RenameIcon className={classes.editIcon} /> Edit
+                </Button>
+                : ''
+            }
             <DetailsAttribute label='Type' value={project.groupClass === GroupClass.FILTER ? 'Filter group' : resourceLabel(ResourceKind.PROJECT)} />
             <DetailsAttribute label='Owner' linkToUuid={project.ownerUuid}
-                uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />
+                uuidEnhancer={(uuid: string) => <ResourceWithName uuid={uuid} />} />
             <DetailsAttribute label='Last modified' value={formatDate(project.modifiedAt)} />
             <DetailsAttribute label='Created at' value={formatDate(project.createdAt)} />
             <DetailsAttribute label='UUID' linkToUuid={project.uuid} value={project.uuid} />
@@ -94,9 +111,9 @@ const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
             {
                 Object.keys(project.properties).map(k =>
                     Array.isArray(project.properties[k])
-                    ? project.properties[k].map((v: string) =>
-                        getPropertyChip(k, v, undefined, classes.tag))
-                    : getPropertyChip(k, project.properties[k], undefined, classes.tag)
+                        ? project.properties[k].map((v: string) =>
+                            getPropertyChip(k, v, undefined, classes.tag))
+                        : getPropertyChip(k, project.properties[k], undefined, classes.tag)
                 )
             }
         </div>
