[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`, 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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`, teamsAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/teams-action-type.html#configuring-teams`,
}, },
maps: { maps: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/maps.html`, guide: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/maps.html`,

View file

@ -116,6 +116,11 @@ describe('EsQueryAlertTypeExpression', () => {
docLinks: { docLinks: {
ELASTIC_WEBSITE_URL: '', ELASTIC_WEBSITE_URL: '',
DOC_LINK_VERSION: '', 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} isInvalid={errors.esQuery.length > 0}
error={errors.esQuery} error={errors.esQuery}
helpText={ helpText={
<EuiLink <EuiLink href={docLinks.links.query.queryDsl} target="_blank">
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${docLinks.DOC_LINK_VERSION}/query-dsl.html`}
target="_blank"
>
<FormattedMessage <FormattedMessage
id="xpack.stackAlerts.esQuery.ui.queryPrompt.help" id="xpack.stackAlerts.esQuery.ui.queryPrompt.help"
defaultMessage="ES Query DSL documentation" defaultMessage="ES Query DSL documentation"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -99,7 +99,7 @@ export const TriggersActionsUIHome: React.FunctionComponent<RouteComponentProps<
</EuiFlexItem> </EuiFlexItem>
<EuiFlexItem grow={false}> <EuiFlexItem grow={false}>
<EuiButtonEmpty <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" target="_blank"
iconType="help" iconType="help"
data-test-subj="documentationLink" data-test-subj="documentationLink"

View file

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

View file

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