-
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.
- Loading branch information
Showing
18 changed files
with
332 additions
and
26 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
26 changes: 19 additions & 7 deletions
26
...me/public/components/monitor/ping_list/__tests__/__snapshots__/expanded_row.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
97 changes: 97 additions & 0 deletions
97
x-pack/plugins/uptime/public/components/monitor/ping_list/ping_redirects.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,97 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import styled from 'styled-components'; | ||
import { EuiListGroup, EuiListGroupItemProps, EuiPanel, EuiSpacer, EuiText } from '@elastic/eui'; | ||
import { Ping } from '../../../../common/runtime_types/ping'; | ||
|
||
const ListGroup = styled(EuiListGroup)` | ||
&&& { | ||
a { | ||
padding-left: 0; | ||
} | ||
} | ||
`; | ||
|
||
interface Props { | ||
monitorStatus: Ping | null; | ||
showTitle?: boolean; | ||
} | ||
|
||
export const PingRedirects: React.FC<Props> = ({ monitorStatus, showTitle }) => { | ||
const monitorUrl = monitorStatus?.url?.full; | ||
|
||
const list = monitorStatus?.http?.response?.redirects; | ||
|
||
const listOfRedirects: EuiListGroupItemProps[] = [ | ||
{ | ||
label: monitorUrl, | ||
href: monitorUrl, | ||
iconType: 'globe', | ||
size: 's', | ||
target: '_blank', | ||
extraAction: { | ||
color: 'subdued', | ||
iconType: 'popout', | ||
iconSize: 's', | ||
alwaysShow: true, | ||
'aria-label': i18n.translate('xpack.uptime.monitorList.redirects.openWindow', { | ||
defaultMessage: 'Link will open in new window.', | ||
}), | ||
}, | ||
}, | ||
]; | ||
|
||
(list ?? []).forEach((url: string) => { | ||
listOfRedirects.push({ | ||
label: url, | ||
href: url, | ||
iconType: 'sortDown', | ||
size: 's', | ||
target: '_blank', | ||
extraAction: { | ||
color: 'subdued', | ||
iconType: 'popout', | ||
iconSize: 's', | ||
'aria-label': i18n.translate('xpack.uptime.monitorList.redirects.openWindow', { | ||
defaultMessage: 'Link will open in new window.', | ||
}), | ||
alwaysShow: true, | ||
}, | ||
}); | ||
}); | ||
|
||
const Panel = showTitle ? EuiPanel : 'div'; | ||
|
||
return list ? ( | ||
<Panel data-test-subj="uptimeMonitorPingListRedirectInfo"> | ||
{showTitle && ( | ||
<EuiText size="xs"> | ||
<h3> | ||
{i18n.translate('xpack.uptime.monitorList.redirects.title', { | ||
defaultMessage: 'Redirects', | ||
})} | ||
</h3> | ||
</EuiText> | ||
)} | ||
<EuiSpacer size="xs" /> | ||
{ | ||
<EuiText> | ||
{i18n.translate('xpack.uptime.monitorList.redirects.description', { | ||
defaultMessage: 'Heartbeat followed {number} redirects while executing ping.', | ||
values: { | ||
number: list?.length ?? 0, | ||
}, | ||
})} | ||
</EuiText> | ||
} | ||
<EuiSpacer size="s" /> | ||
<ListGroup gutterSize={'none'} listItems={listOfRedirects} /> | ||
</Panel> | ||
) : null; | ||
}; |
58 changes: 58 additions & 0 deletions
58
.../plugins/uptime/public/components/monitor/status_details/status_bar/monitor_redirects.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,58 @@ | ||
/* | ||
* 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 React, { useState } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiPopover } from '@elastic/eui'; | ||
import styled from 'styled-components'; | ||
import { Ping } from '../../../../../common/runtime_types'; | ||
import { PingRedirects } from '../../ping_list/ping_redirects'; | ||
import { MonListDescription, MonListTitle } from './status_bar'; | ||
|
||
interface Props { | ||
monitorStatus: Ping | null; | ||
} | ||
|
||
const RedirectBtn = styled.span` | ||
cursor: pointer; | ||
`; | ||
|
||
export const MonitorRedirects: React.FC<Props> = ({ monitorStatus }) => { | ||
const list = monitorStatus?.http?.response?.redirects; | ||
|
||
const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
|
||
const button = ( | ||
<MonListDescription> | ||
<RedirectBtn | ||
className="euiLink euiLink--primary" | ||
onClick={() => setIsPopoverOpen(!isPopoverOpen)} | ||
data-test-subj="uptimeMonitorRedirectInfo" | ||
> | ||
{i18n.translate('xpack.uptime.monitorList.redirects.title.number', { | ||
defaultMessage: '{number}', | ||
values: { | ||
number: list?.length ?? 0, | ||
}, | ||
})} | ||
</RedirectBtn> | ||
</MonListDescription> | ||
); | ||
|
||
return list ? ( | ||
<> | ||
<MonListTitle>Redirects</MonListTitle> | ||
<EuiPopover | ||
button={button} | ||
isOpen={isPopoverOpen} | ||
anchorPosition="downLeft" | ||
closePopover={() => setIsPopoverOpen(false)} | ||
> | ||
<PingRedirects monitorStatus={monitorStatus} /> | ||
</EuiPopover> | ||
</> | ||
) : null; | ||
}; |
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
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
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
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
Oops, something went wrong.