19079: Add search results context menu with clipboard and new tab options
[arvados.git] / src / views-components / run-process-dialog / change-workflow-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 { RootState } from 'store/store';
8 import { setWorkflow, SET_WORKFLOW_DIALOG } from 'store/run-process-panel/run-process-panel-actions';
9 import { ConfirmationDialog } from "components/confirmation-dialog/confirmation-dialog";
10 import { withDialog, WithDialogProps } from "store/dialog/with-dialog";
11 import { WorkflowResource } from 'models/workflow';
12
13 const mapStateToProps = (state: RootState, props: WithDialogProps<{ workflow: WorkflowResource }>) => ({
14     workflow: props.data.workflow
15 });
16
17 const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
18     onConfirm: (workflow: WorkflowResource) => {
19         props.closeDialog();
20         dispatch<any>(setWorkflow(workflow));
21     }
22 });
23
24 const mergeProps = (
25     stateProps: { workflow: WorkflowResource },
26     dispatchProps: { onConfirm: (workflow: WorkflowResource) => void },
27     props: WithDialogProps<{ workflow: WorkflowResource }>) => ({
28         onConfirm: () => dispatchProps.onConfirm(stateProps.workflow),
29         ...props
30     });
31
32 export const [ChangeWorkflowDialog] = [ConfirmationDialog]
33     .map(connect(mapStateToProps, mapDispatchToProps, mergeProps) as any)
34     .map(withDialog(SET_WORKFLOW_DIALOG));