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 { RootState } from "~/store/store";
8 import { Field } from "redux-form";
9 import { ResourcesState, getResource } from "~/store/resources/resources";
10 import { GroupResource } from "~/models/group";
11 import { TextField } from "~/components/text-field/text-field";
12 import { getUserUuid } from "~/common/getuser";
14 interface ResourceParentFieldProps {
15 resources: ResourcesState;
16 userUuid: string|undefined;
19 export const ResourceParentField = connect(
20 (state: RootState) => {
22 resources: state.resources,
23 userUuid: getUserUuid(state),
26 ((props: ResourceParentFieldProps) =>
27 <span data-cy='parent-field'><Field
30 label='Parent project'
33 if (value === props.userUuid) {
34 return 'Home project';
36 const rsc = getResource<GroupResource>(value)(props.resources);
37 if (rsc !== undefined) {
38 return `${rsc.name} (${rsc.uuid})`;
43 component={TextField} /></span>