Merge "Allows creation of resources without forcing the creation of children"

This commit is contained in:
Zuul 2021-03-11 22:14:40 +00:00 committed by Gerrit Code Review
commit 08ba87ee6b
12 changed files with 651 additions and 487 deletions

View File

@ -39,6 +39,7 @@
function ListenerDetailsController($scope, gettext) {
var ctrl = this;
ctrl.protocolChange = protocolChange;
ctrl.createChange = createChange;
// Error text for invalid fields
ctrl.portNumberError = gettext('The port must be a number between 1 and 65535.');
@ -71,6 +72,14 @@
}
}
function createChange() {
if ($scope.model.context.create_listener === false) {
// Disabling listener form disables pool form and monitor form
$scope.model.context.create_pool = false;
$scope.model.context.create_monitor = false;
}
}
function listenerPortExists(port) {
return $scope.model.listenerPorts.some(function(element) {
return element === port;

View File

@ -36,6 +36,11 @@
};
scope = {
model: {
context: {
create_listener: true,
create_pool: true,
create_monitor: true
},
listenerPorts: [80],
members: [{port: ''}, {port: ''}],
spec: {
@ -118,6 +123,18 @@
});
});
it('should update create_pool and create_monitor flags', function() {
scope.model.context.create_listener = true;
ctrl.createChange();
expect(scope.model.context.create_pool).toBe(true);
expect(scope.model.context.create_monitor).toBe(true);
scope.model.context.create_listener = false;
ctrl.createChange();
expect(scope.model.context.create_pool).toBe(false);
expect(scope.model.context.create_monitor).toBe(false);
});
});
});
})();

View File

@ -1,6 +1,26 @@
<div ng-controller="ListenerDetailsController as ctrl">
<p translate>Provide the details for the listener.</p>
<div class="row" ng-if="model.context.resource !== 'listener' && !model.context.id">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="form-group">
<label class="control-label required" translate>Create Listener</label>
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in model.yesNoOptions"
ng-model="model.context.create_listener"
ng-change="ctrl.createChange()"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>
</div>
</div>
</div>
</div>
<div ng-if="model.context.create_listener">
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6">
@ -252,5 +272,6 @@
</div>
</div>
</div>
</div>

View File

@ -1,4 +1,5 @@
<div ng-controller="MemberDetailsController as ctrl">
<div ng-controller="MemberDetailsController as ctrl"
ng-if="model.context.create_pool || model.context.id">
<p translate>Add members to the load balancer pool.</p>
<transfer-table tr-model="ctrl.tableData"
limits="::ctrl.tableLimits"

View File

@ -137,7 +137,10 @@
model.context = {
resource: resource,
id: id,
submit: null
submit: null,
create_listener: true,
create_pool: true,
create_monitor: true
};
model.certificates = [];

View File

@ -55,6 +55,16 @@
}
});
ctrl.createChange = createChange;
function createChange() {
if ($scope.model.context.create_monitor) {
// Enabling pool form enables listener form and pool form
$scope.model.context.create_listener = true;
$scope.model.context.create_pool = true;
}
}
// Error text for invalid fields
/* eslint-disable max-len */
ctrl.intervalError = gettext('The health check interval must be greater than or equal to the timeout.');

View File

@ -73,6 +73,30 @@
to: 1
});
});
it('should update create_pool and create_monitor flags', function() {
scope.model = {
context: {
create_listener: false,
create_pool: false,
create_monitor: true
}
};
ctrl.createChange();
expect(scope.model.context.create_listener).toBe(true);
expect(scope.model.context.create_pool).toBe(true);
scope.model = {
context: {
create_listener: false,
create_pool: false,
create_monitor: false
}
};
ctrl.createChange();
expect(scope.model.context.create_listener).toBe(false);
expect(scope.model.context.create_pool).toBe(false);
});
});
});
})();

View File

@ -1,6 +1,26 @@
<div ng-controller="MonitorDetailsController as ctrl">
<p translate>Provide the details for the health monitor.</p>
<div class="row" ng-if="model.context.resource !== 'monitor' && !model.context.id">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="form-group">
<label class="control-label required" translate>Create Health Monitor</label>
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in model.yesNoOptions"
ng-model="model.context.create_monitor"
ng-change="ctrl.createChange()"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>
</div>
</div>
</div>
</div>
<div ng-if="model.context.create_monitor">
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4">
@ -152,5 +172,6 @@
</div>
</div>
</div>
</div>

View File

@ -38,6 +38,17 @@
function PoolDetailsController($scope, gettext) {
var ctrl = this;
ctrl.createChange = createChange;
function createChange() {
if ($scope.model.context.create_pool) {
// Enabling pool form enables listener form
$scope.model.context.create_listener = true;
} else {
// Disabling pool form disables monitor form
$scope.model.context.create_monitor = false;
}
}
// Error text for invalid fields
ctrl.tls_ciphersError = gettext('The cipher string must conform to OpenSSL syntax.');

View File

@ -24,8 +24,16 @@
describe('PoolDetailsController', function() {
var ctrl, scope;
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
beforeEach(inject(function($controller) {
scope = {
model: {
context: {
create_listener: true,
create_pool: true,
create_monitor: true
}
}
};
ctrl = $controller('PoolDetailsController', {
$scope: scope
});
@ -35,6 +43,18 @@
expect(ctrl.tls_ciphersError).toBeDefined();
});
it('should update create_listener and create_monitor flags', function() {
scope.model.context.create_pool = true;
ctrl.createChange();
expect(scope.model.context.create_listener).toBe(true);
expect(scope.model.context.create_monitor).toBe(true);
scope.model.context.create_pool = false;
ctrl.createChange();
expect(scope.model.context.create_listener).toBe(true);
expect(scope.model.context.create_monitor).toBe(false);
});
});
});
})();

View File

@ -1,6 +1,26 @@
<div ng-controller="PoolDetailsController as ctrl">
<p translate>Provide the details for the pool.</p>
<div class="row" ng-if="model.context.resource !== 'pool' && !model.context.id">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="form-group">
<label class="control-label required" translate>Create Pool</label>
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in model.yesNoOptions"
ng-model="model.context.create_pool"
ng-change="ctrl.createChange()"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>
</div>
</div>
</div>
</div>
<div ng-if="model.context.create_pool">
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6">
@ -66,7 +86,7 @@
ng-model="model.spec.pool.session_persistence.type">
<option value="">None</option>
<option ng-repeat="type in model.types"
ng-disabled="(model.spec.listener.protocol === 'UDP' || model.spec.listener.protocol === 'SCTP') && type !== 'SOURCE_IP'"
ng-disabled="model.spec.listener.protocol === 'UDP' && type !== 'SOURCE_IP'"
value="{$ type $}">
{$ type $}
</option>
@ -136,5 +156,5 @@
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Allows the creation of single resources (i.e Load Balancer) without
enforcing the creation of children resources (Listeners, Pools, Health
monitors). A switch has been added in the children resource wizards to
avoid resource creation.