1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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";
12 const FILE_REMOVE_DIALOG = 'fileRemoveDialog';
14 const mapDispatchToProps = (dispatch: Dispatch) => ({
16 // TODO: dispatch action that removes single file
17 dispatch(dialogActions.CLOSE_DIALOG({ id: FILE_REMOVE_DIALOG }));
18 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing file...', hideDuration: 2000 }));
20 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File removed.', hideDuration: 2000 }));
25 export const openFileRemoveDialog = (fileId: string) =>
26 dialogActions.OPEN_DIALOG({
27 id: FILE_REMOVE_DIALOG,
29 title: 'Removing file',
30 text: 'Are you sure you want to remove this file?',
31 confirmButtonLabel: 'Remove',
36 export const [FileRemoveDialog] = [ConfirmationDialog]
37 .map(withDialog(FILE_REMOVE_DIALOG))
38 .map(connect(undefined, mapDispatchToProps));