1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { compose } from 'redux';
7 import { connect } from 'react-redux';
8 import { openProjectPropertiesDialog } from '~/store/details-panel/details-panel-action';
9 import { ProjectIcon, RenameIcon } from '~/components/icon/icon';
10 import { ProjectResource } from '~/models/project';
11 import { formatDate } from '~/common/formatters';
12 import { ResourceKind } from '~/models/resource';
13 import { resourceLabel } from '~/common/labels';
14 import { DetailsData } from "./details-data";
15 import { DetailsAttribute } from "~/components/details-attribute/details-attribute";
16 import { RichTextEditorLink } from '~/components/rich-text-editor-link/rich-text-editor-link';
17 import { withStyles, StyleRulesCallback, Chip, WithStyles } from '@material-ui/core';
18 import { ArvadosTheme } from '~/common/custom-theme';
20 export class ProjectDetails extends DetailsData<ProjectResource> {
21 getIcon(className?: string) {
22 return <ProjectIcon className={className} />;
26 return <ProjectDetailsComponent project={this.item} />;
30 type CssRules = 'tag' | 'editIcon';
32 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
34 marginRight: theme.spacing.unit,
35 marginBottom: theme.spacing.unit
44 interface ProjectDetailsComponentDataProps {
45 project: ProjectResource;
48 interface ProjectDetailsComponentActionProps {
52 const mapDispatchToProps = ({ onClick: openProjectPropertiesDialog });
54 type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
56 const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
58 ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
59 <DetailsAttribute label='Type' value={resourceLabel(ResourceKind.PROJECT)} />
61 <DetailsAttribute label='Size' value='---' />
62 <DetailsAttribute label='Owner' value={project.ownerUuid} lowercaseValue={true} />
63 <DetailsAttribute label='Last modified' value={formatDate(project.modifiedAt)} />
64 <DetailsAttribute label='Created at' value={formatDate(project.createdAt)} />
66 {/*<DetailsAttribute label='File size' value='1.4 GB' />*/}
67 <DetailsAttribute label='Description'>
68 {project.description ?
70 title={`Description of ${project.name}`}
71 content={project.description}
72 label='Show full description' />
76 <DetailsAttribute label='Properties'>
77 <div onClick={onClick}>
78 <RenameIcon className={classes.editIcon} />
82 Object.keys(project.properties).map(k => {
83 return <Chip key={k} className={classes.tag} label={`${k}: ${project.properties[k]}`} />;