-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] Show troubleshoot guide on missing monitors (#128527)
- Loading branch information
Showing
6 changed files
with
195 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/uptime/public/components/overview/monitor_list/no_items_meesage.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { render } from '../../../lib/helper/rtl_helpers'; | ||
import { NoItemsMessage } from './no_items_message'; | ||
|
||
describe('NoItemsMessage', () => { | ||
it('returns loading message while loading', () => { | ||
render(<NoItemsMessage loading />); | ||
|
||
expect(screen.getByText('Loading...')).toBeInTheDocument(); | ||
}); | ||
|
||
it('returns loading message when filters are defined and loading', () => { | ||
render(<NoItemsMessage loading filters={'es'} />); | ||
|
||
expect(screen.getByText('Loading...')).toBeInTheDocument(); | ||
}); | ||
|
||
it('returns no monitors selected when filters are defined and not loading', () => { | ||
render(<NoItemsMessage loading={false} filters={'es'} />); | ||
|
||
expect(screen.getByText('No monitors found for selected filter criteria')).toBeInTheDocument(); | ||
}); | ||
|
||
it('returns no data message when no filters and not loading', () => { | ||
render(<NoItemsMessage loading={false} filters={''} />); | ||
|
||
expect(screen.getByText('No uptime monitors found')).toBeInTheDocument(); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
x-pack/plugins/uptime/public/components/overview/monitor_list/no_items_message.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { useSelector } from 'react-redux'; | ||
import * as labels from './translations'; | ||
import { useGetUrlParams } from '../../../hooks'; | ||
import { selectPingHistogram } from '../../../state/selectors'; | ||
import { TroubleshootPopover } from './troubleshoot_popover'; | ||
|
||
export const NoItemsMessage = ({ loading, filters }: { loading: boolean; filters?: string }) => { | ||
const { statusFilter } = useGetUrlParams(); | ||
|
||
const { pingHistogram } = useSelector(selectPingHistogram); | ||
|
||
const hasPingsData = pingHistogram?.histogram && pingHistogram.histogram.length > 0; | ||
|
||
const clockSyncError = hasPingsData && !statusFilter ? <TroubleshootPopover /> : null; | ||
|
||
if (loading) { | ||
return <> {labels.LOADING}</>; | ||
} | ||
|
||
if (filters) { | ||
return ( | ||
<> | ||
<EuiFlexGroup alignItems="center" gutterSize="xs"> | ||
<EuiFlexItem grow={false}>{labels.NO_MONITOR_ITEM_SELECTED}</EuiFlexItem> | ||
<EuiFlexItem grow={false}>{clockSyncError}</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
{labels.NO_DATA_MESSAGE} | ||
{clockSyncError} | ||
</> | ||
); | ||
}; |
98 changes: 98 additions & 0 deletions
98
x-pack/plugins/uptime/public/components/overview/monitor_list/troubleshoot_popover.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiButton, | ||
EuiButtonEmpty, | ||
EuiText, | ||
EuiPopoverTitle, | ||
EuiPopover, | ||
EuiPopoverFooter, | ||
} from '@elastic/eui'; | ||
import { useSelector } from 'react-redux'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
||
import { selectPingHistogram } from '../../../state/selectors'; | ||
import { useUrlParams } from '../../../hooks'; | ||
|
||
export const TroubleshootPopover = () => { | ||
const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
|
||
const onButtonClick = () => setIsPopoverOpen((prevState) => !prevState); | ||
const closePopover = () => setIsPopoverOpen(false); | ||
|
||
const { pingHistogram } = useSelector(selectPingHistogram); | ||
|
||
const updatedUrlParams = useUrlParams()[1]; | ||
|
||
const histogram = pingHistogram?.histogram ?? []; | ||
|
||
const middleBucketTimestamp = histogram?.[Math.floor(histogram.length / 2)].x; | ||
const firstBucketTimestamp = histogram?.[0].x; | ||
|
||
return ( | ||
<EuiPopover | ||
button={<EuiButtonEmpty onClick={onButtonClick}>{WHERE_ARE_MY_MONITORS}</EuiButtonEmpty>} | ||
isOpen={isPopoverOpen} | ||
closePopover={closePopover} | ||
anchorPosition="upCenter" | ||
> | ||
<EuiPopoverTitle>{SYSTEM_CLOCK_OUT_OF_SYNC}</EuiPopoverTitle> | ||
<div style={{ width: '300px' }}> | ||
<EuiText size="s"> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.uptime.monitorList.noMessage.troubleshoot" | ||
defaultMessage="Try using an absolute date range. If monitors appears afterwards, | ||
there may be an issue with the system clock where Heartbeat or Kibana is installed." | ||
/> | ||
</p> | ||
</EuiText> | ||
</div> | ||
<EuiPopoverFooter> | ||
<EuiButton | ||
fullWidth | ||
iconType="calendar" | ||
size="s" | ||
onClick={() => { | ||
if (middleBucketTimestamp && firstBucketTimestamp) { | ||
updatedUrlParams({ | ||
dateRangeStart: new Date(firstBucketTimestamp).toISOString(), | ||
dateRangeEnd: new Date(middleBucketTimestamp).toISOString(), | ||
}); | ||
} | ||
}} | ||
> | ||
{APPLY_ABSOLUTE_DATE_RANGE} | ||
</EuiButton> | ||
</EuiPopoverFooter> | ||
</EuiPopover> | ||
); | ||
}; | ||
|
||
export const APPLY_ABSOLUTE_DATE_RANGE = i18n.translate( | ||
'xpack.uptime.monitorList.troubleshoot.tryDateRange', | ||
{ | ||
defaultMessage: 'Apply absolute date range', | ||
} | ||
); | ||
|
||
export const WHERE_ARE_MY_MONITORS = i18n.translate( | ||
'xpack.uptime.monitorList.troubleshoot.whereAreMyMonitors', | ||
{ | ||
defaultMessage: 'Where are my monitors?', | ||
} | ||
); | ||
|
||
export const SYSTEM_CLOCK_OUT_OF_SYNC = i18n.translate( | ||
'xpack.uptime.monitorList.troubleshoot.systemClockOutOfSync', | ||
{ | ||
defaultMessage: 'System clock may be out of sync', | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters