1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } 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 { RenameDialog } from "~/components/rename-dialog/rename-dialog";
11 export const RENAME_FILE_DIALOG = 'renameFileDialog';
13 export const openRenameFileDialog = (originalName: string) =>
14 (dispatch: Dispatch) => {
15 dispatch(reset(RENAME_FILE_DIALOG));
16 dispatch(dialogActions.OPEN_DIALOG({ id: RENAME_FILE_DIALOG, data: originalName }));
19 export const [RenameFileDialog] = [RenameDialog]
20 .map(withDialog(RENAME_FILE_DIALOG))
22 form: RENAME_FILE_DIALOG,
23 onSubmit: (data, dispatch) => {
24 dispatch(startSubmit(RENAME_FILE_DIALOG));
25 // TODO: call collection file renaming action here
26 setTimeout(() => dispatch(stopSubmit(RENAME_FILE_DIALOG, { name: 'Invalid name' })), 2000);