From 0c504d8ef0d71980c00e48343f277176cdfdbe35 Mon Sep 17 00:00:00 2001 From: Jacob Kiefer Date: Mon, 23 Oct 2017 17:14:09 -0400 Subject: [PATCH] feat(trigger/pubsub): Suggest subscriptions from echo configuration. --- app/scripts/modules/core/src/index.ts | 1 + .../config/triggers/pubsub/pubsub.trigger.ts | 14 ++++++- .../config/triggers/pubsub/pubsubTrigger.html | 42 ++++++++++--------- app/scripts/modules/core/src/pubsub/index.ts | 1 + .../src/pubsub/pubsubSubscription.service.ts | 15 +++++++ 5 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 app/scripts/modules/core/src/pubsub/index.ts create mode 100644 app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts diff --git a/app/scripts/modules/core/src/index.ts b/app/scripts/modules/core/src/index.ts index f45ad180f6c..b5ff26e17d7 100644 --- a/app/scripts/modules/core/src/index.ts +++ b/app/scripts/modules/core/src/index.ts @@ -45,6 +45,7 @@ export * from './overrideRegistry'; export * from './pageTitle'; export * from './pipeline'; export * from './presentation'; +export * from './pubsub'; export * from './reactShims'; export * from './retry'; diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts index c4fe3d2f085..be96210c80a 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts +++ b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts @@ -1,19 +1,29 @@ import { IController, module } from 'angular'; import { PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from 'core/pipeline/config/pipelineConfigProvider'; -import { IPubsubTrigger } from '@spinnaker/core'; +import { + IPubsubTrigger, + PUBSUB_SUBSCRIPTION_SERVICE, + PubsubSubscriptionService, +} from '@spinnaker/core'; class PubsubTriggerController implements IController { public pubsubSystems = ['kafka', 'google']; + public pubsubSubscriptions: string[]; - constructor(public trigger: IPubsubTrigger) { + constructor(public trigger: IPubsubTrigger, + public pubsubSubscriptionService: PubsubSubscriptionService) { 'ngInject'; + pubsubSubscriptionService.getPubsubSubscriptions().then(subscriptions => { + this.pubsubSubscriptions = subscriptions; + }); } } export const PUBSUB_TRIGGER = 'spinnaker.core.pipeline.trigger.pubsub'; module(PUBSUB_TRIGGER, [ PIPELINE_CONFIG_PROVIDER, + PUBSUB_SUBSCRIPTION_SERVICE, ]).config((pipelineConfigProvider: PipelineConfigProvider) => { pipelineConfigProvider.registerTrigger({ label: 'Pub/Sub', diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html index aa9357d31fc..e650a015961 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html +++ b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html @@ -1,25 +1,27 @@ - -
- -
- -
+
+ +
+
+
-
-
- Subscription Name -
-
- -
+
+
+ Subscription Name
- +
+ +
+
diff --git a/app/scripts/modules/core/src/pubsub/index.ts b/app/scripts/modules/core/src/pubsub/index.ts new file mode 100644 index 00000000000..9661b25e9ac --- /dev/null +++ b/app/scripts/modules/core/src/pubsub/index.ts @@ -0,0 +1 @@ +export * from './pubsubSubscription.service'; diff --git a/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts b/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts new file mode 100644 index 00000000000..4133002844f --- /dev/null +++ b/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts @@ -0,0 +1,15 @@ +import { module } from 'angular'; + +import { API_SERVICE, Api } from 'core/api/api.service'; + +export class PubsubSubscriptionService { + constructor(private API: Api) { 'ngInject'; } + + public getPubsubSubscriptions(): ng.IPromise { + return this.API.one('pubsub').one('subscriptions').get(); + } +} + +export const PUBSUB_SUBSCRIPTION_SERVICE = 'spinnaker.core.pubsubSubscription.service'; +module(PUBSUB_SUBSCRIPTION_SERVICE, [API_SERVICE]) + .service('pubsubSubscriptionService', PubsubSubscriptionService);