forked from opensearch-project/dashboards-flow-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.tsx
46 lines (42 loc) · 1.27 KB
/
header.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import React, { useContext } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { EuiPageHeader, EuiButton } from '@elastic/eui';
import { Workflow } from '../../../../common';
import { saveWorkflow } from '../utils';
import { rfContext, AppState, removeDirty } from '../../../store';
interface WorkflowDetailHeaderProps {
tabs: any[];
workflow?: Workflow;
}
export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
const dispatch = useDispatch();
const { reactFlowInstance } = useContext(rfContext);
const isDirty = useSelector((state: AppState) => state.workspace.isDirty);
return (
<EuiPageHeader
pageTitle={props.workflow ? props.workflow.name : ''}
rightSideItems={[
<EuiButton fill={false} onClick={() => {}}>
Prototype
</EuiButton>,
<EuiButton
fill={false}
disabled={!props.workflow || !isDirty}
onClick={() => {
// @ts-ignore
saveWorkflow(props.workflow, reactFlowInstance);
dispatch(removeDirty());
}}
>
Save
</EuiButton>,
]}
tabs={props.tabs}
bottomBorder={true}
/>
);
}