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 ${DEFAULT_SKIP_WINDOW_TEXT} This pipeline is currently running - restarting this stage will result in multiple concurrently running pipelines.{instance.name}
-
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() {