Merge branch 'master' into 14078-obtain-configuration-data-from-discovery-endpoint
[arvados.git] / src / views-components / move-to-dialog / move-to-dialog.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch, compose } from "redux";
6 import { withDialog } from "../../store/dialog/with-dialog";
7 import { dialogActions } from "../../store/dialog/dialog-actions";
8 import { MoveToDialog } from "../../components/move-to-dialog/move-to-dialog";
9 import { reduxForm, startSubmit, stopSubmit } from "redux-form";
10 import { resetPickerProjectTree } from "~/store/project-tree-picker/project-tree-picker-actions";
11
12 export const MOVE_TO_DIALOG = 'moveToDialog';
13
14 export const openMoveToDialog = () =>
15     (dispatch: Dispatch) => {
16         dispatch<any>(resetPickerProjectTree());
17         dispatch(dialogActions.OPEN_DIALOG({ id: MOVE_TO_DIALOG, data: {} }));
18     };
19
20 export const MoveToProjectDialog = compose(
21     withDialog(MOVE_TO_DIALOG),
22     reduxForm({
23         form: MOVE_TO_DIALOG,
24         onSubmit: (data, dispatch) => {
25             dispatch(startSubmit(MOVE_TO_DIALOG));
26             setTimeout(() => dispatch(stopSubmit(MOVE_TO_DIALOG, { name: 'Invalid path' })), 2000);
27         }
28     })
29 )(MoveToDialog);