1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { connect } from 'react-redux';
7 import { openProjectPropertiesDialog } from '~/store/details-panel/details-panel-action';
8 import { ProjectIcon, RenameIcon, FilterGroupIcon } from '~/components/icon/icon';
9 import { ProjectResource } from '~/models/project';
10 import { formatDate } from '~/common/formatters';
11 import { ResourceKind } from '~/models/resource';
12 import { resourceLabel } from '~/common/labels';
13 import { DetailsData } from "./details-data";
14 import { DetailsAttribute } from "~/components/details-attribute/details-attribute";
15 import { RichTextEditorLink } from '~/components/rich-text-editor-link/rich-text-editor-link';
16 import { withStyles, StyleRulesCallback, WithStyles } from '@material-ui/core';
17 import { ArvadosTheme } from '~/common/custom-theme';
18 import { Dispatch } from 'redux';
19 import { getPropertyChip } from '../resource-properties-form/property-chip';
20 import { ResourceOwnerWithName } from '../data-explorer/renderers';
21 import { GroupClass } from "~/models/group";
23 export class ProjectDetails extends DetailsData<ProjectResource> {
24 getIcon(className?: string) {
25 if (this.item.groupClass === GroupClass.FILTER) {
26 return <FilterGroupIcon className={className} />;
28 return <ProjectIcon className={className} />;
32 return <ProjectDetailsComponent project={this.item} />;
36 type CssRules = 'tag' | 'editIcon';
38 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
40 marginRight: theme.spacing.unit,
41 marginBottom: theme.spacing.unit
49 interface ProjectDetailsComponentDataProps {
50 project: ProjectResource;
53 interface ProjectDetailsComponentActionProps {
57 const mapDispatchToProps = (dispatch: Dispatch) => ({
58 onClick: () => dispatch<any>(openProjectPropertiesDialog()),
61 type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
63 const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
65 ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
66 <DetailsAttribute label='Type' value={project.groupClass === GroupClass.FILTER ? 'Filter group' : resourceLabel(ResourceKind.PROJECT)} />
67 <DetailsAttribute label='Owner' linkToUuid={project.ownerUuid}
68 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />
69 <DetailsAttribute label='Last modified' value={formatDate(project.modifiedAt)} />
70 <DetailsAttribute label='Created at' value={formatDate(project.createdAt)} />
71 <DetailsAttribute label='UUID' linkToUuid={project.uuid} value={project.uuid} />
72 <DetailsAttribute label='Description'>
73 {project.description ?
75 title={`Description of ${project.name}`}
76 content={project.description}
77 label='Show full description' />
81 <DetailsAttribute label='Properties'>
82 {project.groupClass !== GroupClass.FILTER ?
83 <div onClick={onClick}>
84 <RenameIcon className={classes.editIcon} />
90 Object.keys(project.properties).map(k =>
91 Array.isArray(project.properties[k])
92 ? project.properties[k].map((v: string) =>
93 getPropertyChip(k, v, undefined, classes.tag))
94 : getPropertyChip(k, project.properties[k], undefined, classes.tag)