Allow setting custom username for shared servers, with default as username of server being shared. #6229

This commit is contained in:
Aditya Toshniwal
2023-10-11 12:56:06 +05:30
committed by GitHub
parent 4450145d31
commit fc411bfc49
9 changed files with 90 additions and 36 deletions

View File

@@ -36,6 +36,7 @@ export default class ServerSchema extends BaseUISchema {
passexec: undefined,
passexec_expiration: undefined,
service: undefined,
shared_username: '',
use_ssh_tunnel: false,
tunnel_host: undefined,
tunnel_port: 22,
@@ -130,6 +131,34 @@ export default class ServerSchema extends BaseUISchema {
return current_user.is_admin && pgAdmin.server_mode == 'True';
},
},
{
id: 'shared_username', label: gettext('Shared Username'), type: 'text',
controlProps: { maxLength: 64},
mode: ['properties', 'create', 'edit'], deps: ['shared', 'username'],
readonly: (s)=>{
if(!this.origData.shared && s.shared) {
return false;
}
return true;
}, visible: (s)=>!obj.isShared(s),
depChange: (state, source, _topState, actionObj)=>{
let ret = {};
if(this.origData.shared) {
return ret;
}
if(source == 'username' && actionObj.oldState.username == state.shared_username) {
ret['shared_username'] = state.username;
}
if(source == 'shared') {
if(state.shared) {
ret['shared_username'] = state.username;
} else {
ret['shared_username'] = '';
}
}
return ret;
},
},
{
id: 'comment', label: gettext('Comments'), type: 'multiline', group: null,
mode: ['properties', 'edit', 'create'],