1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { Field, Validator } from "redux-form";
7 import { TextField } from "~/components/text-field/text-field";
9 COLLECTION_NAME_VALIDATION, COLLECTION_NAME_VALIDATION_ALLOW_SLASH,
10 COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION
11 } from "~/validators/validators";
12 import { ProjectTreePickerField, CollectionTreePickerField } from "~/views-components/projects-tree-picker/tree-picker-field";
13 import { PickerIdProp } from '~/store/tree-picker/picker-id';
14 import { connect } from "react-redux";
15 import { RootState } from "~/store/store";
17 interface CollectionNameFieldProps {
18 validate: Validator[];
21 // See implementation note on declaration of ProjectNameField
23 export const CollectionNameField = connect(
24 (state: RootState) => {
26 validate: (state.auth.config.clusterConfig.Collections.ForwardSlashNameSubstitution === "" ?
27 COLLECTION_NAME_VALIDATION : COLLECTION_NAME_VALIDATION_ALLOW_SLASH)
29 })((props: CollectionNameFieldProps) =>
30 <span data-cy='name-field'><Field
33 validate={props.validate}
34 label="Collection Name"
35 autoFocus={true} /></span>
38 export const CollectionDescriptionField = () =>
42 validate={COLLECTION_DESCRIPTION_VALIDATION}
43 label="Description - optional" />;
45 export const CollectionProjectPickerField = (props: PickerIdProp) =>
48 pickerId={props.pickerId}
49 component={ProjectTreePickerField}
50 validate={COLLECTION_PROJECT_VALIDATION} />;
52 export const CollectionPickerField = (props: PickerIdProp) =>
55 pickerId={props.pickerId}
56 component={CollectionTreePickerField}
57 validate={COLLECTION_PROJECT_VALIDATION} />;