1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch, compose } from "redux";
6 import { reduxForm, reset, startSubmit, stopSubmit } from "redux-form";
7 import { withDialog } from "~/store/dialog/with-dialog";
8 import { dialogActions } from "~/store/dialog/dialog-actions";
9 import { DialogCollectionCreateWithSelected } from "../dialog-create/dialog-collection-create-selected";
10 import { loadProjectTreePickerProjects } from "../project-tree-picker/project-tree-picker";
12 export const DIALOG_COLLECTION_CREATE_WITH_SELECTED = 'dialogCollectionCreateWithSelected';
14 export const createCollectionWithSelected = () =>
15 (dispatch: Dispatch) => {
16 dispatch(reset(DIALOG_COLLECTION_CREATE_WITH_SELECTED));
17 dispatch<any>(loadProjectTreePickerProjects(''));
18 dispatch(dialogActions.OPEN_DIALOG({ id: DIALOG_COLLECTION_CREATE_WITH_SELECTED, data: {} }));
22 export const DialogCollectionCreateWithSelectedFile = compose(
23 withDialog(DIALOG_COLLECTION_CREATE_WITH_SELECTED),
25 form: DIALOG_COLLECTION_CREATE_WITH_SELECTED,
26 onSubmit: (data, dispatch) => {
27 dispatch(startSubmit(DIALOG_COLLECTION_CREATE_WITH_SELECTED));
28 setTimeout(() => dispatch(stopSubmit(DIALOG_COLLECTION_CREATE_WITH_SELECTED, { name: 'Invalid name' })), 2000);
30 }))(DialogCollectionCreateWithSelected);