Merge "Show certificates step only for secure listener"

This commit is contained in:
Zuul 2018-01-22 18:26:43 +00:00 committed by Gerrit Code Review
commit e4395f7bd6
5 changed files with 60 additions and 4 deletions

View File

@ -40,6 +40,8 @@
var ctrl = this;
$('#wizard-side-nav ul li:last').hide();
ctrl.tableData = {
available: $scope.model.certificates,
allocated: $scope.model.spec.certificates,

View File

@ -66,6 +66,12 @@
members.forEach(function setMemberPort(member) {
member.port = { HTTP: 80, TERMINATED_HTTPS: 80 }[protocol];
});
if (protocol === 'TERMINATED_HTTPS') {
$('#wizard-side-nav ul li:last').show();
} else {
$('#wizard-side-nav ul li:last').hide();
}
}
function listenerPortExists(port) {

View File

@ -583,6 +583,7 @@
});
});
model.visibleResources.push('certificates');
$('#wizard-side-nav ul li:last').show();
}
}

View File

@ -21,7 +21,9 @@
.controller('MonitorDetailsController', MonitorDetailsController);
MonitorDetailsController.$inject = [
'$scope',
'horizon.dashboard.project.lbaasv2.patterns',
'horizon.framework.widgets.wizard.events',
'horizon.framework.util.i18n.gettext'
];
@ -31,15 +33,28 @@
* @description
* The `MonitorDetailsController` controller provides functions for
* configuring the health monitor step of the LBaaS wizard.
* @param $scope The angular scope object.
* @param patterns The LBaaS v2 patterns constant.
* @param wizardEvents The horizon wizard events.
* @param gettext The horizon gettext function for translation.
* @returns undefined
*/
function MonitorDetailsController(patterns, gettext) {
function MonitorDetailsController($scope, patterns, wizardEvents, gettext) {
var ctrl = this;
$scope.$on(wizardEvents.ON_SWITCH, function(event, args) {
var nextButtonSelector = "div.modal-footer button:nth-last-of-type(2)";
if (args.to === $scope.$index) {
if ($scope.model.spec.listener.protocol !== 'TERMINATED_HTTPS') {
$(nextButtonSelector).attr("disabled", "");
}
} else {
$(nextButtonSelector).removeAttr("disabled");
}
});
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }

View File

@ -22,10 +22,13 @@
beforeEach(module('horizon.dashboard.project.lbaasv2'));
describe('MonitorDetailsController', function() {
var ctrl;
var ctrl, scope;
beforeEach(inject(function($controller) {
ctrl = $controller('MonitorDetailsController');
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
ctrl = $controller('MonitorDetailsController', {
$scope: scope
});
}));
it('should define error messages for invalid fields', function() {
@ -41,6 +44,35 @@
expect(ctrl.urlPathPattern).toBeDefined();
});
it('should handle wizard event', function() {
scope.$index = 2;
scope.model = {
spec: {
listener: {
protocol: 'TERMINATED_HTTPS'
}
}
};
scope.$broadcast('ON_SWITCH', {
from: 1,
to: 2
});
scope.model = {
spec: {
listener: {
protocol: 'HTTP'
}
}
};
scope.$broadcast('ON_SWITCH', {
from: 1,
to: 2
});
scope.$broadcast('ON_SWITCH', {
from: 2,
to: 1
});
});
});
});
})();