diff --git a/packages/kubernetes/src/kubernetes.module.ts b/packages/kubernetes/src/kubernetes.module.ts index 59cb58ef250..e9c436f5110 100644 --- a/packages/kubernetes/src/kubernetes.module.ts +++ b/packages/kubernetes/src/kubernetes.module.ts @@ -32,7 +32,6 @@ import { KUBERNETES_MANIFEST_STATUS } from './manifest/status/status.component'; import { ManifestWizard } from './manifest/wizard/ManifestWizard'; import './pipelines/stages'; import { KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE } from './pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage'; -import { KUBERNETES_SCALE_MANIFEST_STAGE } from './pipelines/stages/scaleManifest/scaleManifestStage'; import { KUBERNETES_DISABLE_MANIFEST_STAGE } from './pipelines/stages/traffic/disableManifest.stage'; import { KUBERNETES_ENABLE_MANIFEST_STAGE } from './pipelines/stages/traffic/enableManifest.stage'; import { KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE } from './pipelines/stages/undoRolloutManifest/undoRolloutManifestStage'; @@ -73,7 +72,6 @@ const requires = [ KUBERNETES_MANIFEST_ARTIFACT, KUBERNETES_LOAD_BALANCER_TRANSFORMER, KUBERNETES_SECURITY_GROUP_TRANSFORMER, - KUBERNETES_SCALE_MANIFEST_STAGE, KUBERNETES_UNDO_ROLLOUT_MANIFEST_STAGE, KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE, KUBERNETES_MANIFEST_SELECTOR, diff --git a/packages/kubernetes/src/manifest/scale/ScaleSettingsForm.tsx b/packages/kubernetes/src/manifest/scale/ScaleSettingsForm.tsx new file mode 100644 index 00000000000..11daa37937b --- /dev/null +++ b/packages/kubernetes/src/manifest/scale/ScaleSettingsForm.tsx @@ -0,0 +1,43 @@ +import React, { useState } from 'react'; +import { NumberInput, StageConfigField } from '@spinnaker/core'; +import type { IScaleCommand } from './scale.controller'; + +export interface IScaleSettingsFormProps { + options: IScaleCommand; + onChange(options: IScaleCommand): void; +} + +export interface IScaleSettingsFormState { + options: IScaleCommand; +} + +export function ScaleSettingsForm({ options, onChange }: IScaleSettingsFormProps) { + const [state, setState] = useState({ + options: options, + }); + + const updateReplicas = (newReplicas: number) => { + state.options.replicas = newReplicas; + if (onChange) { + onChange(state.options); + } + setState({ options: state.options }); + }; + + return ( +
+ +
+ ) => { + updateReplicas(e.target.valueAsNumber); + }} + value={options.replicas} + min={0} + /> +
+
+
+ ); +} diff --git a/packages/kubernetes/src/manifest/scale/scale.controller.ts b/packages/kubernetes/src/manifest/scale/scale.controller.ts index 1530e293391..96a36409c94 100644 --- a/packages/kubernetes/src/manifest/scale/scale.controller.ts +++ b/packages/kubernetes/src/manifest/scale/scale.controller.ts @@ -1,4 +1,4 @@ -import type { IController } from 'angular'; +import type { IController, IScope } from 'angular'; import { copy, module } from 'angular'; import type { IModalServiceInstance } from 'angular-ui-bootstrap'; @@ -7,7 +7,7 @@ import { ManifestWriter, TaskMonitor } from '@spinnaker/core'; import type { IManifestCoordinates } from '../IManifestCoordinates'; import { KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM } from './scaleSettingsForm.component'; -interface IScaleCommand { +export interface IScaleCommand { manifestName: string; location: string; account: string; @@ -17,13 +17,13 @@ interface IScaleCommand { class KubernetesManifestScaleController implements IController { public taskMonitor: TaskMonitor; - public command: IScaleCommand; public verification = { verified: false, }; - public static $inject = ['coordinates', 'currentReplicas', '$uibModalInstance', 'application']; + public static $inject = ['$scope', 'coordinates', 'currentReplicas', '$uibModalInstance', 'application']; constructor( + private $scope: IScope, coordinates: IManifestCoordinates, currentReplicas: number, private $uibModalInstance: IModalServiceInstance, @@ -35,13 +35,18 @@ class KubernetesManifestScaleController implements IController { modalInstance: $uibModalInstance, }); - this.command = { + this.$scope.command = { manifestName: coordinates.name, location: coordinates.namespace, account: coordinates.account, reason: null, replicas: currentReplicas, }; + + // used by react components to update command fields in parent (angular) scope + this.$scope.onChange = () => { + this.$scope.$applyAsync(); + }; } public isValid(): boolean { @@ -54,7 +59,7 @@ class KubernetesManifestScaleController implements IController { public scale(): void { this.taskMonitor.submit(() => { - const payload = copy(this.command) as any; + const payload = copy(this.$scope.command) as any; payload.cloudProvider = 'kubernetes'; return ManifestWriter.scaleManifest(payload, this.application); diff --git a/packages/kubernetes/src/manifest/scale/scale.html b/packages/kubernetes/src/manifest/scale/scale.html index 0e0d08c0b2b..674bdb70626 100644 --- a/packages/kubernetes/src/manifest/scale/scale.html +++ b/packages/kubernetes/src/manifest/scale/scale.html @@ -3,14 +3,19 @@