Browse Source

ref: convert incidentTrigger.js to typescript (#54500)

Michelle Zhang 1 year ago
parent
commit
0f81a20eeb

+ 0 - 11
fixtures/js-stubs/incidentTrigger.js

@@ -1,11 +0,0 @@
-export function IncidentTrigger(params = {}) {
-  return {
-    alertRuleId: '4',
-    alertThreshold: 70,
-    dateCreated: '2019-09-24T18:07:47.714Z',
-    id: '1',
-    label: 'critical',
-    actions: [],
-    ...params,
-  };
-}

+ 13 - 0
fixtures/js-stubs/incidentTrigger.ts

@@ -0,0 +1,13 @@
+import {AlertRuleTriggerType, SavedTrigger} from 'sentry/views/alerts/rules/metric/types';
+
+export function IncidentTrigger(params: Partial<SavedTrigger> = {}): SavedTrigger {
+  return {
+    alertRuleId: '4',
+    alertThreshold: 70,
+    dateCreated: '2019-09-24T18:07:47.714Z',
+    id: '1',
+    label: AlertRuleTriggerType.CRITICAL,
+    actions: [],
+    ...params,
+  };
+}

+ 1 - 1
static/app/views/alerts/rules/metric/ruleForm.spec.tsx

@@ -304,7 +304,7 @@ describe('Incident Rules Form', () => {
       editTrigger = MockApiClient.addMockResponse({
       editTrigger = MockApiClient.addMockResponse({
         url: `/organizations/org-slug/alert-rules/${rule.id}/triggers/1/`,
         url: `/organizations/org-slug/alert-rules/${rule.id}/triggers/1/`,
         method: 'PUT',
         method: 'PUT',
-        body: TestStubs.IncidentTrigger({id: 1}),
+        body: TestStubs.IncidentTrigger({id: '1'}),
       });
       });
     });
     });
     afterEach(() => {
     afterEach(() => {

+ 1 - 1
static/app/views/alerts/rules/metric/types.tsx

@@ -73,7 +73,7 @@ export type ThresholdControlValue = {
   thresholdType: AlertRuleThresholdType;
   thresholdType: AlertRuleThresholdType;
 };
 };
 
 
-type SavedTrigger = Omit<UnsavedTrigger, 'actions'> & {
+export type SavedTrigger = Omit<UnsavedTrigger, 'actions'> & {
   actions: Action[];
   actions: Action[];
   dateCreated: string;
   dateCreated: string;
   id: string;
   id: string;