mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Fixed dialog crash issue when added security label and changing the type to shell. Fixes #6744
This commit is contained in:
parent
4bbc811aed
commit
bfb65e82aa
@ -1040,21 +1040,24 @@ class CompositeSchema extends BaseUISchema {
|
||||
|
||||
validate(state, setError) {
|
||||
|
||||
let errmsg = null;
|
||||
|
||||
if (isEmptyString(state.member_name)) {
|
||||
errmsg = gettext('Please specify the value for member name.');
|
||||
setError('member_name', errmsg);
|
||||
return true;
|
||||
} else if(isEmptyString(state.type)) {
|
||||
errmsg = gettext('Please specify the type.');
|
||||
setError('type', errmsg);
|
||||
return true;
|
||||
}
|
||||
if(_.isUndefined(errmsg) || errmsg == null) {
|
||||
let self = this,
|
||||
errmsg = null;
|
||||
setError('member_name', errmsg);
|
||||
setError('type', errmsg);
|
||||
|
||||
if(self.top && self.top.sessData && self.top.sessData.typtype === 'c') {
|
||||
if (isEmptyString(state.member_name)) {
|
||||
errmsg = gettext('Please specify the value for member name.');
|
||||
setError('member_name', errmsg);
|
||||
return true;
|
||||
} else if(isEmptyString(state.type)) {
|
||||
errmsg = gettext('Please specify the type.');
|
||||
setError('type', errmsg);
|
||||
return true;
|
||||
}
|
||||
if(_.isUndefined(errmsg) || errmsg == null) {
|
||||
errmsg = null;
|
||||
setError('member_name', errmsg);
|
||||
setError('type', errmsg);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1286,7 +1289,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
...fieldOptions
|
||||
};
|
||||
this.getPrivilegeRoleSchema = getPrivilegeRoleSchema;
|
||||
this.getCompositeSchema = getCompositeSchema;
|
||||
this.compositeSchema = getCompositeSchema(); // create only once the composite schema to avoid initializing the current (i.e. top)
|
||||
this.getRangeSchema = getRangeSchema;
|
||||
this.getExternalSchema = getExternalSchema;
|
||||
this.getDataTypeSchema = getDataTypeSchema;
|
||||
@ -1409,8 +1412,13 @@ export default class TypeSchema extends BaseUISchema {
|
||||
uniqueCol : ['member_name'],
|
||||
canAdd: true, canEdit: false, canDelete: true,
|
||||
disabled: () => obj.inCatalog(),
|
||||
schema: obj.getCompositeSchema(),
|
||||
schema: obj.compositeSchema,
|
||||
deps: ['typtype'],
|
||||
depChange: (state)=>{
|
||||
if(_.isArray(state.composite) && state.composite.length > 0 && state.typtype !== 'c') {
|
||||
state.composite.splice(0, state.composite.length);
|
||||
}
|
||||
},
|
||||
visible: (state) => {
|
||||
return state.typtype === 'c';
|
||||
},
|
||||
@ -1658,7 +1666,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
if (state.typtype === 'p') {
|
||||
var secLabs = state.seclabels;
|
||||
if(secLabs && secLabs.length > 0)
|
||||
secLabs.reset();
|
||||
secLabs.splice(0, secLabs.length);
|
||||
}
|
||||
return (state.typtype !== 'p');
|
||||
},
|
||||
|
@ -96,6 +96,9 @@ describe('TypeSchema', ()=>{
|
||||
it('composite validate', () => {
|
||||
let state = { typtype: 'b' }; //validating for ExternalSchema which is distinguish as r
|
||||
let setError = jasmine.createSpy('setError');
|
||||
compositeCollObj.top = {
|
||||
'sessData': { 'typtype':'c' }
|
||||
};
|
||||
|
||||
compositeCollObj.validate(state, setError);
|
||||
expect(setError).toHaveBeenCalledWith('member_name', 'Please specify the value for member name.');
|
||||
|
Loading…
Reference in New Issue
Block a user