Update process statuses, update process status rendering in tables, disable process...
[arvados.git] / src / views-components / file-remove-dialog / file-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, WithDialogProps } from '~/store/dialog/with-dialog';
9 import { RootState } from '~/store/store';
10 import { removeCollectionFiles, FILE_REMOVE_DIALOG } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
11
12 const mapStateToProps = (state: RootState, props: WithDialogProps<{ filePath: string }>) => ({
13     filePath: props.data.filePath
14 });
15
16 const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<{ filePath: string }>) => ({
17     onConfirm: (filePath: string) => {
18         props.closeDialog();
19         dispatch<any>(removeCollectionFiles([filePath]));
20     }
21 });
22
23 const mergeProps = (
24     stateProps: { filePath: string },
25     dispatchProps: { onConfirm: (filePath: string) => void },
26     props: WithDialogProps<{ filePath: string }>) => ({
27         onConfirm: () => dispatchProps.onConfirm(stateProps.filePath),
28         ...props
29     });
30
31 export const [FileRemoveDialog] = [ConfirmationDialog]
32     .map(connect(mapStateToProps, mapDispatchToProps, mergeProps))
33     .map(withDialog(FILE_REMOVE_DIALOG));