diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html index ddf4b08ac418c894d7edcd8e1d2d0193713fb2d3..353415cbe9a2b84de3e10d4792df178b081c9c28 100644 --- a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.html @@ -15,10 +15,12 @@ limitations under the License. --> -
+
-
+
arrow_back @@ -27,103 +29,20 @@ limitations under the License.
-
-
- - delete - DELETE REPLICATION CONTROLLER - -
- - Replication controller - -
- Name - - {{::ctrl.replicationControllerDetail.name}} - - Namespace - - {{::ctrl.replicationControllerDetail.namespace}} - -
-
- Pods - - {{::ctrl.replicationControllerDetail.podInfo.current}} created, - {{::ctrl.replicationControllerDetail.podInfo.desired}} desired - - - {{::ctrl.replicationControllerDetail.podInfo.running}} running - -
-
- - - mode_edit - - -
-
-
- Pods status - - - {{::ctrl.replicationControllerDetail.podInfo.pending}} pending - - {{::ctrl.replicationControllerDetail.podInfo.failed}} failed - - {{::ctrl.replicationControllerDetail.podInfo.running}} running - - -
- Label selector - - - - Labels - - - - Images - - {{image}} - -
- Services -
- Name - - {{::service.name}} - - Label selector - - - - Internal endpoint -
-
- -
- none -
- External endpoint -
-
- -
- - none - -
-
-
-
+ + +
+
+
+
+ + arrow_back + +

+ {{::ctrl.replicationControllerDetail.name}} +

@@ -134,15 +53,13 @@ limitations under the License. + currently-selected-order="ctrl.podsOrder" column-name="name"> Pod Status @@ -157,38 +74,37 @@ limitations under the License. + currently-selected-order="ctrl.podsOrder" column-name="startTime" + tooltip="Time the pod was last started"> Age + currently-selected-order="ctrl.podsOrder" column-name="cpu" + tooltip="CPU used by the pod"> CPU + currently-selected-order="ctrl.podsOrder" column-name="memory" + tooltip="Memory used by the pod"> Memory + currently-selected-order="ctrl.podsOrder" column-name="podIP" + tooltip="IP adress of the pod in the cluster"> Cluster IP Node @@ -221,7 +137,8 @@ limitations under the License. - - + {{::(pod.metrics.cpuUsage | kdCores)}} @@ -229,7 +146,8 @@ limitations under the License. - - + {{::(pod.metrics.memoryUsage | kdMemory)}} @@ -281,13 +199,13 @@ limitations under the License.
- +
@@ -301,31 +219,27 @@ limitations under the License.
+ currently-selected-order="ctrl.eventsOrder" column-name="message"> Message + currently-selected-order="ctrl.eventsOrder" column-name="object"> Sub-object + column-name="count" tooltip="Number of times the event occurred"> Count First seen Last seen @@ -353,16 +267,22 @@ limitations under the License.
- -
- info_outline -
No events were found
- - There are no events to display. It's possible that all of them have expired. - Learn more - -
+
+ + info_outline + +
No events were found
+ + There are no events to display. It's possible that all of them have expired. + Learn more + +
- - + + + + + + +
diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.scss b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.scss index c66610e857589fdcf0e235bb524c502cfdccb243..5c7ac91e63d9244b285ba83be16b618f5315845f 100644 --- a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.scss +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail.scss @@ -48,34 +48,6 @@ $table-cell-height-half: $table-cell-height / 2; border-bottom: 1px solid $foreground-4; } -.kd-replicationcontrollerdetail-sidebar-title { - font-size: $subhead-font-size-base; - font-weight: $bold-font-weight; - padding-bottom: $baseline-grid; - padding-top: $baseline-grid; -} - -.kd-replicationcontrollerdetail-sidebar-line { - color: $foreground-2; - display: block; - font-size: $body-font-size-base; - padding-bottom: 0; -} - -.kd-replicationcontrollerdetail-sidebar-subline { - color: $foreground-1; - display: block; - font-size: $body-font-size-base; - overflow: hidden; - padding-bottom: $baseline-grid; - text-overflow: ellipsis; - - &.kd-has-labels { - // To offset for labels margin. - margin-bottom: -$baseline-grid / 2; - } -} - .kd-replicationcontrollerdetail-warning-icon { color: $warning; font-size: $table-cell-height-half; @@ -87,11 +59,6 @@ $table-cell-height-half: $table-cell-height / 2; margin: 2 * $baseline-grid; } -.kd-replicationcontrollerdetail-sidebar-info { - // 6px needed to offset for md-button padding. - padding-left: $baseline-grid + 6px; -} - .kd-replicationcontrollerdetail-option-picker { padding-right: 2 * $baseline-grid; width: 15 * $baseline-grid; @@ -131,7 +98,7 @@ $table-cell-height-half: $table-cell-height / 2; } .kd-replicationcontrollerdetail-no-events { - margin-top: 4 * $baseline-grid; + margin: (4 * $baseline-grid) 0 (4 * $baseline-grid); text-align: center; } diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller.js b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller.js index 252398e92ad932e90d8889d9fbc7f69bcc56cd21..8360de7995a38cb1a53cd5ee6067ca1996c6c5e9 100644 --- a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller.js +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller.js @@ -13,9 +13,6 @@ // limitations under the License. import {UPWARDS, DOWNWARDS} from 'replicationcontrollerdetail/sortedheader_controller'; -import { - stateName as replicationcontrollers, -} from 'replicationcontrollerlist/replicationcontrollerlist_state'; import {stateName as logsStateName} from 'logs/logs_state'; import {StateParams as LogsStateParams} from 'logs/logs_state'; @@ -32,6 +29,7 @@ const EVENT_SOURCE_SYSTEM = 'System'; */ export default class ReplicationControllerDetailController { /** + * @param {function(string):boolean} $mdMedia Angular Material $mdMedia service * @param {!md.$dialog} $mdDialog * @param {!./replicationcontrollerdetail_state.StateParams} $stateParams * @param {!ui.router.$state} $state @@ -39,13 +37,14 @@ export default class ReplicationControllerDetailController { * @param {!angular.$log} $log * @param {!backendApi.ReplicationControllerDetail} replicationControllerDetail * @param {!backendApi.Events} replicationControllerEvents - * @param {!./replicationcontroller_service.ReplicationControllerService} - * kdReplicationControllerService * @ngInject */ constructor( - $mdDialog, $stateParams, $state, $resource, $log, replicationControllerDetail, - replicationControllerEvents, kdReplicationControllerService) { + $mdMedia, $mdDialog, $stateParams, $state, $resource, $log, replicationControllerDetail, + replicationControllerEvents) { + /** @export {function(string):boolean} */ + this.mdMedia = $mdMedia; + /** @export {!backendApi.ReplicationControllerDetail} */ this.replicationControllerDetail = replicationControllerDetail; @@ -82,9 +81,6 @@ export default class ReplicationControllerDetailController { /** @private {!angular.$log} */ this.log_ = $log; - /** @private {!./replicationcontroller_service.ReplicationControllerService} */ - this.kdReplicationControllerService_ = kdReplicationControllerService; - /** * Name of column, that will be used for pods sorting. * @export {string} @@ -110,6 +106,13 @@ export default class ReplicationControllerDetailController { this.eventsOrder = DOWNWARDS; } + /** + * Returns true if sidebar is visible, false if it is hidden. + * @returns {boolean} + * @export + */ + isSidebarVisible() { return this.mdMedia('gt-sm'); } + /** * Returns true if event is a warning. * @param {!backendApi.Event} event @@ -181,36 +184,6 @@ export default class ReplicationControllerDetailController { } } - /** - * @return {boolean} - * @export - */ - areDesiredPodsRunning() { - return this.replicationControllerDetail.podInfo.running === - this.replicationControllerDetail.podInfo.desired; - } - - /** - * Handles update of replicas count in replication controller dialog. - * @export - */ - handleUpdateReplicasDialog() { - this.kdReplicationControllerService_.showUpdateReplicasDialog( - this.replicationControllerDetail.namespace, this.replicationControllerDetail.name, - this.replicationControllerDetail.podInfo.current, - this.replicationControllerDetail.podInfo.desired); - } - - /** - * Handles replication controller delete dialog. - * @export - */ - handleDeleteReplicationControllerDialog() { - this.kdReplicationControllerService_ - .showDeleteDialog(this.stateParams_.namespace, this.stateParams_.replicationController) - .then(this.onReplicationControllerDeleteSuccess_.bind(this)); - } - /** * @param {!backendApi.ReplicationControllerPod} pod * @return {boolean} @@ -228,20 +201,4 @@ export default class ReplicationControllerDetailController { hasMemoryUsage(pod) { return !!pod.metrics && (!!pod.metrics.memoryUsage || pod.metrics.memoryUsage === 0); } - - /** - * Callbacks used after clicking dialog confirmation button in order to delete replication - * controller - * or log unsuccessful operation error. - */ - - /** - * Changes state back to replication controller list after successful deletion of replication - * controller. - * @private - */ - onReplicationControllerDeleteSuccess_() { - this.log_.info('Replication controller successfully deleted.'); - this.state_.go(replicationcontrollers); - } } diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_module.js b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_module.js index f54a10f0616b9ebf17db9953d42c61bd9e7a3ccf..5c6404d5a8ff82099f6dac13dcbaa16cae192864 100644 --- a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_module.js +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerdetail_module.js @@ -15,6 +15,7 @@ import componentsModule from './../common/components/components_module'; import filtersModule from 'common/filters/filters_module'; import logsModule from 'logs/logs_module'; +import replicationControllerInfo from './replicationcontrollerinfo_directive'; import serviceEndpointDirective from './serviceendpoint_directive'; import stateConfig from './replicationcontrollerdetail_stateconfig'; import sortedHeaderDirective from './sortedheader_directive'; @@ -37,6 +38,7 @@ export default angular logsModule.name, ]) .config(stateConfig) + .directive('kdReplicationControllerInfo', replicationControllerInfo) .directive('kdServiceEndpoint', serviceEndpointDirective) .directive('kdSortedHeader', sortedHeaderDirective) .service('kdReplicationControllerService', ReplicationControllerService); diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo.html b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo.html new file mode 100644 index 0000000000000000000000000000000000000000..479c4267549fb08debd173572fdde559a2aa098e --- /dev/null +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo.html @@ -0,0 +1,115 @@ + + +
+ + delete + DELETE REPLICATION CONTROLLER + +
+
+
+ + Replication controller + + Name + + {{infoCtrl.details.name}} + + Namespace + + {{::infoCtrl.details.namespace}} + +
+
+ Pods + + {{::infoCtrl.details.podInfo.current}} created, + {{::infoCtrl.details.podInfo.desired}} desired + + + {{::infoCtrl.details.running}} running + +
+
+ + + mode_edit + + +
+
+
+ Pods status + + + {{::infoCtrl.details.podInfo.pending}} pending + + {{::infoCtrl.details.podInfo.failed}} failed + + {{::infoCtrl.details.podInfo.running}} running + + +
+ Label selector + + + + Labels + + + + Images + + {{image}} + +
+
+
+ Services +
+ Name + + {{::service.name}} + + Label selector + + + + Internal endpoint +
+
+ +
+ none +
+ External endpoint +
+
+ +
+ + none + +
+
+
+
+
diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo.scss b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo.scss new file mode 100644 index 0000000000000000000000000000000000000000..69b616407a67c813ab8f6de746b3d950d200c8cc --- /dev/null +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo.scss @@ -0,0 +1,53 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +@import '../variables'; + +.kd-replicationcontrollerinfo-item { + padding-left: 2 * $baseline-grid; + padding-right: $baseline-grid; +} + +.kd-replicationcontrollerinfo-title { + font-size: $subhead-font-size-base; + font-weight: $bold-font-weight; + padding-bottom: $baseline-grid; + padding-top: $baseline-grid; +} + +.kd-replicationcontrollerinfo-line { + color: $foreground-2; + display: block; + font-size: $body-font-size-base; + padding-bottom: 0; +} + +.kd-replicationcontrollerinfo-subline { + color: $foreground-1; + display: block; + font-size: $body-font-size-base; + overflow: hidden; + padding-bottom: $baseline-grid; + text-overflow: ellipsis; + + &.kd-has-labels { + // To offset for labels margin. + margin-bottom: -$baseline-grid / 2; + } +} + +.kd-replicationcontrollerinfo-info { + // 6px needed to offset for md-button padding. + padding-left: $baseline-grid + 6px; +} diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo_controller.js b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo_controller.js new file mode 100644 index 0000000000000000000000000000000000000000..bbca39509ab081ce6ac74dd10194f3198e8d4d02 --- /dev/null +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo_controller.js @@ -0,0 +1,93 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { + stateName as replicationcontrollers, +} from 'replicationcontrollerlist/replicationcontrollerlist_state'; + +/** + * Controller for the replication controller info directive. + * @final + */ +export default class ReplicationControllerInfoController { + /** + * @param {!./replicationcontrollerdetail_state.StateParams} $stateParams + * @param {!ui.router.$state} $state + * @param {!angular.$log} $log + * @param {!./replicationcontroller_service.ReplicationControllerService} + * kdReplicationControllerService + * + * @ngInject + */ + constructor($stateParams, $state, $log, kdReplicationControllerService) { + /** @private {!./replicationcontrollerdetail_state.StateParams} */ + this.stateParams_ = $stateParams; + + /** @private {!./replicationcontroller_service.ReplicationControllerService} */ + this.kdReplicationControllerService_ = kdReplicationControllerService; + + /** @private {!ui.router.$state} */ + this.state_ = $state; + + /** @private {!angular.$log} */ + this.log_ = $log; + + /** + * Replication controller details. Initialized from the scope. + * @export {!backendApi.ReplicationControllerDetail} + */ + this.details; + } + + /** + * @return {boolean} + * @export + */ + areDesiredPodsRunning() { return this.details.podInfo.running === this.details.podInfo.desired; } + + /** + * Handles update of replicas count in replication controller dialog. + * @export + */ + handleUpdateReplicasDialog() { + this.kdReplicationControllerService_.showUpdateReplicasDialog( + this.details.namespace, this.details.name, this.details.podInfo.current, + this.details.podInfo.desired); + } + + /** + * Handles replication controller delete dialog. + * @export + */ + handleDeleteReplicationControllerDialog() { + this.kdReplicationControllerService_ + .showDeleteDialog(this.stateParams_.namespace, this.stateParams_.replicationController) + .then(this.onReplicationControllerDeleteSuccess_.bind(this)); + } + + /** + * Callbacks used after clicking dialog confirmation button in order to delete replication + * controller or log unsuccessful operation error. + */ + + /** + * Changes state back to replication controller list after successful deletion of replication + * controller. + * @private + */ + onReplicationControllerDeleteSuccess_() { + this.log_.info('Replication controller successfully deleted.'); + this.state_.go(replicationcontrollers); + } +} diff --git a/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo_directive.js b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo_directive.js new file mode 100644 index 0000000000000000000000000000000000000000..5a31753db0b5b97913586bb88f9685e5b7b67626 --- /dev/null +++ b/src/app/frontend/replicationcontrollerdetail/replicationcontrollerinfo_directive.js @@ -0,0 +1,31 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ReplicationControllerInfoController from 'replicationcontrollerdetail/replicationcontrollerinfo_controller'; + +/** + * Returns directive definition object for the component that displays replication controller info. + * @return {!angular.Directive} + */ +export default function replicationControllerInfoDirective() { + return { + controller: ReplicationControllerInfoController, + controllerAs: 'infoCtrl', + templateUrl: 'replicationcontrollerdetail/replicationcontrollerinfo.html', + scope: {}, + bindToController: { + 'details': '=', + }, + }; +} diff --git a/src/test/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller_test.js b/src/test/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller_test.js index 5a5f3ff0ef0284a34470ef5753e629ea9642f56d..0446bd3a511b8cb528f43aab2194b5811f06defd 100644 --- a/src/test/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller_test.js +++ b/src/test/frontend/replicationcontrollerdetail/replicationcontrollerdetail_controller_test.js @@ -21,18 +21,11 @@ describe('Replication Controller Detail controller', () => { * @type {!ReplicationControllerDetailController} */ let ctrl; - /** @type - * {!replicationcontrollerdetail/replicationcontroller_service.ReplicationControllerService} */ - let kdReplicationControllerService; - /** @type {!angular.$q} */ - let q; beforeEach(() => { angular.mock.module(replicationControllerDetailModule.name); - angular.mock.inject(($controller, $resource, $q, _kdReplicationControllerService_) => { - q = $q; - kdReplicationControllerService = _kdReplicationControllerService_; + angular.mock.inject(($controller, $resource) => { ctrl = $controller(ReplicationControllerDetailController, { replicationControllerDetail: {}, replicationControllerEvents: {}, @@ -90,43 +83,12 @@ describe('Replication Controller Detail controller', () => { expect(result.length).toEqual(1); }); - it('should show edit replicas dialog', () => { - // given - ctrl.replicationControllerDetail = { - namespace: 'foo-namespace', - name: 'foo-name', - podInfo: { - current: 3, - desired: 3, - }, - }; - spyOn(kdReplicationControllerService, 'showUpdateReplicasDialog'); - - // when - ctrl.handleUpdateReplicasDialog(); - - // then - expect(kdReplicationControllerService.showUpdateReplicasDialog).toHaveBeenCalled(); - }); - it('should create logs href', () => { expect(ctrl.getPodLogsHref({ name: 'foo-pod', })).toBe('#/logs/foo-namespace/foo-replicationcontroller/foo-pod/'); }); - it('should show delete replicas dialog', () => { - // given - let deferred = q.defer(); - spyOn(kdReplicationControllerService, 'showDeleteDialog').and.returnValue(deferred.promise); - - // when - ctrl.handleDeleteReplicationControllerDialog(); - - // then - expect(kdReplicationControllerService.showDeleteDialog).toHaveBeenCalled(); - }); - it('should return true when there are events to display', () => { // given ctrl.events = ["Some event"]; @@ -146,32 +108,6 @@ describe('Replication Controller Detail controller', () => { expect(result).toBeFalsy(); }); - it('should return true when all desired pods are running', () => { - // given - ctrl.replicationControllerDetail = { - podInfo: { - running: 0, - desired: 0, - }, - }; - - // then - expect(ctrl.areDesiredPodsRunning()).toBeTruthy(); - }); - - it('should return false when not all desired pods are running', () => { - // given - ctrl.replicationControllerDetail = { - podInfo: { - running: 0, - desired: 1, - }, - }; - - // then - expect(ctrl.areDesiredPodsRunning()).toBeFalsy(); - }); - it('should show/hide cpu and memory metrics for pods', () => { expect(ctrl.hasMemoryUsage({})).toBe(false); expect(ctrl.hasMemoryUsage({metrics: {}})).toBe(false); diff --git a/src/test/frontend/replicationcontrollerdetail/replicationcontrollerinfo_controller_test.js b/src/test/frontend/replicationcontrollerdetail/replicationcontrollerinfo_controller_test.js new file mode 100644 index 0000000000000000000000000000000000000000..710ad90f05a164d3ce0587bb0c6e87527e1087ad --- /dev/null +++ b/src/test/frontend/replicationcontrollerdetail/replicationcontrollerinfo_controller_test.js @@ -0,0 +1,125 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ReplicationControllerInfoController from 'replicationcontrollerdetail/replicationcontrollerinfo_controller'; +import replicationControllerDetailModule from 'replicationcontrollerdetail/replicationcontrollerdetail_module'; +import { + stateName as replicationcontrollers, +} from 'replicationcontrollerlist/replicationcontrollerlist_state'; + +describe('Replication Controller Detail controller', () => { + /** + * Replication Controller Detail controller. + * @type {!ReplicationControllerDetailController} + */ + let ctrl; + /** @type + * {!replicationcontrollerdetail/replicationcontroller_service.ReplicationControllerService} */ + let kdReplicationControllerService; + /** @type {!angular.$q} */ + let q; + /** @type {!ui.router.$state} */ + let state; + /** @type {!angular.$log} */ + let log; + + beforeEach(() => { + angular.mock.module(replicationControllerDetailModule.name); + + angular.mock.inject( + ($controller, $state, $log, $resource, $q, _kdReplicationControllerService_) => { + q = $q; + state = $state; + log = $log; + kdReplicationControllerService = _kdReplicationControllerService_; + ctrl = $controller(ReplicationControllerInfoController, { + replicationControllerDetail: {}, + replicationControllerEvents: {}, + replicationControllerDetailResource: $resource('/foo'), + replicationControllerSpecPodsResource: $resource('/bar'), + }); + }); + }); + + it('should show edit replicas dialog', () => { + // given + ctrl.details = { + namespace: 'foo-namespace', + name: 'foo-name', + podInfo: { + current: 3, + desired: 3, + }, + }; + spyOn(kdReplicationControllerService, 'showUpdateReplicasDialog'); + + // when + ctrl.handleUpdateReplicasDialog(); + + // then + expect(kdReplicationControllerService.showUpdateReplicasDialog).toHaveBeenCalled(); + }); + + it('should show delete replicas dialog', () => { + // given + let deferred = q.defer(); + spyOn(kdReplicationControllerService, 'showDeleteDialog').and.returnValue(deferred.promise); + + // when + ctrl.handleDeleteReplicationControllerDialog(); + + // then + expect(kdReplicationControllerService.showDeleteDialog).toHaveBeenCalled(); + }); + + it('should return true when all desired pods are running', () => { + // given + ctrl.details = { + podInfo: { + running: 0, + desired: 0, + }, + }; + + // then + expect(ctrl.areDesiredPodsRunning()).toBeTruthy(); + }); + + it('should return false when not all desired pods are running', () => { + // given + ctrl.details = { + podInfo: { + running: 0, + desired: 1, + }, + }; + + // then + expect(ctrl.areDesiredPodsRunning()).toBeFalsy(); + }); + + it('should change state to replication controller and log on delete success', () => { + // given + spyOn(state, 'go'); + spyOn(log, 'info'); + + // when + ctrl.onReplicationControllerDeleteSuccess_(); + + // then + expect(state.go).toHaveBeenCalledWith(replicationcontrollers); + expect(log.info).toHaveBeenCalledWith('Replication controller successfully deleted.'); + }); + +});