Hi Akshay, Please find the attached patch. I have improved the code coverage of Function node and also fixed the test cases which were failing for Cast ,Subscription and Publication node.
On Tue, Aug 24, 2021 at 10:54 AM Pradip Parkale < pradip.park...@enterprisedb.com> wrote: > Hi Hackers, > > Please find the attached patch for RM6677 and RM6632 [React] Port > Procedure and Function node to react. > > Also Updated a few test cases for previous ported nodes. > > -- > Thanks & Regards, > Pradip Parkale > Software Engineer | EnterpriseDB Corporation > -- Thanks & Regards, Pradip Parkale Software Engineer | EnterpriseDB Corporation
diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/default/test.json index f3f7fdc5d..fd9f7dfae 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/default/test.json @@ -7,7 +7,7 @@ "sql_endpoint": "NODE-cast.sql_id", "msql_endpoint": "NODE-cast.msql", "data": { - "castcontext": "IMPLICIT", + "castcontext": true, "encoding": "UTF8", "name": "money->bigint", "srctyp": "money", @@ -43,7 +43,7 @@ "sql_endpoint": "NODE-cast.sql_id", "msql_endpoint": "NODE-cast.msql", "data": { - "castcontext": "EXPLICIT", + "castcontext": false, "encoding": "UTF8", "name": "money->bigint", "srctyp": "money", diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/utils.py index 69ff12f75..1ccece65a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/utils.py @@ -27,7 +27,7 @@ def get_tables(self): self.server_id) + '/' + str(self.db_id) + '/', content_type='html/json') - return json.dumps([tables.json['data'][1]['value']]) + return [tables.json['data'][1]['value']] def create_publication_api(self): diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js index ac29accb9..834de7a0c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js @@ -161,11 +161,7 @@ export default class FunctionSchema extends BaseUISchema { return false; } } - isDisabled() { - if (this.node_info && 'catalog' in this.node_info) { - return true; - } - } + isGreaterThan95(state){ if ( this.node_info['node_info'].server.version < 90500 || @@ -195,35 +191,17 @@ export default class FunctionSchema extends BaseUISchema { } } - isProcedure(state) { - - if (this.node_info && 'catalog' in this.node_info) { - return true; - } - - if (state.prorows) { - var server = this.node_info['node_info']['server']; - return !(server.version >= 90500 && state.proretset == true); - } - } isReadonly() { return !this.isNew(); } - canVarAdd(){ - if(this.node_info && 'catalog' in this.node_info) { - return false; - } - return true; - } - get baseFields() { let obj = this; return [{ id: 'name', label: gettext('Name'), cell: 'string', type: 'text', mode: ['properties', 'create', 'edit'], - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + disabled: obj.inCatalog(), noEmpty: true, },{ id: 'oid', label: gettext('OID'), cell: 'string', @@ -231,11 +209,11 @@ export default class FunctionSchema extends BaseUISchema { },{ id: 'funcowner', label: gettext('Owner'), cell: 'string', options: this.fieldOptions.role, type: 'select', - disabled: (!(this.type === 'procedure')) ? obj.isDisabled : obj.isGreaterThan95, + disabled: (!(this.type === 'procedure')) ? obj.inCatalog() : obj.isGreaterThan95, noEmpty: true, },{ id: 'pronamespace', label: gettext('Schema'), cell: 'string', - type: 'select', disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + type: 'select', disabled: obj.inCatalog(), mode: ['create', 'edit'], controlProps: { allowClear: false, @@ -252,7 +230,7 @@ export default class FunctionSchema extends BaseUISchema { mode: ['properties'], visible: obj.isVisible, },{ id: 'description', label: gettext('Comment'), cell: 'string', - type: 'multiline', disabled: obj.isDisabled, + type: 'multiline', disabled: obj.inCatalog(), },{ id: 'pronargs', label: gettext('Argument count'), cell: 'string', type: 'text', group: gettext('Definition'), mode: ['properties'], @@ -289,14 +267,14 @@ export default class FunctionSchema extends BaseUISchema { function(state) { if (state.lanname == 'c') { return true; } return false; - }, disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + }, disabled: obj.inCatalog(), },{ id: 'prosrc_c', label: gettext('Link symbol'), cell: 'string', type: 'text', group: gettext('Definition'), deps: ['lanname'], visible: function(state) { if (state.lanname == 'c') { return true; } return false; - }, disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + }, disabled: obj.inCatalog(), }, { id: 'arguments', label: gettext('Arguments'), cell: 'string', @@ -306,7 +284,7 @@ export default class FunctionSchema extends BaseUISchema { canDelete: true, mode: ['create', 'edit'], columns: ['argtype', 'argmode', 'argname', 'argdefval'], schema : new DefaultArgumentSchema(this.node_info, this.fieldOptions.getTypes), - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + disabled: obj.inCatalog(), canDeleteRow: function() { return obj.isNew(); }, @@ -320,7 +298,7 @@ export default class FunctionSchema extends BaseUISchema { return false; } return true; - }, disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + }, disabled: obj.inCatalog(), },{ id: 'provolatile', label: gettext('Volatility'), cell: 'text', type: 'select', group: gettext('Options'), @@ -329,7 +307,7 @@ export default class FunctionSchema extends BaseUISchema { {'label': 'VOLATILE', 'value': 'v'}, {'label': 'STABLE', 'value': 's'}, {'label': 'IMMUTABLE', 'value': 'i'}, - ], disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + ], disabled: obj.inCatalog(), controlProps: {allowClear: false}, },{ id: 'proretset', label: gettext('Returns a set?'), type: 'switch', @@ -337,12 +315,12 @@ export default class FunctionSchema extends BaseUISchema { visible: obj.isVisible, readonly: obj.isReadonly, },{ id: 'proisstrict', label: gettext('Strict?'), type: 'switch', - group: gettext('Options'), disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isGreaterThan95, + group: gettext('Options'), disabled: obj.inCatalog(), deps: ['lanname'], },{ id: 'prosecdef', label: gettext('Security of definer?'), group: gettext('Options'), type: 'switch', - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: ()=>{ + disabled: (!(this.type === 'procedure')) ? obj.inCatalog(): ()=>{ return obj.node_info['node_info'].server.version < 90500; }, },{ @@ -358,13 +336,13 @@ export default class FunctionSchema extends BaseUISchema { {'label': 'RESTRICTED', 'value': 'r'}, {'label': 'SAFE', 'value': 's'}, ], - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isGreaterThan96, + disabled: (!(this.type === 'procedure')) ? obj.inCatalog(): obj.isGreaterThan96, min_version: 90600, controlProps: {allowClear: false}, },{ id: 'procost', label: gettext('Estimated cost'), group: gettext('Options'), cell:'string', type: 'text', deps: ['lanname'], - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isGreaterThan95, + disabled: (!(this.type === 'procedure')) ? obj.inCatalog(): obj.isGreaterThan95, },{ id: 'prorows', label: gettext('Estimated rows'), type: 'text', deps: ['proretset'], visible: obj.isVisible, @@ -379,7 +357,7 @@ export default class FunctionSchema extends BaseUISchema { },{ id: 'proleakproof', label: gettext('Leak proof?'), group: gettext('Options'), cell:'boolean', type: 'switch', min_version: 90200, - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isGreaterThan95, + disabled: (!(this.type === 'procedure')) ? obj.inCatalog(): obj.isGreaterThan95, deps: ['lanname'], },{ id: 'prosupportfunc', label: gettext('Support function'), @@ -403,7 +381,7 @@ export default class FunctionSchema extends BaseUISchema { id: 'variables', label: '', type: 'collection', group: gettext('Parameters'), schema: this.getNodeVariableSchema(), - mode: ['edit', 'create'], canAdd: obj.canVarAdd, canEdit: false, + mode: ['edit', 'create'], canAdd: obj.inCatalog(), canEdit: false, canDelete: true, }, { @@ -412,13 +390,13 @@ export default class FunctionSchema extends BaseUISchema { uniqueCol : ['grantee', 'grantor'], type: 'collection', group: 'Security', mode: ['edit', 'create'], canAdd: true, canDelete: true, - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + disabled: obj.inCatalog(), },{ id: 'seclabels', label: gettext('Security labels'), canAdd: true, schema: new SecLabelSchema(), type: 'collection', min_version: 90100, group: 'Security', mode: ['edit', 'create'], canEdit: false, canDelete: true, uniqueCol : ['provider'], - disabled: (!(this.type === 'procedure')) ? obj.isDisabled: obj.isProcedure, + disabled: obj.inCatalog(), visible: function() { return this.node_info && !(this.type === 'procedure'); }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/test.json index d9cf45bdd..c60a0d447 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/test.json @@ -21,7 +21,7 @@ "port": 5432, "password": "edb", "sync": "off", - "pub": "[\"sample__1\"]" + "pub": ["sample__1"] }, "expected_sql_file": "create_subscription.sql", "expected_msql_file": "create_subscription_msql.sql" diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/subscription_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/subscription_test_data.json index dca2e5a78..60a1a1348 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/subscription_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/subscription_test_data.json @@ -19,7 +19,7 @@ "port": 5432, "password": "", "sync": "off", - "pub": "[\"sample__1\"]" + "pub": ["sample__1"] }, "mocking_required": false, "mock_data": {}, @@ -47,7 +47,7 @@ "port": 5432, "password": "", "sync": "off", - "pub": "[\"sample__1\"]" + "pub": ["sample__1"] }, "mocking_required": false, "mock_data": {}, @@ -75,7 +75,7 @@ "port": 5432, "password": "", "sync": "off", - "pub": "[\"sample__1\"]" + "pub": ["sample__1"] }, "mocking_required": false, "mock_data": {}, @@ -103,7 +103,7 @@ "port": 5432, "password": "", "sync": "off", - "pub": "[\"sample__1\"]" + "pub": ["sample__1"] }, "mocking_required": true, "mock_data": { @@ -133,7 +133,7 @@ "port": 5432, "password": "", "sync": "off", - "pub": "[\"sample__1\"]" + "pub": ["sample__1"] }, "mocking_required": true, "mock_data": { diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/utils.py b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/utils.py index c54d22f18..9b4b58a87 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/utils.py @@ -27,7 +27,7 @@ def get_tables(self): self.server_id) + '/' + str(self.db_id) + '/', content_type='html/json') - return json.dumps([tables.json['data'][1]['value']]) + return [tables.json['data'][1]['value']] def create_subscription_api(self): diff --git a/web/regression/javascript/schema_ui_files/functions.ui.spec.js b/web/regression/javascript/schema_ui_files/functions.ui.spec.js index e9f78663e..f83341f18 100644 --- a/web/regression/javascript/schema_ui_files/functions.ui.spec.js +++ b/web/regression/javascript/schema_ui_files/functions.ui.spec.js @@ -463,7 +463,8 @@ describe('FunctionSchema', ()=>{ />); }); - it('pronamespace disabled', ()=>{ + + it('proparallel disabled', ()=>{ let editSchemaObj = new FunctionSchema( @@ -486,7 +487,8 @@ describe('FunctionSchema', ()=>{ server: { host: '127.0.0.1', port: 5432, - server_type: 'postgres', + + server_type: 'ppas', user: { id: 10, name: 'postgres', @@ -498,11 +500,12 @@ describe('FunctionSchema', ()=>{ }, }, { - type: 'procedure', + + type: 'function', }, { funcowner: 'postgres', - pronamespace: 'public', + lanname: 'edbspl', } );