Skip to content

Commit bfca202

Browse files
[Uptime] Add default chart empty state (#57725)
* Add default chart empty state. * Delete obsolete translations. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 4ef594c commit bfca202

File tree

9 files changed

+163
-231
lines changed

9 files changed

+163
-231
lines changed

x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_empty_state.test.tsx.snap

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { ChartEmptyState } from '../chart_empty_state';
8+
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
9+
import React from 'react';
10+
import { FormattedMessage } from '@kbn/i18n/react';
11+
12+
describe('ChartEmptyState', () => {
13+
it('renders string values', () => {
14+
expect(
15+
shallowWithIntl(<ChartEmptyState body="This is the body" title="This is the title" />)
16+
).toMatchSnapshot();
17+
});
18+
19+
it('renders JSX values', () => {
20+
expect(
21+
shallowWithIntl(
22+
<ChartEmptyState
23+
body={
24+
<FormattedMessage
25+
id="test.body"
26+
defaultMessage="This is the default with a {val} included"
27+
values={{ val: <strong>down</strong> }}
28+
/>
29+
}
30+
title={<FormattedMessage id="test.title" defaultMessage="The title" />}
31+
/>
32+
)
33+
).toMatchSnapshot();
34+
});
35+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { EuiEmptyPrompt, EuiTitle } from '@elastic/eui';
8+
import React, { FC } from 'react';
9+
10+
interface ChartEmptyStateProps {
11+
title: string | JSX.Element;
12+
body: string | JSX.Element;
13+
}
14+
15+
export const ChartEmptyState: FC<ChartEmptyStateProps> = ({ title, body }) => (
16+
<EuiEmptyPrompt
17+
title={
18+
<EuiTitle>
19+
<h5>{title}</h5>
20+
</EuiTitle>
21+
}
22+
body={<p>{body}</p>}
23+
/>
24+
);

x-pack/legacy/plugins/uptime/public/components/functional/charts/checks_chart.tsx

Lines changed: 0 additions & 124 deletions
This file was deleted.

x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_chart.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import { FormattedMessage } from '@kbn/i18n/react';
1313
import { getChartDateLabel } from '../../../lib/helper';
1414
import { LocationDurationLine } from '../../../../common/graphql/types';
1515
import { DurationLineSeriesList } from './duration_line_series_list';
16-
import { DurationChartEmptyState } from './duration_chart_empty_state';
1716
import { ChartWrapper } from './chart_wrapper';
1817
import { useUrlParams } from '../../../hooks';
1918
import { getTickFormat } from './get_tick_format';
19+
import { ChartEmptyState } from './chart_empty_state';
2020

2121
interface DurationChartProps {
2222
/**
@@ -102,7 +102,18 @@ export const DurationChart = ({
102102
<DurationLineSeriesList lines={locationDurationLines} meanColor={meanColor} />
103103
</Chart>
104104
) : (
105-
<DurationChartEmptyState />
105+
<ChartEmptyState
106+
body={
107+
<FormattedMessage
108+
id="xpack.uptime.durationChart.emptyPrompt.description"
109+
defaultMessage="This monitor has never been {emphasizedText} during the selected time range."
110+
values={{ emphasizedText: <strong>up</strong> }}
111+
/>
112+
}
113+
title={i18n.translate('xpack.uptime.durationChart.emptyPrompt.title', {
114+
defaultMessage: 'No duration data available',
115+
})}
116+
/>
106117
)}
107118
</ChartWrapper>
108119
</EuiPanel>

x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_chart_empty_state.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)