Skip to content

Commit

Permalink
refactor(core/entityTag): Convert clusterTargetBuilder.service to pla…
Browse files Browse the repository at this point in the history
…in JS
  • Loading branch information
Justin Reynolds committed Apr 11, 2018
1 parent d9f313b commit 378f228
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Dropdown, Tooltip } from 'react-bootstrap';
import { get, find, filter, orderBy } from 'lodash';

import {
ClusterTargetBuilder,
IOwnerOption,
IServerGroupActionsProps,
IServerGroupJob,
Expand Down Expand Up @@ -285,7 +286,7 @@ export class AmazonServerGroupActions extends React.Component<IAmazonServerGroup

const { AddEntityTagLinks } = NgReact;
const showEntityTags = SETTINGS.feature && SETTINGS.feature.entityTags;
const entityTagTargets: IOwnerOption[] = ReactInjector.clusterTargetBuilder.buildClusterTargets(serverGroup);
const entityTagTargets: IOwnerOption[] = ClusterTargetBuilder.buildClusterTargets(serverGroup);

return (
<Dropdown className="dropdown" id="server-group-actions-dropdown">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { module } from 'angular';

import { IServerGroup } from 'core/domain';
import { NameUtils } from 'core/naming';

import { IOwnerOption } from './EntityTagEditor';

export class ClusterTargetBuilder {
public buildClusterTargets(serverGroup: IServerGroup): IOwnerOption[] {
public static buildClusterTargets(serverGroup: IServerGroup): IOwnerOption[] {
const clusterName = NameUtils.getClusterNameFromServerGroupName(serverGroup.name);
return [
{
Expand Down Expand Up @@ -40,6 +38,3 @@ export class ClusterTargetBuilder {
];
}
}

export const CLUSTER_TARGET_BUILDER = 'spinnaker.core.entityTag.clusterTargetBuilder';
module(CLUSTER_TARGET_BUILDER, []).service('clusterTargetBuilder', ClusterTargetBuilder);
2 changes: 1 addition & 1 deletion app/scripts/modules/core/src/entityTag/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './AddEntityTagLinks';
export * from './EntityTagEditor';
export * from './clusterTargetBuilder.service';
export * from './clusterTargetBuilder';
export * from './entityTags.read.service';
export * from './entityTags.write.service';
export * from './notifications';
2 changes: 0 additions & 2 deletions app/scripts/modules/core/src/reactShims/react.injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { CancelModalService } from '../cancelModal/cancelModal.service';
import { CloudProviderRegistry } from '../cloudProvider/cloudProvider.registry';
import { ClusterFilterModel } from 'core/cluster/filter/clusterFilter.model';
import { ClusterFilterService } from '../cluster/filter/clusterFilter.service';
import { ClusterTargetBuilder } from '../entityTag/clusterTargetBuilder.service';
import { CollapsibleSectionStateCache } from '../cache/collapsibleSectionStateCache';
import { ConfirmationModalService } from '../confirmationModal/confirmationModal.service';
import { EntityTagWriter } from '../entityTag';
Expand Down Expand Up @@ -98,7 +97,6 @@ export class CoreReactInject extends ReactInject {
public get cloudProviderRegistry() { return this.$injector.get('cloudProviderRegistry') as CloudProviderRegistry; }
public get clusterFilterModel() { return this.$injector.get('clusterFilterModel') as ClusterFilterModel; }
public get clusterFilterService() { return this.$injector.get('clusterFilterService') as ClusterFilterService; }
public get clusterTargetBuilder() { return this.$injector.get('clusterTargetBuilder') as ClusterTargetBuilder; }
public get collapsibleSectionStateCache() { return this.$injector.get('collapsibleSectionStateCache') as CollapsibleSectionStateCache; }
public get confirmationModalService() { return this.$injector.get('confirmationModalService') as ConfirmationModalService; }
public get entityTagWriter() { return this.$injector.get('entityTagWriter') as EntityTagWriter; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ECS_SERVER_GROUP_TRANSFORMER } from '../serverGroup.transformer';

import {
ACCOUNT_SERVICE,
CLUSTER_TARGET_BUILDER,
CONFIRMATION_MODAL_SERVICE,
OVERRIDE_REGISTRY,
SERVER_GROUP_READER,
Expand All @@ -20,7 +19,6 @@ module.exports = angular
require('@uirouter/angularjs').default,
ACCOUNT_SERVICE,
ECS_SERVER_GROUP_TRANSFORMER,
CLUSTER_TARGET_BUILDER,
CONFIRMATION_MODAL_SERVICE,
OVERRIDE_REGISTRY,
SERVER_GROUP_READER,
Expand All @@ -41,7 +39,6 @@ module.exports = angular
confirmationModalService,
serverGroupWriter,
subnetReader,
clusterTargetBuilder,
ecsServerGroupTransformer,
accountService,
serverGroupWarningMessageService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const angular = require('angular');
import _ from 'lodash';

import {
CLUSTER_TARGET_BUILDER,
CONFIRMATION_MODAL_SERVICE,
ClusterTargetBuilder,
NETWORK_READ_SERVICE,
SERVER_GROUP_READER,
SERVER_GROUP_WARNING_MESSAGE_SERVICE,
Expand All @@ -26,7 +26,6 @@ module.exports = angular
CONFIRMATION_MODAL_SERVICE,
NETWORK_READ_SERVICE,
SERVER_GROUP_WRITER,
CLUSTER_TARGET_BUILDER,
require('google/common/xpnNaming.gce.service.js').name,
require('./resize/resizeServerGroup.controller').name,
require('./rollback/rollbackServerGroup.controller').name,
Expand All @@ -47,7 +46,6 @@ module.exports = angular
serverGroupWriter,
serverGroupWarningMessageService,
networkReader,
clusterTargetBuilder,
gceXpnNamingService,
) {
this.state = {
Expand Down Expand Up @@ -540,6 +538,6 @@ module.exports = angular
};

let configureEntityTagTargets = () => {
this.entityTagTargets = clusterTargetBuilder.buildClusterTargets(this.serverGroup);
this.entityTagTargets = ClusterTargetBuilder.buildClusterTargets(this.serverGroup);
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from 'lodash';

import {
ACCOUNT_SERVICE,
CLUSTER_TARGET_BUILDER,
ClusterTargetBuilder,
CONFIRMATION_MODAL_SERVICE,
NameUtils,
SERVER_GROUP_READER,
Expand All @@ -31,7 +31,6 @@ module.exports = angular
SERVER_GROUP_WRITER,
require('./resize/resizeServerGroup.controller').name,
require('./rollback/rollbackServerGroup.controller').name,
CLUSTER_TARGET_BUILDER,
SCALING_POLICY_MODULE,
])
.controller('titusServerGroupDetailsCtrl', function(
Expand All @@ -46,7 +45,6 @@ module.exports = angular
$uibModal,
confirmationModalService,
serverGroupWriter,
clusterTargetBuilder,
awsServerGroupTransformer,
serverGroupWarningMessageService,
accountService,
Expand Down Expand Up @@ -217,7 +215,7 @@ module.exports = angular
});

let configureEntityTagTargets = () => {
this.entityTagTargets = clusterTargetBuilder.buildClusterTargets($scope.serverGroup);
this.entityTagTargets = ClusterTargetBuilder.buildClusterTargets($scope.serverGroup);
};

this.destroyServerGroup = function destroyServerGroup() {
Expand Down

0 comments on commit 378f228

Please sign in to comment.