From a102fa9a70dce6a4d9c6392498b5737ebc10530e Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Tue, 2 Mar 2021 13:43:10 -0800 Subject: [PATCH] [Alerting][Docs] Moved alerting links from hard-coded to documentation link service. (#92953) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [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é * fixed jest tests * fixed due to comments Co-authored-by: Mike Côté --- .../public/doc_links/doc_links_service.ts | 10 ++-- .../alert_types/es_query/expression.test.tsx | 5 ++ .../alert_types/es_query/expression.tsx | 5 +- .../public/alert_types/es_query/index.ts | 4 +- .../public/alert_types/threshold/index.ts | 4 +- .../email/email_connector.tsx | 5 +- .../es_index/es_index_connector.tsx | 5 +- .../es_index/es_index_params.tsx | 5 +- .../pagerduty/pagerduty_connectors.tsx | 5 +- .../servicenow/servicenow_connectors.tsx | 5 +- .../slack/slack_connectors.tsx | 5 +- .../teams/teams_connectors.tsx | 5 +- .../application/components/health_check.tsx | 50 ++++--------------- .../public/application/home.tsx | 2 +- .../action_connector_form.tsx | 5 +- .../connector_edit_flyout.tsx | 5 +- 16 files changed, 33 insertions(+), 92 deletions(-) diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index 7792e25e54d0..e985b5cd61e7 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -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`, diff --git a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx index f475d97e2f39..51c2f0471d48 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx @@ -116,6 +116,11 @@ describe('EsQueryAlertTypeExpression', () => { docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '', + links: { + query: { + queryDsl: 'query-dsl.html', + }, + }, }, }, }); diff --git a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx index 37c64688ec49..6adcada9b273 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx @@ -287,10 +287,7 @@ export const EsQueryAlertTypeExpression: React.FunctionComponent< isInvalid={errors.esQuery.length > 0} error={errors.esQuery} helpText={ - + { 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( diff --git a/x-pack/plugins/stack_alerts/public/alert_types/threshold/index.ts b/x-pack/plugins/stack_alerts/public/alert_types/threshold/index.ts index 95ecd121cf5a..1b229bb4a9d0 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/threshold/index.ts +++ b/x-pack/plugins/stack_alerts/public/alert_types/threshold/index.ts @@ -18,9 +18,7 @@ export function getAlertType(): AlertTypeModel { 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( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.tsx index 2f518780c9f6..df6822c85340 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.tsx @@ -55,10 +55,7 @@ export const EmailActionConnectorFields: React.FunctionComponent< } )} helpText={ - + - + + + + + + = ({ }; interface PromptErrorProps { - docLinks: Pick; + 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) => ( + {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) => ( + {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) => ( + {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) => ( + {i18n.translate( 'xpack.triggersActionsUI.components.healthCheck.tlsAndEncryptionErrorAction', { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/home.tsx b/x-pack/plugins/triggers_actions_ui/public/application/home.tsx index 1e7fa3c51e68..c251a1d597f2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/home.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/home.tsx @@ -99,7 +99,7 @@ export const TriggersActionsUIHome: React.FunctionComponent + - +