diff --git a/app/scripts/modules/amazon/src/function/details/FunctionActions.tsx b/app/scripts/modules/amazon/src/function/details/FunctionActions.tsx index f718b9d3e54..f2e79c641fe 100644 --- a/app/scripts/modules/amazon/src/function/details/FunctionActions.tsx +++ b/app/scripts/modules/amazon/src/function/details/FunctionActions.tsx @@ -1,7 +1,14 @@ import React from 'react'; import { Dropdown } from 'react-bootstrap'; -import { Application, ApplicationReader, FunctionWriter, SETTINGS, NgReact, ReactInjector } from '@spinnaker/core'; +import { + Application, + ApplicationReader, + FunctionWriter, + SETTINGS, + NgReact, + ConfirmationModalService, +} from '@spinnaker/core'; import { IAmazonFunction, IAmazonFunctionDeleteCommand } from 'amazon/domain'; @@ -70,7 +77,7 @@ export class FunctionActions extends React.Component FunctionWriter.deleteFunction(command, app); - ReactInjector.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${functionFromParams.functionName} in ${functionFromParams.region}: ${functionFromParams.account}?`, buttonText: `Delete ${functionFromParams.functionName}`, account: functionFromParams.account, diff --git a/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js b/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js index ecbe8d432a6..5ce95ec4b95 100644 --- a/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js @@ -6,7 +6,7 @@ import { getAllTargetGroups, applyHealthCheckInfoToTargetGroups } from './utils' import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, InstanceReader, RecentHistoryService, SETTINGS, @@ -25,30 +25,17 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ ANGULAR_UI_BOOTSTRAP, AMAZON_INSTANCE_WRITE_SERVICE, AMAZON_VPC_VPCTAG_DIRECTIVE, - CONFIRMATION_MODAL_SERVICE, ]).controller('awsInstanceDetailsCtrl', [ '$scope', '$state', 'amazonInstanceWriter', - 'confirmationModalService', 'instance', 'app', 'moniker', 'environment', '$q', 'overrides', - function( - $scope, - $state, - amazonInstanceWriter, - confirmationModalService, - instance, - app, - moniker, - environment, - $q, - overrides, - ) { + function($scope, $state, amazonInstanceWriter, instance, app, moniker, environment, $q, overrides) { // needed for standalone instances $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('aws', 'instance.detailsTemplateUrl'); @@ -316,7 +303,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.terminateInstance(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + '?', buttonText: 'Terminate ' + instance.instanceId, account: instance.account, @@ -342,7 +329,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.terminateInstanceAndShrinkServerGroup(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?', buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup, account: instance.account, @@ -367,7 +354,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.rebootInstance(instance, app, params); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really reboot ' + instance.instanceId + '?', buttonText: 'Reboot ' + instance.instanceId, account: instance.account, @@ -391,7 +378,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.registerInstanceWithLoadBalancer(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?', buttonText: 'Register ' + instance.instanceId, account: instance.account, @@ -413,7 +400,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.deregisterInstanceFromLoadBalancer(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?', buttonText: 'Deregister ' + instance.instanceId, account: instance.account, @@ -435,7 +422,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.registerInstanceWithTargetGroup(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really register ' + instance.instanceId + ' with ' + targetGroupNames + '?', buttonText: 'Register ' + instance.instanceId, account: instance.account, @@ -457,7 +444,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.deregisterInstanceFromTargetGroup(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really deregister ' + instance.instanceId + ' from ' + targetGroupNames + '?', buttonText: 'Deregister ' + instance.instanceId, account: instance.account, @@ -478,7 +465,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.enableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really enable ' + instance.instanceId + ' in discovery?', buttonText: 'Enable ' + instance.instanceId, account: instance.account, @@ -499,7 +486,7 @@ module(AMAZON_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return amazonInstanceWriter.disableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really disable ' + instance.instanceId + ' in discovery?', buttonText: 'Disable ' + instance.instanceId, account: instance.account, diff --git a/app/scripts/modules/amazon/src/loadBalancer/configure/application/ALBListeners.tsx b/app/scripts/modules/amazon/src/loadBalancer/configure/application/ALBListeners.tsx index 82417fa77aa..a36e8b3b14b 100644 --- a/app/scripts/modules/amazon/src/loadBalancer/configure/application/ALBListeners.tsx +++ b/app/scripts/modules/amazon/src/loadBalancer/configure/application/ALBListeners.tsx @@ -6,10 +6,10 @@ import { FormikErrors, FormikProps } from 'formik'; import { Application, + ConfirmationModalService, CustomLabels, HelpField, IWizardPageComponent, - ReactInjector, Tooltip, ValidationMessage, } from '@spinnaker/core'; @@ -403,7 +403,7 @@ export class ALBListeners extends React.Component { diff --git a/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx b/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx index da6e794eb60..7c18615a1ea 100644 --- a/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx +++ b/app/scripts/modules/amazon/src/loadBalancer/details/LoadBalancerActions.tsx @@ -5,11 +5,11 @@ import { get, values } from 'lodash'; import { Application, ApplicationReader, + ConfirmationModalService, LoadBalancerWriter, ManagedMenuItem, SETTINGS, NgReact, - ReactInjector, HelpField, } from '@spinnaker/core'; @@ -89,7 +89,7 @@ export class LoadBalancerActions extends React.Component LoadBalancerWriter.deleteLoadBalancer(command, app); - ReactInjector.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${loadBalancerFromParams.name} in ${loadBalancerFromParams.region}: ${loadBalancerFromParams.accountId}?`, buttonText: `Delete ${loadBalancerFromParams.name}`, account: loadBalancerFromParams.accountId, diff --git a/app/scripts/modules/amazon/src/loadBalancer/details/loadBalancerDetails.controller.ts b/app/scripts/modules/amazon/src/loadBalancer/details/loadBalancerDetails.controller.ts index 7719c147028..97badb37202 100644 --- a/app/scripts/modules/amazon/src/loadBalancer/details/loadBalancerDetails.controller.ts +++ b/app/scripts/modules/amazon/src/loadBalancer/details/loadBalancerDetails.controller.ts @@ -4,7 +4,6 @@ import { head, sortBy } from 'lodash'; import { Application, - CONFIRMATION_MODAL_SERVICE, IApplicationSecurityGroup, ILoadBalancer, ISecurityGroup, @@ -235,6 +234,5 @@ module(AWS_LOAD_BALANCER_DETAILS_CTRL, [ SECURITY_GROUP_READER, LOAD_BALANCER_ACTIONS, LOAD_BALANCER_READ_SERVICE, - CONFIRMATION_MODAL_SERVICE, MANAGED_RESOURCE_DETAILS_INDICATOR, ]).controller('awsLoadBalancerDetailsCtrl', AwsLoadBalancerDetailsController); diff --git a/app/scripts/modules/amazon/src/securityGroup/details/securityGroupDetail.controller.js b/app/scripts/modules/amazon/src/securityGroup/details/securityGroupDetail.controller.js index 7fcd9f856f0..aaf7306fccb 100644 --- a/app/scripts/modules/amazon/src/securityGroup/details/securityGroupDetail.controller.js +++ b/app/scripts/modules/amazon/src/securityGroup/details/securityGroupDetail.controller.js @@ -5,7 +5,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, confirmNotManaged, RecentHistoryService, SECURITY_GROUP_READER, @@ -26,7 +26,6 @@ angular .module(AMAZON_SECURITYGROUP_DETAILS_SECURITYGROUPDETAIL_CONTROLLER, [ UIROUTER_ANGULARJS, SECURITY_GROUP_READER, - CONFIRMATION_MODAL_SERVICE, AMAZON_SECURITYGROUP_CLONE_CLONESECURITYGROUP_CONTROLLER, MANAGED_RESOURCE_DETAILS_INDICATOR, ]) @@ -35,10 +34,9 @@ angular '$state', 'resolvedSecurityGroup', 'app', - 'confirmationModalService', 'securityGroupReader', '$uibModal', - function($scope, $state, resolvedSecurityGroup, app, confirmationModalService, securityGroupReader, $uibModal) { + function($scope, $state, resolvedSecurityGroup, app, securityGroupReader, $uibModal) { this.application = app; const application = app; const securityGroup = resolvedSecurityGroup; @@ -215,7 +213,7 @@ angular confirmNotManaged($scope.securityGroup, application).then(notManaged => { notManaged && - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + securityGroup.name + '?', buttonText: 'Delete ' + securityGroup.name, account: securityGroup.accountId, diff --git a/app/scripts/modules/amazon/src/serverGroup/details/AmazonServerGroupActions.tsx b/app/scripts/modules/amazon/src/serverGroup/details/AmazonServerGroupActions.tsx index 02ddad3f396..7cd4fc50b5f 100644 --- a/app/scripts/modules/amazon/src/serverGroup/details/AmazonServerGroupActions.tsx +++ b/app/scripts/modules/amazon/src/serverGroup/details/AmazonServerGroupActions.tsx @@ -4,6 +4,7 @@ import { filter, find, get, orderBy } from 'lodash'; import { ClusterTargetBuilder, + ConfirmationModalService, IOwnerOption, IServerGroupActionsProps, IServerGroupJob, @@ -118,7 +119,7 @@ export class AmazonServerGroupActions extends React.Component { @@ -151,7 +152,7 @@ export class AmazonServerGroupActions extends React.Component { @@ -168,8 +169,7 @@ export class AmazonServerGroupActions extends React.Component this.rollbackServerGroup()) .catch(({ source }) => { // don't show the enable modal if the user cancels with the header button @@ -207,7 +207,7 @@ export class AmazonServerGroupActions extends React.Component { diff --git a/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js b/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js index 6d32fcc0983..3613f527c5d 100644 --- a/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js +++ b/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js @@ -2,7 +2,7 @@ import { module } from 'angular'; -import { CONFIRMATION_MODAL_SERVICE } from '@spinnaker/core'; +import { ConfirmationModalService } from '@spinnaker/core'; import { SCALING_POLICY_POPOVER } from './popover/scalingPolicyPopover.component'; import { ScalingPolicyWriter } from './ScalingPolicyWriter'; @@ -16,7 +16,6 @@ export const name = AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_C module(AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [ AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_UPSERTSCALINGPOLICY_CONTROLLER, SCALING_POLICY_POPOVER, - CONFIRMATION_MODAL_SERVICE, ]).component('alarmBasedSummary', { bindings: { policy: '=', @@ -26,8 +25,7 @@ module(AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [ templateUrl: require('./alarmBasedSummary.component.html'), controller: [ '$uibModal', - 'confirmationModalService', - function($uibModal, confirmationModalService) { + function($uibModal) { this.popoverTemplate = require('./popover/scalingPolicyDetails.popover.html'); this.editPolicy = () => { @@ -53,7 +51,7 @@ module(AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [ const submitMethod = () => ScalingPolicyWriter.deleteScalingPolicy(this.application, this.serverGroup, this.policy); - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + this.policy.policyName + '?', buttonText: 'Delete scaling policy', account: this.policy.alarms.length ? this.serverGroup.account : null, // don't confirm if it's a junk policy diff --git a/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts b/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts index 4481b1af7fc..719d2e26d9b 100644 --- a/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts +++ b/app/scripts/modules/amazon/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts @@ -14,8 +14,8 @@ class TargetTrackingSummaryController implements IComponentController { public config: ITargetTrackingConfiguration; public popoverTemplate = require('./targetTrackingPopover.html'); - public static $inject = ['$uibModal', 'confirmationModalService']; - constructor(private $uibModal: IModalService, private confirmationModalService: ConfirmationModalService) {} + public static $inject = ['$uibModal']; + constructor(private $uibModal: IModalService) {} public $onInit() { this.config = this.policy.targetTrackingConfiguration; @@ -41,7 +41,7 @@ class TargetTrackingSummaryController implements IComponentController { title: 'Deleting scaling policy ' + this.policy.policyName, }; - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${this.policy.policyName}?`, buttonText: 'Delete scaling policy', account: this.serverGroup.account, diff --git a/app/scripts/modules/appengine/src/instance/details/details.controller.ts b/app/scripts/modules/appengine/src/instance/details/details.controller.ts index 638c91d4b52..82790479b25 100644 --- a/app/scripts/modules/appengine/src/instance/details/details.controller.ts +++ b/app/scripts/modules/appengine/src/instance/details/details.controller.ts @@ -3,7 +3,6 @@ import { cloneDeep, flattenDeep } from 'lodash'; import { Application, - CONFIRMATION_MODAL_SERVICE, ConfirmationModalService, INSTANCE_WRITE_SERVICE, InstanceReader, @@ -34,12 +33,11 @@ class AppengineInstanceDetailsController implements IController { public outOfServiceToolTip = ` An App Engine instance is 'Out Of Service' if no load balancers are directing traffic to its server group.`; - public static $inject = ['$q', 'app', 'instanceWriter', 'confirmationModalService', 'instance']; + public static $inject = ['$q', 'app', 'instanceWriter', 'instance']; constructor( private $q: IQService, private app: Application, private instanceWriter: InstanceWriter, - private confirmationModalService: ConfirmationModalService, instance: InstanceFromStateParams, ) { this.app @@ -75,7 +73,7 @@ class AppengineInstanceDetailsController implements IController { return this.instanceWriter.terminateInstance(instance, this.app, { cloudProvider: 'appengine' }); }; - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + shortName + '?', buttonText: 'Terminate ' + shortName, account: instance.account, @@ -124,7 +122,7 @@ class AppengineInstanceDetailsController implements IController { export const APPENGINE_INSTANCE_DETAILS_CTRL = 'spinnaker.appengine.instanceDetails.controller'; -module(APPENGINE_INSTANCE_DETAILS_CTRL, [INSTANCE_WRITE_SERVICE, CONFIRMATION_MODAL_SERVICE]).controller( +module(APPENGINE_INSTANCE_DETAILS_CTRL, [INSTANCE_WRITE_SERVICE]).controller( 'appengineInstanceDetailsCtrl', AppengineInstanceDetailsController, ); diff --git a/app/scripts/modules/appengine/src/loadBalancer/details/details.controller.ts b/app/scripts/modules/appengine/src/loadBalancer/details/details.controller.ts index cb3c9a09ac8..78f652b6716 100644 --- a/app/scripts/modules/appengine/src/loadBalancer/details/details.controller.ts +++ b/app/scripts/modules/appengine/src/loadBalancer/details/details.controller.ts @@ -5,7 +5,6 @@ import { cloneDeep } from 'lodash'; import { Application, - CONFIRMATION_MODAL_SERVICE, ConfirmationModalService, ILoadBalancer, ILoadBalancerDeleteCommand, @@ -26,14 +25,13 @@ class AppengineLoadBalancerDetailsController implements IController { public loadBalancer: IAppengineLoadBalancer; public dispatchRules: string[] = []; - public static $inject = ['$uibModal', '$state', '$scope', 'loadBalancer', 'app', 'confirmationModalService']; + public static $inject = ['$uibModal', '$state', '$scope', 'loadBalancer', 'app']; constructor( private $uibModal: IModalService, private $state: StateService, private $scope: IScope, loadBalancer: ILoadBalancerFromStateParams, private app: Application, - private confirmationModalService: ConfirmationModalService, ) { this.loadBalancerFromParams = loadBalancer; this.app @@ -71,7 +69,7 @@ class AppengineLoadBalancerDetailsController implements IController { return LoadBalancerWriter.deleteLoadBalancer(loadBalancer, this.app); }; - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + this.loadBalancer.name + '?', buttonText: 'Delete ' + this.loadBalancer.name, body: this.getConfirmationModalBodyHtml(), @@ -154,7 +152,7 @@ class AppengineLoadBalancerDetailsController implements IController { } export const APPENGINE_LOAD_BALANCER_DETAILS_CTRL = 'spinnaker.appengine.loadBalancerDetails.controller'; -module(APPENGINE_LOAD_BALANCER_DETAILS_CTRL, [CONFIRMATION_MODAL_SERVICE]).controller( +module(APPENGINE_LOAD_BALANCER_DETAILS_CTRL, []).controller( 'appengineLoadBalancerDetailsCtrl', AppengineLoadBalancerDetailsController, ); diff --git a/app/scripts/modules/appengine/src/serverGroup/details/details.controller.ts b/app/scripts/modules/appengine/src/serverGroup/details/details.controller.ts index 8495d8c9bac..0850f2915d6 100644 --- a/app/scripts/modules/appengine/src/serverGroup/details/details.controller.ts +++ b/app/scripts/modules/appengine/src/serverGroup/details/details.controller.ts @@ -4,7 +4,6 @@ import { cloneDeep, map, mapValues, reduce } from 'lodash'; import { Application, - CONFIRMATION_MODAL_SERVICE, ConfirmationModalService, IConfirmationModalParams, IServerGroup, @@ -65,7 +64,6 @@ class AppengineServerGroupDetailsController implements IController { 'serverGroup', 'app', 'serverGroupWriter', - 'confirmationModalService', 'appengineServerGroupWriter', 'appengineServerGroupCommandBuilder', ]; @@ -76,7 +74,6 @@ class AppengineServerGroupDetailsController implements IController { serverGroup: IServerGroupFromStateParams, public app: Application, private serverGroupWriter: ServerGroupWriter, - private confirmationModalService: ConfirmationModalService, private appengineServerGroupWriter: AppengineServerGroupWriter, private appengineServerGroupCommandBuilder: AppengineServerGroupCommandBuilder, ) { @@ -161,7 +158,7 @@ class AppengineServerGroupDetailsController implements IController { confirmationModalParams.interestingHealthProviderNames = [AppengineHealth.PLATFORM]; } - this.confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); } public enableServerGroup(): void { @@ -203,7 +200,7 @@ class AppengineServerGroupDetailsController implements IController { confirmationModalParams.interestingHealthProviderNames = [AppengineHealth.PLATFORM]; } - this.confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); } public disableServerGroup(): void { @@ -252,7 +249,7 @@ class AppengineServerGroupDetailsController implements IController { confirmationModalParams.interestingHealthProviderNames = [AppengineHealth.PLATFORM]; } - this.confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); } public stopServerGroup(): void { @@ -287,7 +284,7 @@ class AppengineServerGroupDetailsController implements IController { askForReason: true, }; - this.confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); } public startServerGroup(): void { @@ -309,7 +306,7 @@ class AppengineServerGroupDetailsController implements IController { askForReason: true, }; - this.confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); } public cloneServerGroup(): void { @@ -459,8 +456,7 @@ class AppengineServerGroupDetailsController implements IController { export const APPENGINE_SERVER_GROUP_DETAILS_CTRL = 'spinnaker.appengine.serverGroup.details.controller'; -module(APPENGINE_SERVER_GROUP_DETAILS_CTRL, [ - APPENGINE_SERVER_GROUP_WRITER, - CONFIRMATION_MODAL_SERVICE, - SERVER_GROUP_WRITER, -]).controller('appengineServerGroupDetailsCtrl', AppengineServerGroupDetailsController); +module(APPENGINE_SERVER_GROUP_DETAILS_CTRL, [APPENGINE_SERVER_GROUP_WRITER, SERVER_GROUP_WRITER]).controller( + 'appengineServerGroupDetailsCtrl', + AppengineServerGroupDetailsController, +); diff --git a/app/scripts/modules/azure/src/instance/details/instance.details.controller.js b/app/scripts/modules/azure/src/instance/details/instance.details.controller.js index 627be273877..0e227daa1fa 100644 --- a/app/scripts/modules/azure/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/azure/src/instance/details/instance.details.controller.js @@ -5,7 +5,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, InstanceReader, INSTANCE_WRITE_SERVICE, InstanceTemplates, @@ -20,17 +20,15 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ UIROUTER_ANGULARJS, ANGULAR_UI_BOOTSTRAP, INSTANCE_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, ]).controller('azureInstanceDetailsCtrl', [ '$scope', '$state', '$uibModal', 'instanceWriter', - 'confirmationModalService', 'instance', 'app', '$q', - function($scope, $state, $uibModal, instanceWriter, confirmationModalService, instance, app, $q) { + function($scope, $state, $uibModal, instanceWriter, instance, app, $q) { // needed for standalone instances $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('azure', 'instance.detailsTemplateUrl'); @@ -208,7 +206,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.terminateInstance(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + '?', buttonText: 'Terminate ' + instance.instanceId, account: instance.account, @@ -234,7 +232,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.terminateInstanceAndShrinkServerGroup(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?', buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup, account: instance.account, @@ -255,7 +253,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.rebootInstance(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really reboot ' + instance.instanceId + '?', buttonText: 'Reboot ' + instance.instanceId, account: instance.account, @@ -277,7 +275,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.registerInstanceWithLoadBalancer(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?', buttonText: 'Register ' + instance.instanceId, account: instance.account, @@ -299,7 +297,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.deregisterInstanceFromLoadBalancer(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?', buttonText: 'Deregister ' + instance.instanceId, account: instance.account, @@ -320,7 +318,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.enableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really enable ' + instance.instanceId + ' in discovery?', buttonText: 'Enable ' + instance.instanceId, account: instance.account, @@ -341,7 +339,7 @@ module(AZURE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.disableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really disable ' + instance.instanceId + ' in discovery?', buttonText: 'Disable ' + instance.instanceId, account: instance.account, diff --git a/app/scripts/modules/azure/src/loadBalancer/details/loadBalancerDetail.controller.js b/app/scripts/modules/azure/src/loadBalancer/details/loadBalancerDetail.controller.js index 7138c92ec74..65866d370e5 100644 --- a/app/scripts/modules/azure/src/loadBalancer/details/loadBalancerDetail.controller.js +++ b/app/scripts/modules/azure/src/loadBalancer/details/loadBalancerDetail.controller.js @@ -4,7 +4,7 @@ import * as angular from 'angular'; import _ from 'lodash'; import { - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, LOAD_BALANCER_READ_SERVICE, LoadBalancerWriter, SECURITY_GROUP_READER, @@ -22,7 +22,6 @@ angular UIROUTER_ANGULARJS, SECURITY_GROUP_READER, LOAD_BALANCER_READ_SERVICE, - CONFIRMATION_MODAL_SERVICE, ]) .controller('azureLoadBalancerDetailsCtrl', [ '$scope', @@ -32,7 +31,6 @@ angular 'loadBalancer', 'app', 'securityGroupReader', - 'confirmationModalService', 'loadBalancerReader', '$q', function( @@ -43,7 +41,6 @@ angular loadBalancer, app, securityGroupReader, - confirmationModalService, loadBalancerReader, $q, ) { @@ -172,7 +169,7 @@ angular const submitMethod = () => LoadBalancerWriter.deleteLoadBalancer(command, app); - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + loadBalancer.name + '?', buttonText: 'Delete ' + loadBalancer.name, account: loadBalancer.accountId, diff --git a/app/scripts/modules/azure/src/securityGroup/details/securityGroupDetail.controller.js b/app/scripts/modules/azure/src/securityGroup/details/securityGroupDetail.controller.js index 71dc9bc9bbe..2de5ce141a1 100644 --- a/app/scripts/modules/azure/src/securityGroup/details/securityGroupDetail.controller.js +++ b/app/scripts/modules/azure/src/securityGroup/details/securityGroupDetail.controller.js @@ -3,7 +3,7 @@ import * as angular from 'angular'; import _ from 'lodash'; -import { CONFIRMATION_MODAL_SERVICE, SECURITY_GROUP_READER, FirewallLabels } from '@spinnaker/core'; +import { SECURITY_GROUP_READER, ConfirmationModalService, FirewallLabels } from '@spinnaker/core'; import { AZURE_SECURITYGROUP_SECURITYGROUP_WRITE_SERVICE } from '../securityGroup.write.service'; import { AZURE_SECURITYGROUP_CLONE_CLONESECURITYGROUP_CONTROLLER } from '../clone/cloneSecurityGroup.controller'; import UIROUTER_ANGULARJS from '@uirouter/angularjs'; @@ -16,7 +16,6 @@ angular UIROUTER_ANGULARJS, SECURITY_GROUP_READER, AZURE_SECURITYGROUP_SECURITYGROUP_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, AZURE_SECURITYGROUP_CLONE_CLONESECURITYGROUP_CONTROLLER, ]) .controller('azureSecurityGroupDetailsCtrl', [ @@ -24,20 +23,10 @@ angular '$state', 'resolvedSecurityGroup', 'app', - 'confirmationModalService', 'azureSecurityGroupWriter', 'securityGroupReader', '$uibModal', - function( - $scope, - $state, - resolvedSecurityGroup, - app, - confirmationModalService, - azureSecurityGroupWriter, - securityGroupReader, - $uibModal, - ) { + function($scope, $state, resolvedSecurityGroup, app, azureSecurityGroupWriter, securityGroupReader, $uibModal) { const application = app; const securityGroup = resolvedSecurityGroup; @@ -133,7 +122,7 @@ angular }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + securityGroup.name + '?', buttonText: 'Delete ' + securityGroup.name, account: securityGroup.accountId, diff --git a/app/scripts/modules/azure/src/serverGroup/details/serverGroupDetails.azure.controller.js b/app/scripts/modules/azure/src/serverGroup/details/serverGroupDetails.azure.controller.js index a59c985dfe8..a89acd47e8d 100644 --- a/app/scripts/modules/azure/src/serverGroup/details/serverGroupDetails.azure.controller.js +++ b/app/scripts/modules/azure/src/serverGroup/details/serverGroupDetails.azure.controller.js @@ -4,7 +4,7 @@ import * as angular from 'angular'; import _ from 'lodash'; import { - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, ServerGroupReader, ServerGroupWarningMessageService, SERVER_GROUP_WRITER, @@ -24,7 +24,6 @@ angular .module(AZURE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_AZURE_CONTROLLER, [ UIROUTER_ANGULARJS, AZURE_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER_SERVICE, - CONFIRMATION_MODAL_SERVICE, SERVER_GROUP_WRITER, ]) .controller('azureServerGroupDetailsCtrl', [ @@ -35,7 +34,6 @@ angular 'serverGroup', 'azureServerGroupCommandBuilder', '$uibModal', - 'confirmationModalService', 'serverGroupWriter', function( $scope, @@ -45,7 +43,6 @@ angular serverGroup, azureServerGroupCommandBuilder, $uibModal, - confirmationModalService, serverGroupWriter, ) { $scope.state = { @@ -180,7 +177,7 @@ angular ServerGroupWarningMessageService.addDestroyWarningMessage(app, serverGroup, confirmationModalParams); - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.disableServerGroup = function disableServerGroup() { @@ -203,7 +200,7 @@ angular ServerGroupWarningMessageService.addDisableWarningMessage(app, serverGroup, confirmationModalParams); - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.enableServerGroup = function enableServerGroup() { @@ -224,7 +221,7 @@ angular ); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really enable ' + serverGroup.name + '?', buttonText: 'Enable ' + serverGroup.name, account: serverGroup.account, diff --git a/app/scripts/modules/cloudfoundry/src/instance/details/CloudFoundryInstanceActions.tsx b/app/scripts/modules/cloudfoundry/src/instance/details/CloudFoundryInstanceActions.tsx index f0f997aa6e6..320ba61b85c 100644 --- a/app/scripts/modules/cloudfoundry/src/instance/details/CloudFoundryInstanceActions.tsx +++ b/app/scripts/modules/cloudfoundry/src/instance/details/CloudFoundryInstanceActions.tsx @@ -9,14 +9,13 @@ import { ICloudFoundryInstance } from 'cloudfoundry/domain'; export interface ICloudFoundryInstanceActionsProps { application: Application; - confirmationModalService: ConfirmationModalService; instance: ICloudFoundryInstance; instanceWriter: InstanceWriter; } export class CloudFoundryInstanceActions extends React.Component { private terminateInstance = () => { - const { application, confirmationModalService, instance, instanceWriter } = this.props; + const { application, instance, instanceWriter } = this.props; const instanceClone = cloneDeep(instance) as any; instanceClone.placement = {}; instanceClone.id = instance.name; @@ -34,7 +33,7 @@ export class CloudFoundryInstanceActions extends React.Component @@ -133,12 +131,7 @@ export class CloudFoundryInstanceDetails extends React.Component<

{instance.name}

- + ); const notFoundContent = () => ( diff --git a/app/scripts/modules/cloudfoundry/src/loadBalancer/details/CloudFoundryLoadBalancerActions.tsx b/app/scripts/modules/cloudfoundry/src/loadBalancer/details/CloudFoundryLoadBalancerActions.tsx index 48a82ba9020..1948f98c19f 100644 --- a/app/scripts/modules/cloudfoundry/src/loadBalancer/details/CloudFoundryLoadBalancerActions.tsx +++ b/app/scripts/modules/cloudfoundry/src/loadBalancer/details/CloudFoundryLoadBalancerActions.tsx @@ -4,6 +4,7 @@ import { Dropdown } from 'react-bootstrap'; import { Application, + ConfirmationModalService, ILoadBalancer, ILoadBalancerDeleteCommand, LoadBalancerWriter, @@ -38,7 +39,7 @@ export class CloudFoundryLoadBalancerActions extends React.Component { @@ -143,7 +144,7 @@ export class CloudFoundryServerGroupActions extends React.Component { @@ -160,8 +161,7 @@ export class CloudFoundryServerGroupActions extends React.Component this.rollbackServerGroup()) .catch(({ source }) => { // don't show the enable modal if the user cancels with the header button @@ -200,7 +200,7 @@ export class CloudFoundryServerGroupActions extends React.Component { diff --git a/app/scripts/modules/core/src/application/config/DeleteApplicationSection.tsx b/app/scripts/modules/core/src/application/config/DeleteApplicationSection.tsx index e7744ffdab9..b1fe8a0cd18 100644 --- a/app/scripts/modules/core/src/application/config/DeleteApplicationSection.tsx +++ b/app/scripts/modules/core/src/application/config/DeleteApplicationSection.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Application, ApplicationWriter } from 'core/application'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { ReactInjector } from 'core/reactShims'; import { FirewallLabel } from 'core/securityGroup/label'; @@ -19,7 +20,7 @@ export function DeleteApplicationSection(props: IDeleteApplicationSection) { }, }; - ReactInjector.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${application.name} ?`, buttonText: `Delete ${application.name}`, taskMonitorConfig: taskMonitor, diff --git a/app/scripts/modules/core/src/application/config/applicationSnapshotSection.component.js b/app/scripts/modules/core/src/application/config/applicationSnapshotSection.component.js index f832902ce93..9220b9fd67c 100644 --- a/app/scripts/modules/core/src/application/config/applicationSnapshotSection.component.js +++ b/app/scripts/modules/core/src/application/config/applicationSnapshotSection.component.js @@ -2,7 +2,7 @@ import { module } from 'angular'; -import { CONFIRMATION_MODAL_SERVICE } from 'core/confirmationModal/confirmationModal.service'; +import { ConfirmationModalService } from 'core/confirmationModal/confirmationModal.service'; import { SnapshotWriter } from 'core/snapshot/SnapshotWriter'; import { CORE_SNAPSHOT_DIFF_VIEWSNAPSHOTDIFFBUTTON_COMPONENT } from 'core/snapshot/diff/viewSnapshotDiffButton.component'; import UIROUTER_ANGULARJS from '@uirouter/angularjs'; @@ -12,7 +12,6 @@ export const CORE_APPLICATION_CONFIG_APPLICATIONSNAPSHOTSECTION_COMPONENT = export const name = CORE_APPLICATION_CONFIG_APPLICATIONSNAPSHOTSECTION_COMPONENT; // for backwards compatibility module(CORE_APPLICATION_CONFIG_APPLICATIONSNAPSHOTSECTION_COMPONENT, [ UIROUTER_ANGULARJS, - CONFIRMATION_MODAL_SERVICE, CORE_SNAPSHOT_DIFF_VIEWSNAPSHOTDIFFBUTTON_COMPONENT, ]).component('applicationSnapshotSection', { templateUrl: require('./applicationSnapshotSection.component.html'), @@ -21,8 +20,7 @@ module(CORE_APPLICATION_CONFIG_APPLICATIONSNAPSHOTSECTION_COMPONENT, [ }, controller: [ '$state', - 'confirmationModalService', - function($state, confirmationModalService) { + function($state) { if (this.application.notFound || this.application.hasError) { return; } @@ -37,7 +35,7 @@ module(CORE_APPLICATION_CONFIG_APPLICATIONSNAPSHOTSECTION_COMPONENT, [ title: 'Taking snapshot of ' + this.application.name, }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Are you sure you want to take a snapshot of: ' + this.application.name + '?', buttonText: 'Take snapshot', taskMonitorConfig: taskMonitor, diff --git a/app/scripts/modules/core/src/confirmationModal/confirmationModal.service.ts b/app/scripts/modules/core/src/confirmationModal/confirmationModal.service.ts index ae102222739..f97137cf067 100644 --- a/app/scripts/modules/core/src/confirmationModal/confirmationModal.service.ts +++ b/app/scripts/modules/core/src/confirmationModal/confirmationModal.service.ts @@ -1,4 +1,4 @@ -import { module, IPromise } from 'angular'; +import { IPromise } from 'angular'; import { $q } from 'ngimport'; import { ConfirmModal, IConfirmModalProps } from 'core/confirmationModal/ConfirmModal'; @@ -30,12 +30,12 @@ export interface IConfirmationModalParams extends IConfirmationModalPassthroughP } export class ConfirmationModalService { - private defaults: IConfirmationModalParams = { + private static defaults: IConfirmationModalParams = { buttonText: 'Confirm', cancelButtonText: 'Cancel', }; - public confirm(params: IConfirmationModalParams): IPromise { + public static confirm(params: IConfirmationModalParams): IPromise { const extendedParams: IConfirmModalProps = { ...this.defaults, ...params }; if (params.body) { @@ -60,6 +60,3 @@ export class ConfirmationModalService { return deferred.promise; } } - -export const CONFIRMATION_MODAL_SERVICE = 'spinnaker.core.confirmationModal.service'; -module(CONFIRMATION_MODAL_SERVICE, []).service('confirmationModalService', ConfirmationModalService); diff --git a/app/scripts/modules/core/src/entityTag/notifications/NotificationsPopover.tsx b/app/scripts/modules/core/src/entityTag/notifications/NotificationsPopover.tsx index eedd133334c..fa788a5af32 100644 --- a/app/scripts/modules/core/src/entityTag/notifications/NotificationsPopover.tsx +++ b/app/scripts/modules/core/src/entityTag/notifications/NotificationsPopover.tsx @@ -12,7 +12,7 @@ import { NotificationList, } from 'core/entityTag'; import { Placement, HoverablePopover, IHoverablePopoverContentsProps } from 'core/presentation'; -import { ReactInjector } from 'core/reactShims'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { noop } from 'core/utils'; import { ITaskMonitorConfig } from 'core/task'; @@ -136,7 +136,6 @@ export class NotificationsPopover extends React.Component application.entityTags.refresh().then(() => onUpdate()), }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${type}?`, buttonText: `Delete ${type}`, account: entity.account, diff --git a/app/scripts/modules/core/src/instance/details/multipleInstances.controller.js b/app/scripts/modules/core/src/instance/details/multipleInstances.controller.js index 2495913a7f0..48ce40e22ff 100644 --- a/app/scripts/modules/core/src/instance/details/multipleInstances.controller.js +++ b/app/scripts/modules/core/src/instance/details/multipleInstances.controller.js @@ -1,6 +1,6 @@ 'use strict'; -import { CONFIRMATION_MODAL_SERVICE } from 'core/confirmationModal/confirmationModal.service'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { INSTANCE_WRITE_SERVICE } from 'core/instance/instance.write.service'; import { ClusterState } from 'core/state'; import { CORE_INSTANCE_DETAILS_MULTIPLEINSTANCESERVERGROUP_DIRECTIVE } from './multipleInstanceServerGroup.directive'; @@ -14,15 +14,13 @@ export const name = CORE_INSTANCE_DETAILS_MULTIPLEINSTANCES_CONTROLLER; // for b module(CORE_INSTANCE_DETAILS_MULTIPLEINSTANCES_CONTROLLER, [ UIROUTER_ANGULARJS, INSTANCE_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, CORE_INSTANCE_DETAILS_MULTIPLEINSTANCESERVERGROUP_DIRECTIVE, ]).controller('MultipleInstancesCtrl', [ '$scope', '$state', - 'confirmationModalService', 'instanceWriter', 'app', - function($scope, $state, confirmationModalService, instanceWriter, app) { + function($scope, $state, instanceWriter, app) { this.selectedGroups = []; /** @@ -44,7 +42,7 @@ module(CORE_INSTANCE_DETAILS_MULTIPLEINSTANCES_CONTROLLER, [ title: verbs.presentContinuous + ' ' + descriptor, }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really ' + verbs.simplePresent.toLowerCase() + ' ' + descriptor + '?', buttonText: verbs.simplePresent + ' ' + descriptor, verificationLabel: diff --git a/app/scripts/modules/core/src/managed/toggleResourceManagement.tsx b/app/scripts/modules/core/src/managed/toggleResourceManagement.tsx index 99341f0e5b5..617f1af08eb 100644 --- a/app/scripts/modules/core/src/managed/toggleResourceManagement.tsx +++ b/app/scripts/modules/core/src/managed/toggleResourceManagement.tsx @@ -3,7 +3,7 @@ import { $q } from 'ngimport'; import { IManagedResource, IManagedResourceSummary, ManagedResourceStatus } from 'core/domain'; import { Application } from 'core/application'; -import { ReactInjector } from 'core/reactShims'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { ManagedWriter } from './ManagedWriter'; @@ -47,18 +47,16 @@ export const confirmNotManaged = (resource: IManagedResource, application: Appli application.managedResources.refresh(true), ); }; - return ReactInjector.confirmationModalService - .confirm({ - header: `Pause Management?`, - bodyContent: , - account: managedResourceSummary.locations.account, - buttonText: 'Pause management', - submitMethod, - }) - .then( - () => true, - () => false, - ); + return ConfirmationModalService.confirm({ + header: `Pause Management?`, + bodyContent: , + account: managedResourceSummary.locations.account, + buttonText: 'Pause management', + submitMethod, + }).then( + () => true, + () => false, + ); }; export const toggleResourcePause = ( @@ -73,7 +71,7 @@ export const toggleResourcePause = ( const submitMethod = () => toggle().then(() => application.managedResources.refresh(true)); - return ReactInjector.confirmationModalService.confirm({ + return ConfirmationModalService.confirm({ header: `Really ${isPaused ? 'resume' : 'pause'} resource management?`, bodyContent: , account: resourceSummary.locations.account, diff --git a/app/scripts/modules/core/src/pipeline/config/stages/executionWindows/ExecutionWindowActions.tsx b/app/scripts/modules/core/src/pipeline/config/stages/executionWindows/ExecutionWindowActions.tsx index 597b9f83f04..a12a997ce2e 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/executionWindows/ExecutionWindowActions.tsx +++ b/app/scripts/modules/core/src/pipeline/config/stages/executionWindows/ExecutionWindowActions.tsx @@ -3,6 +3,7 @@ import { get } from 'lodash'; import { IExecution, IExecutionStage } from 'core/domain'; import { Application } from 'core/application/application.model'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { ReactInjector } from 'core/reactShims'; import { timePickerTime } from 'core/utils/timeFormatters'; import { SystemTimezone } from 'core/utils/SystemTimezone'; @@ -45,7 +46,7 @@ export class ExecutionWindowActions extends React.Component< } private finishWaiting = (e: React.MouseEvent): void => { - const { confirmationModalService, executionService } = ReactInjector; + const { executionService } = ReactInjector; (e.target as HTMLElement).blur(); // forces closing of the popover when the modal opens const { application, execution, stage } = this.props; @@ -55,7 +56,7 @@ export class ExecutionWindowActions extends React.Component< }; const data = { skipRemainingWait: true }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really skip execution window?', buttonText: 'Skip', body: stage.context.skipWindowText || `

${DEFAULT_SKIP_WINDOW_TEXT}

`, diff --git a/app/scripts/modules/core/src/pipeline/config/stages/stage.module.js b/app/scripts/modules/core/src/pipeline/config/stages/stage.module.js index 0abf7f5bd2a..0fc6e245e7c 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/stage.module.js +++ b/app/scripts/modules/core/src/pipeline/config/stages/stage.module.js @@ -9,7 +9,7 @@ import { AccountService } from 'core/account/AccountService'; import { API } from 'core/api'; import { BASE_EXECUTION_DETAILS_CTRL } from './common/baseExecutionDetails.controller'; import { SETTINGS } from 'core/config'; -import { CONFIRMATION_MODAL_SERVICE } from 'core/confirmationModal/confirmationModal.service'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { STAGE_NAME } from './StageName'; import { PipelineConfigService } from 'core/pipeline/config/services/PipelineConfigService'; import { Registry } from 'core/registry'; @@ -33,7 +33,6 @@ module(CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE, [ OVERRRIDE_FAILURE, CORE_PIPELINE_CONFIG_STAGES_OPTIONALSTAGE_OPTIONALSTAGE_DIRECTIVE, CORE_PIPELINE_CONFIG_STAGES_FAILONFAILEDEXPRESSIONS_FAILONFAILEDEXPRESSIONS_DIRECTIVE, - CONFIRMATION_MODAL_SERVICE, CORE_PIPELINE_CONFIG_STAGES_COMMON_STAGECONFIGFIELD_STAGECONFIGFIELD_DIRECTIVE, ]) .directive('pipelineConfigStage', function() { @@ -320,8 +319,7 @@ module(CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE, [ .controller('RestartStageCtrl', [ '$scope', '$stateParams', - 'confirmationModalService', - function($scope, $stateParams, confirmationModalService) { + function($scope, $stateParams) { const restartStage = function() { return API.one('pipelines') .one($stateParams.executionId) @@ -340,7 +338,7 @@ module(CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE, [ body = '

This pipeline is currently running - restarting this stage will result in multiple concurrently running pipelines.

'; } - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really restart ' + $scope.stage.name + '?', buttonText: 'Restart ' + $scope.stage.name, body: body, diff --git a/app/scripts/modules/core/src/pipeline/config/stages/wait/SkipWait.tsx b/app/scripts/modules/core/src/pipeline/config/stages/wait/SkipWait.tsx index 19c9fad6fd2..955ff0c9fc0 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/wait/SkipWait.tsx +++ b/app/scripts/modules/core/src/pipeline/config/stages/wait/SkipWait.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { IExecution, IExecutionStage } from 'core/domain'; import { Application } from 'core/application/application.model'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { ReactInjector } from 'core/reactShims'; import { duration } from 'core/utils/timeFormatters'; import { OrchestratedItemRunningTime } from 'core/pipeline/executions/execution/OrchestratedItemRunningTime'; @@ -33,7 +34,7 @@ export class SkipWait extends React.Component { }; private skipRemainingWait = (e: React.MouseEvent): void => { - const { confirmationModalService, executionService } = ReactInjector; + const { executionService } = ReactInjector; (e.target as HTMLElement).blur(); // forces closing of the popover when the modal opens const { stage, application } = this.props; const matcher = (execution: IExecution) => { @@ -42,7 +43,7 @@ export class SkipWait extends React.Component { }; const data = { skipRemainingWait: true }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really skip wait?', buttonText: 'Skip', body: stage.context.skipWaitText || DEFAULT_SKIP_WAIT_TEXT, diff --git a/app/scripts/modules/core/src/pipeline/config/stages/waitForCondition/SkipConditionWait.tsx b/app/scripts/modules/core/src/pipeline/config/stages/waitForCondition/SkipConditionWait.tsx index 9a77eb0a067..20d933269c1 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/waitForCondition/SkipConditionWait.tsx +++ b/app/scripts/modules/core/src/pipeline/config/stages/waitForCondition/SkipConditionWait.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { IExecution, IExecutionStage } from 'core/domain'; import { Application } from 'core/application/application.model'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { ReactInjector } from 'core/reactShims'; import { duration } from 'core/utils/timeFormatters'; @@ -19,7 +20,7 @@ const skipRemainingWait = ( execution: IExecution, application: Application, ): void => { - const { confirmationModalService, executionService } = ReactInjector; + const { executionService } = ReactInjector; (event.target as HTMLElement).blur(); // forces closing of the popover when the modal opens const matcher = ({ stages }: IExecution) => { const match = stages.find(test => test.id === stage.id); @@ -27,7 +28,7 @@ const skipRemainingWait = ( }; const data = { status: 'SKIPPED' }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really skip wait?', buttonText: 'Skip', body: stage.context.skipWaitText || DEFAULT_SKIP_WAIT_TEXT, diff --git a/app/scripts/modules/core/src/pipeline/details/stageSummary.component.ts b/app/scripts/modules/core/src/pipeline/details/stageSummary.component.ts index dbb08298772..c5b4069ec48 100644 --- a/app/scripts/modules/core/src/pipeline/details/stageSummary.component.ts +++ b/app/scripts/modules/core/src/pipeline/details/stageSummary.component.ts @@ -18,12 +18,11 @@ export class StageSummaryController implements IController { private parser: Parser = new Parser(); private renderer: HtmlRenderer = new HtmlRenderer(); - public static $inject = ['$scope', '$stateParams', '$state', 'confirmationModalService', 'executionService']; + public static $inject = ['$scope', '$stateParams', '$state', 'executionService']; constructor( private $scope: IScope, private $stateParams: StateParams, private $state: StateService, - private confirmationModalService: ConfirmationModalService, private executionService: ExecutionService, ) {} @@ -104,7 +103,7 @@ export class StageSummaryController implements IController { public openManualSkipStageModal(): void { const topLevelStage = this.getTopLevelStage(); - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really skip this stage?', buttonText: 'Skip', askForReason: true, diff --git a/app/scripts/modules/core/src/pipeline/executions/execution/Execution.tsx b/app/scripts/modules/core/src/pipeline/executions/execution/Execution.tsx index b05072d8fac..f5e893fd81d 100644 --- a/app/scripts/modules/core/src/pipeline/executions/execution/Execution.tsx +++ b/app/scripts/modules/core/src/pipeline/executions/execution/Execution.tsx @@ -7,6 +7,7 @@ import { Subscription } from 'rxjs'; import classNames from 'classnames'; import { Application } from 'core/application/application.model'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { StageExecutionDetails } from 'core/pipeline/details/StageExecutionDetails'; import { ExecutionStatus } from 'core/pipeline/status/ExecutionStatus'; import { ParametersAndArtifacts } from 'core/pipeline/status/ParametersAndArtifacts'; @@ -149,8 +150,8 @@ export class Execution extends React.PureComponentThis will permanently delete the execution history.

', @@ -180,8 +181,8 @@ export class Execution extends React.PureComponent executionService.resumeExecution(this.props.application, this.props.execution.id), diff --git a/app/scripts/modules/core/src/reactShims/react.injector.ts b/app/scripts/modules/core/src/reactShims/react.injector.ts index 9f3ad41365b..3b33b30eafa 100644 --- a/app/scripts/modules/core/src/reactShims/react.injector.ts +++ b/app/scripts/modules/core/src/reactShims/react.injector.ts @@ -5,7 +5,6 @@ import { StateParams, StateService, UIRouter } from '@uirouter/core'; import { CacheInitializerService } from '../cache/cacheInitializer.service'; import { ClusterService } from '../cluster/cluster.service'; -import { ConfirmationModalService } from '../confirmationModal/confirmationModal.service'; import { ExecutionDetailsSectionService } from 'core/pipeline/details/executionDetailsSection.service'; import { ExecutionService } from '../pipeline/service/execution.service'; import { ImageReader } from 'core/image/image.reader'; @@ -45,7 +44,6 @@ export class CoreReactInject extends ReactInject { public get $stateParams() { return this.$injector.get('$stateParams') as StateParams; } public get $uiRouter() { return this.$injector.get('$uiRouter') as UIRouter; } public get cacheInitializer() { return this.$injector.get('cacheInitializer') as CacheInitializerService; } - public get confirmationModalService() { return this.$injector.get('confirmationModalService') as ConfirmationModalService; } public get clusterService() { return this.$injector.get('clusterService') as ClusterService; } public get executionDetailsSectionService() { return this.$injector.get('executionDetailsSectionService') as ExecutionDetailsSectionService; } public get executionService() { return this.$injector.get('executionService') as ExecutionService; } diff --git a/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.js b/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.js index 49f3eeae6a3..3addb101cd0 100644 --- a/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.js +++ b/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.js @@ -3,7 +3,7 @@ import * as angular from 'angular'; import { PROVIDER_SERVICE_DELEGATE } from 'core/cloudProvider/providerService.delegate'; -import { CONFIRMATION_MODAL_SERVICE } from 'core/confirmationModal/confirmationModal.service'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { SERVER_GROUP_WRITER } from 'core/serverGroup/serverGroupWriter.service'; import { ClusterState } from 'core/state'; import { CORE_SERVERGROUP_DETAILS_MULTIPLESERVERGROUP_COMPONENT } from './multipleServerGroup.component'; @@ -16,18 +16,16 @@ angular .module(CORE_SERVERGROUP_DETAILS_MULTIPLESERVERGROUPS_CONTROLLER, [ UIROUTER_ANGULARJS, SERVER_GROUP_WRITER, - CONFIRMATION_MODAL_SERVICE, PROVIDER_SERVICE_DELEGATE, CORE_SERVERGROUP_DETAILS_MULTIPLESERVERGROUP_COMPONENT, ]) .controller('MultipleServerGroupsCtrl', [ '$scope', '$state', - 'confirmationModalService', 'serverGroupWriter', 'providerServiceDelegate', 'app', - function($scope, $state, confirmationModalService, serverGroupWriter, providerServiceDelegate, app) { + function($scope, $state, serverGroupWriter, providerServiceDelegate, app) { this.serverGroups = []; /** @@ -66,7 +64,7 @@ angular }; }); - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really ' + verbs.simplePresent.toLowerCase() + ' ' + descriptor + '?', buttonText: verbs.simplePresent + ' ' + descriptor, verificationLabel: diff --git a/app/scripts/modules/core/src/snapshot/diff/snapshotDiff.modal.controller.js b/app/scripts/modules/core/src/snapshot/diff/snapshotDiff.modal.controller.js index e2d22f3dfe2..5351b0d4b8a 100644 --- a/app/scripts/modules/core/src/snapshot/diff/snapshotDiff.modal.controller.js +++ b/app/scripts/modules/core/src/snapshot/diff/snapshotDiff.modal.controller.js @@ -3,7 +3,7 @@ import { module } from 'angular'; import _ from 'lodash'; -import { CONFIRMATION_MODAL_SERVICE } from 'core/confirmationModal/confirmationModal.service'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { DIFF_SUMMARY_COMPONENT } from 'core/pipeline/config/actions/history/diffSummary.component'; import { DIFF_VIEW_COMPONENT } from 'core/pipeline/config/actions/history/diffView.component'; import { JsonUtils } from 'core/utils/json/JsonUtils'; @@ -14,118 +14,116 @@ import './snapshotDiff.modal.less'; export const CORE_SNAPSHOT_DIFF_SNAPSHOTDIFF_MODAL_CONTROLLER = 'spinnaker.deck.core.snapshot.diff.modal.controller'; export const name = CORE_SNAPSHOT_DIFF_SNAPSHOTDIFF_MODAL_CONTROLLER; // for backwards compatibility -module(CORE_SNAPSHOT_DIFF_SNAPSHOTDIFF_MODAL_CONTROLLER, [ - CONFIRMATION_MODAL_SERVICE, - DIFF_SUMMARY_COMPONENT, - DIFF_VIEW_COMPONENT, -]).controller('SnapshotDiffModalCtrl', [ - 'availableAccounts', - 'application', - '$filter', - '$uibModalInstance', - 'confirmationModalService', - function(availableAccounts, application, $filter, $uibModalInstance, confirmationModalService) { - this.availableAccounts = availableAccounts; - this.selectedAccount = _.head(availableAccounts); - this.compareOptions = ['most recent', 'previous version']; - this.compareTo = _.last(this.compareOptions); - this.findLeftMap = { - 'most recent': () => _.head(this.snapshots).contents, - 'previous version': (right, version) => { - let left = right; - if (version < this.snapshots.length - 1) { - left = this.snapshots[version + 1].contents; - } - return left; - }, - }; - - const resetView = () => { - this.state = { - loading: true, - error: false, +module(CORE_SNAPSHOT_DIFF_SNAPSHOTDIFF_MODAL_CONTROLLER, [DIFF_SUMMARY_COMPONENT, DIFF_VIEW_COMPONENT]).controller( + 'SnapshotDiffModalCtrl', + [ + 'availableAccounts', + 'application', + '$filter', + '$uibModalInstance', + function(availableAccounts, application, $filter, $uibModalInstance) { + this.availableAccounts = availableAccounts; + this.selectedAccount = _.head(availableAccounts); + this.compareOptions = ['most recent', 'previous version']; + this.compareTo = _.last(this.compareOptions); + this.findLeftMap = { + 'most recent': () => _.head(this.snapshots).contents, + 'previous version': (right, version) => { + let left = right; + if (version < this.snapshots.length - 1) { + left = this.snapshots[version + 1].contents; + } + return left; + }, }; - this.diff = JsonUtils.diff([], []); - this.snapshots = []; - this.version = 0; - }; - - const formatSnapshots = snapshots => { - const formatted = snapshots - .sort((a, b) => b.timestamp - a.timestamp) - .map((s, index) => { - return { - formattedTimestamp: $filter('timestamp')(s.timestamp), - timestamp: s.timestamp, - contents: JSON.stringify(s.infrastructure, null, 2), - json: s.infrastructure, - index: index, - }; - }); - _.head(formatted).formattedTimestamp += ' (most recent)'; - return formatted; - }; - - const loadSuccess = snapshots => { - this.state.loading = false; - if (!snapshots.length) { - return; - } - - this.snapshots = formatSnapshots(snapshots); - this.updateDiff(); - }; - - const loadError = () => { - this.state.loading = false; - this.state.error = true; - }; - - this.getSnapshotHistoryForAccount = account => { - resetView(); - if (account) { - SnapshotReader.getSnapshotHistory(application.name, account).then(loadSuccess, loadError); - } else { - loadSuccess([]); - } - }; - - this.restoreSnapshot = () => { - const submitMethod = () => { - return SnapshotWriter.restoreSnapshot( - application, - this.selectedAccount, - this.snapshots[this.version].timestamp, - ); + const resetView = () => { + this.state = { + loading: true, + error: false, + }; + this.diff = JsonUtils.diff([], []); + this.snapshots = []; + this.version = 0; }; - const taskMonitor = { - application: application, - title: 'Restoring snapshot of ' + application.name, + const formatSnapshots = snapshots => { + const formatted = snapshots + .sort((a, b) => b.timestamp - a.timestamp) + .map((s, index) => { + return { + formattedTimestamp: $filter('timestamp')(s.timestamp), + timestamp: s.timestamp, + contents: JSON.stringify(s.infrastructure, null, 2), + json: s.infrastructure, + index: index, + }; + }); + + _.head(formatted).formattedTimestamp += ' (most recent)'; + return formatted; }; - confirmationModalService.confirm({ - header: `Are you sure you want to restore snapshot of: ${application.name}?`, - buttonText: 'Restore snapshot', - body: '

This will change your infrastructure to the state specified in the snapshot selected

', - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; - - this.updateDiff = () => { - if (!this.snapshots.length) { + const loadSuccess = snapshots => { + this.state.loading = false; + if (!snapshots.length) { + return; + } + + this.snapshots = formatSnapshots(snapshots); + this.updateDiff(); + }; + + const loadError = () => { + this.state.loading = false; + this.state.error = true; + }; + + this.getSnapshotHistoryForAccount = account => { resetView(); - return; - } - - this.right = this.snapshots[this.version].contents; - this.left = this.findLeftMap[this.compareTo](this.right, this.version); - this.diff = JsonUtils.diff(this.left, this.right); - }; - - this.getSnapshotHistoryForAccount(this.selectedAccount); - this.close = $uibModalInstance.dismiss; - }, -]); + if (account) { + SnapshotReader.getSnapshotHistory(application.name, account).then(loadSuccess, loadError); + } else { + loadSuccess([]); + } + }; + + this.restoreSnapshot = () => { + const submitMethod = () => { + return SnapshotWriter.restoreSnapshot( + application, + this.selectedAccount, + this.snapshots[this.version].timestamp, + ); + }; + + const taskMonitor = { + application: application, + title: 'Restoring snapshot of ' + application.name, + }; + + ConfirmationModalService.confirm({ + header: `Are you sure you want to restore snapshot of: ${application.name}?`, + buttonText: 'Restore snapshot', + body: '

This will change your infrastructure to the state specified in the snapshot selected

', + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); + }; + + this.updateDiff = () => { + if (!this.snapshots.length) { + resetView(); + return; + } + + this.right = this.snapshots[this.version].contents; + this.left = this.findLeftMap[this.compareTo](this.right, this.version); + this.diff = JsonUtils.diff(this.left, this.right); + }; + + this.getSnapshotHistoryForAccount(this.selectedAccount); + this.close = $uibModalInstance.dismiss; + }, + ], +); diff --git a/app/scripts/modules/core/src/task/tasks.controller.js b/app/scripts/modules/core/src/task/tasks.controller.js index d9b7fd44b53..d166962e067 100644 --- a/app/scripts/modules/core/src/task/tasks.controller.js +++ b/app/scripts/modules/core/src/task/tasks.controller.js @@ -4,7 +4,7 @@ import { module } from 'angular'; import _ from 'lodash'; -import { CONFIRMATION_MODAL_SERVICE } from 'core/confirmationModal/confirmationModal.service'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { ViewStateCache } from 'core/cache'; import { DISPLAYABLE_TASKS_FILTER } from './displayableTasks.filter'; import { SETTINGS } from 'core/config/settings'; @@ -17,7 +17,6 @@ export const name = CORE_TASK_TASKS_CONTROLLER; // for backwards compatibility module(CORE_TASK_TASKS_CONTROLLER, [ UIROUTER_ANGULARJS, CORE_TASK_TASKPROGRESSBAR_DIRECTIVE, - CONFIRMATION_MODAL_SERVICE, DISPLAYABLE_TASKS_FILTER, ]).controller('TasksCtrl', [ '$scope', @@ -25,8 +24,7 @@ module(CORE_TASK_TASKS_CONTROLLER, [ '$stateParams', '$q', 'app', - 'confirmationModalService', - function($scope, $state, $stateParams, $q, app, confirmationModalService) { + function($scope, $state, $stateParams, $q, app) { if (app.notFound || app.hasError) { return; } @@ -163,7 +161,7 @@ module(CORE_TASK_TASKS_CONTROLLER, [ }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really cancel ' + task.name + '?', buttonText: 'Yes', cancelButtonText: 'No', diff --git a/app/scripts/modules/core/src/task/tasks.controller.spec.js b/app/scripts/modules/core/src/task/tasks.controller.spec.js index adfb339d6bd..7d9e7548362 100644 --- a/app/scripts/modules/core/src/task/tasks.controller.spec.js +++ b/app/scripts/modules/core/src/task/tasks.controller.spec.js @@ -1,4 +1,5 @@ import { ApplicationModelBuilder } from 'core/application/applicationModel.builder'; +import { ConfirmationModalService } from 'core/confirmationModal'; import { TaskWriter } from './task.write.service'; describe('Controller: tasks', function() { @@ -23,16 +24,10 @@ describe('Controller: tasks', function() { application.tasks.loaded = true; application.tasks.dataUpdated(); - let confirmationModalService = { - confirm: function(params) { - $q.when(null).then(params.submitMethod); - }, - }; scope = $rootScope.$new(); controller = $controller('TasksCtrl', { app: application, $scope: scope, - confirmationModalService: confirmationModalService, }); }; }), @@ -75,6 +70,7 @@ describe('Controller: tasks', function() { this.initializeController(tasks); spyOn(controller.application.tasks, 'refresh').and.callFake(() => taskReloadCalls++); + spyOn(ConfirmationModalService, 'confirm').and.callFake(params => $q.when().then(params.submitMethod)); scope.$digest(); expect(taskReloadCalls).toBe(0); diff --git a/app/scripts/modules/dcos/instance/details/details.controller.js b/app/scripts/modules/dcos/instance/details/details.controller.js index 8fbc5ba93fe..b8e5f0838db 100644 --- a/app/scripts/modules/dcos/instance/details/details.controller.js +++ b/app/scripts/modules/dcos/instance/details/details.controller.js @@ -4,7 +4,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, @@ -15,212 +15,198 @@ import { module } from 'angular'; export const DCOS_INSTANCE_DETAILS_DETAILS_CONTROLLER = 'spinnaker.dcos.instance.details.controller'; export const name = DCOS_INSTANCE_DETAILS_DETAILS_CONTROLLER; // for backwards compatibility -module(DCOS_INSTANCE_DETAILS_DETAILS_CONTROLLER, [INSTANCE_WRITE_SERVICE, CONFIRMATION_MODAL_SERVICE]).controller( - 'dcosInstanceDetailsController', - [ - '$scope', - '$state', - '$uibModal', - 'instanceWriter', - 'confirmationModalService', - 'instance', - 'app', - 'dcosProxyUiService', - '$q', - function( - $scope, - $state, - $uibModal, - instanceWriter, - confirmationModalService, - instance, - app, - dcosProxyUiService, - $q, - ) { - // needed for standalone instances - $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('dcos', 'instance.detailsTemplateUrl'); - - $scope.state = { - loading: true, - standalone: app.isStandalone, - }; - - this.uiLink = function uiLink() { - return dcosProxyUiService.buildLink( - $scope.instance.clusterUrl, - $scope.instance.account, - $scope.instance.region, - $scope.instance.serverGroupName, - $scope.instance.name, - ); - }; - - this.showJson = function showJson() { - $scope.userDataModalTitle = 'Task JSON'; - $scope.userData = $scope.instance.json; - $uibModal.open({ - templateUrl: ServerGroupTemplates.userData, - scope: $scope, - }); - }; - - function retrieveInstance() { - const extraData = {}; - let instanceSummary, loadBalancers, account, region; - app.serverGroups.data.some(function(serverGroup) { - return serverGroup.instances.some(function(possibleInstance) { - if (possibleInstance.id === instance.instanceId) { - instanceSummary = possibleInstance; - loadBalancers = serverGroup.loadBalancers; - account = serverGroup.account; - region = serverGroup.region; - extraData.serverGroup = serverGroup.name; - return true; - } - }); +module(DCOS_INSTANCE_DETAILS_DETAILS_CONTROLLER, [INSTANCE_WRITE_SERVICE]).controller('dcosInstanceDetailsController', [ + '$scope', + '$state', + '$uibModal', + 'instanceWriter', + 'instance', + 'app', + 'dcosProxyUiService', + '$q', + function($scope, $state, $uibModal, instanceWriter, instance, app, dcosProxyUiService, $q) { + // needed for standalone instances + $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('dcos', 'instance.detailsTemplateUrl'); + + $scope.state = { + loading: true, + standalone: app.isStandalone, + }; + + this.uiLink = function uiLink() { + return dcosProxyUiService.buildLink( + $scope.instance.clusterUrl, + $scope.instance.account, + $scope.instance.region, + $scope.instance.serverGroupName, + $scope.instance.name, + ); + }; + + this.showJson = function showJson() { + $scope.userDataModalTitle = 'Task JSON'; + $scope.userData = $scope.instance.json; + $uibModal.open({ + templateUrl: ServerGroupTemplates.userData, + scope: $scope, + }); + }; + + function retrieveInstance() { + const extraData = {}; + let instanceSummary, loadBalancers, account, region; + app.serverGroups.data.some(function(serverGroup) { + return serverGroup.instances.some(function(possibleInstance) { + if (possibleInstance.id === instance.instanceId) { + instanceSummary = possibleInstance; + loadBalancers = serverGroup.loadBalancers; + account = serverGroup.account; + region = serverGroup.region; + extraData.serverGroup = serverGroup.name; + return true; + } }); + }); - if (instanceSummary && account && region) { - extraData.account = account; - extraData.region = region; - RecentHistoryService.addExtraDataToLatest('instances', extraData); - return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { - $scope.state.loading = false; - $scope.instance = _.defaults(details, instanceSummary); - $scope.instance.account = account; - $scope.instance.serverGroupName = extraData.serverGroup; - $scope.instance.region = region; - $scope.instance.loadBalancers = loadBalancers; - }, autoClose); - } + if (instanceSummary && account && region) { + extraData.account = account; + extraData.region = region; + RecentHistoryService.addExtraDataToLatest('instances', extraData); + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { + $scope.state.loading = false; + $scope.instance = _.defaults(details, instanceSummary); + $scope.instance.account = account; + $scope.instance.serverGroupName = extraData.serverGroup; + $scope.instance.region = region; + $scope.instance.loadBalancers = loadBalancers; + }, autoClose); + } - if (!instanceSummary) { - autoClose(); - } - return $q.when(null); + if (!instanceSummary) { + autoClose(); } + return $q.when(null); + } - function autoClose() { - if ($scope.$$destroyed) { - return; - } - $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' }); + function autoClose() { + if ($scope.$$destroyed) { + return; } + $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' }); + } + + this.terminateInstance = function terminateInstance() { + const instance = $scope.instance; + + const taskMonitor = { + application: app, + title: 'Terminating ' + instance.instanceId, + onTaskComplete: function() { + if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) { + $state.go('^'); + } + }, + }; - this.terminateInstance = function terminateInstance() { - const instance = $scope.instance; + const submitMethod = function() { + const params = { cloudProvider: 'dcos' }; - const taskMonitor = { - application: app, - title: 'Terminating ' + instance.instanceId, - onTaskComplete: function() { - if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) { - $state.go('^'); - } - }, - }; + if (instance.serverGroup) { + params.managedInstanceGroupName = instance.serverGroup; + } - const submitMethod = function() { - const params = { cloudProvider: 'dcos' }; + params.namespace = instance.namespace; + instance.placement = {}; - if (instance.serverGroup) { - params.managedInstanceGroupName = instance.serverGroup; - } + return instanceWriter.terminateInstance(instance, app, params); + }; - params.namespace = instance.namespace; - instance.placement = {}; + ConfirmationModalService.confirm({ + header: 'Really terminate ' + instance.instanceId + '?', + buttonText: 'Terminate ' + instance.instanceId, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); + }; - return instanceWriter.terminateInstance(instance, app, params); - }; + this.registerInstanceWithLoadBalancer = function registerInstanceWithLoadBalancer() { + const instance = $scope.instance; + const loadBalancerNames = instance.loadBalancers.join(' and '); - confirmationModalService.confirm({ - header: 'Really terminate ' + instance.instanceId + '?', - buttonText: 'Terminate ' + instance.instanceId, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); + const taskMonitor = { + application: app, + title: 'Registering ' + instance.name + ' with ' + loadBalancerNames, }; - this.registerInstanceWithLoadBalancer = function registerInstanceWithLoadBalancer() { - const instance = $scope.instance; - const loadBalancerNames = instance.loadBalancers.join(' and '); - - const taskMonitor = { - application: app, - title: 'Registering ' + instance.name + ' with ' + loadBalancerNames, - }; - - const submitMethod = function() { - return instanceWriter.registerInstanceWithLoadBalancer(instance, app, { - interestingHealthProviderNames: ['Dcos'], - }); - }; - - confirmationModalService.confirm({ - header: 'Really register ' + instance.name + ' with ' + loadBalancerNames + '?', - buttonText: 'Register ' + instance.name, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, + const submitMethod = function() { + return instanceWriter.registerInstanceWithLoadBalancer(instance, app, { + interestingHealthProviderNames: ['Dcos'], }); }; - this.deregisterInstanceFromLoadBalancer = function deregisterInstanceFromLoadBalancer() { - const instance = $scope.instance; - const loadBalancerNames = instance.loadBalancers.join(' and '); - - const taskMonitor = { - application: app, - title: 'Deregistering ' + instance.name + ' from ' + loadBalancerNames, - }; - - const submitMethod = function() { - return instanceWriter.deregisterInstanceFromLoadBalancer(instance, app, { - interestingHealthProviderNames: ['Dcos'], - }); - }; - - confirmationModalService.confirm({ - header: 'Really deregister ' + instance.name + ' from ' + loadBalancerNames + '?', - buttonText: 'Deregister ' + instance.name, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; + ConfirmationModalService.confirm({ + header: 'Really register ' + instance.name + ' with ' + loadBalancerNames + '?', + buttonText: 'Register ' + instance.name, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); + }; - this.canRegisterWithLoadBalancer = function() { - return false; - }; + this.deregisterInstanceFromLoadBalancer = function deregisterInstanceFromLoadBalancer() { + const instance = $scope.instance; + const loadBalancerNames = instance.loadBalancers.join(' and '); - this.canDeregisterFromLoadBalancer = function() { - return false; + const taskMonitor = { + application: app, + title: 'Deregistering ' + instance.name + ' from ' + loadBalancerNames, }; - this.hasHealthState = function hasHealthState(healthProviderType, state) { - const instance = $scope.instance; - return instance.health.some(function(health) { - return health.type === healthProviderType && health.state === state; + const submitMethod = function() { + return instanceWriter.deregisterInstanceFromLoadBalancer(instance, app, { + interestingHealthProviderNames: ['Dcos'], }); }; - const initialize = app.isStandalone - ? retrieveInstance() - : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance); - - initialize.then(() => { - // Two things to look out for here: - // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there - // is no point in subscribing to the refresh - // 2. If this is a standalone instance, there is no application that will refresh - if (!$scope.$$destroyed && !app.isStandalone) { - app.serverGroups.onRefresh($scope, retrieveInstance); - } + ConfirmationModalService.confirm({ + header: 'Really deregister ' + instance.name + ' from ' + loadBalancerNames + '?', + buttonText: 'Deregister ' + instance.name, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, }); + }; + + this.canRegisterWithLoadBalancer = function() { + return false; + }; + + this.canDeregisterFromLoadBalancer = function() { + return false; + }; + + this.hasHealthState = function hasHealthState(healthProviderType, state) { + const instance = $scope.instance; + return instance.health.some(function(health) { + return health.type === healthProviderType && health.state === state; + }); + }; + + const initialize = app.isStandalone + ? retrieveInstance() + : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance); + + initialize.then(() => { + // Two things to look out for here: + // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there + // is no point in subscribing to the refresh + // 2. If this is a standalone instance, there is no application that will refresh + if (!$scope.$$destroyed && !app.isStandalone) { + app.serverGroups.onRefresh($scope, retrieveInstance); + } + }); - $scope.account = instance.account; - }, - ], -); + $scope.account = instance.account; + }, +]); diff --git a/app/scripts/modules/dcos/loadBalancer/details/details.controller.js b/app/scripts/modules/dcos/loadBalancer/details/details.controller.js index ff59d89e54e..b0f8247e405 100644 --- a/app/scripts/modules/dcos/loadBalancer/details/details.controller.js +++ b/app/scripts/modules/dcos/loadBalancer/details/details.controller.js @@ -1,121 +1,118 @@ 'use strict'; -import { CONFIRMATION_MODAL_SERVICE, LoadBalancerWriter, ServerGroupTemplates } from '@spinnaker/core'; +import { ConfirmationModalService, LoadBalancerWriter, ServerGroupTemplates } from '@spinnaker/core'; import * as angular from 'angular'; export const DCOS_LOADBALANCER_DETAILS_DETAILS_CONTROLLER = 'spinnaker.dcos.loadBalancer.details.controller'; export const name = DCOS_LOADBALANCER_DETAILS_DETAILS_CONTROLLER; // for backwards compatibility -angular - .module(DCOS_LOADBALANCER_DETAILS_DETAILS_CONTROLLER, [CONFIRMATION_MODAL_SERVICE]) - .controller('dcosLoadBalancerDetailsController', [ - '$scope', - '$state', - '$uibModal', - 'loadBalancer', - 'app', - 'confirmationModalService', - 'dcosProxyUiService', - '$q', - function($scope, $state, $uibModal, loadBalancer, app, confirmationModalService, dcosProxyUiService, $q) { - const application = app; - - $scope.state = { - loading: true, - }; +angular.module(DCOS_LOADBALANCER_DETAILS_DETAILS_CONTROLLER, []).controller('dcosLoadBalancerDetailsController', [ + '$scope', + '$state', + '$uibModal', + 'loadBalancer', + 'app', + 'dcosProxyUiService', + '$q', + function($scope, $state, $uibModal, loadBalancer, app, dcosProxyUiService, $q) { + const application = app; + + $scope.state = { + loading: true, + }; + + function extractLoadBalancer() { + $scope.loadBalancer = application.loadBalancers.data.find(function(test) { + return test.name === loadBalancer.name && test.account === loadBalancer.accountId; + }); - function extractLoadBalancer() { - $scope.loadBalancer = application.loadBalancers.data.find(function(test) { - return test.name === loadBalancer.name && test.account === loadBalancer.accountId; - }); + if ($scope.loadBalancer) { + $scope.state.loading = false; + } else { + autoClose(); + } - if ($scope.loadBalancer) { - $scope.state.loading = false; - } else { - autoClose(); - } + return $q.when(null); + } + + this.uiLink = function uiLink() { + return dcosProxyUiService.buildLoadBalancerLink( + $scope.loadBalancer.clusterUrl, + $scope.loadBalancer.account, + $scope.loadBalancer.name, + ); + }; + + this.showJson = function showJson() { + $scope.userDataModalTitle = 'Application JSON'; + $scope.userData = $scope.loadBalancer.json; + $uibModal.open({ + templateUrl: ServerGroupTemplates.userData, + scope: $scope, + }); + }; - return $q.when(null); + function autoClose() { + if ($scope.$$destroyed) { + return; + } + $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' }); + } + + extractLoadBalancer().then(() => { + // If the user navigates away from the view before the initial extractLoadBalancer call completes, + // do not bother subscribing to the refresh + if (!$scope.$$destroyed) { + app.loadBalancers.onRefresh($scope, extractLoadBalancer); } + }); + + this.editLoadBalancer = function editLoadBalancer() { + $uibModal.open({ + templateUrl: require('../configure/wizard/editWizard.html'), + controller: 'dcosUpsertLoadBalancerController as ctrl', + size: 'lg', + resolve: { + application: function() { + return application; + }, + loadBalancer: function() { + return angular.copy($scope.loadBalancer); + }, + isNew: function() { + return false; + }, + }, + }); + }; - this.uiLink = function uiLink() { - return dcosProxyUiService.buildLoadBalancerLink( - $scope.loadBalancer.clusterUrl, - $scope.loadBalancer.account, - $scope.loadBalancer.name, - ); + this.deleteLoadBalancer = function deleteLoadBalancer() { + if ($scope.loadBalancer.instances && $scope.loadBalancer.instances.length) { + return; + } + + const taskMonitor = { + application: application, + title: 'Deleting ' + loadBalancer.name, }; - this.showJson = function showJson() { - $scope.userDataModalTitle = 'Application JSON'; - $scope.userData = $scope.loadBalancer.json; - $uibModal.open({ - templateUrl: ServerGroupTemplates.userData, - scope: $scope, - }); + const command = { + cloudProvider: 'dcos', + loadBalancerName: $scope.loadBalancer.name, + dcosCluster: $scope.loadBalancer.dcosCluster, + region: $scope.loadBalancer.region, + credentials: $scope.loadBalancer.account, }; - function autoClose() { - if ($scope.$$destroyed) { - return; - } - $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' }); - } + const submitMethod = () => LoadBalancerWriter.deleteLoadBalancer(command, application); - extractLoadBalancer().then(() => { - // If the user navigates away from the view before the initial extractLoadBalancer call completes, - // do not bother subscribing to the refresh - if (!$scope.$$destroyed) { - app.loadBalancers.onRefresh($scope, extractLoadBalancer); - } + ConfirmationModalService.confirm({ + header: 'Really delete ' + loadBalancer.name + '?', + buttonText: 'Delete ' + loadBalancer.name, + account: loadBalancer.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, }); - - this.editLoadBalancer = function editLoadBalancer() { - $uibModal.open({ - templateUrl: require('../configure/wizard/editWizard.html'), - controller: 'dcosUpsertLoadBalancerController as ctrl', - size: 'lg', - resolve: { - application: function() { - return application; - }, - loadBalancer: function() { - return angular.copy($scope.loadBalancer); - }, - isNew: function() { - return false; - }, - }, - }); - }; - - this.deleteLoadBalancer = function deleteLoadBalancer() { - if ($scope.loadBalancer.instances && $scope.loadBalancer.instances.length) { - return; - } - - const taskMonitor = { - application: application, - title: 'Deleting ' + loadBalancer.name, - }; - - const command = { - cloudProvider: 'dcos', - loadBalancerName: $scope.loadBalancer.name, - dcosCluster: $scope.loadBalancer.dcosCluster, - region: $scope.loadBalancer.region, - credentials: $scope.loadBalancer.account, - }; - - const submitMethod = () => LoadBalancerWriter.deleteLoadBalancer(command, application); - - confirmationModalService.confirm({ - header: 'Really delete ' + loadBalancer.name + '?', - buttonText: 'Delete ' + loadBalancer.name, - account: loadBalancer.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; - }, - ]); + }; + }, +]); diff --git a/app/scripts/modules/dcos/serverGroup/details/details.controller.js b/app/scripts/modules/dcos/serverGroup/details/details.controller.js index 3bbf1917cb2..31ef1a3916c 100644 --- a/app/scripts/modules/dcos/serverGroup/details/details.controller.js +++ b/app/scripts/modules/dcos/serverGroup/details/details.controller.js @@ -4,7 +4,7 @@ import * as angular from 'angular'; import _ from 'lodash'; import { - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, ServerGroupWarningMessageService, ServerGroupReader, SERVER_GROUP_WRITER, @@ -18,7 +18,6 @@ export const name = DCOS_SERVERGROUP_DETAILS_DETAILS_CONTROLLER; // for backward angular .module(DCOS_SERVERGROUP_DETAILS_DETAILS_CONTROLLER, [ DCOS_SERVERGROUP_CONFIGURE_CONFIGURE_DCOS_MODULE, - CONFIRMATION_MODAL_SERVICE, SERVER_GROUP_WRITER, DCOS_SERVERGROUP_PARAMSMIXIN, ]) @@ -31,7 +30,6 @@ angular 'serverGroupWriter', 'dcosServerGroupCommandBuilder', 'dcosServerGroupParamsMixin', - 'confirmationModalService', 'dcosProxyUiService', function( $scope, @@ -42,7 +40,6 @@ angular serverGroupWriter, dcosServerGroupCommandBuilder, dcosServerGroupParamsMixin, - confirmationModalService, dcosProxyUiService, ) { const application = app; @@ -184,7 +181,7 @@ angular ServerGroupWarningMessageService.addDestroyWarningMessage(app, serverGroup, confirmationModalParams); - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.disableServerGroup = function disableServerGroup() { @@ -211,7 +208,7 @@ angular askForReason: true, }; - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.resizeServerGroup = function resizeServerGroup() { diff --git a/app/scripts/modules/ecs/src/instance/details/instance.details.controller.js b/app/scripts/modules/ecs/src/instance/details/instance.details.controller.js index 1c83693af86..6b93ff38f37 100644 --- a/app/scripts/modules/ecs/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/ecs/src/instance/details/instance.details.controller.js @@ -6,7 +6,7 @@ import { getAllTargetGroups, applyHealthCheckInfoToTargetGroups } from '@spinnak import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, InstanceReader, RecentHistoryService, SETTINGS, @@ -16,155 +16,124 @@ import ANGULAR_UI_BOOTSTRAP from 'angular-ui-bootstrap'; export const ECS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER = 'spinnaker.ecs.instance.details.controller'; export const name = ECS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER; // for backwards compatibility -module(ECS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ - UIROUTER_ANGULARJS, - ANGULAR_UI_BOOTSTRAP, - CONFIRMATION_MODAL_SERVICE, -]).controller('ecsInstanceDetailsCtrl', [ - '$scope', - '$state', - '$uibModal', - 'confirmationModalService', - 'instanceWriter', - 'instance', - 'app', - 'moniker', - 'environment', - '$q', - 'overrides', - function( - $scope, - $state, - $uibModal, - confirmationModalService, - instanceWriter, - instance, - app, - moniker, - environment, - $q, - overrides, - ) { - // needed for standalone instances - $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('ecs', 'instance.detailsTemplateUrl'); - - $scope.state = { - loading: true, - standalone: app.isStandalone, - instancePort: _.get(app, 'attributes.instancePort') || SETTINGS.defaultInstancePort || 80, - }; - - $scope.application = app; - $scope.moniker = moniker; - $scope.environment = environment; - - const cloudProvider = 'ecs'; - const defaultRequestParams = { cloudProvider: cloudProvider }; - - function extractHealthMetrics(instance, latest) { - // do not backfill on standalone instances - if (app.isStandalone) { - instance.health = latest.health; - } +module(ECS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [UIROUTER_ANGULARJS, ANGULAR_UI_BOOTSTRAP]).controller( + 'ecsInstanceDetailsCtrl', + [ + '$scope', + '$state', + '$uibModal', + 'instanceWriter', + 'instance', + 'app', + 'moniker', + 'environment', + '$q', + 'overrides', + function($scope, $state, $uibModal, instanceWriter, instance, app, moniker, environment, $q, overrides) { + // needed for standalone instances + $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('ecs', 'instance.detailsTemplateUrl'); + + $scope.state = { + loading: true, + standalone: app.isStandalone, + instancePort: _.get(app, 'attributes.instancePort') || SETTINGS.defaultInstancePort || 80, + }; - instance.health = instance.health || []; - const displayableMetrics = instance.health.filter(function(metric) { - return metric.type !== 'Ecs' || metric.state !== 'Unknown'; - }); + $scope.application = app; + $scope.moniker = moniker; + $scope.environment = environment; - // augment with target group healthcheck data - const targetGroups = getAllTargetGroups(app.loadBalancers.data); - applyHealthCheckInfoToTargetGroups(displayableMetrics, targetGroups); + const cloudProvider = 'ecs'; + const defaultRequestParams = { cloudProvider: cloudProvider }; - // backfill details where applicable - if (latest.health) { - displayableMetrics.forEach(function(metric) { - const detailsMatch = latest.health.filter(function(latestHealth) { - return latestHealth.type === metric.type; - }); - if (detailsMatch.length) { - _.defaults(metric, detailsMatch[0]); - } + function extractHealthMetrics(instance, latest) { + // do not backfill on standalone instances + if (app.isStandalone) { + instance.health = latest.health; + } + + instance.health = instance.health || []; + const displayableMetrics = instance.health.filter(function(metric) { + return metric.type !== 'Ecs' || metric.state !== 'Unknown'; }); - } - $scope.healthMetrics = displayableMetrics; - } - - function retrieveInstance() { - const extraData = {}; - let instanceSummary, loadBalancers, targetGroup, account, region, vpcId; - if (!app.serverGroups) { - // standalone instance - instanceSummary = {}; - loadBalancers = []; - targetGroup = []; - account = instance.account; - region = instance.region; - } else { - app.serverGroups.data.some(function(serverGroup) { - return serverGroup.instances.some(function(possibleInstance) { - if (possibleInstance.id === instance.instanceId) { - instanceSummary = possibleInstance; - loadBalancers = serverGroup.loadBalancers; - targetGroup = serverGroup.targetGroup; - account = serverGroup.account; - region = serverGroup.region; - vpcId = serverGroup.vpcId; - extraData.serverGroup = serverGroup.name; - extraData.vpcId = serverGroup.vpcId; - return true; + + // augment with target group healthcheck data + const targetGroups = getAllTargetGroups(app.loadBalancers.data); + applyHealthCheckInfoToTargetGroups(displayableMetrics, targetGroups); + + // backfill details where applicable + if (latest.health) { + displayableMetrics.forEach(function(metric) { + const detailsMatch = latest.health.filter(function(latestHealth) { + return latestHealth.type === metric.type; + }); + if (detailsMatch.length) { + _.defaults(metric, detailsMatch[0]); } }); - }); - if (!instanceSummary) { - // perhaps it is in a server group that is part of another app - app.loadBalancers.data.some(function(loadBalancer) { - return ( - loadBalancer.instances.some(function(possibleInstance) { - if (possibleInstance.id === instance.instanceId) { - instanceSummary = possibleInstance; - loadBalancers = [loadBalancer.name]; - account = loadBalancer.account; - region = loadBalancer.region; - vpcId = loadBalancer.vpcId; - return true; - } - }) || - loadBalancer.targetGroup.some(function(targetGroup) { - return targetGroup.instances.some(function(possibleInstance) { + } + $scope.healthMetrics = displayableMetrics; + } + + function retrieveInstance() { + const extraData = {}; + let instanceSummary, loadBalancers, targetGroup, account, region, vpcId; + if (!app.serverGroups) { + // standalone instance + instanceSummary = {}; + loadBalancers = []; + targetGroup = []; + account = instance.account; + region = instance.region; + } else { + app.serverGroups.data.some(function(serverGroup) { + return serverGroup.instances.some(function(possibleInstance) { + if (possibleInstance.id === instance.instanceId) { + instanceSummary = possibleInstance; + loadBalancers = serverGroup.loadBalancers; + targetGroup = serverGroup.targetGroup; + account = serverGroup.account; + region = serverGroup.region; + vpcId = serverGroup.vpcId; + extraData.serverGroup = serverGroup.name; + extraData.vpcId = serverGroup.vpcId; + return true; + } + }); + }); + if (!instanceSummary) { + // perhaps it is in a server group that is part of another app + app.loadBalancers.data.some(function(loadBalancer) { + return ( + loadBalancer.instances.some(function(possibleInstance) { if (possibleInstance.id === instance.instanceId) { instanceSummary = possibleInstance; - targetGroup = targetGroup.name; + loadBalancers = [loadBalancer.name]; account = loadBalancer.account; region = loadBalancer.region; vpcId = loadBalancer.vpcId; return true; } - }); - }) - ); - }); - if (!instanceSummary) { - // perhaps it is in a disabled server group via a load balancer - app.loadBalancers.data.some(function(loadBalancer) { - return ( - loadBalancer.serverGroups.some(function(serverGroup) { - if (!serverGroup.isDisabled) { - return false; - } - return serverGroup.instances.some(function(possibleInstance) { + }) || + loadBalancer.targetGroup.some(function(targetGroup) { + return targetGroup.instances.some(function(possibleInstance) { if (possibleInstance.id === instance.instanceId) { instanceSummary = possibleInstance; - loadBalancers = [loadBalancer.name]; + targetGroup = targetGroup.name; account = loadBalancer.account; region = loadBalancer.region; vpcId = loadBalancer.vpcId; return true; } }); - }) || - loadBalancer.targetGroup.some(function(targetGroup) { - targetGroup.serverGroups.some(function(serverGroup) { + }) + ); + }); + if (!instanceSummary) { + // perhaps it is in a disabled server group via a load balancer + app.loadBalancers.data.some(function(loadBalancer) { + return ( + loadBalancer.serverGroups.some(function(serverGroup) { if (!serverGroup.isDisabled) { return false; } @@ -178,192 +147,209 @@ module(ECS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return true; } }); - }); - }) - ); - }); + }) || + loadBalancer.targetGroup.some(function(targetGroup) { + targetGroup.serverGroups.some(function(serverGroup) { + if (!serverGroup.isDisabled) { + return false; + } + return serverGroup.instances.some(function(possibleInstance) { + if (possibleInstance.id === instance.instanceId) { + instanceSummary = possibleInstance; + loadBalancers = [loadBalancer.name]; + account = loadBalancer.account; + region = loadBalancer.region; + vpcId = loadBalancer.vpcId; + return true; + } + }); + }); + }) + ); + }); + } } } - } - if (instanceSummary && account && region) { - extraData.account = account; - extraData.region = region; - RecentHistoryService.addExtraDataToLatest('instances', extraData); - return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { - if ($scope.$$destroyed) { - return; - } - $scope.state.loading = false; - extractHealthMetrics(instanceSummary, details); - $scope.instance = _.defaults(details, instanceSummary); - $scope.instance.account = account; - $scope.instance.region = region; - $scope.instance.vpcId = vpcId; - $scope.instance.loadBalancers = loadBalancers; - $scope.instance.targetGroup = targetGroup; - if ($scope.instance.networkInterfaces) { - const permanentNetworkInterfaces = $scope.instance.networkInterfaces.filter( - f => f.attachment.deleteOnTermination === false, - ); - if (permanentNetworkInterfaces.length) { - $scope.instance.permanentIps = permanentNetworkInterfaces.map(f => f.privateIpAddress); + if (instanceSummary && account && region) { + extraData.account = account; + extraData.region = region; + RecentHistoryService.addExtraDataToLatest('instances', extraData); + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { + if ($scope.$$destroyed) { + return; } - } - $scope.baseIpAddress = details.publicDnsName || details.privateIpAddress; - if (overrides.instanceDetailsLoaded) { - overrides.instanceDetailsLoaded(); - } - }, autoClose); - } - - if (!instanceSummary) { - $scope.instanceIdNotFound = instance.instanceId; - $scope.state.loading = false; - } + $scope.state.loading = false; + extractHealthMetrics(instanceSummary, details); + $scope.instance = _.defaults(details, instanceSummary); + $scope.instance.account = account; + $scope.instance.region = region; + $scope.instance.vpcId = vpcId; + $scope.instance.loadBalancers = loadBalancers; + $scope.instance.targetGroup = targetGroup; + if ($scope.instance.networkInterfaces) { + const permanentNetworkInterfaces = $scope.instance.networkInterfaces.filter( + f => f.attachment.deleteOnTermination === false, + ); + if (permanentNetworkInterfaces.length) { + $scope.instance.permanentIps = permanentNetworkInterfaces.map(f => f.privateIpAddress); + } + } + $scope.baseIpAddress = details.publicDnsName || details.privateIpAddress; + if (overrides.instanceDetailsLoaded) { + overrides.instanceDetailsLoaded(); + } + }, autoClose); + } - return $q.when(null); - } + if (!instanceSummary) { + $scope.instanceIdNotFound = instance.instanceId; + $scope.state.loading = false; + } - function autoClose() { - if ($scope.$$destroyed) { - return; + return $q.when(null); } - if (app.isStandalone) { - $scope.state.loading = false; - $scope.instanceIdNotFound = instance.instanceId; - $scope.state.notFoundStandalone = true; - RecentHistoryService.removeLastItem('instances'); - } else { - $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' }); + + function autoClose() { + if ($scope.$$destroyed) { + return; + } + if (app.isStandalone) { + $scope.state.loading = false; + $scope.instanceIdNotFound = instance.instanceId; + $scope.state.notFoundStandalone = true; + RecentHistoryService.removeLastItem('instances'); + } else { + $state.go('^', { allowModalToStayOpen: true }, { location: 'replace' }); + } } - } - this.canRegisterWithDiscovery = function() { - const instance = $scope.instance; - const healthMetrics = instance.health || []; - const discoveryHealth = healthMetrics.filter(function(health) { - return health.type === 'Discovery'; - }); - return discoveryHealth.length ? discoveryHealth[0].state === 'OutOfService' : false; - }; - - this.terminateInstance = function terminateInstance() { - const instance = $scope.instance; - - const taskMonitor = { - application: app, - title: 'Terminating ' + instance.instanceId, - onTaskComplete: function() { - if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) { - $state.go('^'); - } - }, + this.canRegisterWithDiscovery = function() { + const instance = $scope.instance; + const healthMetrics = instance.health || []; + const discoveryHealth = healthMetrics.filter(function(health) { + return health.type === 'Discovery'; + }); + return discoveryHealth.length ? discoveryHealth[0].state === 'OutOfService' : false; }; - const submitMethod = function() { - return instanceWriter.terminateInstance(instance, app, defaultRequestParams); - }; + this.terminateInstance = function terminateInstance() { + const instance = $scope.instance; - confirmationModalService.confirm({ - header: 'Really terminate ' + instance.instanceId + '?', - buttonText: 'Terminate ' + instance.instanceId, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; + const taskMonitor = { + application: app, + title: 'Terminating ' + instance.instanceId, + onTaskComplete: function() { + if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) { + $state.go('^'); + } + }, + }; + + const submitMethod = function() { + return instanceWriter.terminateInstance(instance, app, defaultRequestParams); + }; + + ConfirmationModalService.confirm({ + header: 'Really terminate ' + instance.instanceId + '?', + buttonText: 'Terminate ' + instance.instanceId, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); + }; - this.terminateInstanceAndShrinkServerGroup = function terminateInstanceAndShrinkServerGroup() { - const instance = $scope.instance; + this.terminateInstanceAndShrinkServerGroup = function terminateInstanceAndShrinkServerGroup() { + const instance = $scope.instance; - const taskMonitor = { - application: app, - title: 'Terminating ' + instance.instanceId + ' and shrinking server group', - onTaskComplete: function() { - if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) { - $state.go('^'); - } - }, + const taskMonitor = { + application: app, + title: 'Terminating ' + instance.instanceId + ' and shrinking server group', + onTaskComplete: function() { + if ($state.includes('**.instanceDetails', { instanceId: instance.instanceId })) { + $state.go('^'); + } + }, + }; + + const submitMethod = function() { + return instanceWriter.terminateInstanceAndShrinkServerGroup(instance, app, defaultRequestParams); + }; + + ConfirmationModalService.confirm({ + header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?', + buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); }; - const submitMethod = function() { - return instanceWriter.terminateInstanceAndShrinkServerGroup(instance, app, defaultRequestParams); - }; + this.enableInstanceInDiscovery = function enableInstanceInDiscovery() { + const instance = $scope.instance; - confirmationModalService.confirm({ - header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?', - buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; + const taskMonitor = { + application: app, + title: 'Enabling ' + instance.instanceId + ' in discovery', + }; - this.enableInstanceInDiscovery = function enableInstanceInDiscovery() { - const instance = $scope.instance; + const submitMethod = function() { + return instanceWriter.enableInstanceInDiscovery(instance, app, defaultRequestParams); + }; - const taskMonitor = { - application: app, - title: 'Enabling ' + instance.instanceId + ' in discovery', + ConfirmationModalService.confirm({ + header: 'Really enable ' + instance.instanceId + ' in discovery?', + buttonText: 'Enable ' + instance.instanceId, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); }; - const submitMethod = function() { - return instanceWriter.enableInstanceInDiscovery(instance, app, defaultRequestParams); - }; + this.disableInstanceInDiscovery = function disableInstanceInDiscovery() { + const instance = $scope.instance; - confirmationModalService.confirm({ - header: 'Really enable ' + instance.instanceId + ' in discovery?', - buttonText: 'Enable ' + instance.instanceId, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; + const taskMonitor = { + application: app, + title: 'Disabling ' + instance.instanceId + ' in discovery', + }; - this.disableInstanceInDiscovery = function disableInstanceInDiscovery() { - const instance = $scope.instance; + const submitMethod = function() { + return instanceWriter.disableInstanceInDiscovery(instance, app, defaultRequestParams); + }; - const taskMonitor = { - application: app, - title: 'Disabling ' + instance.instanceId + ' in discovery', + ConfirmationModalService.confirm({ + header: 'Really disable ' + instance.instanceId + ' in discovery?', + buttonText: 'Disable ' + instance.instanceId, + account: instance.account, + taskMonitorConfig: taskMonitor, + submitMethod: submitMethod, + }); }; - const submitMethod = function() { - return instanceWriter.disableInstanceInDiscovery(instance, app, defaultRequestParams); + this.hasHealthState = function hasHealthState(healthProviderType, state) { + const instance = $scope.instance; + const healthMetrics = instance.health || []; + return healthMetrics.some(function(health) { + return health.type === healthProviderType && health.state === state; + }); }; - confirmationModalService.confirm({ - header: 'Really disable ' + instance.instanceId + ' in discovery?', - buttonText: 'Disable ' + instance.instanceId, - account: instance.account, - taskMonitorConfig: taskMonitor, - submitMethod: submitMethod, - }); - }; - - this.hasHealthState = function hasHealthState(healthProviderType, state) { - const instance = $scope.instance; - const healthMetrics = instance.health || []; - return healthMetrics.some(function(health) { - return health.type === healthProviderType && health.state === state; + const initialize = app.isStandalone + ? retrieveInstance() + : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance); + + initialize.then(() => { + // Two things to look out for here: + // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there + // is no point in subscribing to the refresh + // 2. If this is a standalone instance, there is no application that will refresh + if (!$scope.$$destroyed && !app.isStandalone) { + app.serverGroups.onRefresh($scope, retrieveInstance); + } }); - }; - - const initialize = app.isStandalone - ? retrieveInstance() - : $q.all([app.serverGroups.ready(), app.loadBalancers.ready()]).then(retrieveInstance); - - initialize.then(() => { - // Two things to look out for here: - // 1. If the retrieveInstance call completes *after* the user has navigated away from the view, there - // is no point in subscribing to the refresh - // 2. If this is a standalone instance, there is no application that will refresh - if (!$scope.$$destroyed && !app.isStandalone) { - app.serverGroups.onRefresh($scope, retrieveInstance); - } - }); - $scope.account = instance.account; - }, -]); + $scope.account = instance.account; + }, + ], +); diff --git a/app/scripts/modules/ecs/src/serverGroup/details/serverGroupDetails.ecs.controller.js b/app/scripts/modules/ecs/src/serverGroup/details/serverGroupDetails.ecs.controller.js index ccb58a16d81..f5458437900 100644 --- a/app/scripts/modules/ecs/src/serverGroup/details/serverGroupDetails.ecs.controller.js +++ b/app/scripts/modules/ecs/src/serverGroup/details/serverGroupDetails.ecs.controller.js @@ -2,13 +2,13 @@ import * as angular from 'angular'; import { chain, filter, find, has, isEmpty } from 'lodash'; -import { FirewallLabels } from '@spinnaker/core'; import { ECS_SERVER_GROUP_TRANSFORMER } from '../serverGroup.transformer'; import { AccountService, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, + FirewallLabels, OVERRIDE_REGISTRY, ServerGroupReader, SERVER_GROUP_WRITER, @@ -26,7 +26,6 @@ angular .module(ECS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_ECS_CONTROLLER, [ UIROUTER_ANGULARJS, ECS_SERVER_GROUP_TRANSFORMER, - CONFIRMATION_MODAL_SERVICE, OVERRIDE_REGISTRY, SERVER_GROUP_WRITER, ECS_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER_SERVICE, @@ -40,7 +39,6 @@ angular 'serverGroup', 'ecsServerGroupCommandBuilder', '$uibModal', - 'confirmationModalService', 'serverGroupWriter', 'ecsServerGroupTransformer', 'overrideRegistry', @@ -51,7 +49,6 @@ angular serverGroup, ecsServerGroupCommandBuilder, $uibModal, - confirmationModalService, serverGroupWriter, ecsServerGroupTransformer, overrideRegistry, @@ -224,7 +221,7 @@ angular confirmationModalParams.interestingHealthProviderNames = ['Ecs']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.disableServerGroup = () => { @@ -256,7 +253,7 @@ angular confirmationModalParams.interestingHealthProviderNames = ['Ecs']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.enableServerGroup = () => { @@ -286,7 +283,7 @@ angular confirmationModalParams.interestingHealthProviderNames = ['Ecs']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.rollbackServerGroup = () => { diff --git a/app/scripts/modules/google/src/instance/details/instance.details.controller.js b/app/scripts/modules/google/src/instance/details/instance.details.controller.js index b049ded200f..2579473a38f 100644 --- a/app/scripts/modules/google/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/google/src/instance/details/instance.details.controller.js @@ -5,7 +5,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, FirewallLabels, InstanceReader, INSTANCE_WRITE_SERVICE, @@ -24,14 +24,12 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ ANGULAR_UI_BOOTSTRAP, GOOGLE_COMMON_XPNNAMING_GCE_SERVICE, INSTANCE_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, GCE_HTTP_LOAD_BALANCER_UTILS, ]).controller('gceInstanceDetailsCtrl', [ '$scope', '$state', '$uibModal', 'instanceWriter', - 'confirmationModalService', 'instance', 'app', 'moniker', @@ -44,7 +42,6 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ $state, $uibModal, instanceWriter, - confirmationModalService, instance, app, moniker, @@ -350,7 +347,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.terminateInstance(instance, app, params); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + '?', buttonText: 'Terminate ' + instance.instanceId, account: instance.account, @@ -380,7 +377,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup + '?', buttonText: 'Terminate ' + instance.instanceId + ' and shrink ' + instance.serverGroup, account: instance.account, @@ -404,7 +401,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really reboot ' + instance.instanceId + '?', buttonText: 'Reboot ' + instance.instanceId, account: instance.account, @@ -426,7 +423,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.registerInstanceWithLoadBalancer(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really register ' + instance.instanceId + ' with ' + loadBalancerNames + '?', buttonText: 'Register ' + instance.instanceId, account: instance.account, @@ -448,7 +445,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.deregisterInstanceFromLoadBalancer(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really deregister ' + instance.instanceId + ' from ' + loadBalancerNames + '?', buttonText: 'Deregister ' + instance.instanceId, account: instance.account, @@ -469,7 +466,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.enableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really enable ' + instance.instanceId + ' in discovery?', buttonText: 'Enable ' + instance.instanceId, account: instance.account, @@ -490,7 +487,7 @@ module(GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.disableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really disable ' + instance.instanceId + ' in discovery?', buttonText: 'Disable ' + instance.instanceId, account: instance.account, diff --git a/app/scripts/modules/google/src/securityGroup/details/securityGroupDetail.controller.js b/app/scripts/modules/google/src/securityGroup/details/securityGroupDetail.controller.js index e76d9e482c4..9255699b74b 100644 --- a/app/scripts/modules/google/src/securityGroup/details/securityGroupDetail.controller.js +++ b/app/scripts/modules/google/src/securityGroup/details/securityGroupDetail.controller.js @@ -6,7 +6,7 @@ import _ from 'lodash'; import { AccountService, CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, FirewallLabels, SECURITY_GROUP_READER, SecurityGroupWriter, @@ -23,7 +23,6 @@ angular .module(GOOGLE_SECURITYGROUP_DETAILS_SECURITYGROUPDETAIL_CONTROLLER, [ UIROUTER_ANGULARJS, SECURITY_GROUP_READER, - CONFIRMATION_MODAL_SERVICE, GOOGLE_SECURITYGROUP_CLONE_CLONESECURITYGROUP_CONTROLLER, GCE_SECURITY_GROUP_HELP_TEXT_SERVICE, ]) @@ -32,7 +31,6 @@ angular '$state', 'resolvedSecurityGroup', 'app', - 'confirmationModalService', 'securityGroupReader', '$uibModal', 'gceSecurityGroupHelpTextService', @@ -41,7 +39,6 @@ angular $state, resolvedSecurityGroup, app, - confirmationModalService, securityGroupReader, $uibModal, gceSecurityGroupHelpTextService, @@ -242,7 +239,7 @@ angular }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + securityGroup.name + '?', buttonText: 'Delete ' + securityGroup.name, account: securityGroup.accountId, diff --git a/app/scripts/modules/google/src/serverGroup/details/autoHealingPolicy/autoHealingPolicy.component.ts b/app/scripts/modules/google/src/serverGroup/details/autoHealingPolicy/autoHealingPolicy.component.ts index 01cd017e518..62cfe79f493 100644 --- a/app/scripts/modules/google/src/serverGroup/details/autoHealingPolicy/autoHealingPolicy.component.ts +++ b/app/scripts/modules/google/src/serverGroup/details/autoHealingPolicy/autoHealingPolicy.component.ts @@ -9,12 +9,8 @@ class GceAutoHealingPolicyDetailsCtrl implements IController { public serverGroup: IGceServerGroup; public application: Application; - public static $inject = ['$uibModal', 'confirmationModalService', 'gceAutoscalingPolicyWriter']; - constructor( - private $uibModal: IModalService, - private confirmationModalService: ConfirmationModalService, - private gceAutoscalingPolicyWriter: any, - ) {} + public static $inject = ['$uibModal', 'gceAutoscalingPolicyWriter']; + constructor(private $uibModal: IModalService, private gceAutoscalingPolicyWriter: any) {} public editPolicy(): void { this.$uibModal.open({ @@ -35,7 +31,7 @@ class GceAutoHealingPolicyDetailsCtrl implements IController { title: `Deleting autohealing policy for ${this.serverGroup.name}`, }; - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete autohealer for ${this.serverGroup.name}?`, buttonText: 'Delete autohealer', account: this.serverGroup.account, diff --git a/app/scripts/modules/google/src/serverGroup/details/autoscalingPolicy/autoscalingPolicy.directive.js b/app/scripts/modules/google/src/serverGroup/details/autoscalingPolicy/autoscalingPolicy.directive.js index a069cf339ad..d22a0f41698 100644 --- a/app/scripts/modules/google/src/serverGroup/details/autoscalingPolicy/autoscalingPolicy.directive.js +++ b/app/scripts/modules/google/src/serverGroup/details/autoscalingPolicy/autoscalingPolicy.directive.js @@ -2,7 +2,7 @@ import { module } from 'angular'; -import { CONFIRMATION_MODAL_SERVICE, SETTINGS } from '@spinnaker/core'; +import { ConfirmationModalService, SETTINGS } from '@spinnaker/core'; import { GOOGLE_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_WRITE_SERVICE } from './../../../autoscalingPolicy/autoscalingPolicy.write.service'; import { GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_MODAL_UPSERTAUTOSCALINGPOLICY_MODAL_CONTROLLER } from './modal/upsertAutoscalingPolicy.modal.controller'; import ANGULAR_UI_BOOTSTRAP from 'angular-ui-bootstrap'; @@ -11,7 +11,6 @@ export const GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRE 'spinnaker.gce.instance.details.scalingPolicy.directive'; export const name = GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE; // for backwards compatibility module(GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE, [ - CONFIRMATION_MODAL_SERVICE, ANGULAR_UI_BOOTSTRAP, GOOGLE_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_WRITE_SERVICE, GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_MODAL_UPSERTAUTOSCALINGPOLICY_MODAL_CONTROLLER, @@ -25,8 +24,7 @@ module(GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE, controller: [ '$uibModal', 'gceAutoscalingPolicyWriter', - 'confirmationModalService', - function($uibModal, gceAutoscalingPolicyWriter, confirmationModalService) { + function($uibModal, gceAutoscalingPolicyWriter) { const policy = this.policy; policy.bases = []; @@ -117,7 +115,7 @@ module(GOOGLE_SERVERGROUP_DETAILS_AUTOSCALINGPOLICY_AUTOSCALINGPOLICY_DIRECTIVE, title: `Deleting autoscaler for ${this.serverGroup.name}`, }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete autoscaler for ${this.serverGroup.name}?`, buttonText: 'Delete autoscaler', account: this.serverGroup.account, diff --git a/app/scripts/modules/google/src/serverGroup/details/serverGroupDetails.gce.controller.js b/app/scripts/modules/google/src/serverGroup/details/serverGroupDetails.gce.controller.js index e77ea8aceb7..9bf8b488462 100644 --- a/app/scripts/modules/google/src/serverGroup/details/serverGroupDetails.gce.controller.js +++ b/app/scripts/modules/google/src/serverGroup/details/serverGroupDetails.gce.controller.js @@ -4,7 +4,7 @@ import * as angular from 'angular'; import _ from 'lodash'; import { - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, ClusterTargetBuilder, FirewallLabels, NetworkReader, @@ -32,7 +32,6 @@ angular .module(GOOGLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_GCE_CONTROLLER, [ UIROUTER_ANGULARJS, GOOGLE_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER_SERVICE, - CONFIRMATION_MODAL_SERVICE, SERVER_GROUP_WRITER, GOOGLE_COMMON_XPNNAMING_GCE_SERVICE, GOOGLE_SERVERGROUP_DETAILS_RESIZE_RESIZESERVERGROUP_CONTROLLER, @@ -49,7 +48,6 @@ angular 'serverGroup', 'gceServerGroupCommandBuilder', '$uibModal', - 'confirmationModalService', 'serverGroupWriter', 'gceXpnNamingService', function( @@ -61,7 +59,6 @@ angular serverGroup, gceServerGroupCommandBuilder, $uibModal, - confirmationModalService, serverGroupWriter, gceXpnNamingService, ) { @@ -363,7 +360,7 @@ angular confirmationModalParams.interestingHealthProviderNames = ['Google']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.disableServerGroup = () => { @@ -393,7 +390,7 @@ angular confirmationModalParams.interestingHealthProviderNames = ['Google']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.enableServerGroup = () => { @@ -421,7 +418,7 @@ angular confirmationModalParams.interestingHealthProviderNames = ['Google']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.rollbackServerGroup = () => { diff --git a/app/scripts/modules/google/src/serverGroup/details/stateful/MarkDiskStatefulButton.tsx b/app/scripts/modules/google/src/serverGroup/details/stateful/MarkDiskStatefulButton.tsx index 7b12e3c004f..a9b5e749ed6 100644 --- a/app/scripts/modules/google/src/serverGroup/details/stateful/MarkDiskStatefulButton.tsx +++ b/app/scripts/modules/google/src/serverGroup/details/stateful/MarkDiskStatefulButton.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { Application, ReactInjector } from '@spinnaker/core'; +import { Application, ConfirmationModalService } from '@spinnaker/core'; import { StatefulMIGService } from 'google/serverGroup/details/stateful/StatefulMIGService'; import { IGceServerGroup } from 'google/domain'; @@ -13,7 +13,7 @@ interface IMarkDiskStatefulButtonProps { export function MarkDiskStatefulButton({ application, deviceName, serverGroup }: IMarkDiskStatefulButtonProps) { function openConfirmationModal(): void { - ReactInjector.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ account: serverGroup.account, askForReason: true, buttonText: 'Mark as stateful', diff --git a/app/scripts/modules/kubernetes/src/v1/instance/details/details.controller.js b/app/scripts/modules/kubernetes/src/v1/instance/details/details.controller.js index 12404b16390..78642a014f2 100644 --- a/app/scripts/modules/kubernetes/src/v1/instance/details/details.controller.js +++ b/app/scripts/modules/kubernetes/src/v1/instance/details/details.controller.js @@ -5,7 +5,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, @@ -20,13 +20,11 @@ module(KUBERNETES_V1_INSTANCE_DETAILS_DETAILS_CONTROLLER, [ UIROUTER_ANGULARJS, ANGULAR_UI_BOOTSTRAP, INSTANCE_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, ]).controller('kubernetesInstanceDetailsController', [ '$scope', '$state', '$uibModal', 'instanceWriter', - 'confirmationModalService', 'instance', 'app', 'moniker', @@ -38,7 +36,6 @@ module(KUBERNETES_V1_INSTANCE_DETAILS_DETAILS_CONTROLLER, [ $state, $uibModal, instanceWriter, - confirmationModalService, instance, app, moniker, @@ -212,7 +209,7 @@ module(KUBERNETES_V1_INSTANCE_DETAILS_DETAILS_CONTROLLER, [ return instanceWriter.terminateInstance(instance, app, params); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.instanceId + '?', buttonText: 'Terminate ' + instance.instanceId, account: instance.account, @@ -237,7 +234,7 @@ module(KUBERNETES_V1_INSTANCE_DETAILS_DETAILS_CONTROLLER, [ }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really register ' + instance.name + ' with ' + loadBalancerNames + '?', buttonText: 'Register ' + instance.name, account: instance.account, @@ -262,7 +259,7 @@ module(KUBERNETES_V1_INSTANCE_DETAILS_DETAILS_CONTROLLER, [ }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really deregister ' + instance.name + ' from ' + loadBalancerNames + '?', buttonText: 'Deregister ' + instance.name, account: instance.account, diff --git a/app/scripts/modules/kubernetes/src/v1/loadBalancer/details/details.controller.js b/app/scripts/modules/kubernetes/src/v1/loadBalancer/details/details.controller.js index ed62394e906..998fe7cdf96 100644 --- a/app/scripts/modules/kubernetes/src/v1/loadBalancer/details/details.controller.js +++ b/app/scripts/modules/kubernetes/src/v1/loadBalancer/details/details.controller.js @@ -3,7 +3,7 @@ import * as angular from 'angular'; import _ from 'lodash'; -import { CONFIRMATION_MODAL_SERVICE, LoadBalancerWriter, ServerGroupTemplates } from '@spinnaker/core'; +import { ConfirmationModalService, LoadBalancerWriter, ServerGroupTemplates } from '@spinnaker/core'; import { KubernetesProviderSettings } from 'kubernetes/kubernetes.settings'; import UIROUTER_ANGULARJS from '@uirouter/angularjs'; @@ -12,7 +12,7 @@ export const KUBERNETES_V1_LOADBALANCER_DETAILS_DETAILS_CONTROLLER = 'spinnaker.loadBalancer.kubernetes.details.controller'; export const name = KUBERNETES_V1_LOADBALANCER_DETAILS_DETAILS_CONTROLLER; // for backwards compatibility angular - .module(KUBERNETES_V1_LOADBALANCER_DETAILS_DETAILS_CONTROLLER, [UIROUTER_ANGULARJS, CONFIRMATION_MODAL_SERVICE]) + .module(KUBERNETES_V1_LOADBALANCER_DETAILS_DETAILS_CONTROLLER, [UIROUTER_ANGULARJS]) .controller('kubernetesLoadBalancerDetailsController', [ '$interpolate', '$scope', @@ -20,18 +20,8 @@ angular '$uibModal', 'loadBalancer', 'app', - 'confirmationModalService', 'kubernetesProxyUiService', - function( - $interpolate, - $scope, - $state, - $uibModal, - loadBalancer, - app, - confirmationModalService, - kubernetesProxyUiService, - ) { + function($interpolate, $scope, $state, $uibModal, loadBalancer, app, kubernetesProxyUiService) { const application = app; $scope.state = { @@ -134,7 +124,7 @@ angular const submitMethod = () => LoadBalancerWriter.deleteLoadBalancer(command, application); - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + loadBalancer.name + '?', buttonText: 'Delete ' + loadBalancer.name, account: loadBalancer.account, diff --git a/app/scripts/modules/kubernetes/src/v1/securityGroup/details/details.controller.js b/app/scripts/modules/kubernetes/src/v1/securityGroup/details/details.controller.js index f91586197cb..d9dcf20eed1 100644 --- a/app/scripts/modules/kubernetes/src/v1/securityGroup/details/details.controller.js +++ b/app/scripts/modules/kubernetes/src/v1/securityGroup/details/details.controller.js @@ -5,7 +5,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, FirewallLabels, SECURITY_GROUP_READER, SecurityGroupWriter, @@ -17,20 +17,15 @@ export const KUBERNETES_V1_SECURITYGROUP_DETAILS_DETAILS_CONTROLLER = 'spinnaker.securityGroup.kubernetes.details.controller'; export const name = KUBERNETES_V1_SECURITYGROUP_DETAILS_DETAILS_CONTROLLER; // for backwards compatibility angular - .module(KUBERNETES_V1_SECURITYGROUP_DETAILS_DETAILS_CONTROLLER, [ - UIROUTER_ANGULARJS, - SECURITY_GROUP_READER, - CONFIRMATION_MODAL_SERVICE, - ]) + .module(KUBERNETES_V1_SECURITYGROUP_DETAILS_DETAILS_CONTROLLER, [UIROUTER_ANGULARJS, SECURITY_GROUP_READER]) .controller('kubernetesSecurityGroupDetailsController', [ '$scope', '$state', 'resolvedSecurityGroup', 'app', - 'confirmationModalService', 'securityGroupReader', '$uibModal', - function($scope, $state, resolvedSecurityGroup, app, confirmationModalService, securityGroupReader, $uibModal) { + function($scope, $state, resolvedSecurityGroup, app, securityGroupReader, $uibModal) { const application = app; const securityGroup = resolvedSecurityGroup; @@ -128,7 +123,7 @@ angular }); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + securityGroup.name + '?', buttonText: 'Delete ' + securityGroup.name, account: securityGroup.accountId, diff --git a/app/scripts/modules/kubernetes/src/v1/serverGroup/details/details.controller.js b/app/scripts/modules/kubernetes/src/v1/serverGroup/details/details.controller.js index 940f5ffa421..8c072a4ed2e 100644 --- a/app/scripts/modules/kubernetes/src/v1/serverGroup/details/details.controller.js +++ b/app/scripts/modules/kubernetes/src/v1/serverGroup/details/details.controller.js @@ -4,7 +4,7 @@ import * as angular from 'angular'; import _ from 'lodash'; import { - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, ServerGroupReader, ServerGroupWarningMessageService, SERVER_GROUP_WRITER, @@ -21,7 +21,6 @@ angular .module(KUBERNETES_V1_SERVERGROUP_DETAILS_DETAILS_CONTROLLER, [ UIROUTER_ANGULARJS, KUBERNETES_V1_SERVERGROUP_CONFIGURE_CONFIGURE_KUBERNETES_MODULE, - CONFIRMATION_MODAL_SERVICE, SERVER_GROUP_WRITER, KUBERNETES_V1_SERVERGROUP_PARAMSMIXIN, ]) @@ -34,7 +33,6 @@ angular 'serverGroupWriter', 'kubernetesServerGroupCommandBuilder', 'kubernetesServerGroupParamsMixin', - 'confirmationModalService', 'kubernetesProxyUiService', function( $scope, @@ -45,7 +43,6 @@ angular serverGroupWriter, kubernetesServerGroupCommandBuilder, kubernetesServerGroupParamsMixin, - confirmationModalService, kubernetesProxyUiService, ) { const application = (this.application = app); @@ -178,7 +175,7 @@ angular ServerGroupWarningMessageService.addDestroyWarningMessage(app, serverGroup, confirmationModalParams); - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.disableServerGroup = function disableServerGroup() { @@ -207,7 +204,7 @@ angular ServerGroupWarningMessageService.addDisableWarningMessage(app, serverGroup, confirmationModalParams); - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.enableServerGroup = function enableServerGroup() { @@ -234,7 +231,7 @@ angular askForReason: true, }; - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.rollbackServerGroup = function rollbackServerGroup() { diff --git a/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts b/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts index 6b967261d28..9338e465d4a 100644 --- a/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts @@ -2,14 +2,7 @@ import { IController, IPromise, IQService, IScope, module } from 'angular'; import { IModalService } from 'angular-ui-bootstrap'; import { flattenDeep } from 'lodash'; -import { - Application, - CONFIRMATION_MODAL_SERVICE, - InstanceReader, - RecentHistoryService, - IManifest, - ILoadBalancer, -} from '@spinnaker/core'; +import { Application, InstanceReader, RecentHistoryService, IManifest, ILoadBalancer } from '@spinnaker/core'; import { IKubernetesInstance } from './IKubernetesInstance'; import { KubernetesManifestService } from 'kubernetes/v2/manifest/manifest.service'; @@ -158,7 +151,7 @@ class KubernetesInstanceDetailsController implements IController { export const KUBERNETES_V2_INSTANCE_DETAILS_CTRL = 'spinnaker.kubernetes.v2.instanceDetails.controller'; -module(KUBERNETES_V2_INSTANCE_DETAILS_CTRL, [CONFIRMATION_MODAL_SERVICE]).controller( +module(KUBERNETES_V2_INSTANCE_DETAILS_CTRL, []).controller( 'kubernetesV2InstanceDetailsCtrl', KubernetesInstanceDetailsController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/RollingRestart.tsx b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/RollingRestart.tsx index 108752d96a5..389b45857b9 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/RollingRestart.tsx +++ b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/RollingRestart.tsx @@ -3,7 +3,7 @@ import { module } from 'angular'; import React from 'react'; import { react2angular } from 'react2angular'; -import { Application, ManifestWriter, ReactInjector } from '@spinnaker/core'; +import { Application, ManifestWriter, ConfirmationModalService } from '@spinnaker/core'; import { IKubernetesServerGroupManager } from 'kubernetes/v2/serverGroupManager'; @@ -27,7 +27,7 @@ function RollingRestart({ application, serverGroupManager }: IRollingRestartProp location: serverGroupManager.namespace, manifestName: serverGroupManager.name, }; - ReactInjector.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ account: serverGroupManager.account, askForReason: true, header: `Initiate rolling restart of ${serverGroupManager.name}`, diff --git a/app/scripts/modules/kubernetes/src/v2/serverGroup/details/details.controller.ts b/app/scripts/modules/kubernetes/src/v2/serverGroup/details/details.controller.ts index c85f1270872..3b1585647c2 100644 --- a/app/scripts/modules/kubernetes/src/v2/serverGroup/details/details.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/serverGroup/details/details.controller.ts @@ -3,7 +3,6 @@ import { IModalService } from 'angular-ui-bootstrap'; import { Application, - CONFIRMATION_MODAL_SERVICE, ClusterTargetBuilder, IEntityTags, IManifest, @@ -32,13 +31,12 @@ class KubernetesServerGroupDetailsController implements IController { public manifest: IManifest; public entityTagTargets: IOwnerOption[]; - public static $inject = ['serverGroup', 'app', '$uibModal', '$scope', 'confirmationModalService']; + public static $inject = ['serverGroup', 'app', '$uibModal', '$scope']; constructor( serverGroup: IServerGroupFromStateParams, public app: Application, private $uibModal: IModalService, private $scope: IScope, - private confirmationModalService: ConfirmationModalService, ) { const unsubscribe = KubernetesManifestService.makeManifestRefresher( this.app, @@ -148,7 +146,7 @@ class KubernetesServerGroupDetailsController implements IController { public canDisable = () => ManifestTrafficService.canDisableServerGroup(this.serverGroup); public disableServerGroup = (): void => { - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really disable ${this.manifest.name}?`, buttonText: 'Disable', askForReason: true, @@ -165,7 +163,7 @@ class KubernetesServerGroupDetailsController implements IController { public canEnable = () => ManifestTrafficService.canEnableServerGroup(this.serverGroup); public enableServerGroup = (): void => { - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really enable ${this.manifest.name}?`, buttonText: 'Enable', askForReason: true, @@ -227,7 +225,7 @@ class KubernetesServerGroupDetailsController implements IController { export const KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL = 'spinnaker.kubernetes.v2.serverGroup.details.controller'; -module(KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL, [CONFIRMATION_MODAL_SERVICE, SERVER_GROUP_WRITER]).controller( +module(KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL, [SERVER_GROUP_WRITER]).controller( 'kubernetesV2ServerGroupDetailsCtrl', KubernetesServerGroupDetailsController, ); diff --git a/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.spec.ts b/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.spec.ts index 515e0b90ca4..f68c9fc8c41 100644 --- a/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.spec.ts +++ b/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.spec.ts @@ -8,8 +8,6 @@ import { ApplicationModelBuilder, SECURITY_GROUP_READER, SecurityGroupReader, - CONFIRMATION_MODAL_SERVICE, - ConfirmationModalService, LOAD_BALANCER_READ_SERVICE, LoadBalancerReader, } from '@spinnaker/core'; @@ -19,7 +17,6 @@ describe('Controller: oracleLoadBalancerDetailCtrl', function() { let $scope: IScope; let $state: StateService; let securityGroupReader: SecurityGroupReader; - let confirmationModalService: ConfirmationModalService; let loadBalancerReader: LoadBalancerReader; const loadBalancer = { @@ -30,14 +27,7 @@ describe('Controller: oracleLoadBalancerDetailCtrl', function() { vpcId: '1', }; - beforeEach( - mock.module( - ORACLE_LOAD_BALANCER_DETAIL_CONTROLLER, - SECURITY_GROUP_READER, - LOAD_BALANCER_READ_SERVICE, - CONFIRMATION_MODAL_SERVICE, - ), - ); + beforeEach(mock.module(ORACLE_LOAD_BALANCER_DETAIL_CONTROLLER, SECURITY_GROUP_READER, LOAD_BALANCER_READ_SERVICE)); beforeEach( mock.inject( @@ -46,7 +36,6 @@ describe('Controller: oracleLoadBalancerDetailCtrl', function() { $rootScope: IRootScopeService, _$state_: StateService, _securityGroupReader_: SecurityGroupReader, - _confirmationModalService_: ConfirmationModalService, _loadBalancerReader_: LoadBalancerReader, ) => { $scope = $rootScope.$new(); @@ -58,7 +47,6 @@ describe('Controller: oracleLoadBalancerDetailCtrl', function() { }); app.loadBalancers.data.push(loadBalancer); securityGroupReader = _securityGroupReader_; - confirmationModalService = _confirmationModalService_; loadBalancerReader = _loadBalancerReader_; controller = $controller('oracleLoadBalancerDetailCtrl', { $scope: $scope, @@ -67,7 +55,6 @@ describe('Controller: oracleLoadBalancerDetailCtrl', function() { $state: $state, securityGroupReader: securityGroupReader, loadBalancerReader: loadBalancerReader, - confirmationModalService: confirmationModalService, }); }, ), diff --git a/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.ts b/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.ts index 53834018e03..3bf1cb72d31 100644 --- a/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.ts +++ b/app/scripts/modules/oracle/src/loadBalancer/details/loadBalancerDetail.controller.ts @@ -24,7 +24,6 @@ export class OracleLoadBalancerDetailController implements IController { 'loadBalancer', 'app', 'securityGroupReader', - 'confirmationModalService', 'loadBalancerReader', '$q', ]; @@ -35,7 +34,6 @@ export class OracleLoadBalancerDetailController implements IController { private loadBalancer: ILoadBalancerDetails, private app: Application, private securityGroupReader: SecurityGroupReader, - private confirmationModalService: ConfirmationModalService, private loadBalancerReader: LoadBalancerReader, private $q: angular.IQService, ) { @@ -152,7 +150,7 @@ export class OracleLoadBalancerDetailController implements IController { const submitMethod = () => LoadBalancerWriter.deleteLoadBalancer(command, this.app); - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really delete ' + this.loadBalancer.name + '?', buttonText: 'Delete ' + this.loadBalancer.name, account: this.loadBalancer.accountId, diff --git a/app/scripts/modules/oracle/src/serverGroup/details/serverGroupDetails.controller.js b/app/scripts/modules/oracle/src/serverGroup/details/serverGroupDetails.controller.js index 337f3d9988f..c477612f80d 100644 --- a/app/scripts/modules/oracle/src/serverGroup/details/serverGroupDetails.controller.js +++ b/app/scripts/modules/oracle/src/serverGroup/details/serverGroupDetails.controller.js @@ -3,7 +3,7 @@ import { module } from 'angular'; import { - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, NetworkReader, ServerGroupReader, ServerGroupWarningMessageService, @@ -20,7 +20,6 @@ export const ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER = export const name = ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER; // for backwards compatibility module(ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER, [ UIROUTER_ANGULARJS, - CONFIRMATION_MODAL_SERVICE, SERVER_GROUP_WRITER, ORACLE_IMAGE_IMAGE_READER, ORACLE_SERVERGROUP_DETAILS_RESIZE_RESIZESERVERGROUP_CONTROLLER, @@ -31,19 +30,9 @@ module(ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER, [ '$uibModal', 'app', 'serverGroup', - 'confirmationModalService', 'serverGroupWriter', 'oracleImageReader', - function( - $scope, - $state, - $uibModal, - app, - serverGroup, - confirmationModalService, - serverGroupWriter, - oracleImageReader, - ) { + function($scope, $state, $uibModal, app, serverGroup, serverGroupWriter, oracleImageReader) { const provider = 'oracle'; this.application = app; @@ -125,7 +114,7 @@ module(ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER, [ region: serverGroup.region, }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really destroy ' + serverGroup.name + '?', buttonText: 'Destroy ' + serverGroup.name, account: serverGroup.account, @@ -196,7 +185,7 @@ module(ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER, [ confirmationModalParams.interestingHealthProviderNames = ['Oracle']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.enableServerGroup = () => { @@ -224,7 +213,7 @@ module(ORACLE_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_CONTROLLER, [ confirmationModalParams.interestingHealthProviderNames = ['Oracle']; } - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; const cancelLoader = () => { diff --git a/app/scripts/modules/titus/src/instance/details/instance.details.controller.js b/app/scripts/modules/titus/src/instance/details/instance.details.controller.js index c44f1b12a88..8134ee3fa41 100644 --- a/app/scripts/modules/titus/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/titus/src/instance/details/instance.details.controller.js @@ -7,7 +7,7 @@ import { getAllTargetGroups, applyHealthCheckInfoToTargetGroups } from '@spinnak import { AccountService, CloudProviderRegistry, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, FirewallLabels, InstanceReader, INSTANCE_WRITE_SERVICE, @@ -24,7 +24,6 @@ module(TITUS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ UIROUTER_ANGULARJS, ANGULAR_UI_BOOTSTRAP, INSTANCE_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, TITUS_SECURITYGROUP_SECURITYGROUP_READ_SERVICE, ]).controller('titusInstanceDetailsCtrl', [ '$scope', @@ -32,25 +31,12 @@ module(TITUS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ '$state', '$uibModal', 'instanceWriter', - 'confirmationModalService', 'instance', 'app', 'moniker', 'environment', 'overrides', - function( - $scope, - $q, - $state, - $uibModal, - instanceWriter, - confirmationModalService, - instance, - app, - moniker, - environment, - overrides, - ) { + function($scope, $q, $state, $uibModal, instanceWriter, instance, app, moniker, environment, overrides) { // needed for standalone instances $scope.detailsTemplateUrl = CloudProviderRegistry.getValue('titus', 'instance.detailsTemplateUrl'); @@ -189,7 +175,7 @@ module(TITUS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.terminateInstance(instance, app, params); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.id + '?', buttonText: 'Terminate ' + instance.id, account: instance.account, @@ -227,7 +213,7 @@ module(TITUS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ ); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really terminate ' + instance.id + ' and shrink ' + instance.serverGroup + '?', buttonText: 'Terminate ' + instance.id + ' and shrink ' + instance.serverGroup, account: instance.account, @@ -257,7 +243,7 @@ module(TITUS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.enableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really enable ' + instance.instanceId + ' in discovery?', buttonText: 'Enable ' + instance.instanceId, account: instance.account, @@ -279,7 +265,7 @@ module(TITUS_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER, [ return instanceWriter.disableInstanceInDiscovery(instance, app); }; - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: 'Really disable ' + instance.instanceId + ' in discovery?', buttonText: 'Disable ' + instance.instanceId, account: instance.account, diff --git a/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js b/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js index a03775729dc..b7ee978aaf7 100644 --- a/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js +++ b/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js @@ -2,7 +2,7 @@ import { module } from 'angular'; -import { AccountService, CONFIRMATION_MODAL_SERVICE, TaskExecutor } from '@spinnaker/core'; +import { AccountService, ConfirmationModalService, TaskExecutor } from '@spinnaker/core'; import './scalingPolicySummary.component.less'; import { TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_UPSERTSCALINGPOLICY_CONTROLLER } from './upsert/upsertScalingPolicy.controller'; @@ -12,7 +12,6 @@ export const TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT export const name = TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT; // for backwards compatibility module(TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [ TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_UPSERT_UPSERTSCALINGPOLICY_CONTROLLER, - CONFIRMATION_MODAL_SERVICE, ]).component('titusAlarmBasedSummary', { bindings: { policy: '=', @@ -22,8 +21,7 @@ module(TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [ templateUrl: require('./alarmBasedSummary.component.html'), controller: [ '$uibModal', - 'confirmationModalService', - function($uibModal, confirmationModalService) { + function($uibModal) { this.$onInit = () => { AccountService.getAccountDetails(this.serverGroup.account).then(details => { // alarmServerGroup is used to trick the chart rendering into using AWS metrics @@ -76,7 +74,7 @@ module(TITUS_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT, [ ], }); - confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${policy.id}?`, buttonText: 'Delete scaling policy', account: serverGroup.account, diff --git a/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts b/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts index b073f95d215..cf646a84d82 100644 --- a/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts +++ b/app/scripts/modules/titus/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts @@ -32,8 +32,8 @@ class TargetTrackingSummaryController implements IComponentController { public config: ITargetTrackingConfiguration; public popoverTemplate = require('./targetTrackingPopover.html'); - public static $inject = ['$uibModal', 'confirmationModalService']; - constructor(private $uibModal: IModalService, private confirmationModalService: ConfirmationModalService) {} + public static $inject = ['$uibModal']; + constructor(private $uibModal: IModalService) {} public $onInit() { this.config = this.policy.targetTrackingConfiguration; @@ -72,7 +72,7 @@ class TargetTrackingSummaryController implements IComponentController { title: 'Deleting scaling policy ' + this.policy.id, }; - this.confirmationModalService.confirm({ + ConfirmationModalService.confirm({ header: `Really delete ${policy.id}?`, buttonText: 'Delete scaling policy', account: this.serverGroup.account, diff --git a/app/scripts/modules/titus/src/serverGroup/details/serverGroupDetails.titus.controller.js b/app/scripts/modules/titus/src/serverGroup/details/serverGroupDetails.titus.controller.js index 3f210af8587..1f6a3b4d763 100644 --- a/app/scripts/modules/titus/src/serverGroup/details/serverGroupDetails.titus.controller.js +++ b/app/scripts/modules/titus/src/serverGroup/details/serverGroupDetails.titus.controller.js @@ -9,7 +9,7 @@ import { AccountService, confirmNotManaged, ClusterTargetBuilder, - CONFIRMATION_MODAL_SERVICE, + ConfirmationModalService, ServerGroupReader, ServerGroupWarningMessageService, SERVER_GROUP_WRITER, @@ -36,7 +36,6 @@ angular .module(TITUS_SERVERGROUP_DETAILS_SERVERGROUPDETAILS_TITUS_CONTROLLER, [ UIROUTER_ANGULARJS, TITUS_SERVERGROUP_CONFIGURE_SERVERGROUPCOMMANDBUILDER, - CONFIRMATION_MODAL_SERVICE, DISRUPTION_BUDGET_DETAILS_SECTION, SERVER_GROUP_WRITER, TITUS_SERVERGROUP_DETAILS_ROLLBACK_ROLLBACKSERVERGROUP_CONTROLLER, @@ -53,7 +52,6 @@ angular 'serverGroup', 'titusServerGroupCommandBuilder', '$uibModal', - 'confirmationModalService', 'serverGroupWriter', 'awsServerGroupTransformer', function( @@ -65,7 +63,6 @@ angular serverGroup, titusServerGroupCommandBuilder, $uibModal, - confirmationModalService, serverGroupWriter, awsServerGroupTransformer, ) { @@ -262,7 +259,7 @@ angular ServerGroupWarningMessageService.addDestroyWarningMessage(app, serverGroup, confirmationModalParams); confirmNotManaged(serverGroup, app).then( - notManaged => notManaged && confirmationModalService.confirm(confirmationModalParams), + notManaged => notManaged && ConfirmationModalService.confirm(confirmationModalParams), ); }; @@ -296,7 +293,7 @@ angular ServerGroupWarningMessageService.addDisableWarningMessage(app, serverGroup, confirmationModalParams); confirmNotManaged(serverGroup, app).then( - notManaged => notManaged && confirmationModalService.confirm(confirmationModalParams), + notManaged => notManaged && ConfirmationModalService.confirm(confirmationModalParams), ); }; @@ -318,8 +315,7 @@ angular cancelButtonText: 'No, I just want to enable the server group', }; - confirmationModalService - .confirm(confirmationModalParams) + ConfirmationModalService.confirm(confirmationModalParams) .then(() => this.rollbackServerGroup()) .catch(({ source }) => { // don't show the enable modal if the user cancels with the header button @@ -363,7 +359,7 @@ angular submitMethod: submitMethod, }; - confirmationModalService.confirm(confirmationModalParams); + ConfirmationModalService.confirm(confirmationModalParams); }; this.cloneServerGroup = function cloneServerGroup() {