diff --git a/src/app/frontend/replicationcontrollerdetail/updatereplicas.html b/src/app/frontend/replicationcontrollerdetail/updatereplicas.html index 025e11017541..4899ad7f96b8 100644 --- a/src/app/frontend/replicationcontrollerdetail/updatereplicas.html +++ b/src/app/frontend/replicationcontrollerdetail/updatereplicas.html @@ -18,16 +18,21 @@

Set desired number of pods

- Replication controller {{ctrl.replicationController}} will be updated to reflect the desired count.
+ Replication controller {{ctrl.replicationController}} will be updated to reflect the desired + count.
- Current status: {{ctrl.currentPods}} - created, {{ctrl.desiredPods}} desired + Current status: {{ctrl.currentPods}} created, {{ctrl.desiredPods}} desired
-
+ - + + + Number of pods is required. + Must be a positive integer. + Cancel diff --git a/src/app/frontend/replicationcontrollerdetail/updatereplicas_controller.js b/src/app/frontend/replicationcontrollerdetail/updatereplicas_controller.js index 110ce4344b6f..b189729a01bd 100644 --- a/src/app/frontend/replicationcontrollerdetail/updatereplicas_controller.js +++ b/src/app/frontend/replicationcontrollerdetail/updatereplicas_controller.js @@ -61,6 +61,9 @@ export default class UpdateReplicasDialogController { /** @private {!angular.$resource} */ this.resource_ = $resource; + + /** @export {!angular.FormController} Initialized from the template */ + this.updateReplicasForm; } /** @@ -69,17 +72,19 @@ export default class UpdateReplicasDialogController { * @export */ updateReplicas() { - let resource = getReplicationControllerSpecPodsResource( - new StateParams(this.namespace_, this.replicationController), this.resource_); - - /** @type {!backendApi.ReplicationControllerSpec} */ - let replicationControllerSpec = { - replicas: this.replicas, - }; - - resource.save( - replicationControllerSpec, this.onUpdateReplicasSuccess_.bind(this), - this.onUpdateReplicasError_.bind(this)); + if (this.updateReplicasForm.$valid) { + let resource = getReplicationControllerSpecPodsResource( + new StateParams(this.namespace_, this.replicationController), this.resource_); + + /** @type {!backendApi.ReplicationControllerSpec} */ + let replicationControllerSpec = { + replicas: this.replicas, + }; + + resource.save( + replicationControllerSpec, this.onUpdateReplicasSuccess_.bind(this), + this.onUpdateReplicasError_.bind(this)); + } } /** diff --git a/src/test/frontend/replicationcontrollerdetail/updatereplicas_controller_test.js b/src/test/frontend/replicationcontrollerdetail/updatereplicas_controller_test.js index cfdd88ea8ea0..dea7883aa8fd 100644 --- a/src/test/frontend/replicationcontrollerdetail/updatereplicas_controller_test.js +++ b/src/test/frontend/replicationcontrollerdetail/updatereplicas_controller_test.js @@ -47,13 +47,15 @@ describe('Update Replicas controller', () => { httpBackend = $httpBackend; log = $log; - ctrl = $controller(UpdateReplicasDialogController, { - $resource: resource, - namespace: namespaceMock, - replicationController: replicationControllerMock, - currentPods: 1, - desiredPods: 1, - }); + ctrl = $controller( + UpdateReplicasDialogController, { + $resource: resource, + namespace: namespaceMock, + replicationController: replicationControllerMock, + currentPods: 1, + desiredPods: 1, + }, + {updateReplicasForm: {$valid: true}}); }); });