[Alerting][Docs] Moved alerting links from hard-coded to documentation link service. (#92953)

* [Alerting][Docs] Moved alerting links from hard-coded to documentation link service

* fixed due to comments

* Update x-pack/plugins/triggers_actions_ui/public/application/components/health_check.tsx

Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>

* fixed jest tests

* fixed due to comments

Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
This commit is contained in:
Yuliia Naumenko 2021-03-02 13:43:10 -08:00 committed by GitHub
parent 36523bb3a1
commit a102fa9a70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 33 additions and 92 deletions

View file

@ -187,15 +187,17 @@ export class DocLinksService {
guide: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/managing-alerts-and-actions.html`,
actionTypes: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/action-types.html`,
emailAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/email-action-type.html`,
emailActionConfig: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/email-action-type.html#configuring-email`,
generalSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`,
indexAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-action-type.html`,
indexThreshold: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-types.html#alert-type-index-threshold`,
esQuery: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-type-es-query.html`,
indexThreshold: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-type-index-threshold.html#index-action-configuration`,
pagerDutyAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/pagerduty-action-type.html`,
preconfiguredConnectors: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/pre-configured-action-types-and-connectors.html`,
serviceNowAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/servicenow-action-type.html`,
serviceNowAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/servicenow-action-type.html#configuring-servicenow`,
setupPrerequisites: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alerting-getting-started.html#alerting-setup-prerequisites`,
slackAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/slack-action-type.html`,
teamsAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/teams-action-type.html`,
slackAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/slack-action-type.html#configuring-slack`,
teamsAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/teams-action-type.html#configuring-teams`,
},
maps: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/maps.html`,

View file

@ -116,6 +116,11 @@ describe('EsQueryAlertTypeExpression', () => {
docLinks: {
ELASTIC_WEBSITE_URL: '',
DOC_LINK_VERSION: '',
links: {
query: {
queryDsl: 'query-dsl.html',
},
},
},
},
});

View file

@ -287,10 +287,7 @@ export const EsQueryAlertTypeExpression: React.FunctionComponent<
isInvalid={errors.esQuery.length > 0}
error={errors.esQuery}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${docLinks.DOC_LINK_VERSION}/query-dsl.html`}
target="_blank"
>
<EuiLink href={docLinks.links.query.queryDsl} target="_blank">
<FormattedMessage
id="xpack.stackAlerts.esQuery.ui.queryPrompt.help"
defaultMessage="ES Query DSL documentation"

View file

@ -18,9 +18,7 @@ export function getAlertType(): AlertTypeModel<EsQueryAlertParams> {
defaultMessage: 'Alert on matches against an ES query.',
}),
iconClass: 'logoElastic',
documentationUrl(docLinks) {
return `${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/alert-types.html#alert-type-es-query`;
},
documentationUrl: (docLinks) => docLinks.links.alerting.esQuery,
alertParamsExpression: lazy(() => import('./expression')),
validate: validateExpression,
defaultActionMessage: i18n.translate(

View file

@ -18,9 +18,7 @@ export function getAlertType(): AlertTypeModel<IndexThresholdAlertParams> {
defaultMessage: 'Alert when an aggregated query meets the threshold.',
}),
iconClass: 'alert',
documentationUrl(docLinks) {
return `${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/alert-types.html#alert-type-index-threshold`;
},
documentationUrl: (docLinks) => docLinks.links.alerting.indexThreshold,
alertParamsExpression: lazy(() => import('./expression')),
validate: validateExpression,
defaultActionMessage: i18n.translate(

View file

@ -55,10 +55,7 @@ export const EmailActionConnectorFields: React.FunctionComponent<
}
)}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/email-action-type.html#configuring-email`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.emailActionConfig} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.emailAction.configureAccountsHelpLabel"
defaultMessage="Configure email accounts"

View file

@ -88,10 +88,7 @@ const IndexActionConnectorFields: React.FunctionComponent<
defaultMessage="Use * to broaden your query."
/>
<EuiSpacer size="s" />
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/index-action-type.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.indexAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.configureIndexHelpLabel"
defaultMessage="Configuring index connector."

View file

@ -61,10 +61,7 @@ export const IndexParamsFields = ({
errors={errors.documents as string[]}
onDocumentsChange={onDocumentsChange}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/index-action-type.html#index-action-configuration`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.indexAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.indexDocumentHelpLabel"
defaultMessage="Index document example."

View file

@ -51,10 +51,7 @@ const PagerDutyActionConnectorFields: React.FunctionComponent<
id="routingKey"
fullWidth
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/pagerduty-action-type.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.pagerDutyAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.routingKeyNameHelpLabel"
defaultMessage="Configure a PagerDuty account"

View file

@ -60,10 +60,7 @@ const ServiceNowConnectorFields: React.FC<
isInvalid={isApiUrlInvalid}
label={i18n.API_URL_LABEL}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/servicenow-action-type.html#configuring-servicenow`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.serviceNowAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.serviceNowAction.apiUrlHelpLabel"
defaultMessage="Configure a Personal Developer Instance"

View file

@ -25,10 +25,7 @@ const SlackActionFields: React.FunctionComponent<
id="webhookUrl"
fullWidth
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/slack-action-type.html#configuring-slack`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.slackAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.slackAction.webhookUrlHelpLabel"
defaultMessage="Create a Slack Webhook URL"

View file

@ -25,10 +25,7 @@ const TeamsActionFields: React.FunctionComponent<
id="webhookUrl"
fullWidth
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/teams-action-type.html#configuring-teams`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.teamsAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.teamsAction.webhookUrlHelpLabel"
defaultMessage="Create a Microsoft Teams Webhook URL"

View file

@ -94,15 +94,11 @@ export const HealthCheck: React.FunctionComponent<Props> = ({
};
interface PromptErrorProps {
docLinks: Pick<DocLinksStart, 'ELASTIC_WEBSITE_URL' | 'DOC_LINK_VERSION'>;
docLinks: DocLinksStart;
className?: string;
}
const EncryptionError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const EncryptionError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="actionNeededEmptyPrompt"
@ -133,11 +129,7 @@ const EncryptionError = ({
' in your kibana.yml file and ensure the Encrypted Saved Objects plugin is enabled. ',
}
)}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`}
external
target="_blank"
>
<EuiLink href={docLinks.links.alerting.generalSettings} external target="_blank">
{i18n.translate(
'xpack.triggersActionsUI.components.healthCheck.encryptionErrorAction',
{
@ -151,11 +143,7 @@ const EncryptionError = ({
/>
);
const TlsError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const TlsError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="actionNeededEmptyPrompt"
@ -176,11 +164,7 @@ const TlsError = ({
defaultMessage:
'Alerting relies on API keys, which require TLS between Elasticsearch and Kibana. ',
})}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/configuring-tls.html`}
external
target="_blank"
>
<EuiLink href={docLinks.links.security.kibanaTLS} external target="_blank">
{i18n.translate('xpack.triggersActionsUI.components.healthCheck.tlsErrorAction', {
defaultMessage: 'Learn how to enable TLS.',
})}
@ -191,11 +175,7 @@ const TlsError = ({
/>
);
const AlertsError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const AlertsError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="alertsNeededEmptyPrompt"
@ -215,11 +195,7 @@ const AlertsError = ({
{i18n.translate('xpack.triggersActionsUI.components.healthCheck.alertsError', {
defaultMessage: 'To create an alert, set alerts and actions plugins enabled. ',
})}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html`}
external
target="_blank"
>
<EuiLink href={docLinks.links.alerting.generalSettings} external target="_blank">
{i18n.translate('xpack.triggersActionsUI.components.healthCheck.alertsErrorAction', {
defaultMessage: 'Learn how to enable Alerts and Actions.',
})}
@ -230,11 +206,7 @@ const AlertsError = ({
/>
);
const TlsAndEncryptionError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const TlsAndEncryptionError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="actionNeededEmptyPrompt"
@ -255,11 +227,7 @@ const TlsAndEncryptionError = ({
defaultMessage:
'You must enable Transport Layer Security between Kibana and Elasticsearch and configure an encryption key in your kibana.yml file. ',
})}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alerting-getting-started.html#alerting-setup-prerequisites`}
external
target="_blank"
>
<EuiLink href={docLinks.links.alerting.setupPrerequisites} external target="_blank">
{i18n.translate(
'xpack.triggersActionsUI.components.healthCheck.tlsAndEncryptionErrorAction',
{

View file

@ -99,7 +99,7 @@ export const TriggersActionsUIHome: React.FunctionComponent<RouteComponentProps<
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/managing-alerts-and-actions.html`}
href={docLinks.links.alerting.guide}
target="_blank"
iconType="help"
data-test-subj="documentationLink"

View file

@ -156,10 +156,7 @@ export const ActionConnectorForm = ({
values={{
actionType: actionTypeName ?? connector.actionTypeId,
docLink: (
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/action-types.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.actionTypes} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.sections.actionConnectorForm.actions.actionConfigurationWarningHelpLinkText"
defaultMessage="Learn more."

View file

@ -319,10 +319,7 @@ export const ConnectorEditFlyout = ({
}
)}
</EuiText>
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/pre-configured-action-types-and-connectors.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.preconfiguredConnectors} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.sections.editConnectorForm.preconfiguredHelpLabel"
defaultMessage="Learn more about preconfigured connectors."