|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | import React, { Component } from 'react';
|
7 |
| -import PropTypes from 'prop-types'; |
8 | 7 | import { EuiSpacer } from '@elastic/eui';
|
9 |
| -import MonitorIndex from '../MonitorIndex'; |
10 |
| -import MonitorTimeField from '../../components/MonitorTimeField'; |
11 |
| -import { MONITOR_TYPE, SEARCH_TYPE } from '../../../../utils/constants'; |
| 8 | +import { connect } from 'formik'; |
12 | 9 | import MinimalAccordion from '../../../../components/FeatureAnywhereContextMenu/MinimalAccordion';
|
| 10 | +import DataSource from '../DataSource' |
13 | 11 |
|
14 |
| -interface DataSourceProps { |
15 |
| - values: Object; |
16 |
| - dataTypes: Object; |
17 |
| - httpClient: Object; |
18 |
| - notifications: Object; |
19 |
| - isMinimal: boolean; |
20 |
| - canCallGetRemoteIndexes: boolean; |
21 |
| - remoteMonitoringEnabled: boolean; |
22 |
| -} |
23 |
| -interface DataSourceState { |
24 |
| - performanceResponse: null | any; |
25 |
| - response: null | any; |
26 |
| - formikSnapshot: Object; |
27 |
| - accordionOpen: boolean; |
28 |
| -} |
29 |
| - |
30 |
| -const propTypes = { |
31 |
| - values: PropTypes.object.isRequired, |
32 |
| - dataTypes: PropTypes.object.isRequired, |
33 |
| - httpClient: PropTypes.object.isRequired, |
34 |
| - notifications: PropTypes.object.isRequired, |
35 |
| - isMinimal: PropTypes.bool, |
36 |
| - canCallGetRemoteIndexes: PropTypes.bool, |
37 |
| - remoteMonitoringEnabled: PropTypes.bool, |
38 |
| -}; |
39 |
| -const defaultProps = { |
40 |
| - isMinimal: false, |
41 |
| -}; |
42 |
| -class DataSourceFlyout extends Component<DataSourceProps, DataSourceState> { |
43 |
| - constructor(props: DataSourceProps) { |
| 12 | +class DataSourceFlyout extends Component<any, any> { |
| 13 | + constructor(props: any) { |
44 | 14 | super(props);
|
45 | 15 |
|
46 | 16 | this.state = {
|
47 |
| - performanceResponse: null, |
48 |
| - response: null, |
49 |
| - formikSnapshot: this.props.values, |
50 | 17 | accordionOpen: false,
|
51 | 18 | };
|
52 | 19 | }
|
53 | 20 |
|
54 | 21 | render() {
|
55 |
| - const { canCallGetRemoteIndexes, remoteMonitoringEnabled } = this.props; |
56 |
| - // @ts-ignore |
57 |
| - const { monitor_type, searchType } = this.props.values; |
58 |
| - const displayTimeField = |
59 |
| - searchType === SEARCH_TYPE.GRAPH && |
60 |
| - monitor_type !== MONITOR_TYPE.DOC_LEVEL && |
61 |
| - monitor_type !== MONITOR_TYPE.CLUSTER_METRICS; |
62 |
| - const monitorIndexDisplay = ( |
63 |
| - <> |
64 |
| - <MonitorIndex |
65 |
| - httpClient={this.props.httpClient} |
66 |
| - monitorType={monitor_type} |
67 |
| - canCallGetRemoteIndexes={canCallGetRemoteIndexes} |
68 |
| - remoteMonitoringEnabled={remoteMonitoringEnabled} |
69 |
| - /> |
70 |
| - |
71 |
| - {displayTimeField && ( |
72 |
| - <> |
73 |
| - <EuiSpacer /> |
74 |
| - <MonitorTimeField dataTypes={this.props.dataTypes} /> |
75 |
| - </> |
76 |
| - )} |
77 |
| - </> |
78 |
| - ); |
79 |
| - |
80 | 22 | return (
|
81 | 23 | <><MinimalAccordion
|
82 | 24 | {...{
|
83 | 25 | id: 'dataSource',
|
84 | 26 | isOpen: this.state.accordionOpen,
|
85 | 27 | onToggle: () => {this.setState({accordionOpen: !this.state.accordionOpen})},
|
86 | 28 | title: 'Data Source',
|
87 |
| - subTitle: `Index: [${this.state.formikSnapshot.index.map((index: {label: string} )=> index.label).join(",")}], timeField: ${this.state.formikSnapshot.timeField}` |
| 29 | + subTitle: `Index: [${this.props.formik.values.index.map((index: {label: string} )=> index.label).join(",")}], timeField: ${this.props.formik.values.timeField}` |
88 | 30 | ,
|
89 | 31 | }}
|
90 | 32 | >
|
91 |
| - {monitorIndexDisplay} |
| 33 | + <DataSource {...this.props} isMinimal={true}/> |
92 | 34 | </MinimalAccordion><EuiSpacer size="xs" /></>
|
93 | 35 | );
|
94 | 36 | }
|
95 | 37 | }
|
96 | 38 |
|
97 |
| -DataSourceFlyout.propTypes = propTypes; |
98 |
| -DataSourceFlyout.defaultProps = defaultProps; |
99 |
| - |
100 |
| -export default DataSourceFlyout; |
| 39 | +export default connect(DataSourceFlyout); |
0 commit comments