Browse Source

fix(metric_alerts): Add units to thresholds (#25961)

Add units to thresholds in placeholder and field description.

FIXES WOR-850.
Kelly Carino 3 years ago
parent
commit
00fdfc503d

+ 1 - 0
static/app/views/settings/incidentRules/ruleForm/index.tsx

@@ -645,6 +645,7 @@ class RuleFormContainer extends AsyncComponent<Props, State> {
         projects={this.state.projects}
         projects={this.state.projects}
         errors={this.state.triggerErrors}
         errors={this.state.triggerErrors}
         triggers={triggers}
         triggers={triggers}
+        aggregate={aggregate}
         resolveThreshold={resolveThreshold}
         resolveThreshold={resolveThreshold}
         thresholdType={thresholdType}
         thresholdType={thresholdType}
         currentProject={params.projectId}
         currentProject={params.projectId}

+ 22 - 5
static/app/views/settings/incidentRules/triggers/form.tsx

@@ -33,6 +33,7 @@ type Props = {
   projects: Project[];
   projects: Project[];
   resolveThreshold: UnsavedIncidentRule['resolveThreshold'];
   resolveThreshold: UnsavedIncidentRule['resolveThreshold'];
   thresholdType: UnsavedIncidentRule['thresholdType'];
   thresholdType: UnsavedIncidentRule['thresholdType'];
+  aggregate: UnsavedIncidentRule['aggregate'];
   trigger: Trigger;
   trigger: Trigger;
   triggerIndex: number;
   triggerIndex: number;
   isCritical: boolean;
   isCritical: boolean;
@@ -145,6 +146,7 @@ class TriggerFormContainer extends React.Component<TriggerFormContainerProps> {
       organization,
       organization,
       triggers,
       triggers,
       thresholdType,
       thresholdType,
+      aggregate,
       resolveThreshold,
       resolveThreshold,
       projects,
       projects,
       onThresholdTypeChange,
       onThresholdTypeChange,
@@ -156,6 +158,13 @@ class TriggerFormContainer extends React.Component<TriggerFormContainerProps> {
       actions: [],
       actions: [],
     };
     };
 
 
+    const thresholdUnits =
+      aggregate.includes('duration') || aggregate.includes('measurements')
+        ? 'ms'
+        : aggregate.includes('failure_rate')
+        ? '%'
+        : '';
+
     return (
     return (
       <React.Fragment>
       <React.Fragment>
         {triggers.map((trigger, index) => {
         {triggers.map((trigger, index) => {
@@ -171,21 +180,26 @@ class TriggerFormContainer extends React.Component<TriggerFormContainerProps> {
               error={errors && errors.get(index)}
               error={errors && errors.get(index)}
               trigger={trigger}
               trigger={trigger}
               thresholdType={thresholdType}
               thresholdType={thresholdType}
+              aggregate={aggregate}
               resolveThreshold={resolveThreshold}
               resolveThreshold={resolveThreshold}
               organization={organization}
               organization={organization}
               projects={projects}
               projects={projects}
               triggerIndex={index}
               triggerIndex={index}
               isCritical={isCritical}
               isCritical={isCritical}
-              fieldHelp={tct('The threshold that will activate the [severity] status.', {
-                severity: isCritical ? t('critical') : t('warning'),
-              })}
+              fieldHelp={tct(
+                'The threshold[units] that will activate the [severity] status.',
+                {
+                  severity: isCritical ? t('critical') : t('warning'),
+                  units: thresholdUnits ? ` (${thresholdUnits})` : '',
+                }
+              )}
               triggerLabel={
               triggerLabel={
                 <React.Fragment>
                 <React.Fragment>
                   <TriggerIndicator size={12} />
                   <TriggerIndicator size={12} />
                   {isCritical ? t('Critical') : t('Warning')}
                   {isCritical ? t('Critical') : t('Warning')}
                 </React.Fragment>
                 </React.Fragment>
               }
               }
-              placeholder={isCritical ? '300' : t('None')}
+              placeholder={isCritical ? `300${thresholdUnits}` : t('None')}
               onChange={this.handleChangeTrigger(index)}
               onChange={this.handleChangeTrigger(index)}
               onThresholdTypeChange={onThresholdTypeChange}
               onThresholdTypeChange={onThresholdTypeChange}
             />
             />
@@ -199,12 +213,15 @@ class TriggerFormContainer extends React.Component<TriggerFormContainerProps> {
           trigger={resolveTrigger}
           trigger={resolveTrigger}
           // Flip rule thresholdType to opposite
           // Flip rule thresholdType to opposite
           thresholdType={+!thresholdType}
           thresholdType={+!thresholdType}
+          aggregate={aggregate}
           resolveThreshold={resolveThreshold}
           resolveThreshold={resolveThreshold}
           organization={organization}
           organization={organization}
           projects={projects}
           projects={projects}
           triggerIndex={2}
           triggerIndex={2}
           isCritical={false}
           isCritical={false}
-          fieldHelp={t('The threshold that will activate the resolved status.')}
+          fieldHelp={tct('The threshold[units] that will activate the resolved status.', {
+            units: thresholdUnits ? ` (${thresholdUnits})` : '',
+          })}
           triggerLabel={
           triggerLabel={
             <React.Fragment>
             <React.Fragment>
               <ResolvedIndicator size={12} />
               <ResolvedIndicator size={12} />

+ 3 - 0
static/app/views/settings/incidentRules/triggers/index.tsx

@@ -23,6 +23,7 @@ type Props = {
   triggers: Trigger[];
   triggers: Trigger[];
   resolveThreshold: UnsavedIncidentRule['resolveThreshold'];
   resolveThreshold: UnsavedIncidentRule['resolveThreshold'];
   thresholdType: UnsavedIncidentRule['thresholdType'];
   thresholdType: UnsavedIncidentRule['thresholdType'];
+  aggregate: UnsavedIncidentRule['aggregate'];
   currentProject: string;
   currentProject: string;
   availableActions: MetricActionTemplate[] | null;
   availableActions: MetricActionTemplate[] | null;
   disabled: boolean;
   disabled: boolean;
@@ -95,6 +96,7 @@ class Triggers extends Component<Props> {
       projects,
       projects,
       triggers,
       triggers,
       disabled,
       disabled,
+      aggregate,
       thresholdType,
       thresholdType,
       resolveThreshold,
       resolveThreshold,
       onThresholdTypeChange,
       onThresholdTypeChange,
@@ -112,6 +114,7 @@ class Triggers extends Component<Props> {
               organization={organization}
               organization={organization}
               projects={projects}
               projects={projects}
               triggers={triggers}
               triggers={triggers}
+              aggregate={aggregate}
               resolveThreshold={resolveThreshold}
               resolveThreshold={resolveThreshold}
               thresholdType={thresholdType}
               thresholdType={thresholdType}
               onChange={this.handleChangeTrigger}
               onChange={this.handleChangeTrigger}