mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Server and Database node fixes:
1. Unable to change shared server switch. 2. DB restriction and schema restriction have an empty option. 3. File select input control does not allow manual text input. 4. In the Parameters tab if the value is a switch control, then an empty value error should not come. 5. Values for parameters should be reset on changing parameters. 6. Added a new key - helpMessageMode which can have a value similar to mode. It will show the help message if the mode is supported. Fixes #6814
This commit is contained in:
parent
7b6101bc6d
commit
be69470d55
@ -69,7 +69,7 @@ export default class DatabaseSchema extends BaseUISchema {
|
||||
defseqacl: [],
|
||||
is_template: false,
|
||||
deftypeacl: [],
|
||||
schema_res:'',
|
||||
schema_res: [],
|
||||
...initValues,
|
||||
});
|
||||
this.getVariableSchema = getVariableSchema;
|
||||
@ -195,6 +195,7 @@ export default class DatabaseSchema extends BaseUISchema {
|
||||
type: 'select', group: gettext('Advanced'),
|
||||
mode: ['properties', 'edit', 'create'],
|
||||
helpMessage: gettext('Note: Changes to the schema restriction will require the Schemas node in the browser to be refreshed before they will be shown.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
controlProps: {
|
||||
multiple: true, allowClear: false, creatable: true,
|
||||
}, depChange: (state)=>{
|
||||
|
@ -741,6 +741,7 @@ define('pgadmin.node.server', [
|
||||
getSchema: (treeNodeInfo, itemNodeData)=>{
|
||||
let schema = new ServerSchema(
|
||||
getNodeListById(pgBrowser.Nodes['server_group'], treeNodeInfo, itemNodeData),
|
||||
itemNodeData.user_id,
|
||||
{
|
||||
gid: treeNodeInfo['server_group']._id,
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import current_user from 'pgadmin.user_management.current_user';
|
||||
import { isEmptyString } from 'sources/validators';
|
||||
|
||||
export default class ServerSchema extends BaseUISchema {
|
||||
constructor(serverGroupOptions=[], initValues) {
|
||||
constructor(serverGroupOptions=[], userId, initValues) {
|
||||
super({
|
||||
gid: undefined,
|
||||
id: undefined,
|
||||
@ -36,7 +36,7 @@ export default class ServerSchema extends BaseUISchema {
|
||||
connect_now: true,
|
||||
password: undefined,
|
||||
save_password: false,
|
||||
db_res: '',
|
||||
db_res: [],
|
||||
passfile: undefined,
|
||||
sslcompression: false,
|
||||
sslcert: undefined,
|
||||
@ -57,13 +57,14 @@ export default class ServerSchema extends BaseUISchema {
|
||||
});
|
||||
|
||||
this.serverGroupOptions = serverGroupOptions;
|
||||
this.userId = userId;
|
||||
_.bindAll(this, 'isShared', 'isSSL');
|
||||
}
|
||||
|
||||
get SSL_MODES() { return ['prefer', 'require', 'verify-ca', 'verify-full']; }
|
||||
|
||||
isShared(state) {
|
||||
if(!this.isNew(state) && state.user_id != current_user.id && state.shared) {
|
||||
if(!this.isNew(state) && this.userId != current_user.id && state.shared) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -103,7 +104,7 @@ export default class ServerSchema extends BaseUISchema {
|
||||
{
|
||||
id: 'server_owner', label: gettext('Shared Server Owner'), type: 'text', mode: ['properties'],
|
||||
visible: function(state) {
|
||||
var serverOwner = state.user_id;
|
||||
var serverOwner = obj.userId;
|
||||
if (state.shared && serverOwner != current_user.id && pgAdmin.server_mode == 'True'){
|
||||
return true;
|
||||
}
|
||||
@ -141,7 +142,7 @@ export default class ServerSchema extends BaseUISchema {
|
||||
id: 'shared', label: gettext('Shared?'), type: 'switch',
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
readonly: function(state){
|
||||
var serverOwner = state.user_id;
|
||||
var serverOwner = obj.userId;
|
||||
if (obj.isNew(state) && serverOwner != current_user.id) {
|
||||
return true;
|
||||
}
|
||||
@ -413,7 +414,7 @@ export default class ServerSchema extends BaseUISchema {
|
||||
id: 'db_res', label: gettext('DB restriction'), type: 'select', group: gettext('Advanced'),
|
||||
options: [],
|
||||
mode: ['properties', 'edit', 'create'], readonly: obj.isConnected, controlProps: {
|
||||
multiple: true, allowClear: false, creatable: true},
|
||||
multiple: true, allowClear: false, creatable: true, noDropdown: true},
|
||||
},
|
||||
{
|
||||
id: 'passfile', label: gettext('Password file'), type: 'file',
|
||||
|
@ -112,10 +112,16 @@ export default class VariableSchema extends BaseUISchema {
|
||||
{
|
||||
id: 'value', label: gettext('Value'), type: 'text',
|
||||
deps: ['name'],
|
||||
depChange: (state, changeSource)=>{
|
||||
if(changeSource == 'name') {
|
||||
return {...state
|
||||
, value: null
|
||||
depChange: (state, source)=>{
|
||||
if(source[source.length-1] == 'name') {
|
||||
let variable = this.varTypes[state.name];
|
||||
if(variable.vartype === 'bool'){
|
||||
return {
|
||||
value: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
value: null
|
||||
};
|
||||
}
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ function MappedFormControlBase({type, value, id, onChange, className, visible, i
|
||||
case 'password':
|
||||
return <FormInputText name={name} value={value} onChange={onTextChange} className={className} type='password' inputRef={inputRef} {...props}/>;
|
||||
case 'select':
|
||||
return <FormInputSelect name={name} value={value} onChange={onTextChange} className={className} {...props} />;
|
||||
return <FormInputSelect name={name} value={value} onChange={onTextChange} className={className} inputRef={inputRef} {...props} />;
|
||||
case 'select-refresh':
|
||||
return <SelectRefresh name={name} value={value} onChange={onTextChange} className={className} {...props} />;
|
||||
case 'switch':
|
||||
|
@ -819,6 +819,9 @@ function SchemaPropertiesView({
|
||||
readonly = true;
|
||||
if(modeSupported) {
|
||||
group = groupLabels[group] || group || defaultTab;
|
||||
if(field.helpMessageMode && field.helpMessageMode.indexOf(viewHelperProps.mode) == -1) {
|
||||
field.helpMessage = '';
|
||||
}
|
||||
|
||||
if(!tabs[group]) tabs[group] = [];
|
||||
if(field && field.type === 'nested-fieldset') {
|
||||
|
@ -381,7 +381,7 @@ export function InputFileSelect({controlProps, onChange, disabled, readonly, ...
|
||||
inpRef.current.focus();
|
||||
};
|
||||
return (
|
||||
<InputText ref={inpRef} disabled={disabled} readonly={readonly} {...props} endAdornment={
|
||||
<InputText ref={inpRef} disabled={disabled} readonly={readonly} onChange={onChange} {...props} endAdornment={
|
||||
<IconButton onClick={()=>showFileDialog(controlProps, onFileSelect)}
|
||||
disabled={disabled||readonly} aria-label={gettext('Select a file')}><FolderOpenRoundedIcon /></IconButton>
|
||||
} />
|
||||
|
@ -20,7 +20,7 @@ describe('ServerSchema', ()=>{
|
||||
let mount;
|
||||
let schemaObj = new ServerSchema([{
|
||||
label: 'Servers', value: 1,
|
||||
}], {
|
||||
}], 0, {
|
||||
user_id: 'jasmine',
|
||||
});
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
Loading…
Reference in New Issue
Block a user