-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
view.js
71 lines (62 loc) · 2.06 KB
/
view.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React, { Component } from 'react';
import { STATUS } from '../../../constants';
import { isEmpty } from 'lodash';
import { loadAgentStatus } from '../../../services/rest/apm';
import { ServiceList } from './ServiceList';
import { EuiSpacer } from '@elastic/eui';
import { ServiceListRequest } from '../../../store/reactReduxRequest/serviceList';
import EmptyMessage from '../../shared/EmptyMessage';
import { SetupInstructionsLink } from '../../shared/SetupInstructionsLink';
class ServiceOverview extends Component {
state = {
historicalDataFound: true
};
async checkForHistoricalData({ serviceList }) {
if (serviceList.status === STATUS.SUCCESS && isEmpty(serviceList.data)) {
const result = await loadAgentStatus();
if (!result.dataFound) {
this.setState({ historicalDataFound: false });
}
}
}
componentDidMount() {
this.checkForHistoricalData(this.props);
}
componentDidUpdate() {
// QUESTION: Do we want to check on ANY update, or only if serviceList status/data have changed?
this.checkForHistoricalData(this.props);
}
render() {
const { urlParams } = this.props;
const { historicalDataFound } = this.state;
const noItemsMessage = (
<EmptyMessage
heading={
historicalDataFound
? 'No services were found'
: "Looks like you don't have any services with APM installed. Let's add some!"
}
subheading={
!historicalDataFound ? <SetupInstructionsLink buttonFill /> : null
}
/>
);
return (
<div>
<EuiSpacer />
<ServiceListRequest
urlParams={urlParams}
render={({ data }) => (
<ServiceList items={data} noItemsMessage={noItemsMessage} />
)}
/>
</div>
);
}
}
export default ServiceOverview;