Fixed dialog crash issue when added security label and changing the type to shell. Fixes #6744

This commit is contained in:
Rahul Shirsat 2021-10-05 17:24:16 +05:30 committed by Akshay Joshi
parent 4bbc811aed
commit bfb65e82aa
2 changed files with 28 additions and 17 deletions

View File

@ -1040,8 +1040,10 @@ class CompositeSchema extends BaseUISchema {
validate(state, setError) {
let errmsg = null;
let self = this,
errmsg = null;
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);
@ -1056,6 +1058,7 @@ class CompositeSchema extends BaseUISchema {
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');
},

View File

@ -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.');