Skip to content

Commit

Permalink
i18nize action variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Mar 31, 2020
1 parent 816eddc commit 3e2095d
Showing 1 changed file with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import uuid from 'uuid';
import { schema } from '@kbn/config-schema';
import { PluginSetupContract } from '../../../../../alerting/server';
Expand Down Expand Up @@ -49,6 +50,37 @@ export async function registerMetricThresholdAlertType(alertingPlugin: PluginSet
metric: schema.never(),
});

const groupActionVariableDescription = i18n.translate(
'xpack.infra.metrics.alerting.threshold.alerting.groupActionVariableDescription',
{
defaultMessage: 'Name of the group reporting data',
}
);

const valueOfActionVariableDescription = i18n.translate(
'xpack.infra.metrics.alerting.threshold.alerting.valueOfActionVariableDescription',
{
defaultMessage:
'Record of the current value of the watched metric; grouped by condition, i.e valueOf.condition0, valueOf.condition1, etc.',
}
);

const thresholdOfActionVariableDescription = i18n.translate(
'xpack.infra.metrics.alerting.threshold.alerting.thresholdOfActionVariableDescription',
{
defaultMessage:
'Record of the alerting threshold; grouped by condition, i.e thresholdOf.condition0, thresholdOf.condition1, etc.',
}
);

const metricOfActionVariableDescription = i18n.translate(
'xpack.infra.metrics.alerting.threshold.alerting.metricOfActionVariableDescription',
{
defaultMessage:
'Record of the watched metric; grouped by condition, i.e metricOf.condition0, metricOf.condition1, etc.',
}
);

alertingPlugin.registerType({
id: METRIC_THRESHOLD_ALERT_TYPE_ID,
name: 'Metric Alert - Threshold',
Expand All @@ -64,10 +96,10 @@ export async function registerMetricThresholdAlertType(alertingPlugin: PluginSet
executor: createMetricThresholdExecutor(alertUUID),
actionVariables: {
context: [
{ name: 'group', description: 'Alerting group' },
{ name: 'valueOf', description: 'Values' },
{ name: 'thresholdOf', description: 'Thresholds' },
{ name: 'metricOf', description: 'Metrics' },
{ name: 'group', description: groupActionVariableDescription },
{ name: 'valueOf', description: valueOfActionVariableDescription },
{ name: 'thresholdOf', description: thresholdOfActionVariableDescription },
{ name: 'metricOf', description: metricOfActionVariableDescription },
],
},
});
Expand Down

0 comments on commit 3e2095d

Please sign in to comment.