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 { CustomStyleRulesCallback } from 'common/custom-theme';
12 import { withStyles, WithStyles } from '@material-ui/core';
13 import { ArvadosTheme } from 'common/custom-theme';
14 import { Dispatch } from 'redux';
15 import { openProjectUpdateDialog, ProjectUpdateFormDialogData } from 'store/projects/project-update-actions';
16 import { RootState } from 'store/store';
17 import { ResourcesState } from 'store/resources/resources';
18 import { UserResource } from 'models/user';
19 import { UserResourceFullName } from 'views-components/data-explorer/renderers';
21 export class RootProjectDetails extends DetailsData<UserResource> {
22 getIcon(className?: string) {
23 return <ProjectsIcon className={className} />;
27 return <RootProjectDetailsComponent rootProject={this.item} />;
31 type CssRules = 'tag' | 'editIcon' | 'editButton';
33 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
35 marginRight: theme.spacing.unit / 2,
36 marginBottom: theme.spacing.unit / 2,
39 paddingRight: theme.spacing.unit / 2,
44 padding: '2px 10px 2px 5px',
49 interface RootProjectDetailsComponentDataProps {
53 const mapStateToProps = (state: RootState): { resources: ResourcesState } => {
55 resources: state.resources
59 const mapDispatchToProps = (dispatch: Dispatch) => ({
60 onClick: (prj: ProjectUpdateFormDialogData) =>
61 () => dispatch<any>(openProjectUpdateDialog(prj)),
64 type RootProjectDetailsComponentProps = RootProjectDetailsComponentDataProps & WithStyles<CssRules>;
66 const RootProjectDetailsComponent = connect(mapStateToProps, mapDispatchToProps)(
68 ({ rootProject}: RootProjectDetailsComponentProps & { resources: ResourcesState }) => <div>
69 <DetailsAttribute label='Type' value="Root Project" />
70 <DetailsAttribute label='User' />
71 <UserResourceFullName uuid={rootProject.uuid} link={true} />
72 <DetailsAttribute label='Created at' value={formatDate(rootProject.createdAt)} />
73 <DetailsAttribute label='UUID' linkToUuid={rootProject.uuid} value={rootProject.uuid} />