- Fix Jasmine test cases failing in framework. - More stability fixes and enhancements.

This commit is contained in:
Aditya Toshniwal 2021-08-17 12:19:10 +05:30 committed by Akshay Joshi
parent 351cb3e6ca
commit 9274df0f11
6 changed files with 18 additions and 12 deletions

View File

@ -65,7 +65,7 @@ export default class PrivilegeRoleSchema extends BaseUISchema {
}, },
{ {
id: 'grantor', label: gettext('Grantor'), type: 'text', readonly: true, id: 'grantor', label: gettext('Grantor'), type: 'text', readonly: true,
cell: ()=>({cell: 'select', options: obj.grantorOptions}), cell: ()=>({cell: 'select', options: obj.grantorOptions}), minWidth: 150,
}]; }];
} }

View File

@ -140,6 +140,7 @@ export function getNodeListById(nodeObj, treeNodeInfo, itemNodeData, params={},
/* Get the nodes list based on node name passed */ /* Get the nodes list based on node name passed */
export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, filter=()=>true, postTransform=(res)=>res) { export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, filter=()=>true, postTransform=(res)=>res) {
let nodeObj = pgAdmin.Browser.Nodes[node]; let nodeObj = pgAdmin.Browser.Nodes[node];
let {includeItemKeys} = params;
/* Transform the result to add image details */ /* Transform the result to add image details */
const transform = (rows) => { const transform = (rows) => {
var res = []; var res = [];
@ -157,6 +158,7 @@ export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, f
'value': r.label, 'value': r.label,
'image': image, 'image': image,
'label': l, 'label': l,
..._.pick(r, includeItemKeys),
}); });
} }
}); });

View File

@ -322,7 +322,7 @@ export default function DataGridView({
return props.columns.indexOf(firstF.id) < props.columns.indexOf(secondF.id) ? -1 : 1; return props.columns.indexOf(firstF.id) < props.columns.indexOf(secondF.id) ? -1 : 1;
} }
return 0; return 0;
}).map((field)=>{ }).map((field, fieldIdx)=>{
let colInfo = { let colInfo = {
Header: field.label||<>&nbsp;</>, Header: field.label||<>&nbsp;</>,
accessor: field.id, accessor: field.id,
@ -332,6 +332,9 @@ export default function DataGridView({
...(field.minWidth ? {minWidth: field.minWidth} : {}), ...(field.minWidth ? {minWidth: field.minWidth} : {}),
...(field.width ? {width: field.width} : {}), ...(field.width ? {width: field.width} : {}),
Cell: ({value, row, ...other}) => { Cell: ({value, row, ...other}) => {
/* Make sure to take the latest field info from schema */
field = schemaRef.current.fields[fieldIdx];
let {visible, editable, readonly, ..._field} = field; let {visible, editable, readonly, ..._field} = field;
let verInLimit = (_.isUndefined(viewHelperProps.serverInfo) ? true : let verInLimit = (_.isUndefined(viewHelperProps.serverInfo) ? true :

View File

@ -123,12 +123,12 @@ export default class BaseUISchema {
getNewData(data={}) { getNewData(data={}) {
let newRow = {}; let newRow = {};
this.fields.forEach((field)=>{ this.fields.forEach((field)=>{
if(!_.isUndefined(data[field.id])){ newRow[field.id] = this.defaults[field.id];
newRow[field.id] = data[field.id];
} else {
newRow[field.id] = this.defaults[field.id];
}
}); });
newRow = {
...newRow,
...data,
};
return newRow; return newRow;
} }

View File

@ -764,8 +764,9 @@ function SchemaPropertiesView({
accessPath={[]} accessPath={[]}
formErr={{}} formErr={{}}
controlClassName={classes.controlRow} controlClassName={classes.controlRow}
{...field}
visible={visible} visible={visible}
{...field} /> />
); );
} else if(field.type === 'collection') { } else if(field.type === 'collection') {
tabs[group].push( tabs[group].push(
@ -792,10 +793,10 @@ function SchemaPropertiesView({
state={origData} state={origData}
name={field.id} name={field.id}
value={origData[field.id]} value={origData[field.id]}
{...field}
readonly={readonly} readonly={readonly}
disabled={disabled} disabled={disabled}
visible={visible} visible={visible}
{...field}
className={classes.controlRow} className={classes.controlRow}
/> />
); );

View File

@ -264,7 +264,7 @@ describe('SchemaView', ()=>{
ctrl.update(); ctrl.update();
expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue(); expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue();
expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue(); expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue();
expect(onDataChange).toHaveBeenCalledWith(false); expect(onDataChange).toHaveBeenCalledWith(false, {});
done(); done();
}, 0); }, 0);
}); });
@ -298,7 +298,7 @@ describe('SchemaView', ()=>{
expect(confirmSpy).not.toHaveBeenCalled(); expect(confirmSpy).not.toHaveBeenCalled();
expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue(); expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue();
expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue(); expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue();
expect(onDataChange).toHaveBeenCalledWith(false); expect(onDataChange).toHaveBeenCalledWith(false, {});
done(); done();
}, 0); }, 0);
}); });
@ -411,7 +411,7 @@ describe('SchemaView', ()=>{
ctrl.update(); ctrl.update();
expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue(); expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue();
expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue(); expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue();
expect(onDataChange).toHaveBeenCalledWith(false); expect(onDataChange).toHaveBeenCalledWith(false, {});
done(); done();
}, 0); }, 0);
}, 0); }, 0);