Skip to content

Commit a11ae7e

Browse files
[Uptime] Add loading message for monitor list no items (#67378)
* Add loading message for monitor list no items. * Add tests. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent c96408d commit a11ae7e

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
CursorDirection,
1111
SortOrder,
1212
} from '../../../../../common/runtime_types';
13-
import { MonitorListComponent } from '../monitor_list';
13+
import { MonitorListComponent, noItemsMessage } from '../monitor_list';
1414
import { renderWithRouter, shallowWithRouter } from '../../../../lib';
1515
import * as redux from 'react-redux';
1616

@@ -288,4 +288,24 @@ describe('MonitorList component', () => {
288288
expect(component).toMatchSnapshot();
289289
});
290290
});
291+
292+
describe('noItemsMessage', () => {
293+
it('returns loading message while loading', () => {
294+
expect(noItemsMessage(true)).toEqual(`Loading...`);
295+
});
296+
297+
it('returns loading message when filters are defined and loading', () => {
298+
expect(noItemsMessage(true, 'filters')).toEqual(`Loading...`);
299+
});
300+
301+
it('returns no monitors selected when filters are defined and not loading', () => {
302+
expect(noItemsMessage(false, 'filters')).toEqual(
303+
`No monitors found for selected filter criteria`
304+
);
305+
});
306+
307+
it('returns no data message when no filters and not loading', () => {
308+
expect(noItemsMessage(false)).toEqual(`No uptime monitors found`);
309+
});
310+
});
291311
});

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ const TruncatedEuiLink = styled(EuiLink)`
4343
text-overflow: ellipsis;
4444
`;
4545

46+
export const noItemsMessage = (loading: boolean, filters?: string) => {
47+
if (loading) return labels.LOADING;
48+
return !!filters ? labels.NO_MONITOR_ITEM_SELECTED : labels.NO_DATA_MESSAGE;
49+
};
50+
4651
export const MonitorListComponent: React.FC<Props> = ({
4752
filters,
4853
monitorList: { list, error, loading },
@@ -163,7 +168,7 @@ export const MonitorListComponent: React.FC<Props> = ({
163168
itemId="monitor_id"
164169
itemIdToExpandedRowMap={getExpandedRowMap()}
165170
items={items}
166-
noItemsMessage={!!filters ? labels.NO_MONITOR_ITEM_SELECTED : labels.NO_DATA_MESSAGE}
171+
noItemsMessage={noItemsMessage(loading, filters)}
167172
columns={columns}
168173
/>
169174
<EuiSpacer size="m" />

x-pack/plugins/uptime/public/components/overview/monitor_list/translations.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export const NO_MONITOR_ITEM_SELECTED = i18n.translate(
5252
}
5353
);
5454

55+
export const LOADING = i18n.translate('xpack.uptime.monitorList.loading', {
56+
defaultMessage: 'Loading...',
57+
description: 'Shown when the monitor list is waiting for a server response',
58+
});
59+
5560
export const NO_DATA_MESSAGE = i18n.translate('xpack.uptime.monitorList.noItemMessage', {
5661
defaultMessage: 'No uptime monitors found',
5762
description: 'This message is shown if the monitors table is rendered but has no items.',

0 commit comments

Comments
 (0)