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';
21 export class ProjectDetails extends DetailsData<ProjectResource> {
22 getIcon(className?: string) {
23 return <ProjectIcon className={className} />;
27 return <ProjectDetailsComponent project={this.item} />;
31 type CssRules = 'tag' | 'editIcon';
33 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
35 marginRight: theme.spacing.unit,
36 marginBottom: theme.spacing.unit
44 interface ProjectDetailsComponentDataProps {
45 project: ProjectResource;
48 interface ProjectDetailsComponentActionProps {
52 const mapDispatchToProps = (dispatch: Dispatch) => ({
53 onClick: () => dispatch<any>(openProjectPropertiesDialog()),
56 type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
58 const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
60 ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
61 <DetailsAttribute label='Type' value={resourceLabel(ResourceKind.PROJECT)} />
62 <DetailsAttribute label='Owner' linkToUuid={project.ownerUuid} lowercaseValue={true} />
63 <DetailsAttribute label='Last modified' value={formatDate(project.modifiedAt)} />
64 <DetailsAttribute label='Created at' value={formatDate(project.createdAt)} />
65 <DetailsAttribute label='Project UUID' linkToUuid={project.uuid} value={project.uuid} />
66 <DetailsAttribute label='Description'>
67 {project.description ?
69 title={`Description of ${project.name}`}
70 content={project.description}
71 label='Show full description' />
75 <DetailsAttribute label='Properties'>
76 <div onClick={onClick}>
77 <RenameIcon className={classes.editIcon} />
81 Object.keys(project.properties).map(k =>
82 Array.isArray(project.properties[k])
83 ? project.properties[k].map((v: string) =>
84 getPropertyChip(k, v, undefined, classes.tag))
85 : getPropertyChip(k, project.properties[k], undefined, classes.tag)