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, 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';
12 const mapStateToProps = (state: RootState, props: WithDialogProps<{ filePath: string }>) => ({
13 filePath: props.data.filePath
16 const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<{ filePath: string }>) => ({
17 onConfirm: (filePath: string) => {
19 dispatch<any>(removeCollectionFiles([filePath]));
24 stateProps: { filePath: string },
25 dispatchProps: { onConfirm: (filePath: string) => void },
26 props: WithDialogProps<{ filePath: string }>) => ({
27 onConfirm: () => dispatchProps.onConfirm(stateProps.filePath),
31 export const [FileRemoveDialog] = [ConfirmationDialog]
32 .map(connect(mapStateToProps, mapDispatchToProps, mergeProps))
33 .map(withDialog(FILE_REMOVE_DIALOG));