merge master
[arvados-workbench2.git] / src / views-components / file-remove-dialog / multiple-files-remove-dialog.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from "redux";
6 import { connect } from "react-redux";
7 import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
8 import { withDialog } from "~/store/dialog/with-dialog";
9 import { dialogActions } from "~/store/dialog/dialog-actions";
10 import { snackbarActions } from "~/store/snackbar/snackbar-actions";
11
12 const MULTIPLE_FILES_REMOVE_DIALOG = 'multipleFilesRemoveDialog';
13
14 const mapDispatchToProps = (dispatch: Dispatch) => ({
15     onConfirm: () => {
16         // TODO: dispatch action that removes multiple files
17         dispatch(dialogActions.CLOSE_DIALOG({ id: MULTIPLE_FILES_REMOVE_DIALOG }));
18         dispatch(snackbarActions.OPEN_SNACKBAR({message: 'Removing files...', hideDuration: 2000}));
19         setTimeout(() => {
20             dispatch(snackbarActions.OPEN_SNACKBAR({message: 'Files removed.', hideDuration: 2000}));
21         }, 1000);
22     }
23 });
24
25 export const openMultipleFilesRemoveDialog = () =>
26     dialogActions.OPEN_DIALOG({
27         id: MULTIPLE_FILES_REMOVE_DIALOG,
28         data: {
29             title: 'Removing files',
30             text: 'Are you sure you want to remove selected files?',
31             confirmButtonLabel: 'Remove'
32         }
33     });
34
35 export const [MultipleFilesRemoveDialog] = [ConfirmationDialog]
36     .map(withDialog(MULTIPLE_FILES_REMOVE_DIALOG))
37     .map(connect(undefined, mapDispatchToProps));