basic-view-recent-queries
[arvados-workbench2.git] / src / views-components / dialog-copy / dialog-copy.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 { InjectedFormProps, Field } from 'redux-form';
7 import { WithDialogProps } from '~/store/dialog/with-dialog';
8 import { FormDialog } from '~/components/form-dialog/form-dialog';
9 import { ProjectTreePickerField } from '~/views-components/project-tree-picker/project-tree-picker';
10 import { COPY_NAME_VALIDATION, COPY_FILE_VALIDATION } from '~/validators/validators';
11 import { TextField } from "~/components/text-field/text-field";
12 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
13
14 type CopyFormDialogProps = WithDialogProps<string> & InjectedFormProps<CopyFormDialogData>;
15
16 export const DialogCopy = (props: CopyFormDialogProps) =>
17     <FormDialog
18         dialogTitle='Make a copy'
19         formFields={CopyDialogFields}
20         submitLabel='Copy'
21         {...props}
22     />;
23
24 const CopyDialogFields = () => <span>
25     <Field
26         name='name'
27         component={TextField}
28         validate={COPY_NAME_VALIDATION}
29         label="Enter a new name for the copy" />
30     <Field
31         name="ownerUuid"
32         component={ProjectTreePickerField}
33         validate={COPY_FILE_VALIDATION} />
34 </span>;