@spinnaker/amazon 0.11.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/aws.settings.d.ts +1 -0
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/instance/awsInstanceType.service.d.ts +10 -2
  6. package/dist/instance/awsInstanceTypes.d.ts +10 -0
  7. package/dist/instance/details/CostFactor.d.ts +6 -0
  8. package/dist/search/searchResultFormatter.d.ts +2 -2
  9. package/dist/serverGroup/configure/serverGroupConfiguration.service.d.ts +14 -1
  10. package/dist/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.d.ts +3 -4
  11. package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.d.ts +9 -0
  12. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.d.ts +13 -0
  13. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.d.ts +9 -0
  14. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.d.ts +11 -0
  15. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.d.ts +14 -0
  16. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.d.ts +12 -0
  17. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.d.ts +15 -0
  18. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.d.ts +8 -0
  19. package/dist/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.d.ts +8 -0
  20. package/dist/serverGroup/configure/wizard/pages/ServerGroupInstanceType.d.ts +9 -6
  21. package/dist/serverGroup/details/scalingPolicy/ScalingPolicySummary.d.ts +0 -1
  22. package/dist/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.d.ts +0 -4
  23. package/dist/serverGroup/details/scalingPolicy/index.d.ts +0 -1
  24. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingChart.d.ts +1 -3
  25. package/package.json +5 -5
  26. package/src/aws.module.ts +3 -3
  27. package/src/aws.settings.ts +2 -0
  28. package/src/function/details/FunctionActions.spec.tsx +15 -12
  29. package/src/function/details/FunctionActions.tsx +2 -1
  30. package/src/help/amazon.help.ts +9 -6
  31. package/src/image/image.reader.spec.ts +75 -0
  32. package/src/instance/awsInstanceType.service.spec.js +37 -71
  33. package/src/instance/awsInstanceType.service.ts +191 -0
  34. package/src/instance/awsInstanceTypes.ts +311 -0
  35. package/src/instance/details/CostFactor.tsx +29 -0
  36. package/src/instance/details/InstanceInformation.spec.tsx +2 -1
  37. package/src/instance/details/instance.details.controller.js +472 -473
  38. package/src/loadBalancer/details/LoadBalancerActions.tsx +2 -1
  39. package/src/loadBalancer/details/loadBalancerDetails.controller.spec.ts +5 -3
  40. package/src/search/{searchResultFormatter.js → searchResultFormatter.ts} +5 -4
  41. package/src/securityGroup/details/securityGroupDetail.controller.js +2 -1
  42. package/src/serverGroup/configure/AmazonImageSelectInput.spec.tsx +10 -7
  43. package/src/serverGroup/configure/serverGroupCommandBuilder.aws.service.spec.js +302 -1
  44. package/src/serverGroup/configure/serverGroupCommandBuilder.service.js +96 -24
  45. package/src/serverGroup/configure/serverGroupCommandBuilder.spec.js +25 -8
  46. package/src/serverGroup/configure/serverGroupConfiguration.service.spec.ts +6 -13
  47. package/src/serverGroup/configure/serverGroupConfiguration.service.ts +26 -1
  48. package/src/serverGroup/configure/wizard/AmazonCloneServerGroupModal.tsx +1 -1
  49. package/src/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.tsx +31 -31
  50. package/src/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.tsx +133 -0
  51. package/src/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.tsx +99 -0
  52. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.tsx +36 -0
  53. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.tsx +144 -0
  54. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.tsx +137 -0
  55. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.tsx +135 -0
  56. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.tsx +137 -0
  57. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.less +5 -0
  58. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.tsx +108 -0
  59. package/src/serverGroup/configure/wizard/instanceType/advancedMode/advancedMode.less +110 -0
  60. package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.tsx +62 -0
  61. package/src/serverGroup/configure/wizard/pages/ServerGroupInstanceType.tsx +106 -62
  62. package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.tsx +1 -1
  63. package/src/serverGroup/details/AmazonServerGroupActions.tsx +2 -1
  64. package/src/serverGroup/details/scalingPolicy/ScalingPolicySummary.tsx +7 -3
  65. package/src/serverGroup/details/scalingPolicy/StepPolicySummary.tsx +26 -28
  66. package/src/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.tsx +1 -25
  67. package/src/serverGroup/details/scalingPolicy/index.ts +0 -1
  68. package/src/serverGroup/details/scalingPolicy/scalingPolicy.module.ts +1 -9
  69. package/src/serverGroup/details/scalingPolicy/scalingPolicySummary.component.ts +6 -2
  70. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingChart.tsx +2 -17
  71. package/src/serverGroup/details/scalingPolicy/upsert/alarm/AlarmConfigurer.less +1 -1
  72. package/src/serverGroup/details/scalingProcesses/AutoScalingProcessService.spec.ts +1 -2
  73. package/src/serverGroup/details/sections/AdvancedSettingsDetailsSection.tsx +3 -2
  74. package/src/serverGroup/details/sections/AmazonCapacityDetailsSection.tsx +3 -8
  75. package/src/serverGroup/details/sections/InstancesDistributionDetailsSection.spec.tsx +8 -5
  76. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +8 -5
  77. package/src/serverGroup/details/sections/ScalingPoliciesDetailsSection.tsx +3 -3
  78. package/src/serverGroup/details/sections/ScalingProcessesDetailsSection.tsx +3 -10
  79. package/src/serverGroup/details/sections/ScheduledActionsDetailsSection.tsx +3 -2
  80. package/src/serverGroup/details/sections/SecurityGroupsDetailsSection.tsx +3 -2
  81. package/src/serverGroup/serverGroup.transformer.spec.ts +5 -3
  82. package/src/subnet/SubnetSelectInput.spec.tsx +7 -4
  83. package/src/vpc/{VpcReader.spec.js → VpcReader.spec.ts} +2 -10
  84. package/src/vpc/VpcTag.spec.tsx +37 -0
  85. package/src/vpc/vpc.module.ts +6 -2
  86. package/dist/reactShims/aws.ngReact.d.ts +0 -11
  87. package/dist/serverGroup/details/scalingPolicy/ScalingPolicyTypeRegistry.d.ts +0 -10
  88. package/dist/serverGroup/details/scalingPolicy/alarmBasedSummary.component.d.ts +0 -2
  89. package/dist/serverGroup/details/scalingPolicy/detailsSummary.component.d.ts +0 -12
  90. package/dist/serverGroup/details/scalingPolicy/popover/scalingPolicyPopover.component.d.ts +0 -1
  91. package/dist/serverGroup/details/scalingPolicy/stepPolicySummary.component.d.ts +0 -1
  92. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingPolicy.config.d.ts +0 -1
  93. package/dist/serverGroup/details/scalingPolicy/targetTracking/targetTracking.module.d.ts +0 -2
  94. package/dist/serverGroup/details/scalingPolicy/targetTracking/targetTrackingChart.component.d.ts +0 -1
  95. package/dist/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.d.ts +0 -1
  96. package/dist/vpc/vpcTag.directive.d.ts +0 -2
  97. package/src/image/image.reader.spec.js +0 -123
  98. package/src/instance/awsInstanceType.service.js +0 -437
  99. package/src/reactShims/aws.ngReact.ts +0 -27
  100. package/src/serverGroup/details/scalingPolicy/ScalingPolicyTypeRegistry.ts +0 -18
  101. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.html +0 -35
  102. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.component.js +0 -60
  103. package/src/serverGroup/details/scalingPolicy/alarmBasedSummary.template.html +0 -5
  104. package/src/serverGroup/details/scalingPolicy/detailsSummary.component.ts +0 -32
  105. package/src/serverGroup/details/scalingPolicy/popover/scalingPolicyDetails.popover.html +0 -1
  106. package/src/serverGroup/details/scalingPolicy/popover/scalingPolicyPopover.component.html +0 -107
  107. package/src/serverGroup/details/scalingPolicy/popover/scalingPolicyPopover.component.ts +0 -31
  108. package/src/serverGroup/details/scalingPolicy/scalingPolicySummary.component.less +0 -15
  109. package/src/serverGroup/details/scalingPolicy/stepPolicySummary.component.ts +0 -10
  110. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingPolicy.config.ts +0 -6
  111. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTracking.module.ts +0 -8
  112. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingChart.component.ts +0 -16
  113. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.component.ts +0 -14
  114. package/src/serverGroup/details/scalingPolicy/targetTracking/targetTrackingSummary.html +0 -5
  115. package/src/vpc/vpcTag.directive.js +0 -34
  116. package/src/vpc/vpcTag.directive.spec.js +0 -60
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
- import { CollapsibleSection, confirmNotManaged, ModalInjector, SETTINGS } from '@spinnaker/core';
3
+ import { CollapsibleSection, confirmNotManaged, ModalInjector } from '@spinnaker/core';
4
4
  import { HelpField } from '@spinnaker/core';
5
5
 
6
6
  import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
7
+ import { AWSProviderSettings } from '../../../aws.settings';
7
8
 
8
9
  export class AdvancedSettingsDetailsSection extends React.Component<IAmazonServerGroupDetailsSectionProps> {
9
10
  private editAdvancedSettings = (): void => {
@@ -49,7 +50,7 @@ export class AdvancedSettingsDetailsSection extends React.Component<IAmazonServe
49
50
  <dd>{`${asg.capacityRebalance}`}</dd>,
50
51
  ]}
51
52
  </dl>
52
- {SETTINGS.awsAdHocInfraWritesEnabled && (
53
+ {AWSProviderSettings.adHocInfraWritesEnabled && (
53
54
  <a className="clickable" onClick={this.editAdvancedSettings}>
54
55
  Edit Advanced Settings
55
56
  </a>
@@ -1,15 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
3
  import type { ICapacity } from '@spinnaker/core';
4
- import {
5
- CapacityDetailsSection,
6
- CollapsibleSection,
7
- Overridable,
8
- SETTINGS,
9
- ViewScalingActivitiesLink,
10
- } from '@spinnaker/core';
4
+ import { CapacityDetailsSection, CollapsibleSection, Overridable, ViewScalingActivitiesLink } from '@spinnaker/core';
11
5
 
12
6
  import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
7
+ import { AWSProviderSettings } from '../../../aws.settings';
13
8
  import { AmazonResizeServerGroupModal } from '../resize/AmazonResizeServerGroupModal';
14
9
 
15
10
  @Overridable('amazon.serverGroup.CapacityDetailsSection')
@@ -28,7 +23,7 @@ export class AmazonCapacityDetailsSection extends React.Component<IAmazonServerG
28
23
  <CapacityDetailsSection current={serverGroup.instances.length} capacity={capacity} />
29
24
 
30
25
  <div>
31
- {SETTINGS.awsAdHocInfraWritesEnabled && (
26
+ {AWSProviderSettings.adHocInfraWritesEnabled && (
32
27
  <a className="clickable" onClick={() => AmazonResizeServerGroupModal.show({ application, serverGroup })}>
33
28
  Resize Server Group
34
29
  </a>
@@ -1,9 +1,12 @@
1
- import React from 'react';
2
1
  import { shallow } from 'enzyme';
2
+ import React from 'react';
3
+
4
+ import type { Application } from '@spinnaker/core';
5
+ import { ApplicationModelBuilder } from '@spinnaker/core';
3
6
  import { mockLaunchTemplate, mockServerGroup } from '@spinnaker/mocks';
4
- import { IAmazonMixedInstancesPolicy, IAmazonServerGroupView, IScalingPolicy } from '../../../domain';
7
+
8
+ import type { IAmazonMixedInstancesPolicy, IAmazonServerGroupView, IScalingPolicy } from '../../../domain';
5
9
  import { InstancesDistributionDetailsSection } from '../../../index';
6
- import { Application, ApplicationModelBuilder } from '@spinnaker/core';
7
10
 
8
11
  describe('InstancesDistribution', () => {
9
12
  let app: Application;
@@ -50,7 +53,7 @@ describe('InstancesDistribution', () => {
50
53
  ]);
51
54
  let index = 0;
52
55
  expectedLabels.forEach((value, key) => {
53
- let labeledValue = actualLabeledValues.at(index++);
56
+ const labeledValue = actualLabeledValues.at(index++);
54
57
  expect(labeledValue.prop('label')).toEqual(key);
55
58
  expect(labeledValue.prop('value')).toEqual(value);
56
59
  });
@@ -77,7 +80,7 @@ describe('InstancesDistribution', () => {
77
80
  ]);
78
81
  let index = 0;
79
82
  expectedLabels.forEach((value, key) => {
80
- let labeledValue = actualLabeledValues.at(index++);
83
+ const labeledValue = actualLabeledValues.at(index++);
81
84
  expect(labeledValue.prop('label')).toEqual(key);
82
85
  expect(labeledValue.prop('value')).toEqual(value);
83
86
  });
@@ -1,15 +1,18 @@
1
- import React from 'react';
2
1
  import { shallow } from 'enzyme';
2
+ import React from 'react';
3
+
4
+ import type { Application } from '@spinnaker/core';
5
+ import { ApplicationModelBuilder } from '@spinnaker/core';
3
6
  import {
4
7
  createCustomMockLaunchTemplate,
5
8
  mockLaunchTemplate,
6
9
  mockLaunchTemplateData,
7
10
  mockServerGroup,
8
11
  } from '@spinnaker/mocks';
9
- import { Application, ApplicationModelBuilder } from '@spinnaker/core';
10
- import { IAmazonServerGroupView, IAmazonMixedInstancesPolicy, IScalingPolicy } from '../../../domain';
12
+
11
13
  import { LaunchTemplateDetailsSection } from './LaunchTemplateDetailsSection';
12
14
  import { MultipleInstanceTypesSubSection } from './MultipleInstanceTypesSubSection';
15
+ import type { IAmazonMixedInstancesPolicy, IAmazonServerGroupView, IScalingPolicy } from '../../../domain';
13
16
 
14
17
  describe('Launch template details', () => {
15
18
  let app: Application;
@@ -144,7 +147,7 @@ describe('Launch template details', () => {
144
147
  ]);
145
148
  let index = 0;
146
149
  expectedLabels.forEach((value, key) => {
147
- let labeledValue = actualLabeledValues.at(index++);
150
+ const labeledValue = actualLabeledValues.at(index++);
148
151
  expect(labeledValue.prop('label')).toEqual(key);
149
152
  value != '' && expect(labeledValue.prop('value')).toEqual(value);
150
153
  });
@@ -239,7 +242,7 @@ describe('Launch template details', () => {
239
242
  });
240
243
 
241
244
  it('should not render multiple instance types subsection when overrides are not specified', () => {
242
- let testServerGroup = baseServerGroupWithMipOverrides;
245
+ const testServerGroup = baseServerGroupWithMipOverrides;
243
246
  testServerGroup.mixedInstancesPolicy.launchTemplateOverridesForInstanceType = null;
244
247
 
245
248
  const multipleInstanceTypes = shallow(
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
- import { CollapsibleSection, Overridable, SETTINGS, Tooltip } from '@spinnaker/core';
3
+ import { CollapsibleSection, Overridable, Tooltip } from '@spinnaker/core';
4
4
 
5
5
  import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
6
+ import { AWSProviderSettings } from '../../../aws.settings';
6
7
  import type { IAmazonServerGroupView, IScalingProcess } from '../../../domain';
7
-
8
8
  import { CreateScalingPolicyButton } from '../scalingPolicy/CreateScalingPolicyButton';
9
9
  import { ScalingPolicySummary } from '../scalingPolicy/ScalingPolicySummary';
10
10
  import { AutoScalingProcessService } from '../scalingProcesses/AutoScalingProcessService';
@@ -54,7 +54,7 @@ export class ScalingPoliciesDetailsSection extends React.Component<IAmazonServer
54
54
  {serverGroup.scalingPolicies.map((policy) => (
55
55
  <ScalingPolicySummary key={policy.policyARN} policy={policy} serverGroup={serverGroup} application={app} />
56
56
  ))}
57
- {SETTINGS.awsAdHocInfraWritesEnabled ? (
57
+ {AWSProviderSettings.adHocInfraWritesEnabled ? (
58
58
  <CreateScalingPolicyButton serverGroup={serverGroup} application={app} />
59
59
  ) : (
60
60
  <p>Can not create scaling policy, because ad-hoc operations are disabled for AWS providers.</p>
@@ -1,16 +1,9 @@
1
1
  import React from 'react';
2
2
 
3
- import {
4
- CollapsibleSection,
5
- confirmNotManaged,
6
- HelpField,
7
- ModalInjector,
8
- SETTINGS,
9
- timestamp,
10
- Tooltip,
11
- } from '@spinnaker/core';
3
+ import { CollapsibleSection, confirmNotManaged, HelpField, ModalInjector, timestamp, Tooltip } from '@spinnaker/core';
12
4
 
13
5
  import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
6
+ import { AWSProviderSettings } from '../../../aws.settings';
14
7
  import type { IScalingProcess } from '../../../domain';
15
8
  import { AutoScalingProcessService } from '../scalingProcesses/AutoScalingProcessService';
16
9
 
@@ -109,7 +102,7 @@ export class ScalingProcessesDetailsSection extends React.Component<
109
102
  </li>
110
103
  ))}
111
104
  </ul>
112
- {SETTINGS.awsAdHocInfraWritesEnabled && (
105
+ {AWSProviderSettings.adHocInfraWritesEnabled && (
113
106
  <a className="clickable" onClick={this.toggleScalingProcesses}>
114
107
  Edit Scaling Processes
115
108
  </a>
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
 
3
- import { CollapsibleSection, ModalInjector, SETTINGS, Tooltip } from '@spinnaker/core';
3
+ import { CollapsibleSection, ModalInjector, Tooltip } from '@spinnaker/core';
4
4
 
5
5
  import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
6
+ import { AWSProviderSettings } from '../../../aws.settings';
6
7
  import type { IScalingProcess } from '../../../domain';
7
8
  import { AutoScalingProcessService } from '../scalingProcesses/AutoScalingProcessService';
8
9
  import { ScheduledAction } from '../scheduledAction/ScheduledAction';
@@ -80,7 +81,7 @@ export class ScheduledActionsDetailsSection extends React.Component<
80
81
  </p>
81
82
  )}
82
83
  {serverGroup.scheduledActions.length === 0 && <p>No Scheduled Actions are configured for this server group.</p>}
83
- {SETTINGS.awsAdHocInfraWritesEnabled && (
84
+ {AWSProviderSettings.adHocInfraWritesEnabled && (
84
85
  <a className="clickable" onClick={this.editScheduledActions}>
85
86
  Edit Scheduled Actions
86
87
  </a>
@@ -3,9 +3,10 @@ import { chain, find, sortBy } from 'lodash';
3
3
  import React from 'react';
4
4
 
5
5
  import type { ISecurityGroup, ISecurityGroupsByAccount } from '@spinnaker/core';
6
- import { CollapsibleSection, confirmNotManaged, FirewallLabels, ModalInjector, SETTINGS } from '@spinnaker/core';
6
+ import { CollapsibleSection, confirmNotManaged, FirewallLabels, ModalInjector } from '@spinnaker/core';
7
7
 
8
8
  import type { IAmazonServerGroupDetailsSectionProps } from './IAmazonServerGroupDetailsSectionProps';
9
+ import { AWSProviderSettings } from '../../../aws.settings';
9
10
  import { AwsSecurityGroupReader } from '../../../securityGroup/securityGroup.reader';
10
11
 
11
12
  export interface ISecurityGroupsDetailsSectionState {
@@ -107,7 +108,7 @@ export class SecurityGroupsDetailsSection extends React.Component<
107
108
  </li>
108
109
  ))}
109
110
  </ul>
110
- {SETTINGS.awsAdHocInfraWritesEnabled && serverGroup.vpcId && (
111
+ {AWSProviderSettings.adHocInfraWritesEnabled && serverGroup.vpcId && (
111
112
  <a className="clickable" onClick={this.updateSecurityGroups}>
112
113
  Edit {FirewallLabels.get('Firewalls')}
113
114
  </a>
@@ -1,7 +1,9 @@
1
- import { mock, IQService, IRootScopeService, IScope } from 'angular';
1
+ import type { IQService, IRootScopeService, IScope } from 'angular';
2
+ import { mock } from 'angular';
2
3
 
3
- import { AWS_SERVER_GROUP_TRANSFORMER, AwsServerGroupTransformer } from './serverGroup.transformer';
4
- import { IScalingPolicyAlarmView, IAmazonServerGroup, IStepAdjustment } from '../domain';
4
+ import type { IAmazonServerGroup, IScalingPolicyAlarmView, IStepAdjustment } from '../domain';
5
+ import type { AwsServerGroupTransformer } from './serverGroup.transformer';
6
+ import { AWS_SERVER_GROUP_TRANSFORMER } from './serverGroup.transformer';
5
7
  import { VpcReader } from '../vpc/VpcReader';
6
8
 
7
9
  describe('awsServerGroupTransformer', () => {
@@ -1,10 +1,13 @@
1
- import React from 'react';
2
- import { shallow, render } from 'enzyme';
3
1
  import { mock } from 'angular';
4
- import { SubnetSelectInput } from './SubnetSelectInput';
5
- import { Application, ApplicationModelBuilder } from '@spinnaker/core';
2
+ import { render, shallow } from 'enzyme';
3
+ import React from 'react';
4
+
5
+ import type { Application } from '@spinnaker/core';
6
+ import { ApplicationModelBuilder } from '@spinnaker/core';
6
7
  import { mockServerGroupDataSourceConfig, mockSubnet } from '@spinnaker/mocks';
7
8
 
9
+ import { SubnetSelectInput } from './SubnetSelectInput';
10
+
8
11
  describe('SubnetSelectInput', () => {
9
12
  let application: Application;
10
13
 
@@ -1,16 +1,8 @@
1
- 'use strict';
2
- import { mockHttpClient } from 'core/api/mock/jasmine';
1
+ // eslint-disable-next-line @spinnaker/import-from-npm-not-relative
2
+ import { mockHttpClient } from '../../../core/src/api/mock/jasmine';
3
3
  import { VpcReader } from '../vpc/VpcReader';
4
4
 
5
5
  describe('VpcReader', function () {
6
- var $scope;
7
-
8
- beforeEach(
9
- window.inject(function ($rootScope) {
10
- $scope = $rootScope.$new();
11
- }),
12
- );
13
-
14
6
  afterEach(function () {
15
7
  VpcReader.resetCache();
16
8
  });
@@ -0,0 +1,37 @@
1
+ import { mount } from 'enzyme';
2
+ import React from 'react';
3
+
4
+ import { VpcTag } from './VpcTag';
5
+ import { VpcReader } from '../vpc/VpcReader';
6
+
7
+ const tick = () => new Promise((resolve) => setTimeout(resolve));
8
+
9
+ describe('VpcTag', function () {
10
+ describe('vpc tag rendering - no VPC provided', function () {
11
+ it('displays default message when no vpcId supplied', function () {
12
+ const component = mount(<VpcTag vpcId={undefined} />);
13
+ expect(component.text()).toBe('None (EC2 Classic)');
14
+ });
15
+
16
+ it('displays default message when null vpcId supplied', function () {
17
+ const component = mount(<VpcTag vpcId={null} />);
18
+ expect(component.text()).toBe('None (EC2 Classic)');
19
+ });
20
+ });
21
+
22
+ describe('vpc tag rendering - VPC provided', function () {
23
+ it('displays vpc name when found', async function () {
24
+ spyOn(VpcReader, 'getVpcName').and.returnValue(Promise.resolve('Main VPC'));
25
+ const component = mount(<VpcTag vpcId="vpc-1" />);
26
+ await tick();
27
+ expect(component.text()).toBe('Main VPC (vpc-1)');
28
+ });
29
+
30
+ it('displays vpc id when not found', async function () {
31
+ spyOn(VpcReader, 'getVpcName').and.returnValue(Promise.resolve(null));
32
+ const component = mount(<VpcTag vpcId="vpc-2" />);
33
+ await tick();
34
+ expect(component.text()).toBe('(vpc-2)');
35
+ });
36
+ });
37
+ });
@@ -1,5 +1,9 @@
1
1
  import { module } from 'angular';
2
- import { AMAZON_VPC_VPCTAG_DIRECTIVE } from './vpcTag.directive';
2
+ import { react2angular } from 'react2angular';
3
+
4
+ import { withErrorBoundary } from '@spinnaker/core';
5
+
6
+ import { VpcTag } from './VpcTag';
3
7
 
4
8
  export const VPC_MODULE = 'spinnaker.amazon.vpc';
5
- module(VPC_MODULE, [AMAZON_VPC_VPCTAG_DIRECTIVE]);
9
+ module(VPC_MODULE, []).component('vpcTag', react2angular(withErrorBoundary(VpcTag, 'vpcTag'), ['vpcId']));
@@ -1,11 +0,0 @@
1
- /// <reference types="angular" />
2
- import type React from 'react';
3
- import { ReactInject } from '@spinnaker/core';
4
- import type { IScalingPolicySummaryProps } from '../serverGroup/details/scalingPolicy/ScalingPolicySummary';
5
- import IInjectorService = angular.auto.IInjectorService;
6
- export declare class AwsNgReactInjector extends ReactInject {
7
- $injectorProxy: IInjectorService;
8
- ScalingPolicySummary: React.ComponentClass<IScalingPolicySummaryProps>;
9
- initialize($injector: IInjectorService): void;
10
- }
11
- export declare const AwsNgReact: AwsNgReactInjector;
@@ -1,10 +0,0 @@
1
- export interface IScalingPolicyTypeConfig {
2
- type: string;
3
- summaryTemplateUrl: string;
4
- }
5
- export declare class ScalingPolicyTypeRegistrar {
6
- private policyTypes;
7
- registerPolicyType(policyConfig: IScalingPolicyTypeConfig): void;
8
- getPolicyConfig(policyType: string): IScalingPolicyTypeConfig;
9
- }
10
- export declare const ScalingPolicyTypeRegistry: ScalingPolicyTypeRegistrar;
@@ -1,2 +0,0 @@
1
- export const AMAZON_SERVERGROUP_DETAILS_SCALINGPOLICY_ALARMBASEDSUMMARY_COMPONENT: "spinnaker.amazon.serverGroup.details.scalingPolicy.alarmBasedSummary.component";
2
- export const name: "spinnaker.amazon.serverGroup.details.scalingPolicy.alarmBasedSummary.component";
@@ -1,12 +0,0 @@
1
- import type { IComponentOptions, IController } from 'angular';
2
- import type { Application, IServerGroup } from '@spinnaker/core';
3
- import type { IScalingPolicy } from '../../../domain';
4
- export declare class ScalingPolicyDetailsSummaryController implements IController {
5
- templateUrl: string;
6
- policy: IScalingPolicy;
7
- serverGroup: IServerGroup;
8
- application: Application;
9
- $onInit(): void;
10
- }
11
- export declare const scalingPolicyDetailsSummary: IComponentOptions;
12
- export declare const DETAILS_SUMMARY = "spinnaker.amazon.scalingPolicy.details.summary.component";
@@ -1 +0,0 @@
1
- export declare const SCALING_POLICY_POPOVER = "spinnaker.amazon.serverGroup.details.scalingPolicy.popover.component";
@@ -1 +0,0 @@
1
- export declare const STEP_POLICY_SUMMARY_COMPONENT = "spinnaker.amazon.scalingPolicy.stepPolicySummary.component";
@@ -1,2 +0,0 @@
1
- import './TargetTrackingPolicy.config';
2
- export declare const TARGET_TRACKING_MODULE = "spinnaker.amazon.scalingPolicy.targetTracking";
@@ -1 +0,0 @@
1
- export declare const TARGET_TRACKING_CHART_COMPONENT = "spinnaker.amazon.scalingPolicy.targetTracking.chart.component";
@@ -1 +0,0 @@
1
- export declare const TARGET_TRACKING_SUMMARY_COMPONENT = "spinnaker.amazon.scalingPolicy.targetTracking.summary.component";
@@ -1,2 +0,0 @@
1
- export const AMAZON_VPC_VPCTAG_DIRECTIVE: "spinnaker.amazon.vpc.tag.directive";
2
- export const name: "spinnaker.amazon.vpc.tag.directive";
@@ -1,123 +0,0 @@
1
- 'use strict';
2
- import { mockHttpClient } from 'core/api/mock/jasmine';
3
- import { AwsImageReader } from './image.reader';
4
-
5
- describe('Service: aws Image Reader', function () {
6
- var service, scope;
7
-
8
- beforeEach(
9
- window.inject(function ($rootScope) {
10
- service = new AwsImageReader();
11
- scope = $rootScope.$new();
12
- }),
13
- );
14
-
15
- describe('findImages', function () {
16
- var query = 'abc',
17
- region = 'us-west-1';
18
-
19
- const buildQueryString = () => `/images/find?provider=aws&q=${query}&region=${region}`;
20
-
21
- it('queries gate when 3 characters are supplied', async function () {
22
- const http = mockHttpClient();
23
- var result = null;
24
-
25
- http.expectGET(buildQueryString()).respond(200, [{ success: true }]);
26
-
27
- service.findImages({ provider: 'aws', q: query, region: region }).then(function (results) {
28
- result = results;
29
- });
30
-
31
- await http.flush();
32
-
33
- expect(result.length).toBe(1);
34
- expect(result[0].success).toBe(true);
35
- });
36
-
37
- it('queries gate when more than 3 characters are supplied', async function () {
38
- const http = mockHttpClient();
39
- var result = null;
40
-
41
- query = 'abcd';
42
-
43
- http.expectGET(buildQueryString()).respond(200, [{ success: true }]);
44
-
45
- var promise = service.findImages({ provider: 'aws', q: query, region: region });
46
-
47
- promise.then(function (results) {
48
- result = results;
49
- });
50
-
51
- await http.flush();
52
-
53
- expect(result.length).toBe(1);
54
- expect(result[0].success).toBe(true);
55
- });
56
-
57
- it('returns a message prompting user to enter more characters when less than 3 are supplied', function () {
58
- query = 'ab';
59
-
60
- var result = null;
61
-
62
- service.findImages({ provider: 'aws', q: query, region: region }).then(function (results) {
63
- result = results;
64
- });
65
-
66
- scope.$digest();
67
-
68
- expect(result.length).toBe(1);
69
- expect(result[0].message).toBe('Please enter at least 3 characters...');
70
- });
71
-
72
- it('returns an empty array when server errors', async function () {
73
- const http = mockHttpClient();
74
- query = 'abc';
75
- var result = null;
76
-
77
- http.expectGET(buildQueryString()).respond(404, {});
78
-
79
- service.findImages({ provider: 'aws', q: query, region: region }).then(function (results) {
80
- result = results;
81
- });
82
-
83
- await http.flush();
84
-
85
- expect(result.length).toBe(0);
86
- });
87
- });
88
-
89
- describe('getImage', function () {
90
- var imageName = 'abc',
91
- region = 'us-west-1',
92
- credentials = 'test';
93
-
94
- const buildQueryString = () => `/images/${credentials}/${region}/${imageName}?provider=aws`;
95
-
96
- it('returns null if server returns 404 or an empty list', async function () {
97
- const http = mockHttpClient();
98
- var result = 'not null';
99
-
100
- http.expectGET(buildQueryString()).respond(404, {});
101
-
102
- service.getImage(imageName, region, credentials).then(function (results) {
103
- result = results;
104
- });
105
-
106
- await http.flush();
107
-
108
- expect(result).toBe(null);
109
-
110
- result = 'not null';
111
-
112
- http.expectGET(buildQueryString()).respond(200, []);
113
-
114
- service.getImage(imageName, region, credentials).then(function (results) {
115
- result = results;
116
- });
117
-
118
- await http.flush();
119
-
120
- expect(result).toBe(null);
121
- });
122
- });
123
- });