forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] TLS alerting (elastic#63913)
* Refactor settings form event handling and modify certs fields. * Fix/improve broken types/unit/integration/api tests. * Modify default expiration threshold. * Rename test vars. * Implement PR feedback. * Refresh snapshots, fix broken tests/types. * Remove unnecessary state spreading. * Add type for settings field errors. * Refresh test snapshots. * Improve punctuation. * Add TLS alert type. * Add cert API request and runtime type checking. * Add api test for cert api. * Add unload command to certs test. * Extract API params interface to io-ts type. * Add TLS alert type on server. * WIP - add state for changing selected alert type. * Finish adding alert type for client, add server alert summary. * Add some state variables. * Update certs summary function to create required values. * Refresh test snapshots. * Clean up message generator function. * Add a comment. * Update formatting for alert messages, add flags denoting presence of age/expiration data. * Add relative date information to tls alert messages. * Clean up more logic in certs request function. * Fix broken unit tests. * Move tests for common function to new file. * Fix logic error in test and add common state fields to tls alerts. * Extract common state field translations from status check alert. * Add a comment. * Add nested context navigation for uptime alert selection. * Clean up types. * Fix translation key typo. * Extract translations from tls alert factory. * Extract summary messages to translation file. * Change default tls alert time window from 1w to 1d. * Remove unnecessary import. * Simplify page linking. * Extract a non-trivial component to a dedicated file. * Simplify create alert copy. * Fix broken functional test. * Fix busted types. * Fix tls query error. * Allow for alerts toggle button to receive a set of types to display. * Add alerts toggle button to certs page. * Fix copy. * Fixup punctuation in default message to avoid double-period symbols. * Refresh snapshots.
- Loading branch information
1 parent
e3de86b
commit 21a7b74
Showing
37 changed files
with
1,260 additions
and
409 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
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/uptime/common/runtime_types/alerts/common.ts
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,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>; |
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
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/uptime/public/components/overview/alerts/alert_tls.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,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" /> | ||
</> | ||
); |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_tls.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,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} | ||
/> | ||
); | ||
}; |
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
72 changes: 72 additions & 0 deletions
72
.../plugins/uptime/public/components/overview/alerts/settings_message_expression_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,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}." | ||
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> | ||
); | ||
}; |
Oops, something went wrong.