From 9274df0f1108156f1af2728ff8ea81d8465cbe3c Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Tue, 17 Aug 2021 12:19:10 +0530 Subject: [PATCH] - Fix Jasmine test cases failing in framework. - More stability fixes and enhancements. --- .../server_groups/servers/static/js/privilege.ui.js | 2 +- web/pgadmin/browser/static/js/node_ajax.js | 2 ++ web/pgadmin/static/js/SchemaView/DataGridView.jsx | 5 ++++- web/pgadmin/static/js/SchemaView/base_schema.ui.js | 10 +++++----- web/pgadmin/static/js/SchemaView/index.jsx | 5 +++-- .../javascript/SchemaView/SchemaView.spec.js | 6 +++--- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.ui.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.ui.js index 67233095c..20af1901f 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.ui.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.ui.js @@ -65,7 +65,7 @@ export default class PrivilegeRoleSchema extends BaseUISchema { }, { id: 'grantor', label: gettext('Grantor'), type: 'text', readonly: true, - cell: ()=>({cell: 'select', options: obj.grantorOptions}), + cell: ()=>({cell: 'select', options: obj.grantorOptions}), minWidth: 150, }]; } diff --git a/web/pgadmin/browser/static/js/node_ajax.js b/web/pgadmin/browser/static/js/node_ajax.js index 7b5b9fe0a..124bcb531 100644 --- a/web/pgadmin/browser/static/js/node_ajax.js +++ b/web/pgadmin/browser/static/js/node_ajax.js @@ -140,6 +140,7 @@ export function getNodeListById(nodeObj, treeNodeInfo, itemNodeData, params={}, /* Get the nodes list based on node name passed */ export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, filter=()=>true, postTransform=(res)=>res) { let nodeObj = pgAdmin.Browser.Nodes[node]; + let {includeItemKeys} = params; /* Transform the result to add image details */ const transform = (rows) => { var res = []; @@ -157,6 +158,7 @@ export function getNodeListByName(node, treeNodeInfo, itemNodeData, params={}, f 'value': r.label, 'image': image, 'label': l, + ..._.pick(r, includeItemKeys), }); } }); diff --git a/web/pgadmin/static/js/SchemaView/DataGridView.jsx b/web/pgadmin/static/js/SchemaView/DataGridView.jsx index 90f582b15..c7661df64 100644 --- a/web/pgadmin/static/js/SchemaView/DataGridView.jsx +++ b/web/pgadmin/static/js/SchemaView/DataGridView.jsx @@ -322,7 +322,7 @@ export default function DataGridView({ return props.columns.indexOf(firstF.id) < props.columns.indexOf(secondF.id) ? -1 : 1; } return 0; - }).map((field)=>{ + }).map((field, fieldIdx)=>{ let colInfo = { Header: field.label||<> , accessor: field.id, @@ -332,6 +332,9 @@ export default function DataGridView({ ...(field.minWidth ? {minWidth: field.minWidth} : {}), ...(field.width ? {width: field.width} : {}), 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 verInLimit = (_.isUndefined(viewHelperProps.serverInfo) ? true : diff --git a/web/pgadmin/static/js/SchemaView/base_schema.ui.js b/web/pgadmin/static/js/SchemaView/base_schema.ui.js index 591b0e627..48a905156 100644 --- a/web/pgadmin/static/js/SchemaView/base_schema.ui.js +++ b/web/pgadmin/static/js/SchemaView/base_schema.ui.js @@ -123,12 +123,12 @@ export default class BaseUISchema { getNewData(data={}) { let newRow = {}; this.fields.forEach((field)=>{ - if(!_.isUndefined(data[field.id])){ - newRow[field.id] = data[field.id]; - } else { - newRow[field.id] = this.defaults[field.id]; - } + newRow[field.id] = this.defaults[field.id]; }); + newRow = { + ...newRow, + ...data, + }; return newRow; } diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx index 48d0bcb78..6904d1792 100644 --- a/web/pgadmin/static/js/SchemaView/index.jsx +++ b/web/pgadmin/static/js/SchemaView/index.jsx @@ -764,8 +764,9 @@ function SchemaPropertiesView({ accessPath={[]} formErr={{}} controlClassName={classes.controlRow} + {...field} visible={visible} - {...field} /> + /> ); } else if(field.type === 'collection') { tabs[group].push( @@ -792,10 +793,10 @@ function SchemaPropertiesView({ state={origData} name={field.id} value={origData[field.id]} + {...field} readonly={readonly} disabled={disabled} visible={visible} - {...field} className={classes.controlRow} /> ); diff --git a/web/regression/javascript/SchemaView/SchemaView.spec.js b/web/regression/javascript/SchemaView/SchemaView.spec.js index a30d84867..05471bf92 100644 --- a/web/regression/javascript/SchemaView/SchemaView.spec.js +++ b/web/regression/javascript/SchemaView/SchemaView.spec.js @@ -264,7 +264,7 @@ describe('SchemaView', ()=>{ ctrl.update(); expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue(); expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue(); - expect(onDataChange).toHaveBeenCalledWith(false); + expect(onDataChange).toHaveBeenCalledWith(false, {}); done(); }, 0); }); @@ -298,7 +298,7 @@ describe('SchemaView', ()=>{ expect(confirmSpy).not.toHaveBeenCalled(); expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue(); expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue(); - expect(onDataChange).toHaveBeenCalledWith(false); + expect(onDataChange).toHaveBeenCalledWith(false, {}); done(); }, 0); }); @@ -411,7 +411,7 @@ describe('SchemaView', ()=>{ ctrl.update(); expect(ctrl.find('DefaultButton[data-test="Reset"]').prop('disabled')).toBeTrue(); expect(ctrl.find('PrimaryButton[data-test="Save"]').prop('disabled')).toBeTrue(); - expect(onDataChange).toHaveBeenCalledWith(false); + expect(onDataChange).toHaveBeenCalledWith(false, {}); done(); }, 0); }, 0);