import { withDialog } from "../../store/dialog/with-dialog";
import { dialogActions } from "../../store/dialog/dialog-actions";
import { DialogCollectionCreateWithSelected } from "../dialog-create/dialog-collection-create-selected";
+import { loadProjectTreePickerProjects } from "../project-tree-picker/project-tree-picker";
export const DIALOG_COLLECTION_CREATE_WITH_SELECTED = 'dialogCollectionCreateWithSelected';
export const createCollectionWithSelected = () =>
(dispatch: Dispatch) => {
dispatch(reset(DIALOG_COLLECTION_CREATE_WITH_SELECTED));
+ dispatch<any>(loadProjectTreePickerProjects(''));
dispatch(dialogActions.OPEN_DIALOG({ id: DIALOG_COLLECTION_CREATE_WITH_SELECTED, data: {} }));
};
// SPDX-License-Identifier: AGPL-3.0
import * as React from "react";
-import { InjectedFormProps, Field } from "redux-form";
-import { Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress } from "@material-ui/core";
+import { InjectedFormProps, Field, WrappedFieldProps } from "redux-form";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, FormHelperText } from "@material-ui/core";
import { WithDialogProps } from "../../store/dialog/with-dialog";
import { TextField } from "../../components/text-field/text-field";
-import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from "../../validators/create-project/create-project-validator";
+import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION } from "../../validators/create-project/create-project-validator";
+import { ProjectTreePicker } from "../project-tree-picker/project-tree-picker";
export const DialogCollectionCreateWithSelected = (props: WithDialogProps<string> & InjectedFormProps<{ name: string }>) =>
<form>
validate={COLLECTION_DESCRIPTION_VALIDATION}
label="Description - optional" />
</div>
- <div style={{ overflowY: 'auto' }}>TREE</div>
+ <Field
+ name="projectUuid"
+ component={Picker}
+ validate={COLLECTION_PROJECT_VALIDATION} />
</DialogContent>
<DialogActions>
<Button
</Button>
</DialogActions>
</Dialog>
- </form>;
\ No newline at end of file
+ </form>;
+
+const Picker = (props: WrappedFieldProps) =>
+ <div style={{ width: '400px', height: '144px', display: 'flex', flexDirection: 'column' }}>
+ <ProjectTreePicker onChange={projectUuid => props.input.onChange(projectUuid)} />
+ </div>;
type ProjectTreePickerProps = Pick<TreeProps<ProjectResource>, 'toggleItemActive' | 'toggleItemOpen'>;
-const mapDispatchToProps = (dispatch: Dispatch): ProjectTreePickerProps => ({
+const mapDispatchToProps = (dispatch: Dispatch, props: {onChange: (projectUuid: string) => void}): ProjectTreePickerProps => ({
toggleItemActive: id => {
dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_SELECT({ id }));
+ props.onChange(id);
},
toggleItemOpen: (id, status) => {
status === TreeItemStatus.INITIAL
});
export const ProjectTreePicker = connect(undefined, mapDispatchToProps)((props: ProjectTreePickerProps) =>
- <div>
- <Typography variant='caption'>
+ <div style={{display: 'flex', flexDirection: 'column'}}>
+ <Typography variant='caption' style={{flexShrink: 0}}>
Select a project
</Typography>
- <TreePicker {...props} render={renderTreeItem} />
+ <div style={{flexGrow: 1, overflow: 'auto'}}>
+ <TreePicker {...props} render={renderTreeItem} />
+ </div>
</div>);
// TODO: move action creator to store directory