Skip to content

Commit 669ebf9

Browse files
committed
Add collection entity add/remove forms to menu
1 parent cac0196 commit 669ebf9

File tree

4 files changed

+75
-39
lines changed

4 files changed

+75
-39
lines changed

src/components/collection/CollectionEntityAddForm.jsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import FormControl from '@material-ui/core/FormControl';
22
import FormControlLabel from '@material-ui/core/FormControlLabel';
3-
import Grid from '@material-ui/core/Grid';
43
import InputLabel from '@material-ui/core/InputLabel';
54
import MenuItem from '@material-ui/core/MenuItem';
65
import Typography from '@material-ui/core/Typography';
@@ -12,19 +11,7 @@ import BoolCheckbox from '../ui/BoolCheckbox';
1211
import Field from '../ui/Field';
1312
import FieldTypeArray from '../ui/FieldTypeArray';
1413
import FormSection from '../ui/FormSection';
15-
16-
function KeyValueType() {
17-
return (
18-
<Grid container spacing={8}>
19-
<Grid item sm={6}>
20-
<Field name="key" label="key" component={TextField} fullWidth />
21-
</Grid>
22-
<Grid item sm={6}>
23-
<Field name="value" label="value" component={TextField} fullWidth />
24-
</Grid>
25-
</Grid>
26-
);
27-
}
14+
import { KeyValuePairType } from '../ui/FormType';
2815

2916
const queryParams = () => (
3017
<>
@@ -36,6 +23,15 @@ const queryParams = () => (
3623
<MenuItem value="library">Library</MenuItem>
3724
</Field>
3825
</FormControl>
26+
<Field name="reference" label="Reference" component={TextField} fullWidth />
27+
<FormControl fullWidth>
28+
<InputLabel htmlFor="mode">Mode</InputLabel>
29+
<Field name="mode" component={Select}>
30+
<MenuItem value="REPLACE">Replace</MenuItem>
31+
<MenuItem value="ADD">Add</MenuItem>
32+
</Field>
33+
</FormControl>
34+
<Field name="before" label="Before" component={TextField} fullWidth />
3935
<FormControlLabel
4036
control={<Field name="addItems" component={BoolCheckbox} />}
4137
label="Add Items"
@@ -46,7 +42,7 @@ const queryParams = () => (
4642
arrayHeader
4743
withHeader={false}
4844
dense
49-
component={KeyValueType}
45+
component={KeyValuePairType}
5046
/>
5147
</>
5248
);

src/components/collection/CollectionEntityRemove.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function CollectionEntityRemove({
4242
};
4343
return (
4444
<Dialog open={open} onClose={onClose} fullWidth maxWidth={false}>
45-
<DialogTitle>Remove Entity From Collection</DialogTitle>
45+
<DialogTitle>
46+
{`Remove Entity${entityId ? ` ${entityId}` : ''} From Collection${collectionId ? ` ${collectionId}` : ''}`}
47+
</DialogTitle>
4648
<DialogContent>
4749
<CollectionEntityRemoveForm
4850
onSubmit={formActions.onRemoveEntity}

src/components/collection/CollectionEntityRemoveForm.jsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,32 @@ const queryParams = () => (
1717
<MenuItem value="collection">Collection</MenuItem>
1818
<MenuItem value="library">Library</MenuItem>
1919
</Field>
20+
<Field name="reference" label="Reference" component={TextField} fullWidth />
2021
</FormControl>
2122
);
2223

23-
function CollectionEntityRemoveForm({ error, handleSubmit }) {
24+
function CollectionEntityRemoveForm({ error, collectionId, entityId, handleSubmit }) {
2425
return (
2526
<form onSubmit={handleSubmit}>
2627
{error && <Typography color="error">{error}</Typography>}
27-
<Field name="collectionId" label="Collection ID" component={TextField} fullWidth />
28-
<Field name="entityId" label="Entity ID" component={TextField} fullWidth />
28+
{!collectionId && (
29+
<Field
30+
name="collectionId"
31+
label="Collection ID"
32+
component={TextField}
33+
validate={[required]}
34+
fullWidth
35+
/>
36+
)}
37+
{!entityId && (
38+
<Field
39+
name="entityId"
40+
label="Entity ID"
41+
component={TextField}
42+
validate={[required]}
43+
fullWidth
44+
/>
45+
)}
2946
<FormSection name="queryParams" component={queryParams} />
3047
</form>
3148
);

src/containers/Collection.jsx

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import { PureComponent } from 'react';
22

33
import List from '@material-ui/core/List';
4-
import Typography from '@material-ui/core/Typography';
54
import { Route, Switch, generatePath } from 'react-router-dom';
65
import { compose } from 'redux';
76

87
import AccessControlDialog from '../components/access/AccessControlDialog';
98
import CollectionEntityAdd from '../components/collection/CollectionEntityAdd';
9+
import CollectionEntityRemove from '../components/collection/CollectionEntityRemove';
1010
import CollectionExport from '../components/collection/CollectionExport';
1111
import CollectionFolderMap from '../components/collection/CollectionFolderMap';
1212
import CollectionRemove from '../components/collection/CollectionRemove';
1313
import CollectionRename from '../components/collection/CollectionRename';
1414
import DrawerContainer from '../components/ui/DrawerContainer';
1515
import ListItemLink from '../components/ui/ListItemLink';
16-
import Menu, { MenuItem } from '../components/ui/Menu';
1716
import TitleHeader from '../components/ui/TitleHeader';
1817
import withTabs from '../hoc/withTabs';
1918
import withUI from '../hoc/withUI';
@@ -48,6 +47,7 @@ const COLLECTION_EXPORT_DIALOG = 'COLLECTION_EXPORT_DIALOG';
4847
const COLLECTION_RENAME_DIALOG = 'COLLECTION_RENAME_DIALOG';
4948
const COLLECTION_ENTITY_ADD_DIALOG = 'COLLECTION_ENTITY_ADD_DIALOG';
5049
const COLLECTION_FOLDERMAP_DIALOG = 'COLLECTION_FOLDERMAP_DIALOG';
50+
const REMOVE_COLLECTION_ENTITY_GENERIC_DIALOG = 'REMOVE_COLLECTION_ENTITY_GENERIC_DIALOG';
5151
const ACCESSGRAPH_TAB = 'ACCESSGRAPH_TAB';
5252
const METADATAGRAPH_TAB = 'METADATAGRAPH_TAB';
5353
const SEQUENCE_TAB = 'SEQUENCE_TAB';
@@ -210,7 +210,7 @@ class Collection extends PureComponent {
210210
}
211211

212212
render() {
213-
const { onChangeTab, tabValue, collectionId, history, onOpen } = this.props;
213+
const { onChangeTab, tabValue, collectionId, history } = this.props;
214214
const { collectionName } = this.state;
215215
const titleComponent = (props) => (
216216
<TitleHeader
@@ -222,25 +222,41 @@ class Collection extends PureComponent {
222222
entityId={collectionId}
223223
entityType="collection"
224224
addAccessControl={COLLECTION_ACCESSCONTROL_ADD_DIALOG}
225-
exportModal={COLLECTION_EXPORT_DIALOG}
226225
titleChip={collectionName}
227-
actionComponent={
228-
<Menu>
229-
<MenuItem onClick={() => onOpen({ modalName: COLLECTION_ENTITY_ADD_DIALOG })}>
230-
<Typography>Add Entity</Typography>
231-
</MenuItem>
232-
<MenuItem onClick={() => onOpen({ modalName: COLLECTION_RENAME_DIALOG })}>
233-
<Typography>Rename</Typography>
234-
</MenuItem>
235-
<MenuItem onClick={() => onOpen({ modalName: COLLECTION_FOLDERMAP_DIALOG })}>
236-
<Typography>Map To Folder</Typography>
237-
</MenuItem>
238-
<MenuItem onClick={() => onOpen({ modalName: COLLECTION_REMOVE_DIALOG })}>
239-
<Typography color="secondary">Delete Collection</Typography>
240-
</MenuItem>
241-
</Menu>
242-
}
243226
{...props}
227+
menuList={[
228+
{
229+
label: 'Add Entity',
230+
modalName: COLLECTION_ENTITY_ADD_DIALOG,
231+
},
232+
{
233+
label: 'Rename',
234+
modalName: COLLECTION_RENAME_DIALOG,
235+
},
236+
{
237+
label: 'Map To Folder',
238+
modalName: COLLECTION_FOLDERMAP_DIALOG,
239+
},
240+
{
241+
label: 'Add Access Control',
242+
modalName: COLLECTION_ACCESSCONTROL_ADD_DIALOG,
243+
},
244+
{
245+
label: 'Export',
246+
modalName: COLLECTION_EXPORT_DIALOG,
247+
},
248+
...(props?.menuList || []),
249+
{
250+
label: 'Remove Entity',
251+
modalName: REMOVE_COLLECTION_ENTITY_GENERIC_DIALOG,
252+
color: 'secondary',
253+
},
254+
{
255+
label: 'Delete Collection',
256+
modalName: COLLECTION_REMOVE_DIALOG,
257+
color: 'secondary',
258+
},
259+
]}
244260
/>
245261
);
246262
return (
@@ -290,6 +306,11 @@ class Collection extends PureComponent {
290306
onSuccess={(response) => history.push(`/job/${response.data.jobId}/`)}
291307
collectionId={collectionId}
292308
/>
309+
<CollectionEntityRemove
310+
dialogName={REMOVE_COLLECTION_ENTITY_GENERIC_DIALOG}
311+
onSuccess={this.onRefresh}
312+
collectionId={collectionId}
313+
/>
293314
</>
294315
);
295316
}

0 commit comments

Comments
 (0)