From f2750ba645f83a4d1080ae0d83dc0a9a02632803 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 7 Mar 2017 14:05:55 -0500 Subject: [PATCH] Make sure to initialize trigger setup when *both* values change Hopefully fixes https://www.pivotaltracker.com/story/show/141245817 --- .../manage-trigger-githost.component.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts index a28f1e2f4..f83e58d96 100644 --- a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts +++ b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts @@ -62,14 +62,8 @@ export class ManageTriggerGithostComponent implements ng.IComponentController { public $onInit(): void { // TODO: Replace $scope.$watch with @Output methods for child component mutations or $onChanges for parent mutations - this.$scope.$watch(() => this.trigger, (trigger) => { - if (trigger && this.repository) { - this.config = trigger['config'] || {}; - this.namespaceTitle = 'organization'; - this.local.selectedNamespace = null; - this.loadNamespaces(); - } - }); + this.$scope.$watch(() => this.trigger, this.initialSetup.bind(this)); + this.$scope.$watch(() => this.repository, this.initialSetup.bind(this)); this.$scope.$watch(() => this.local.selectedNamespace, (namespace) => { if (namespace) { @@ -102,6 +96,20 @@ export class ManageTriggerGithostComponent implements ng.IComponentController { this.$scope.$watch(() => this.local.robotOptions.filter, this.buildOrderedRobotAccounts); } + private initialSetup(): void { + if (!this.repository || !this.trigger) { return; } + + if (this.namespaceTitle) { + // Already setup. + return; + } + + this.config = this.trigger['config'] || {}; + this.namespaceTitle = 'organization'; + this.local.selectedNamespace = null; + this.loadNamespaces(); + } + public getTriggerIcon(): any { return this.TriggerService.getIcon(this.trigger.service); }