Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Uptime] Add loading message for monitor list no items (#67378) #68186

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CursorDirection,
SortOrder,
} from '../../../../../common/runtime_types';
import { MonitorListComponent } from '../monitor_list';
import { MonitorListComponent, noItemsMessage } from '../monitor_list';
import { renderWithRouter, shallowWithRouter } from '../../../../lib';
import * as redux from 'react-redux';

Expand Down Expand Up @@ -288,4 +288,24 @@ describe('MonitorList component', () => {
expect(component).toMatchSnapshot();
});
});

describe('noItemsMessage', () => {
it('returns loading message while loading', () => {
expect(noItemsMessage(true)).toEqual(`Loading...`);
});

it('returns loading message when filters are defined and loading', () => {
expect(noItemsMessage(true, 'filters')).toEqual(`Loading...`);
});

it('returns no monitors selected when filters are defined and not loading', () => {
expect(noItemsMessage(false, 'filters')).toEqual(
`No monitors found for selected filter criteria`
);
});

it('returns no data message when no filters and not loading', () => {
expect(noItemsMessage(false)).toEqual(`No uptime monitors found`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const TruncatedEuiLink = styled(EuiLink)`
text-overflow: ellipsis;
`;

export const noItemsMessage = (loading: boolean, filters?: string) => {
if (loading) return labels.LOADING;
return !!filters ? labels.NO_MONITOR_ITEM_SELECTED : labels.NO_DATA_MESSAGE;
};

export const MonitorListComponent: React.FC<Props> = ({
filters,
monitorList: { list, error, loading },
Expand Down Expand Up @@ -164,7 +169,7 @@ export const MonitorListComponent: React.FC<Props> = ({
itemId="monitor_id"
itemIdToExpandedRowMap={getExpandedRowMap()}
items={items}
noItemsMessage={!!filters ? labels.NO_MONITOR_ITEM_SELECTED : labels.NO_DATA_MESSAGE}
noItemsMessage={noItemsMessage(loading, filters)}
columns={columns}
/>
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const NO_MONITOR_ITEM_SELECTED = i18n.translate(
}
);

export const LOADING = i18n.translate('xpack.uptime.monitorList.loading', {
defaultMessage: 'Loading...',
description: 'Shown when the monitor list is waiting for a server response',
});

export const NO_DATA_MESSAGE = i18n.translate('xpack.uptime.monitorList.noItemMessage', {
defaultMessage: 'No uptime monitors found',
description: 'This message is shown if the monitors table is rendered but has no items.',
Expand Down