Skip to content

Commit

Permalink
refactor(*): de-angularize confirmationModalService (#7759)
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry authored and mergify[bot] committed Jan 10, 2020
1 parent 4302a0f commit e6c6c66
Show file tree
Hide file tree
Showing 62 changed files with 864 additions and 1,058 deletions.
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -70,7 +77,7 @@ export class FunctionActions extends React.Component<IFunctionActionsProps, IFun

const submitMethod = () => 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getAllTargetGroups, applyHealthCheckInfoToTargetGroups } from './utils'

import {
CloudProviderRegistry,
CONFIRMATION_MODAL_SERVICE,
ConfirmationModalService,
InstanceReader,
RecentHistoryService,
SETTINGS,
Expand All @@ -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');

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { FormikErrors, FormikProps } from 'formik';

import {
Application,
ConfirmationModalService,
CustomLabels,
HelpField,
IWizardPageComponent,
ReactInjector,
Tooltip,
ValidationMessage,
} from '@spinnaker/core';
Expand Down Expand Up @@ -403,7 +403,7 @@ export class ALBListeners extends React.Component<IALBListenersProps, IALBListen

if (confirmDefaultRemove || confirmRemove) {
// TODO: Confirmation Dialog first.
ReactInjector.confirmationModalService.confirm({
ConfirmationModalService.confirm({
header: 'Really remove authentication?',
buttonText: `Remove Auth`,
submitMethod: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { get, values } from 'lodash';
import {
Application,
ApplicationReader,
ConfirmationModalService,
LoadBalancerWriter,
ManagedMenuItem,
SETTINGS,
NgReact,
ReactInjector,
HelpField,
} from '@spinnaker/core';

Expand Down Expand Up @@ -89,7 +89,7 @@ export class LoadBalancerActions extends React.Component<ILoadBalancerActionsPro

const submitMethod = () => 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { head, sortBy } from 'lodash';

import {
Application,
CONFIRMATION_MODAL_SERVICE,
IApplicationSecurityGroup,
ILoadBalancer,
ISecurityGroup,
Expand Down Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from 'lodash';

import {
CloudProviderRegistry,
CONFIRMATION_MODAL_SERVICE,
ConfirmationModalService,
confirmNotManaged,
RecentHistoryService,
SECURITY_GROUP_READER,
Expand All @@ -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,
])
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { filter, find, get, orderBy } from 'lodash';

import {
ClusterTargetBuilder,
ConfirmationModalService,
IOwnerOption,
IServerGroupActionsProps,
IServerGroupJob,
Expand Down Expand Up @@ -118,7 +119,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup
confirmationModalParams.interestingHealthProviderNames = ['Amazon'];
}

ReactInjector.confirmationModalService.confirm(confirmationModalParams);
ConfirmationModalService.confirm(confirmationModalParams);
};

private disableServerGroup = (): void => {
Expand Down Expand Up @@ -151,7 +152,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup
confirmationModalParams.interestingHealthProviderNames = ['Amazon'];
}

ReactInjector.confirmationModalService.confirm(confirmationModalParams);
ConfirmationModalService.confirm(confirmationModalParams);
};

private enableServerGroup = (): void => {
Expand All @@ -168,8 +169,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup
cancelButtonText: 'No, I just want to enable the server group',
};

ReactInjector.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
Expand Down Expand Up @@ -207,7 +207,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup
confirmationModalParams.interestingHealthProviderNames = ['Amazon'];
}

ReactInjector.confirmationModalService.confirm(confirmationModalParams);
ConfirmationModalService.confirm(confirmationModalParams);
}

private rollbackServerGroup = (): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: '=',
Expand All @@ -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 = () => {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { cloneDeep, flattenDeep } from 'lodash';

import {
Application,
CONFIRMATION_MODAL_SERVICE,
ConfirmationModalService,
INSTANCE_WRITE_SERVICE,
InstanceReader,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
);
Loading

0 comments on commit e6c6c66

Please sign in to comment.