mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure port and username should not be mandatory when a service is provided. Fixes #4642
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user