-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Uptime] Remove tabs from details page #85955
Changes from 1 commit
ccf1107
1b9bce4
12b3303
b8977ca
c6ea0a6
914f9b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this new component need unit tests? |
||
* 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 { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui'; | ||
import React from 'react'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, do you have any standards for how you order imports? I've worked at companies where there were strong opinions about how to order imports. I noticed that in this component third party libraries are listed after internal libraries, whereas in another its reversed, so just curious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My $0.02 cents is that so long as the linter doesn't complain it's fine, esp. given that imports tend to be mostly managed by editors these days. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't sort alphabetically, but we have lint rule for relative/absolute import orders |
||
import { useSelector } from 'react-redux'; | ||
import { useMonitorId } from '../../hooks'; | ||
import { monitorStatusSelector } from '../../state/selectors'; | ||
import { EnableMonitorAlert } from '../overview/monitor_list/columns/enable_alert'; | ||
import { Ping } from '../../../common/runtime_types/ping'; | ||
|
||
const isAutogeneratedId = (id: string) => { | ||
const autoGeneratedId = /^auto-(icmp|http|tcp)-OX[A-F0-9]{16}-[a-f0-9]{16}/; | ||
return autoGeneratedId.test(id); | ||
}; | ||
|
||
// For monitors with no explicit ID, we display the URL instead of the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the comment! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i fixed this |
||
// auto-generated ID because it is difficult to derive meaning from a | ||
// generated id like `auto-http-0X8D6082B94BBE3B8A`. | ||
// We may deprecate this behavior in the next major release, because | ||
// the heartbeat config will require an explicit ID. | ||
const getPageTitle = (monId: string, selectedMonitor: Ping | null) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer |
||
if (isAutogeneratedId(monId)) { | ||
return selectedMonitor?.url?.full || monId; | ||
} | ||
return monId; | ||
}; | ||
|
||
export const MonitorPageTitle: React.FC = () => { | ||
const monitorId = useMonitorId(); | ||
|
||
const selectedMonitor = useSelector(monitorStatusSelector); | ||
|
||
const nameOrId = selectedMonitor?.monitor?.name || getPageTitle(monitorId, selectedMonitor); | ||
|
||
return ( | ||
<EuiFlexGroup wrap={false}> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle> | ||
<h1 className="eui-textNoWrap">{nameOrId}</h1> | ||
</EuiTitle> | ||
<EuiSpacer size="xs" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false} style={{ justifyContent: 'center' }}> | ||
<EnableMonitorAlert | ||
monitorId={monitorId} | ||
monitorName={selectedMonitor?.monitor?.name || selectedMonitor?.url?.full} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui'; | ||
import { EuiSpacer } from '@elastic/eui'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect a test to fail from removing this much markup. Do we have unit tests for this component? |
||
import React, { useEffect } from 'react'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { monitorStatusSelector } from '../state/selectors'; | ||
|
@@ -16,7 +16,6 @@ import { MonitorStatusDetails, PingList } from '../components/monitor'; | |
import { getDynamicSettings } from '../state/actions/dynamic_settings'; | ||
import { Ping } from '../../common/runtime_types/ping'; | ||
import { setSelectedMonitorId } from '../state/actions'; | ||
import { EnableMonitorAlert } from '../components/overview/monitor_list/columns/enable_alert'; | ||
import { getMonitorAlertsAction } from '../state/alerts/alerts'; | ||
import { useInitApp } from '../hooks/use_init_app'; | ||
|
||
|
@@ -63,20 +62,6 @@ export const MonitorPage: React.FC = () => { | |
|
||
return ( | ||
<> | ||
<EuiFlexGroup wrap={false}> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle> | ||
<h1 className="eui-textNoWrap">{nameOrId}</h1> | ||
</EuiTitle> | ||
<EuiSpacer size="xs" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false} style={{ justifyContent: 'center' }}> | ||
<EnableMonitorAlert | ||
monitorId={monitorId} | ||
monitorName={selectedMonitor?.monitor?.name || selectedMonitor?.url?.full} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer size="s" /> | ||
<MonitorStatusDetails monitorId={monitorId} /> | ||
<EuiSpacer size="s" /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need unit tests for these? I'd use react testing library to check if these pieces, either the tabs, monitor heading, or nothing, were in the DOM depending on the route found with
useRouteMatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i totally agree, those are missing