Update filters in views so that the code can be compiled, leave TODO markers to guide...
[arvados.git] / src / views-components / details-panel / project-details.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
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';
19
20 export class ProjectDetails extends DetailsData<ProjectResource> {
21     getIcon(className?: string) {
22         return <ProjectIcon className={className} />;
23     }
24
25     getDetails() {
26         return <ProjectDetailsComponent project={this.item} />;
27     }
28 }
29
30 type CssRules = 'tag' | 'editIcon';
31
32 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
33     tag: {
34         marginRight: theme.spacing.unit,
35         marginBottom: theme.spacing.unit
36     },
37     editIcon: {
38         fontSize: '1.125rem',
39         cursor: 'pointer'
40     }
41 });
42
43
44 interface ProjectDetailsComponentDataProps {
45     project: ProjectResource;
46 }
47
48 interface ProjectDetailsComponentActionProps {
49     onClick: () => void;
50 }
51
52 const mapDispatchToProps = ({ onClick: openProjectPropertiesDialog });
53
54 type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
55
56 const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
57     withStyles(styles)(
58         ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
59             <DetailsAttribute label='Type' value={resourceLabel(ResourceKind.PROJECT)} />
60                 {/* Missing attr */}
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)} />
65                 {/* Missing attr */}
66                 {/*<DetailsAttribute label='File size' value='1.4 GB' />*/}
67                 <DetailsAttribute label='Description'>
68                     {project.description ?
69                         <RichTextEditorLink
70                             title={`Description of ${project.name}`}
71                             content={project.description}
72                             label='Show full description' />
73                         : '---'
74                     }
75                 </DetailsAttribute>
76                 <DetailsAttribute label='Properties'>
77                     <div onClick={onClick}>
78                         <RenameIcon className={classes.editIcon} />
79                     </div>
80                 </DetailsAttribute>
81                 {
82                     Object.keys(project.properties).map(k => {
83                         return <Chip key={k} className={classes.tag} label={`${k}: ${project.properties[k]}`} />;
84                     })
85                 }
86         </div>
87 ));