1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { connect } from 'react-redux';
7 import { ProjectsIcon } from 'components/icon/icon';
8 import { formatDate } from 'common/formatters';
9 import { DetailsData } from "./details-data";
10 import { DetailsAttribute } from "components/details-attribute/details-attribute";
11 import { withStyles, StyleRulesCallback, WithStyles } from '@material-ui/core';
12 import { ArvadosTheme } from 'common/custom-theme';
13 import { Dispatch } from 'redux';
14 import { openProjectUpdateDialog, ProjectUpdateFormDialogData } from 'store/projects/project-update-actions';
15 import { RootState } from 'store/store';
16 import { ResourcesState } from 'store/resources/resources';
17 import { UserResource } from 'models/user';
18 import { UserResourceFullName } from 'views-components/data-explorer/renderers';
20 export class RootProjectDetails extends DetailsData<UserResource> {
21 getIcon(className?: string) {
22 return <ProjectsIcon className={className} />;
26 return <RootProjectDetailsComponent rootProject={this.item} />;
30 type CssRules = 'tag' | 'editIcon' | 'editButton';
32 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
34 marginRight: theme.spacing.unit / 2,
35 marginBottom: theme.spacing.unit / 2,
38 paddingRight: theme.spacing.unit / 2,
43 padding: '2px 10px 2px 5px',
48 interface RootProjectDetailsComponentDataProps {
52 const mapStateToProps = (state: RootState): { resources: ResourcesState } => {
54 resources: state.resources
58 const mapDispatchToProps = (dispatch: Dispatch) => ({
59 onClick: (prj: ProjectUpdateFormDialogData) =>
60 () => dispatch<any>(openProjectUpdateDialog(prj)),
63 type RootProjectDetailsComponentProps = RootProjectDetailsComponentDataProps & WithStyles<CssRules>;
65 const RootProjectDetailsComponent = connect(mapStateToProps, mapDispatchToProps)(
67 ({ rootProject}: RootProjectDetailsComponentProps & { resources: ResourcesState }) => <div>
68 <DetailsAttribute label='Type' value="Root Project" />
69 <DetailsAttribute label='User' />
70 <UserResourceFullName uuid={rootProject.uuid} link={true} />
71 <DetailsAttribute label='Created at' value={formatDate(rootProject.createdAt)} />
72 <DetailsAttribute label='UUID' linkToUuid={rootProject.uuid} value={rootProject.uuid} />