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 } 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';
22 export class ProjectDetails extends DetailsData<ProjectResource> {
23 getIcon(className?: string) {
24 return <ProjectIcon className={className} />;
28 return <ProjectDetailsComponent project={this.item} />;
32 type CssRules = 'tag' | 'editIcon';
34 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
36 marginRight: theme.spacing.unit,
37 marginBottom: theme.spacing.unit
45 interface ProjectDetailsComponentDataProps {
46 project: ProjectResource;
49 interface ProjectDetailsComponentActionProps {
53 const mapDispatchToProps = (dispatch: Dispatch) => ({
54 onClick: () => dispatch<any>(openProjectPropertiesDialog()),
57 type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
59 const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
61 ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
62 <DetailsAttribute label='Type' value={resourceLabel(ResourceKind.PROJECT)} />
63 <DetailsAttribute label='Owner' linkToUuid={project.ownerUuid}
64 uuidEnhancer={(uuid: string) => <ResourceOwnerWithName uuid={uuid} />} />
65 <DetailsAttribute label='Last modified' value={formatDate(project.modifiedAt)} />
66 <DetailsAttribute label='Created at' value={formatDate(project.createdAt)} />
67 <DetailsAttribute label='Project UUID' linkToUuid={project.uuid} value={project.uuid} />
68 <DetailsAttribute label='Description'>
69 {project.description ?
71 title={`Description of ${project.name}`}
72 content={project.description}
73 label='Show full description' />
77 <DetailsAttribute label='Properties'>
78 <div onClick={onClick}>
79 <RenameIcon className={classes.editIcon} />
83 Object.keys(project.properties).map(k =>
84 Array.isArray(project.properties[k])
85 ? project.properties[k].map((v: string) =>
86 getPropertyChip(k, v, undefined, classes.tag))
87 : getPropertyChip(k, project.properties[k], undefined, classes.tag)