Browse Source

fix(crons): Correct owner field (#68920)

This doesn't come back as a string, it's an Actor
Evan Purkhiser 11 months ago
parent
commit
604a22e116

+ 2 - 2
fixtures/js-stubs/monitor.tsx

@@ -5,8 +5,8 @@ import {
   ScheduleType,
 } from 'sentry/views/monitors/types';
 
+import {ActorFixture} from './actor';
 import {ProjectFixture} from './project';
-import {UserFixture} from './user';
 
 export function MonitorFixture(params: Partial<Monitor> = {}): Monitor {
   return {
@@ -16,7 +16,7 @@ export function MonitorFixture(params: Partial<Monitor> = {}): Monitor {
     project: ProjectFixture(),
     slug: 'my-monitor',
     status: 'active',
-    owner: `user:${UserFixture().id}`,
+    owner: ActorFixture(),
     type: MonitorType.CRON_JOB,
     config: {
       checkin_margin: 5,

+ 3 - 1
static/app/views/monitors/components/monitorForm.tsx

@@ -215,6 +215,8 @@ function MonitorForm({
     target => `${RULES_SELECTOR_MAP[target.targetType]}:${target.targetIdentifier}`
   );
 
+  const owner = monitor?.owner ? `${monitor.owner.type}:${monitor.owner.id}` : null;
+
   const envOptions = selectedProject?.environments.map(e => ({value: e, label: e})) ?? [];
   const alertRuleEnvs = [
     {
@@ -239,7 +241,7 @@ function MonitorForm({
           ? {
               name: monitor.name,
               slug: monitor.slug,
-              owner: monitor.owner,
+              owner: owner,
               type: monitor.type ?? DEFAULT_MONITOR_TYPE,
               project: monitor.project.slug,
               'alertRule.targets': alertRuleTarget,

+ 2 - 2
static/app/views/monitors/types.tsx

@@ -1,4 +1,4 @@
-import type {ObjectStatus, Project} from 'sentry/types';
+import type {Actor, ObjectStatus, Project} from 'sentry/types';
 import type {ColorOrAlias} from 'sentry/utils/theme';
 
 export enum MonitorType {
@@ -121,7 +121,7 @@ export interface Monitor {
   id: string;
   isMuted: boolean;
   name: string;
-  owner: string;
+  owner: Actor;
   project: Project;
   slug: string;
   status: ObjectStatus;