Ensure port and username should not be mandatory when a service is provided. Fixes #4642

This commit is contained in:
Akshay Joshi
2019-09-13 11:54:16 +05:30
parent 9a69d27009
commit da553eec9b
5 changed files with 105 additions and 14 deletions

View File

@@ -723,9 +723,8 @@ class ServerNode(PGChildNodeView):
"""Add a server node to the settings database"""
required_args = [
u'name',
u'port',
u'db',
u'sslmode',
u'username'
]
data = request.form if request.form else json.loads(
@@ -741,7 +740,8 @@ class ServerNode(PGChildNodeView):
if 'service' in data and not data['service']:
required_args.extend([
u'host',
u'db',
u'port',
u'username',
u'role'
])
for arg in required_args:

View File

@@ -36,13 +36,13 @@ export class ModelValidation {
this.checkHostAndHostAddress();
this.checkForEmpty('db', gettext('Maintenance database must be specified.'));
this.checkForEmpty('username', gettext('Username must be specified.'));
this.checkForEmpty('port', gettext('Port must be specified.'));
} else {
this.checkForEmpty('db', gettext('Maintenance database must be specified.'));
this.clearHostAddressAndDbErrors();
}
this.checkForEmpty('username', gettext('Username must be specified.'));
this.checkForEmpty('port', gettext('Port must be specified.'));
if (this.model.get('use_ssh_tunnel')) {
this.checkForEmpty('tunnel_host', gettext('SSH Tunnel host must be specified.'));
this.checkForEmpty('tunnel_port', gettext('SSH Tunnel port must be specified.'));
@@ -73,7 +73,7 @@ export class ModelValidation {
}
clearHostAddressAndDbErrors() {
_.each(['host', 'hostaddr', 'db'], (item) => {
_.each(['host', 'hostaddr', 'db', 'username', 'port'], (item) => {
this.setNullValueForEmptyString(item);
this.model.errorModel.unset(item);
});