Skip to content

Commit

Permalink
fix(core/pagerDuty): give appropriate app to PagerDutyWriter (#6789)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikmunson authored Mar 31, 2019
1 parent e866c9f commit 8b1e5bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 8 additions & 3 deletions app/scripts/modules/core/src/pagerDuty/PageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@ export class PageModal extends React.Component<IPageModalProps, IPageModalState>
};

public sendPage = (): void => {
const { applications, services } = this.props;
const defaultApp = new ApplicationModelBuilder().createStandaloneApplication('spinnaker');
const ownerApp = applications && applications.length === 1 ? applications[0] : defaultApp;

const taskMonitor = new TaskMonitor({
application: new ApplicationModelBuilder().createStandaloneApplication('spinnaker'),
application: ownerApp,
title: `Sending page to ${this.state.pageCount} policies`,
modalInstance: TaskMonitor.modalInstanceEmulation(() => this.close()),
onTaskComplete: () => this.props.closeCallback(true),
});

const submitMethod = () => {
const { applications, services } = this.props;
const { subject, details } = this.state;

return PagerDutyWriter.sendPage(applications, services.map(s => s.integration_key), subject, { details });
return PagerDutyWriter.sendPage(applications, services.map(s => s.integration_key), subject, ownerApp, {
details,
});
};

taskMonitor.submit(submitMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class PagerDutyWriter {
applications: Application[],
keys: string[],
reason: string,
ownerApp: Application,
details?: { [key: string]: any },
): IPromise<any> {
const job = {
Expand All @@ -38,19 +39,15 @@ export class PagerDutyWriter {
}

const task = {
application: ownerApp,
job: [job],
description: 'Send Page',
} as ITaskCommand;

// If only one application was passed in, assign ownership
if (applications && applications.length === 1) {
task.application = applications[0];
}

return TaskExecutor.executeTask(task);
}

public static pageApplicationOwner(application: Application, reason: string, details?: string): IPromise<any> {
return this.sendPage([application], undefined, reason, { details });
return this.sendPage([application], undefined, reason, application, { details });
}
}

0 comments on commit 8b1e5bf

Please sign in to comment.