19434: fixed ripple shape, moved some inline styles to where they should be
[arvados.git] / src / views-components / dialog-update / dialog-collection-update.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { InjectedFormProps } from 'redux-form';
7 import { WithDialogProps } from 'store/dialog/with-dialog';
8 import { CollectionUpdateFormDialogData, COLLECTION_UPDATE_FORM_NAME } from 'store/collections/collection-update-actions';
9 import { FormDialog } from 'components/form-dialog/form-dialog';
10 import {
11     CollectionNameField,
12     CollectionDescriptionField,
13     CollectionStorageClassesField
14 } from 'views-components/form-fields/collection-form-fields';
15 import { UpdateCollectionPropertiesForm } from 'views-components/collection-properties/update-collection-properties-form';
16 import { FormGroup, FormLabel, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
17 import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
18
19 type CssRules = 'propertiesForm';
20
21 const styles: StyleRulesCallback<CssRules> = theme => ({
22     propertiesForm: {
23         marginTop: theme.spacing.unit * 2,
24         marginBottom: theme.spacing.unit * 2,
25     },
26 });
27
28 type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionUpdateFormDialogData>;
29
30 export const DialogCollectionUpdate = (props: DialogCollectionProps) =>
31     <FormDialog
32         dialogTitle='Edit Collection'
33         formFields={CollectionEditFields as any}
34         submitLabel='Save'
35         {...props}
36     />;
37
38 const UpdateCollectionPropertiesList = resourcePropertiesList(COLLECTION_UPDATE_FORM_NAME);
39
40 const CollectionEditFields = withStyles(styles)(
41     ({ classes }: WithStyles<CssRules>) => <span>
42         <CollectionNameField />
43         <CollectionDescriptionField />
44         <div className={classes.propertiesForm}>
45             <FormLabel>Properties</FormLabel>
46             <FormGroup>
47                 <UpdateCollectionPropertiesForm />
48                 <UpdateCollectionPropertiesList />
49             </FormGroup>
50         </div>
51         <CollectionStorageClassesField />
52     </span>);