-
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] TLS alerting #63913
[Uptime] TLS alerting #63913
Changes from 54 commits
674857e
7d2bf4c
caf3ef2
d0246a7
f7678b6
0ddd97b
ef21286
8412951
59e60e8
d47d429
a1fdf46
929e38a
07055cb
9e017cb
b7ab73b
6f007bc
a18ee01
ff773bf
5870a59
4c94906
6e0b469
de52717
36a9ee1
6f4365f
1a339d1
e5febce
86a1ff9
b13c74f
3092dad
4c0d3f6
1255978
2326449
ba9bc8c
844f443
9162a65
c436914
4ed9d11
77ac31a
f044861
d820bb1
9551b14
4a39540
cbf85eb
2420c81
e34742e
7bc051e
d693a2a
5d57988
2c07456
6fb9d3b
5902515
190610c
86add5b
d1b414a
f3f18c1
98418d2
8566b00
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,23 @@ | ||
/* | ||
* 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 * as t from 'io-ts'; | ||
|
||
export const UptimeCommonStateType = t.intersection([ | ||
t.partial({ | ||
currentTriggerStarted: t.string, | ||
firstTriggeredAt: t.string, | ||
lastTriggeredAt: t.string, | ||
lastResolvedAt: t.string, | ||
}), | ||
t.type({ | ||
firstCheckedAt: t.string, | ||
lastCheckedAt: t.string, | ||
isTriggered: t.boolean, | ||
}), | ||
]); | ||
|
||
export type UptimeCommonState = t.TypeOf<typeof UptimeCommonStateType>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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 { EuiExpression, EuiFlexItem, EuiFlexGroup, EuiSpacer } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { TlsTranslations } from './translations'; | ||
import { SettingsMessageExpressionPopover } from './settings_message_expression_popover'; | ||
|
||
interface Props { | ||
ageThreshold?: number; | ||
expirationThreshold?: number; | ||
setAlertFlyoutVisible: (value: boolean) => void; | ||
} | ||
|
||
export const AlertTlsComponent: React.FC<Props> = props => ( | ||
<> | ||
<EuiSpacer size="l" /> | ||
<EuiFlexGroup direction="column" gutterSize="none"> | ||
<EuiFlexItem> | ||
<EuiExpression | ||
aria-label={TlsTranslations.criteriaAriaLabel} | ||
color="secondary" | ||
description={TlsTranslations.criteriaDescription} | ||
value={TlsTranslations.criteriaValue} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<SettingsMessageExpressionPopover | ||
aria-label={TlsTranslations.expirationAriaLabel} | ||
id="expiration" | ||
description={TlsTranslations.expirationDescription} | ||
value={TlsTranslations.expirationValue(props.expirationThreshold)} | ||
{...props} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<SettingsMessageExpressionPopover | ||
aria-label={TlsTranslations.ageAriaLabel} | ||
id="age" | ||
description={TlsTranslations.ageDescription} | ||
value={TlsTranslations.ageValue(props.ageThreshold)} | ||
{...props} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer size="l" /> | ||
</> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 { useDispatch, useSelector } from 'react-redux'; | ||
import React, { useCallback } from 'react'; | ||
import { AlertTlsComponent } from '../alert_tls'; | ||
import { setAlertFlyoutVisible } from '../../../../state/actions'; | ||
import { selectDynamicSettings } from '../../../../state/selectors'; | ||
|
||
export const AlertTls = () => { | ||
const dispatch = useDispatch(); | ||
const setFlyoutVisible = useCallback((value: boolean) => dispatch(setAlertFlyoutVisible(value)), [ | ||
dispatch, | ||
]); | ||
const { settings } = useSelector(selectDynamicSettings); | ||
return ( | ||
<AlertTlsComponent | ||
ageThreshold={settings?.certThresholds?.age} | ||
expirationThreshold={settings?.certThresholds?.expiration} | ||
setAlertFlyoutVisible={setFlyoutVisible} | ||
/> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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 { EuiExpression, EuiPopover } from '@elastic/eui'; | ||
import { Link } from 'react-router-dom'; | ||
import React, { useState } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { SETTINGS_ROUTE } from '../../../../common/constants'; | ||
|
||
interface SettingsMessageExpressionPopoverProps { | ||
'aria-label': string; | ||
description: string; | ||
id: string; | ||
setAlertFlyoutVisible: (value: boolean) => void; | ||
value: string; | ||
} | ||
|
||
export const SettingsMessageExpressionPopover: React.FC<SettingsMessageExpressionPopoverProps> = ({ | ||
'aria-label': ariaLabel, | ||
description, | ||
setAlertFlyoutVisible, | ||
value, | ||
id, | ||
}) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
return ( | ||
<EuiPopover | ||
id={id} | ||
anchorPosition="downLeft" | ||
button={ | ||
<EuiExpression | ||
aria-label={ariaLabel} | ||
color="secondary" | ||
description={description} | ||
isActive={isOpen} | ||
onClick={() => setIsOpen(!isOpen)} | ||
value={value} | ||
/> | ||
} | ||
isOpen={isOpen} | ||
closePopover={() => setIsOpen(false)} | ||
> | ||
<FormattedMessage | ||
id="xpack.uptime.alerts.tls.settingsPageNav.text" | ||
defaultMessage="You can edit these thresholds on the {settingsPageLink}." | ||
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. Should it be less verbose? 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. The copy comes from the spec, so I think we can just leave it for now. |
||
values={{ | ||
settingsPageLink: ( | ||
// this link is wrapped around a span so we can also change the UI state | ||
// and hide the alert flyout before triggering the navigation to the settings page | ||
<Link to={SETTINGS_ROUTE} data-test-subj="xpack.uptime.alerts.tlsFlyout.linkToSettings"> | ||
<span | ||
onClick={() => { | ||
setAlertFlyoutVisible(false); | ||
}} | ||
onKeyUp={e => { | ||
if (e.key === 'Enter') { | ||
setAlertFlyoutVisible(false); | ||
} | ||
}} | ||
> | ||
settings page | ||
</span> | ||
</Link> | ||
), | ||
}} | ||
/> | ||
</EuiPopover> | ||
); | ||
}; |
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 have been lately thinking, should we start using hooks for this pattern instead of container approach? I mean write a simple hook, which will dispatch action and return data, WDYT?
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.
It's a good idea, and I think we should do it in the future; however, we are going to have some interesting state management concerns for these alert creation UIs post-FF because they don't currently work with the Edit feature on the management page (because our store isn't available there). This only came to my attention after we finished NP migration.
For the time being I think we should keep these presentational components relying solely on props, until we devise a solution with the alerting team.
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.
Yes, it doesnt apply to this PR.