Skip to content

Commit

Permalink
Re-use rule.url variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Feb 15, 2023
1 parent 5884437 commit 2f11382
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 40 deletions.
32 changes: 16 additions & 16 deletions x-pack/plugins/alerting/server/task_runner/execution_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ export class ExecutionHandler<
actionsPlugin,
actionTypeId,
kibanaBaseUrl: this.taskRunnerContext.kibanaBaseUrl,
ruleUrl: this.buildRuleUrl(spaceId),
viewInAppUrl: buildViewInAppUrl({
kibanaBaseUrl: this.taskRunnerContext.kibanaBaseUrl,
spaceId,
getViewInAppRelativeUrl: this.ruleType.getViewInAppRelativeUrl,
opts: { rule: this.rule },
logger: this.logger,
}),
ruleUrl:
buildViewInAppUrl({
kibanaBaseUrl: this.taskRunnerContext.kibanaBaseUrl,
spaceId,
getViewInAppRelativeUrl: this.ruleType.getViewInAppRelativeUrl,
opts: { rule: this.rule },
logger: this.logger,
}) || this.buildRuleUrl(spaceId),
}),
}),
};
Expand Down Expand Up @@ -278,15 +278,15 @@ export class ExecutionHandler<
kibanaBaseUrl: this.taskRunnerContext.kibanaBaseUrl,
alertParams: this.rule.params,
actionParams: action.params,
ruleUrl: this.buildRuleUrl(spaceId),
flapping: executableAlert.getFlapping(),
viewInAppUrl: buildViewInAppUrl({
kibanaBaseUrl: this.taskRunnerContext.kibanaBaseUrl,
spaceId,
getViewInAppRelativeUrl: this.ruleType.getViewInAppRelativeUrl,
opts: { rule: this.rule },
logger: this.logger,
}),
ruleUrl:
buildViewInAppUrl({
kibanaBaseUrl: this.taskRunnerContext.kibanaBaseUrl,
spaceId,
getViewInAppRelativeUrl: this.ruleType.getViewInAppRelativeUrl,
opts: { rule: this.rule },
logger: this.logger,
}) || this.buildRuleUrl(spaceId),
}),
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ interface TransformActionParamsOptions {
context: AlertInstanceContext;
ruleUrl?: string;
flapping: boolean;
viewInAppUrl?: string;
}

interface SummarizedAlertsWithAll {
Expand Down Expand Up @@ -74,7 +73,6 @@ export function transformActionParams({
alertParams,
ruleUrl,
flapping,
viewInAppUrl,
}: TransformActionParamsOptions): RuleActionParams {
// when the list of variables we pass in here changes,
// the UI will need to be updated as well; see:
Expand All @@ -100,7 +98,6 @@ export function transformActionParams({
spaceId,
tags,
url: ruleUrl,
viewInAppUrl,
},
alert: {
id: alertInstanceId,
Expand Down Expand Up @@ -128,7 +125,6 @@ export function transformSummaryActionParams({
actionParams,
ruleUrl,
kibanaBaseUrl,
viewInAppUrl,
}: {
alerts: SummarizedAlertsWithAll;
rule: SanitizedRule<RuleTypeParams>;
Expand All @@ -140,7 +136,6 @@ export function transformSummaryActionParams({
actionParams: RuleActionParams;
kibanaBaseUrl?: string;
ruleUrl?: string;
viewInAppUrl?: string;
}): RuleActionParams {
const variables = {
kibanaBaseUrl,
Expand All @@ -153,7 +148,6 @@ export function transformSummaryActionParams({
url: ruleUrl,
tags: rule.tags,
spaceId,
viewInAppUrl,
},
alerts,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ const expectedTransformResult = [
'The URL to the Stack Management rule page that generated the alert. This will be an empty string if the server.publicBaseUrl is not configured.',
name: 'rule.url',
},
{
name: 'rule.viewInAppUrl',
description:
'The URL to the associated application that generated the alert. This will be an empty string if the server.publicBaseUrl is not configured.',
},
{ description: 'The date the rule scheduled the action.', name: 'date' },
{ description: 'The ID of the alert that scheduled actions for the rule.', name: 'alert.id' },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export enum AlertProvidedActionVariables {
ruleTags = 'rule.tags',
ruleType = 'rule.type',
ruleUrl = 'rule.url',
viewInAppUrl = 'rule.viewInAppUrl',
date = 'date',
alertId = 'alert.id',
alertActionGroup = 'alert.actionGroup',
Expand Down Expand Up @@ -115,14 +114,7 @@ const AlertProvidedActionVariableDescriptions = {
name: AlertProvidedActionVariables.ruleUrl,
description: i18n.translate('xpack.triggersActionsUI.actionVariables.ruleUrlLabel', {
defaultMessage:
'The URL to the Stack Management rule page that generated the alert. This will be an empty string if the server.publicBaseUrl is not configured.',
}),
},
[AlertProvidedActionVariables.viewInAppUrl]: {
name: AlertProvidedActionVariables.viewInAppUrl,
description: i18n.translate('xpack.triggersActionsUI.actionVariables.viewInAppUrlLabel', {
defaultMessage:
'The URL to the associated application that generated the alert. This will be an empty string if the server.publicBaseUrl is not configured.',
'The URL to the rule that generated the alert. This will be an empty string if the server.publicBaseUrl is not configured.',
}),
},
[AlertProvidedActionVariables.date]: {
Expand Down Expand Up @@ -163,8 +155,6 @@ function getAlwaysProvidedActionVariables(): ActionVariable[] {

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.ruleUrl]);

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.viewInAppUrl]);

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.date]);

result.push({
Expand Down Expand Up @@ -335,8 +325,6 @@ function getSummaryAlertActionVariables(): ActionVariable[] {

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.ruleUrl]);

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.viewInAppUrl]);

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.ruleTags]);

result.push(AlertProvidedActionVariableDescriptions[AlertProvidedActionVariables.ruleSpaceId]);
Expand Down

0 comments on commit 2f11382

Please sign in to comment.