From b8f63adf411e9c6f1382dcc9f888c9a3a89f86b5 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Thu, 8 Sep 2022 19:56:02 +0530 Subject: [PATCH] Fixes following code smell reported by SonarQube: 1) Replace this if-then-else flow by a single return statement 2) Remove the unnecessary boolean literals. --- .../extensions/static/js/extension.ui.js | 6 +- .../publications/static/js/publication.ui.js | 29 +++---- .../collations/static/js/collation.ui.js | 8 +- .../static/js/domain_constraints.ui.js | 5 +- .../static/js/foreign_table.ui.js | 18 ++-- .../functions/static/js/function.ui.js | 38 +++------ .../functions/static/js/trigger_function.js | 5 +- .../static/js/trigger_function.ui.js | 21 ++--- .../packages/edbfuncs/static/js/edbfunc.ui.js | 9 +- .../schemas/packages/static/js/package.js | 8 +- .../schemas/sequences/static/js/sequence.js | 5 +- .../databases/schemas/static/js/schema.js | 16 +--- .../schemas/synonyms/static/js/synonym.js | 8 +- .../tables/columns/static/js/column.ui.js | 36 ++------ .../static/js/compound_trigger.js | 8 +- .../static/js/check_constraint.ui.js | 15 +--- .../static/js/exclusion_constraint.ui.js | 10 +-- .../foreign_key/static/js/foreign_key.ui.js | 15 +--- .../index_constraint/static/js/primary_key.js | 17 ++-- .../static/js/primary_key.ui.js | 15 +--- .../static/js/unique_constraint.ui.js | 17 +--- .../tables/indexes/static/js/index.ui.js | 15 +--- .../partitions/static/js/partition.ui.js | 26 ++---- .../static/js/row_security_policy.js | 6 +- .../static/js/row_security_policy.ui.js | 15 +--- .../schemas/tables/rules/static/js/rule.ui.js | 10 +-- .../tables/static/js/partition.utils.ui.js | 84 +++++-------------- .../schemas/tables/static/js/table.js | 10 +-- .../schemas/tables/static/js/table.ui.js | 61 +++----------- .../tables/triggers/static/js/trigger.ui.js | 34 ++------ .../schemas/types/static/js/type.ui.js | 10 +-- .../schemas/views/static/js/view.ui.js | 5 +- .../servers/databases/static/js/database.js | 14 ++-- .../static/js/subscription.ui.js | 19 ++--- .../server_groups/servers/static/js/server.js | 56 ++++--------- .../servers/static/js/vacuum.ui.js | 21 +---- .../server_groups/static/js/server_group.js | 10 +-- web/pgadmin/browser/static/js/datamodel.js | 11 +-- .../misc/cloud/static/js/azure_schema.ui.js | 10 +-- .../static/js/cloud_db_details_schema.ui.js | 8 +- .../static/js/SchemaView/base_schema.ui.js | 10 +-- .../addon/fold/pgadmin-sqlfoldcode.js | 5 +- web/pgadmin/static/js/components/PgTable.jsx | 5 +- .../tools/backup/static/js/backup.ui.js | 8 +- .../static/js/import_export_selection.ui.js | 5 +- .../tools/psql/static/js/psql_module.js | 6 +- .../static/js/UserManagementDialog.jsx | 18 +--- 47 files changed, 193 insertions(+), 598 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.ui.js b/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.ui.js index b0fcc6bd3..df3f187ce 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.ui.js @@ -104,11 +104,7 @@ export default class ExtensionsSchema extends BaseUISchema { controlProps: { allowClear: true }, editable: false, options: this.schemaList, disabled: function (state) { - if (!obj.isNew(state) && !state.relocatable) { - return true; - } - - return false; + return !obj.isNew(state) && !state.relocatable; }, }, { diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/static/js/publication.ui.js b/web/pgadmin/browser/server_groups/servers/databases/publications/static/js/publication.ui.js index 577b0ad00..32fd57a85 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/static/js/publication.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/static/js/publication.ui.js @@ -34,22 +34,18 @@ export class DefaultWithSchema extends BaseUISchema { id: 'evnt_truncate', label: gettext('TRUNCATE'), type: 'switch', group: gettext('With'), visible: function() { - if(!_.isUndefined(this.node_info['node_info']) - && !_.isUndefined(this.node_info['node_info'].version) && - this.node_info['node_info'].version >= 110000) - return true; - return false; + return !_.isUndefined(this.node_info['node_info']) + && !_.isUndefined(this.node_info['node_info'].version) + && this.node_info['node_info'].version >= 110000; }, },{ id: 'publish_via_partition_root', label: gettext('Publish via root?'), type: 'switch', group: gettext('With'), visible: function() { - if(!_.isUndefined(this.node_info['node_info']) - && !_.isUndefined(this.node_info['node_info'].version) && - this.node_info['node_info'].version >= 130000) - return true; - return false; + return !_.isUndefined(this.node_info['node_info']) + && !_.isUndefined(this.node_info['node_info'].version) + && this.node_info['node_info'].version >= 130000; }, }]; } @@ -111,12 +107,9 @@ export default class PublicationSchema extends BaseUISchema { id: 'name', label: gettext('Name'), type: 'text', mode: ['properties', 'create', 'edit'], noEmpty: true, visible: function() { - if(!_.isUndefined(this.node_info['node_info']) - && !_.isUndefined(this.node_info['node_info'].version) - && this.node_info['node_info'].version >= 100000) { - return true; - } - return false; + return !_.isUndefined(this.node_info['node_info']) + && !_.isUndefined(this.node_info['node_info'].version) + && this.node_info['node_info'].version >= 100000; }, },{ id: 'oid', label: gettext('OID'), cell: 'string', mode: ['properties'], @@ -125,9 +118,7 @@ export default class PublicationSchema extends BaseUISchema { id: 'pubowner', label: gettext('Owner'), type: 'select', options: this.fieldOptions.role, disabled: () => { - if (obj.isNew()) - return true; - return false; + return obj.isNew(); }, mode: ['edit', 'properties', 'create'], controlProps: { allowClear: false}, },{ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.ui.js index a8fd2702f..67d3e37c5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.ui.js @@ -79,9 +79,7 @@ export default class CollationSchema extends BaseUISchema { // Enable copy_collation only if locale & lc_* is not provided if (state.locale) return true; - if (state.lc_collate || state.lc_type) - return true; - return false; + return state.lc_collate || state.lc_type; }, deps: ['locale', 'lc_collate', 'lc_type'], }, @@ -94,9 +92,7 @@ export default class CollationSchema extends BaseUISchema { // Enable localy only if lc_* & copy_collation is not provided if (state.lc_collate || state.lc_type) return true; - if (state.copy_collation) - return true; - return false; + return state.copy_collation; } }, { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.ui.js index fc074eaee..ff2a24a2b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.ui.js @@ -51,10 +51,7 @@ export default class DomainConstraintSchema extends BaseUISchema { cell:'boolean', group: gettext('Definition'), min_version: 90200, mode: ['properties', 'create', 'edit'], readonly: function(state) { - if (!obj.isNew(state) && obj._origData.convalidated) { - return true; - } - return false; + return !obj.isNew(state) && obj._origData.convalidated; } } ]; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.ui.js index 26ceefac5..aaa1e8850 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.ui.js @@ -59,10 +59,7 @@ export default class ForeignTableSchema extends BaseUISchema { } canEditDeleteRowColumns(colstate) { - if (!isEmptyString(colstate.inheritedfrom)) { - return false; - } - return true; + return isEmptyString(colstate.inheritedfrom); } getTableOid(tabId) { @@ -183,7 +180,7 @@ export default class ForeignTableSchema extends BaseUISchema { canAdd: true, canDelete: true, columns: ['conname','consrc', 'connoinherit', 'convalidated'], canEdit: true, canDeleteRow: function(state) { - return (state.conislocal == true || _.isUndefined(state.conislocal)) ? true : false; + return (state.conislocal || _.isUndefined(state.conislocal)) ? true : false; }, canEditRow: function(state) { return obj.isNew(state); @@ -430,10 +427,8 @@ export class ColumnSchema extends BaseUISchema { || _.isNull(state.inheritedid) || _.isUndefined(state.inheritedfrom) || _.isNull(state.inheritedfrom))) { return false; } - if (obj.nodeInfo.server.version < 90300){ - return false; - } - return true; + + return obj.nodeInfo.server.version >= 90300; }, }, { @@ -531,10 +526,7 @@ export class CheckConstraintSchema extends BaseUISchema { editable: (state) => { if (_.isUndefined(obj.isNew)) { return true; } if (!obj.isNew(state)) { - if(state.convalidated && obj.convalidated_default) { - return false; - } - return true; + return !(state.convalidated && obj.convalidated_default); } return true; }, 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 caf602501..621dbd4c9 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 @@ -84,12 +84,9 @@ export class DefaultArgumentSchema extends BaseUISchema { } // Below will disable default value cell if argument mode is 'INOUT' or 'OUT' as // user cannot set default value for out parameters. - if(!_.isUndefined(state.argmode) && !_.isUndefined(state.name) && + return !(!_.isUndefined(state.argmode) && !_.isUndefined(state.name) && state.name == 'argdefval' && - (state.argmode == 'INOUT' || state.argmode == 'OUT')) { - return false; - } - return true; + (state.argmode == 'INOUT' || state.argmode == 'OUT')); } } @@ -149,8 +146,7 @@ export default class FunctionSchema extends BaseUISchema { isVisible(state) { if(this.type !== 'procedure'){ - if (state.sysproc) { return false; } - return true; + return !state.sysproc; }else{ if (state.sysfunc) { return false; @@ -234,10 +230,7 @@ export default class FunctionSchema extends BaseUISchema { id: 'sysproc', label: gettext('System procedure?'), cell:'boolean', type: 'switch', mode: ['properties'], visible: () => { - if(this.type === 'procedure'){ - return true; - } - return false; + return this.type === 'procedure'; }, },{ id: 'description', label: gettext('Comment'), cell: 'string', @@ -268,25 +261,21 @@ export default class FunctionSchema extends BaseUISchema { if(this.type === 'procedure'){ return this.node_info['node_info'].server.version < 110000; } - if (this.node_info && 'catalog' in this.node_info) { - return true; - } - return false; + + return this.node_info && 'catalog' in this.node_info; } }, { id: 'probin', label: gettext('Object file'), cell: 'string', type: 'text', group: gettext('Definition'), deps: ['lanname'], visible: function(state) { - if (state.lanname == 'c') { return true; } - return false; + return state.lanname == 'c'; }, 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; + return state.lanname == 'c'; }, disabled: obj.inCatalog(), }, { @@ -307,10 +296,7 @@ export default class FunctionSchema extends BaseUISchema { group: gettext('Code'), deps: ['lanname'], isFullTab: true, visible: function(state) { - if (state.lanname === 'c') { - return false; - } - return true; + return state.lanname !== 'c'; }, disabled: obj.inCatalog(), },{ id: 'provolatile', label: gettext('Volatility'), cell: 'text', @@ -361,7 +347,7 @@ export default class FunctionSchema extends BaseUISchema { deps: ['proretset'], visible: obj.isVisible, readonly: (state) => { let isReadonly = true; - if(state.proretset == true) { + if(state.proretset) { isReadonly = false; } return isReadonly; @@ -380,9 +366,7 @@ export default class FunctionSchema extends BaseUISchema { return true; } - if (obj.node_info['node_info'].server.user.is_superuser) - return false; - return true; + return !(obj.node_info['node_info'].server.user.is_superuser); }, group: gettext('Options'), visible: obj.isVisible, options: this.fieldOptions.getSupportFunctions, min_version: 120000, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js index d9ac6bbb0..313d4c87d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.js @@ -45,10 +45,7 @@ define('pgadmin.node.trigger_function', [ canEdit: function(itemData, item) { let node = pgBrowser.tree.findNodeByDomElement(item); - if (!node || node.parentNode.getData()._type === 'trigger') - return false; - - return true; + return !(!node || node.parentNode.getData()._type === 'trigger'); }, hasSQL: true, showMenu: function(itemData, item) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.ui.js index 72a7e6316..0df469b86 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.ui.js @@ -75,15 +75,11 @@ export default class TriggerFunctionSchema extends BaseUISchema { isVisible(state) { - if (state.name == 'sysproc') { return false; } - return true; + return state.name != 'sysproc'; } isDisabled() { - if('catalog' in this.fieldOptions.nodeInfo) { - return true; - } - return false; + return 'catalog' in this.fieldOptions.nodeInfo; } @@ -166,26 +162,21 @@ export default class TriggerFunctionSchema extends BaseUISchema { mode: ['properties', 'create', 'edit'], group: gettext('Code'), deps: ['lanname'], visible: (state) => { - if (state.lanname == 'c') { - return false; - } - return true; + return state.lanname !== 'c'; }, disabled: obj.isDisabled, readonly: obj.isReadonly, },{ id: 'probin', label: gettext('Object file'), cell: 'string', type: 'text', group: gettext('Definition'), deps: ['lanname'], visible: (state) => { - if (state.lanname == 'c') { return true; } - return false; + return state.lanname == 'c'; }, disabled: obj.isDisabled, readonly: obj.isReadonly, },{ id: 'prosrc_c', label: gettext('Link symbol'), cell: 'string', type: 'text', group: gettext('Definition'), deps: ['lanname'], visible: (state) => { - if (state.lanname == 'c') { return true; } - return false; + return state.lanname == 'c'; }, disabled: obj.isDisabled, readonly: obj.isReadonly, },{ @@ -220,7 +211,7 @@ export default class TriggerFunctionSchema extends BaseUISchema { group: gettext('Options'), disabled: (state) => { let isDisabled = true; - if(state.proretset == true) { + if(state.proretset) { isDisabled = false; } return isDisabled; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbfunc.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbfunc.ui.js index 95599039d..d15053259 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbfunc.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbfunc.ui.js @@ -33,9 +33,7 @@ export default class EDBFuncSchema extends BaseUISchema { } isVisible(state) { - if (state.name == 'sysfunc') { return true; } - else if (state.name == 'sysproc') { return true; } - return false; + return state.name == 'sysfunc' || state.name == 'sysproc'; } get idAttribute() { @@ -77,10 +75,7 @@ export default class EDBFuncSchema extends BaseUISchema { group: gettext('Code'), type: 'sql', isFullTab: true, visible: function(state) { - if (state.lanname == 'c') { - return false; - } - return true; + return state.lanname !== 'c'; }, disabled: true, }]; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js index 5b43f7508..0b46816c5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.js @@ -75,7 +75,7 @@ define('pgadmin.node.package', [ }, canCreate: function(itemData, item, data) { //If check is false then , we will allow create menu - if (data && data.check == false) + if (data && !data.check) return true; let treeData = pgBrowser.tree.getTreeNodeHierarchy(item), @@ -85,11 +85,7 @@ define('pgadmin.node.package', [ return false; // If it is catalog then don't allow user to create package - if (treeData['catalog'] != undefined) - return false; - - // by default we want to allow create menu - return true; + return treeData['catalog'] == undefined; }, getSchema: (treeNodeInfo, itemNodeData) => { let nodeObj = pgBrowser.Nodes['package']; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js index 57026803d..f6798b6be 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js @@ -82,10 +82,7 @@ define('pgadmin.node.sequence', [ role: ()=>getNodeListByName('role', treeNodeInfo, itemNodeData), schema: ()=>getNodeListByName('schema', treeNodeInfo, itemNodeData, {}, (m)=>{ // If schema name start with pg_* then we need to exclude them - if (m.label.match(/^pg_/)) { - return false; - } - return true; + return !(m.label.match(/^pg_/)); }), allTables: ()=>getNodeListByName('table', treeNodeInfo, itemNodeData, {includeItemKeys: ['_id']}), getColumns: (params)=>{ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js index fda8a4979..0b4b588f8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js @@ -175,10 +175,7 @@ define('pgadmin.node.schema', [ return true; } - if(!m.top.inSchema.apply(this, [m])) { - return false; - } - return true; + return m.top.inSchema.apply(this, [m]); }, },{ id: 'autovacuum_enabled', label: gettext('Autovacuum Enabled?'), @@ -192,9 +189,7 @@ define('pgadmin.node.schema', [ ], deps: ['autovacuum_custom'], disabled: function(m) { - if(!m.top.inSchema.apply(this, [m]) && - m.get('autovacuum_custom') == true) { - + if(!m.top.inSchema.apply(this, [m]) && m.get('autovacuum_custom')) { return false; } @@ -243,11 +238,8 @@ define('pgadmin.node.schema', [ disabled: function(m) { // We need to check additional condition to toggle enable/disable // for table auto-vacuum - if(!m.top.inSchema.apply(this, [m]) && - (m.isNew() || (m.get('toast_autovacuum_enabled') === true || m.top.get('hastoasttable') === true))) { - return false; - } - return true; + return !(!m.top.inSchema.apply(this, [m]) && + (m.isNew() || (m.get('toast_autovacuum_enabled') === true || m.top.get('hastoasttable') === true))); }, },{ id: 'toast_autovacuum_enabled', label: gettext('Autovacuum Enabled?'), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js index 40896b078..721a9cafa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js @@ -102,7 +102,7 @@ define('pgadmin.node.synonym', [ }, canCreate: function(itemData, item, data) { //If check is false then , we will allow create menu - if (data && data.check == false) + if (data && !data.check) return true; let treeData = pgBrowser.tree.getTreeNodeHierarchy(item), @@ -112,11 +112,7 @@ define('pgadmin.node.synonym', [ return false; // If it is catalog then don't allow user to create synonyms - if (treeData['catalog'] != undefined) - return false; - - // by default we do not want to allow create menu - return true; + return treeData['catalog'] == undefined; }, }); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js index 7b37d899e..96bb15910 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js @@ -105,27 +105,19 @@ export default class ColumnSchema extends BaseUISchema { // Check whether the column is identity column or not isIdentityColumn(state) { let isIdentity = state.attidentity; - if(!_.isUndefined(isIdentity) && !_.isNull(isIdentity) && !_.isEmpty(isIdentity)) - return false; - return true; + return !(!_.isUndefined(isIdentity) && !_.isNull(isIdentity) && !_.isEmpty(isIdentity)); } // Check whether the column is a identity column isTypeIdentity(state) { let colconstype = state.colconstype; - if (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'i') { - return true; - } - return false; + return (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'i'); } // Check whether the column is a generated column isTypeGenerated(state) { let colconstype = state.colconstype; - if (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'g') { - return true; - } - return false; + return (!_.isUndefined(colconstype) && !_.isNull(colconstype) && colconstype == 'g'); } // We will check if we are under schema node & in 'create' mode @@ -200,11 +192,8 @@ export default class ColumnSchema extends BaseUISchema { let name = state.name; - if(!obj.inSchemaWithColumnCheck(state) - && (_.isUndefined(name) || _.isNull(name) || name == '')) { - return true; - } - return false; + return (!obj.inSchemaWithColumnCheck(state) + && (_.isUndefined(name) || _.isNull(name) || name == '')); }, editable: function(state) { // If primary key already exist then disable. @@ -229,10 +218,7 @@ export default class ColumnSchema extends BaseUISchema { return false; } - if(!obj.inSchemaWithColumnCheck(state)) { - return true; - } - return false; + return !obj.inSchemaWithColumnCheck(state); }, },{ id: 'attnum', label: gettext('Position'), cell: 'text', @@ -401,10 +387,7 @@ export default class ColumnSchema extends BaseUISchema { } }, editable: function(state) { // inheritedfrom has value then we should disable it - if (!isEmptyString(state.inheritedfrom) || !this.editableCheckForTable(state)) { - return false; - } - return true; + return !(!isEmptyString(state.inheritedfrom) || !this.editableCheckForTable(state)); }, },{ id: 'attnotnull', label: gettext('Not NULL?'), cell: 'switch', @@ -451,10 +434,7 @@ export default class ColumnSchema extends BaseUISchema { }; }, disabled: function(state) { - if (!this.isNew(state) && state.colconstype == 'g') { - return true; - } - return false; + return (!this.isNew(state) && state.colconstype == 'g'); }, min_version: 100000, }, { id: 'attidentity', label: gettext('Identity'), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js index fb0fb3872..ab29b46f1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.js @@ -191,7 +191,7 @@ define('pgadmin.node.compound_trigger', [ canCreate: function(itemData, item, data) { //If check is false then , we will allow create menu - if (data && data.check == false) + if (data && !data.check) return true; let treeData = pgBrowser.tree.getTreeNodeHierarchy(item), @@ -201,11 +201,7 @@ define('pgadmin.node.compound_trigger', [ return false; // If it is catalog then don't allow user to create package - if (treeData['catalog'] != undefined) - return false; - - // by default we want to allow create menu - return true; + return treeData['catalog'] == undefined; }, // Check to whether trigger is disable ? canCreate_with_compound_trigger_enable: function(itemData, item, data) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js index 484962d0c..563e35bf8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui.js @@ -57,10 +57,7 @@ export default class CheckConstraintSchema extends BaseUISchema { id: 'comment', label: gettext('Comment'), type: 'multiline', cell: 'text', mode: ['properties', 'create', 'edit'], deps:['name'], disabled: function(state) { - if(isEmptyString(state.name)) { - return true; - } - return false; + return isEmptyString(state.name); }, depChange: (state)=>{ if(isEmptyString(state.name)) { @@ -77,10 +74,7 @@ export default class CheckConstraintSchema extends BaseUISchema { deps: [['is_partitioned']], disabled: function() { // Disabled if table is a partitioned table. - if(obj.inTable && obj.top?.sessData.is_partitioned) { - return true; - } - return false; + return obj.inTable && obj.top?.sessData.is_partitioned; }, depChange: ()=>{ if(obj.inTable && obj.top?.sessData.is_partitioned) { @@ -96,10 +90,7 @@ export default class CheckConstraintSchema extends BaseUISchema { if(obj.inTable && obj.top && !obj.top.isNew()) { return !(_.isUndefined(state.oid) || state.convalidated); } - if(!obj.isNew(state) && !obj.origData.convalidated) { - return true; - } - return false; + return !obj.isNew(state) && !obj.origData.convalidated; }, mode: ['properties', 'create', 'edit'], }]; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js index 0d7a4cb62..3c82efba0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui.js @@ -219,10 +219,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema { } get inTable() { - if(this.top && this.top instanceof TableSchema) { - return true; - } - return false; + return this.top && this.top instanceof TableSchema; } initialise(data) { @@ -262,10 +259,7 @@ export default class ExclusionConstraintSchema extends BaseUISchema { id: 'comment', label: gettext('Comment'), cell: 'text', type: 'multiline', mode: ['properties', 'create', 'edit'], deps:['name'], disabled:function(state) { - if(isEmptyString(state.name)) { - return true; - } - return false; + return isEmptyString(state.name); }, depChange: (state)=>{ if(isEmptyString(state.name)) { return {comment: ''}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js index 8aaf93bf0..a2167facc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js @@ -160,10 +160,7 @@ export default class ForeignKeySchema extends BaseUISchema { } get inTable() { - if(this.top && this.top instanceof TableSchema) { - return true; - } - return false; + return this.top && this.top instanceof TableSchema; } changeColumnOptions(columns) { @@ -194,10 +191,7 @@ export default class ForeignKeySchema extends BaseUISchema { id: 'comment', label: gettext('Comment'), cell: 'text', type: 'multiline', mode: ['properties', 'create', 'edit'], deps:['name'], disabled:function(state) { - if(isEmptyString(state.name)) { - return true; - } - return false; + return isEmptyString(state.name); }, depChange: (state)=>{ if(isEmptyString(state.name)) { return {comment: ''}; @@ -252,10 +246,7 @@ export default class ForeignKeySchema extends BaseUISchema { return true; } // If we are in table edit mode then - if(state.hasindex) { - return true; - } - return false; + return state.hasindex; }, depChange: (state, source, topState, actionObj)=>{ if(!obj.isNew(state)) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js index aeb3d9354..006e70b9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.js @@ -53,7 +53,7 @@ define('pgadmin.node.primary_key', [ }, canCreate: function(itemData, item, data) { // If check is false then , we will allow create menu - if (data && data.check == false) + if (data && !data.check) return true; let t = pgBrowser.tree, i = item, d = itemData, parents = [], @@ -164,11 +164,7 @@ define('pgadmin.node.primary_key', [ } // We can't update columns of existing index constraint. - if (!m.isNew()) { - return true; - } - - return false; + return !m.isNew(); }, // Define the schema for the index constraint node schema: [{ @@ -451,12 +447,9 @@ define('pgadmin.node.primary_key', [ visible: function(m) { /* In table properties, m.node_info is not available */ m = m.top; - if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server) + return (!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server) && !_.isUndefined(m.node_info.server.version) && - m.node_info.server.version >= 110000) - return true; - - return false; + m.node_info.server.version >= 110000); }, control: Backform.MultiSelectAjaxControl.extend({ defaults: _.extend( @@ -602,7 +595,7 @@ define('pgadmin.node.primary_key', [ }, disabled: function(m) { // Disable if condeferred is false or unselected. - if(m.get('condeferrable') == true) { + if(m.get('condeferrable')) { return false; } else { setTimeout(function(){ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js index 634212380..8571f3de0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui.js @@ -37,10 +37,7 @@ export default class PrimaryKeySchema extends BaseUISchema { } get inTable() { - if(this.top && this.top instanceof TableSchema) { - return true; - } - return false; + return this.top && this.top instanceof TableSchema; } changeColumnOptions(columns) { @@ -64,10 +61,7 @@ export default class PrimaryKeySchema extends BaseUISchema { id: 'comment', label: gettext('Comment'), cell: 'multiline', type: 'multiline', mode: ['properties', 'create', 'edit'], deps:['name'], disabled: (state)=>{ - if(isEmptyString(state.name)){ - return true; - } - return false; + return isEmptyString(state.name); }, depChange: (state)=>{ if(isEmptyString(state.name)){ return {comment: ''}; @@ -159,10 +153,7 @@ export default class PrimaryKeySchema extends BaseUISchema { mode: ['properties', 'create', 'edit'], visible: function() { /* In table properties, nodeInfo is not available */ - if(this.getServerVersion() >= 110000) - return true; - - return false; + return this.getServerVersion() >= 110000; }, deps: ['index'], readonly: function(state) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js index 014f3b634..1f50dd7b5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui.js @@ -38,10 +38,7 @@ export default class UniqueConstraintSchema extends BaseUISchema { } get inTable() { - if(this.top && this.top instanceof TableSchema) { - return true; - } - return false; + return this.top && this.top instanceof TableSchema; } changeColumnOptions(columns) { @@ -65,10 +62,7 @@ export default class UniqueConstraintSchema extends BaseUISchema { id: 'comment', label: gettext('Comment'), cell: 'multiline', type: 'multiline', mode: ['properties', 'create', 'edit'], deps:['name'], disabled: (state)=>{ - if(isEmptyString(state.name)){ - return true; - } - return false; + return isEmptyString(state.name); }, depChange: (state)=>{ if(isEmptyString(state.name)){ return {comment: ''}; @@ -158,12 +152,9 @@ export default class UniqueConstraintSchema extends BaseUISchema { mode: ['properties', 'create', 'edit'], visible: function() { /* In table properties, nodeInfo is not available */ - if(!_.isUndefined(this.nodeInfo) && !_.isUndefined(this.nodeInfo.server) + return (!_.isUndefined(this.nodeInfo) && !_.isUndefined(this.nodeInfo.server) && !_.isUndefined(this.nodeInfo.server.version) && - this.nodeInfo.server.version >= 110000) - return true; - - return false; + this.nodeInfo.server.version >= 110000); }, deps: ['index'], readonly: function(state) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js index 8788cf5ed..59e39bb15 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js @@ -163,7 +163,7 @@ export class ColumnSchema extends BaseUISchema { if(isEmptyString(topState.amname) || topState.amname === 'btree') { // We need to set nulls to true if sort_order is set to desc // nulls first is default for desc - if(state.sort_order == true && actionObj.oldState.sort_order == false) { + if(state.sort_order && !actionObj.oldState.sort_order) { setTimeout(function() { state.nulls = true; }, 10); @@ -195,11 +195,7 @@ export class ColumnSchema extends BaseUISchema { } function inSchema(node_info) { - if(node_info && 'catalog' in node_info) - { - return true; - } - return false; + return node_info && 'catalog' in node_info; } export default class IndexSchema extends BaseUISchema { @@ -257,12 +253,9 @@ export default class IndexSchema extends BaseUISchema { } isVisible() { - if(!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server) + return (!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server) && !_.isUndefined(this.node_info.server.version) && - this.node_info.server.version >= 110000) - return true; - - return false; + this.node_info.server.version >= 110000); } get baseFields() { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.ui.js index 330c9c8e1..ef806d504 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.ui.js @@ -34,11 +34,7 @@ export function getNodePartitionTableSchema(treeNodeInfo, itemNodeData, pgBrowse cacheNode: 'database', }, (d)=>{ // If schema name start with pg_* then we need to exclude them - if(d && d.label.match(/^pg_/)) - { - return false; - } - return true; + return !(d && d.label.match(/^pg_/)); }), spcname: spcname, coll_inherits: ()=>getNodeAjaxOptions('get_inherits', partNode, treeNodeInfo, itemNodeData), @@ -186,18 +182,14 @@ export default class PartitionTableSchema extends BaseUISchema { mode: ['edit', 'create'], min_version: 100000, visible: function(state) { // Always show in case of create mode - if (obj.isNew(state) || state.is_partitioned) - return true; - return false; + return obj.isNew(state) || state.is_partitioned; }, },{ id: 'is_partitioned', label:gettext('Partitioned table?'), cell: 'switch', type: 'switch', mode: ['properties', 'create', 'edit'], min_version: 100000, readonly: function(state) { - if (!obj.isNew(state)) - return true; - return false; + return !obj.isNew(state); }, },{ id: 'is_sys_table', label: gettext('System table?'), cell: 'switch', @@ -297,9 +289,7 @@ export default class PartitionTableSchema extends BaseUISchema { mode:['create'], min_version: 100000, disabled: function(state) { - if (!state.is_partitioned) - return true; - return false; + return !state.is_partitioned; }, readonly: function(state) {return !obj.isNew(state);}, }, @@ -311,9 +301,7 @@ export default class PartitionTableSchema extends BaseUISchema { deps: ['is_partitioned', 'partition_type', 'typname'], canEdit: false, canDelete: true, canAdd: function(state) { - if (obj.isNew(state) && state.is_partitioned) - return true; - return false; + return obj.isNew(state) && state.is_partitioned; }, canAddRow: function(state) { let columnsExist = false; @@ -384,9 +372,7 @@ export default class PartitionTableSchema extends BaseUISchema { customDeleteMsg: gettext('Are you sure you wish to detach this partition?'), columns:['is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder'], canAdd: function(state) { - if (state.is_partitioned) - return true; - return false; + return state.is_partitioned; }, min_version: 100000, }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.js index 768cd0742..97595517e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.js @@ -96,11 +96,7 @@ define('pgadmin.node.row_security_policy', [ return false; // If server is less than 9.5 then do not allow 'create' menu - if (server && server.version < 90500) - return false; - - // by default we want to allow create menu - return true; + return server && server.version >= 90500; }, }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.ui.js index 2cf6e550f..00434f22f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.ui.js @@ -40,10 +40,7 @@ export default class RowSecurityPolicySchema extends BaseUISchema { } disableUsingField(state){ - if (state.event == 'INSERT'){ - return true; - } - return false; + return state.event == 'INSERT'; } disableWithCheckField(state){ @@ -69,10 +66,7 @@ export default class RowSecurityPolicySchema extends BaseUISchema { { id: 'event', label: gettext('Event'), type: 'select', group: gettext('Commands'),disabled: () => { - if(obj.isNew()) { - return false; - } - return true; + return !obj.isNew(); }, controlProps: { allowClear: false }, options:[ @@ -126,10 +120,7 @@ export default class RowSecurityPolicySchema extends BaseUISchema { {label: 'RESTRICTIVE', value: 'RESTRICTIVE'}, ], visible: () => { - if(obj.nodeInfo.server.version >= 100000) - return true; - - return false; + return obj.nodeInfo.server.version >= 100000; }, }, ]; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.ui.js index ab2e011f4..7e7016780 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.ui.js @@ -42,10 +42,7 @@ export default class RuleSchema extends BaseUISchema { if (state.name == '_RETURN') { return true; } - if (obj.isNew(state) || obj.fieldOptions.nodeInfo.server.version >= 90400) { - return false; - } - return true; + return !(obj.isNew(state) || obj.fieldOptions.nodeInfo.server.version >= 90400); }, noEmpty: true }, { @@ -71,10 +68,7 @@ export default class RuleSchema extends BaseUISchema { mode: ['edit', 'properties'], group: gettext('Definition'), type: 'select', disabled: () => { - if('catalog' in obj.fieldOptions.nodeInfo || 'view' in obj.fieldOptions.nodeInfo) { - return true; - } - return false; + return 'catalog' in obj.fieldOptions.nodeInfo || 'view' in obj.fieldOptions.nodeInfo; }, options: [ {label: gettext('Enable'), value: 'O'}, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.ui.js index e847c931b..021cfff1d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.ui.js @@ -27,10 +27,7 @@ export class PartitionKeysSchema extends BaseUISchema { } isEditable(state) { - if(state.key_type == 'expression') { - return false; - } - return true; + return state.key_type != 'expression'; } get baseFields() { @@ -75,10 +72,7 @@ export class PartitionKeysSchema extends BaseUISchema { } }, editable: function(state) { - if(state.key_type == 'expression') { - return true; - } - return false; + return state.key_type == 'expression'; }, },{ id: 'collationame', label: gettext('Collation'), cell: 'select', @@ -144,19 +138,13 @@ export class PartitionsSchema extends BaseUISchema { } isEditable(state, type) { - if(this.top && this.top.sessData.partition_type == type && this.isNew(state) - && state.is_default !== true) { - return true; - } - return false; + return (this.top && this.top.sessData.partition_type == type && this.isNew(state) + && state.is_default !== true); } isDisable(state, type) { - if(this.top && this.top.sessData.partition_type == type && this.isNew(state) - && state.is_default !== true) { - return false; - } - return true; + return !(this.top && this.top.sessData.partition_type == type && this.isNew(state) + && state.is_default !== true); } get baseFields() { @@ -171,16 +159,10 @@ export class PartitionsSchema extends BaseUISchema { {label: gettext('Create'), value: false}, ], controlProps: {allowClear: false}, editable: function(state) { - if(obj.isNew(state) && !obj.top.isNew()) { - return true; - } - return false; + return obj.isNew(state) && !obj.top.isNew(); }, readonly: function(state) { - if(obj.isNew(state) && !obj.top.isNew()) { - return false; - } - return true; + return !(obj.isNew(state) && !obj.top.isNew()); }, },{ id: 'partition_name', label: gettext('Name'), deps: ['is_attach'], @@ -211,35 +193,23 @@ export class PartitionsSchema extends BaseUISchema { } }, editable: function(state) { - if(obj.isNew(state)) { - return true; - } - return false; + return obj.isNew(state); }, readonly: function(state) { - if(obj.isNew(state)) { - return false; - } - return true; + return !obj.isNew(state); }, noEmpty: true, },{ id: 'is_default', label: gettext('Default'), type: 'switch', cell:'switch', width: 55, disableResizing: true, min_version: 110000, editable: function(state) { - if(obj.top && (obj.top.sessData.partition_type == 'range' || + return (obj.top && (obj.top.sessData.partition_type == 'range' || obj.top.sessData.partition_type == 'list') && obj.isNew(state) - && obj.getServerVersion() >= 110000) { - return true; - } - return false; + && obj.getServerVersion() >= 110000); }, readonly: function(state) { - if(obj.top && (obj.top.sessData.partition_type == 'range' || + return !(obj.top && (obj.top.sessData.partition_type == 'range' || obj.top.sessData.partition_type == 'list') && obj.isNew(state) - && obj.getServerVersion() >= 110000) { - return false; - } - return true; + && obj.getServerVersion() >= 110000); }, },{ id: 'values_from', label: gettext('From'), type:'text', cell: 'text', @@ -280,17 +250,11 @@ export class PartitionsSchema extends BaseUISchema { },{ id: 'values_remainder', label: gettext('Remainder'), type:'int', cell: 'int', editable: function(state) { - if(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state)) { - return true; - } - return false; + return obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state); }, disabled: function(state) { - if(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state) - && state.is_default !== true) { - return false; - } - return true; + return !(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state) + && state.is_default !== true); }, },{ id: 'is_sub_partitioned', label:gettext('Partitioned table?'), cell: 'switch', @@ -299,10 +263,7 @@ export class PartitionsSchema extends BaseUISchema { if(!obj.isNew(state)) { return true; } - if(state.is_attach) { - return true; - } - return false; + return state.is_attach; }, depChange: (state)=>{ if(state.is_attach) { @@ -338,9 +299,7 @@ export class PartitionsSchema extends BaseUISchema { deps: ['is_sub_partitioned', 'sub_partition_type', ['typname']], canEdit: false, canDelete: true, canAdd: function(state) { - if (obj.isNew(state) && state.is_sub_partitioned) - return true; - return false; + return obj.isNew(state) && state.is_sub_partitioned; }, canAddRow: function(state) { let columnsExist = false; @@ -376,10 +335,7 @@ export class PartitionsSchema extends BaseUISchema { text: state.sub_partition_scheme, }), visible: function(state) { - if(obj.isNew(state) && !isEmptyString(state.sub_partition_scheme)) { - return true; - } - return false; + return obj.isNew(state) && !isEmptyString(state.sub_partition_scheme); }, }]; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index 27cce8b86..69f2a5732 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -316,9 +316,7 @@ define('pgadmin.node.table', [ type: 'switch', mode: ['properties', 'create', 'edit'], visible: 'isVersionGreaterThan96', readonly: function(m) { - if (!m.isNew()) - return true; - return false; + return !m.isNew(); }, },{ id: 'description', label: gettext('Comment'), type: 'multiline', @@ -336,11 +334,7 @@ define('pgadmin.node.table', [ }, // We will disable everything if we are under catalog node inSchema: function() { - if(this.node_info && 'catalog' in this.node_info) - { - return true; - } - return false; + return this.node_info && 'catalog' in this.node_info; }, }), // Check to whether table has disable trigger(s) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js index 7dccff922..d2d376a37 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui.js @@ -39,11 +39,7 @@ export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) { cacheNode: 'database', }, (d)=>{ // If schema name start with pg_* then we need to exclude them - if(d && d.label.match(/^pg_/)) - { - return false; - } - return true; + return !(d && d.label.match(/^pg_/)); }), spcname: spcname, coll_inherits: ()=>getNodeAjaxOptions('get_inherits', tableNode, treeNodeInfo, itemNodeData), @@ -106,10 +102,7 @@ export class ConstraintsSchema extends BaseUISchema { } canAdd(state) { - if (state.is_partitioned && this.top.getServerVersion() < 110000) { - return false; - } - return true; + return !(state.is_partitioned && this.top.getServerVersion() < 110000); } get baseFields() { @@ -219,17 +212,11 @@ export class LikeSchema extends BaseUISchema { } isLikeDisable(state) { - if(!this.top.inSchemaWithModelCheck(state) && isEmptyString(state.typname)) { - return false; - } - return true; + return !(!this.top.inSchemaWithModelCheck(state) && isEmptyString(state.typname)); } isRelationDisable(state) { - if(isEmptyString(state.like_relation)) { - return true; - } - return false; + return isEmptyString(state.like_relation); } resetVals(state) { @@ -396,20 +383,14 @@ export default class TableSchema extends BaseUISchema { canAddRowColumns(state) { if(!this.inCatalog()) { // if of_type then disable add in grid - if (!isEmptyString(state.typname)) { - return false; - } - return true; + return isEmptyString(state.typname); } return false; } // Check for column grid when to edit/delete (for each row) canEditDeleteRowColumns(colstate) { - if (!isEmptyString(colstate.inheritedfrom)) { - return false; - } - return true; + return isEmptyString(colstate.inheritedfrom); } isPartitioned(state) { @@ -464,18 +445,14 @@ export default class TableSchema extends BaseUISchema { return false; } // Always show in case of create mode - if (obj.isNew(state) || state.is_partitioned) - return true; - return false; + return (obj.isNew(state) || state.is_partitioned); }, },{ id: 'is_partitioned', label:gettext('Partitioned table?'), cell: 'switch', type: 'switch', mode: ['properties', 'create', 'edit'], min_version: 100000, visible: !this.inErd, readonly: function(state) { - if (!obj.isNew(state)) - return true; - return false; + return !obj.isNew(state); }, },{ id: 'is_sys_table', label: gettext('System table?'), cell: 'switch', @@ -495,10 +472,7 @@ export default class TableSchema extends BaseUISchema { if(state.adding_inherit_cols || state.is_partitioned){ return true; } - if(!obj.inCatalog() && isEmptyString(state.typname)) { - return false; - } - return true; + return !(!obj.inCatalog() && isEmptyString(state.typname)); }, depChange: (state, source, topState, actionObj)=>{ if(actionObj.type == SCHEMA_STATE_ACTIONS.SET_VALUE && actionObj.path[0] == 'coll_inherits') { @@ -703,10 +677,7 @@ export default class TableSchema extends BaseUISchema { mode: ['properties', 'create', 'edit'], group: 'advanced', deps: ['coll_inherits'], visible: !this.inErd, disabled: (state)=>{ - if(!obj.inSchemaWithModelCheck(state) && isEmptyString(state.coll_inherits)) { - return false; - } - return true; + return !(!obj.inSchemaWithModelCheck(state) && isEmptyString(state.coll_inherits)); }, options: this.fieldOptions.typname, optionsLoaded: (res)=>{ obj.ofTypeTables = res; }, @@ -836,9 +807,7 @@ export default class TableSchema extends BaseUISchema { mode:['create'], min_version: 100000, disabled: function(state) { - if (!state.is_partitioned) - return true; - return false; + return !state.is_partitioned; }, readonly: function(state) {return !obj.isNew(state);}, }, @@ -851,9 +820,7 @@ export default class TableSchema extends BaseUISchema { deps: ['is_partitioned', 'partition_type', 'typname'], canEdit: false, canDelete: true, canAdd: function(state) { - if (obj.isNew(state) && state.is_partitioned) - return true; - return false; + return obj.isNew(state) && state.is_partitioned; }, canAddRow: function(state) { let columnsExist = false; @@ -924,9 +891,7 @@ export default class TableSchema extends BaseUISchema { customDeleteMsg: gettext('Are you sure you wish to detach this partition?'), columns:['is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder'], canAdd: function(state) { - if (state.is_partitioned) - return true; - return false; + return state.is_partitioned; }, min_version: 100000, }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.ui.js index 285262f75..ee9499553 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.ui.js @@ -84,7 +84,7 @@ export class EventSchema extends BaseUISchema { let is_constraint_trigger = state.is_constraint_trigger, is_row_trigger = state.is_row_trigger, server_type = obj.nodeInfo ? obj.nodeInfo.server.server_type: null; - if (is_row_trigger == true){ + if (is_row_trigger){ state.evnt_truncate = false; return true; } @@ -189,10 +189,7 @@ export default class TriggerSchema extends BaseUISchema { } isDisable(state) { - if(!state.is_constraint_trigger) { - return true; - } - return false; + return !state.is_constraint_trigger; } get baseFields() { @@ -208,10 +205,7 @@ export default class TriggerSchema extends BaseUISchema { mode: ['edit', 'properties'], group: gettext('Definition'), type: 'select', disabled: () => { - if('catalog' in obj.nodeInfo || 'view' in obj.nodeInfo) { - return true; - } - return false; + return 'catalog' in obj.nodeInfo || 'view' in obj.nodeInfo; }, options: [ {label: gettext('Enable'), value: 'O'}, @@ -252,11 +246,7 @@ export default class TriggerSchema extends BaseUISchema { } else { // Check if it is row trigger then enabled it. let is_row_trigger = state.is_row_trigger; - if (!_.isUndefined(is_row_trigger) && obj.nodeInfo.server.server_type == 'ppas') { - return false; - } - // Disable it - return true; + return !(!_.isUndefined(is_row_trigger) && obj.nodeInfo.server.server_type == 'ppas'); } }, },{ @@ -278,10 +268,7 @@ export default class TriggerSchema extends BaseUISchema { return obj.inSchemaWithModelCheck(state); }, disabled: () => { - if('view' in obj.nodeInfo) { - return true; - } - return false; + return 'view' in obj.nodeInfo; } },{ id: 'tgdeferrable', label: gettext('Deferrable?'), @@ -403,11 +390,7 @@ export default class TriggerSchema extends BaseUISchema { } else { // Check if it is row trigger then enabled it. let fires_ = state.fires; - if (!_.isUndefined(fires_) && obj.nodeInfo.server.server_type == 'ppas') { - return false; - } - // Disable it - return true; + return !(!_.isUndefined(fires_) && obj.nodeInfo.server.server_type == 'ppas'); } }, },{ @@ -435,10 +418,7 @@ export default class TriggerSchema extends BaseUISchema { } // Enable column only if update event is set true let isUpdate = state.evnt_update; - if(!_.isUndefined(isUpdate) && isUpdate) { - return false; - } - return true; + return !(!_.isUndefined(isUpdate) && isUpdate); }, },{ id: 'tgoldtable', label: gettext('Old table'), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js index 492a7db1a..1cdc4954e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js @@ -191,10 +191,7 @@ function getDataTypeSchema(nodeObj, treeNodeInfo, itemNodeData) { } function isVisible(state, type) { - if(state.typtype === type) { - return true; - } - return false; + return state.typtype === type; } class EnumerationSchema extends BaseUISchema { @@ -1413,10 +1410,7 @@ export default class TypeSchema extends BaseUISchema { type: 'text', mode: ['properties'], group: gettext('Definition'), disabled: () => obj.inCatalog(), visible: function(state) { - if(state.typtype === 'N' || state.typtype === 'V') { - return true; - } - return false; + return state.typtype === 'N' || state.typtype === 'V'; } }, { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js index cfccfeee9..677f5d172 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js @@ -36,10 +36,7 @@ export default class ViewSchema extends BaseUISchema { } notInSchema() { - if(this.nodeInfo && 'catalog' in this.nodeInfo) { - return true; - } - return false; + return this.nodeInfo && 'catalog' in this.nodeInfo; } diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js index 4ace61d6c..82b0bad47 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js +++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js @@ -118,24 +118,20 @@ define('pgadmin.node.database', [ server = treeData['server']; // If server is less than 10 then do not allow 'create' menu - if (server && server.version < 100000) - return false; - - // by default we want to allow create menu - return true; + return server && server.version >= 100000; }, is_not_connected: function(node) { - return (node && node.connected != true && node.allowConn == true); + return (node && !node.connected && node.allowConn); }, is_connected: function(node) { - return (node && node.connected == true && node.canDisconn == true); + return (node && node.connected && node.canDisconn); }, is_psql_enabled: function(node) { - return (node && node.connected == true) && pgAdmin['enable_psql']; + return (node && node.connected) && pgAdmin['enable_psql']; }, is_conn_allow: function(node) { - return (node && node.allowConn == true); + return (node && node.allowConn); }, connection_lost: function(i, resp, server_connected) { if (pgBrowser.tree) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/static/js/subscription.ui.js b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/static/js/subscription.ui.js index 8cb87a745..d9bcb10fc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/static/js/subscription.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/static/js/subscription.ui.js @@ -53,9 +53,7 @@ export default class SubscriptionSchema extends BaseUISchema{ get SSL_MODES() { return ['prefer', 'require', 'verify-ca', 'verify-full']; } isDisable(){ - if (this.isNew()) - return false; - return true; + return !this.isNew(); } isSameDB(state){ let host = state.host, @@ -76,9 +74,7 @@ export default class SubscriptionSchema extends BaseUISchema{ db = state.db, port = state.port, username = state.username; - if ((!_.isUndefined(host) && host) && (!_.isUndefined(db) && db) && (!_.isUndefined(port) && port) && (!_.isUndefined(username) && username)) - return false; - return true; + return !((!_.isUndefined(host) && host) && (!_.isUndefined(db) && db) && (!_.isUndefined(port) && port) && (!_.isUndefined(username) && username)); } isConnect(state){ if(!_.isUndefined(state.connect) && !state.connect){ @@ -106,12 +102,9 @@ export default class SubscriptionSchema extends BaseUISchema{ id: 'name', label: gettext('Name'), type: 'text', mode: ['properties', 'create', 'edit'], noEmpty: true, visible: function() { - if(!_.isUndefined(this.node_info['node_info']) + return (!_.isUndefined(this.node_info['node_info']) && !_.isUndefined(this.node_info['node_info'].version) - && this.node_info['node_info'].version >= 100000) { - return true; - } - return false; + && this.node_info['node_info'].version >= 100000); }, },{ id: 'oid', label: gettext('OID'), cell: 'string', mode: ['properties'], @@ -123,9 +116,7 @@ export default class SubscriptionSchema extends BaseUISchema{ type: 'select', mode: ['edit', 'properties', 'create'], controlProps: { allowClear: false}, disabled: function(){ - if(obj.isNew()) - return true; - return false; + return obj.isNew(); }, },{ id: 'host', label: gettext('Host name/address'), type: 'text', group: gettext('Connection'), diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js index 4ecb4b4f1..c85f663a9 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/server.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js @@ -60,9 +60,7 @@ define('pgadmin.node.server', [ label: gettext('Server'), canDrop: function(node){ let serverOwner = node.user_id; - if (serverOwner != current_user.id && !_.isUndefined(serverOwner)) - return false; - return true; + return !(serverOwner != current_user.id && !_.isUndefined(serverOwner)); }, dropAsRemove: true, dropPriority: 5, @@ -146,11 +144,8 @@ define('pgadmin.node.server', [ label: gettext('Clear Saved Password'), icon: 'fa fa-eraser', priority: 11, enable: function(node) { - if (node && node._type === 'server' && - node.is_password_saved) { - return true; - } - return false; + return (node && node._type === 'server' && + node.is_password_saved); }, },{ name: 'clear_sshtunnel_password', node: 'server', module: this, @@ -158,11 +153,8 @@ define('pgadmin.node.server', [ label: gettext('Clear SSH Tunnel Password'), icon: 'fa fa-eraser', priority: 12, enable: function(node) { - if (node && node._type === 'server' && - node.is_tunnel_password_saved) { - return true; - } - return false; + return (node && node._type === 'server' && + node.is_tunnel_password_saved); }, data: { data_disabled: gettext('SSH Tunnel password is not saved for selected server.'), @@ -175,54 +167,38 @@ define('pgadmin.node.server', [ ); }, is_not_connected: function(node) { - return (node && node.connected != true); + return (node && !node.connected); }, canCreate: function(node){ let serverOwner = node.user_id; - if (serverOwner == current_user.id || _.isUndefined(serverOwner)) - return true; - return false; + return (serverOwner == current_user.id || _.isUndefined(serverOwner)); }, is_connected: function(node) { - return (node && node.connected == true); + return (node && node.connected); }, enable_reload_config: function(node) { // Must be connected & is Super user - if (node && node._type == 'server' && - node.connected && node.user.is_superuser) { - return true; - } - return false; + return (node && node._type == 'server' && + node.connected && node.user.is_superuser); }, is_applicable: function(node) { // Must be connected & super user & not in recovery mode - if (node && node._type == 'server' && + return (node && node._type == 'server' && node.connected && node.user.is_superuser - && node.in_recovery == false) { - return true; - } - return false; + && !node.in_recovery); }, wal_pause_enabled: function(node) { // Must be connected & is Super user & in Recovery mode - if (node && node._type == 'server' && + return (node && node._type == 'server' && node.connected && node.user.is_superuser - && node.in_recovery == true - && node.wal_pause == false) { - return true; - } - return false; + && node.in_recovery && !node.wal_pause); }, wal_resume_enabled: function(node) { // Must be connected & is Super user & in Recovery mode - if (node && node._type == 'server' && + return (node && node._type == 'server' && node.connected && node.user.is_superuser - && node.in_recovery == true - && node.wal_pause == true) { - return true; - } - return false; + && node.in_recovery && node.wal_pause); }, callbacks: { /* Connect the server */ diff --git a/web/pgadmin/browser/server_groups/servers/static/js/vacuum.ui.js b/web/pgadmin/browser/server_groups/servers/static/js/vacuum.ui.js index 6ff44f648..197a70a38 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/vacuum.ui.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/vacuum.ui.js @@ -74,11 +74,7 @@ export default class VacuumSettingsSchema extends BaseUISchema { return true; } - if(obj.inCatalog) - { - return false; - } - return true; + return !obj.inCatalog; }, depChange(state) { if(state.is_partitioned) { @@ -96,10 +92,7 @@ export default class VacuumSettingsSchema extends BaseUISchema { ], deps: ['autovacuum_custom'], disabled: function(state) { - if(obj.inCatalog && state.autovacuum_custom) { - return false; - } - return true; + return !(obj.inCatalog && state.autovacuum_custom); }, depChange: function(state) { if(obj.inCatalog && state.autovacuum_custom) { @@ -122,10 +115,7 @@ export default class VacuumSettingsSchema extends BaseUISchema { disabled: function(state) { // We need to check additional condition to toggle enable/disable // for table auto-vacuum - if(obj.inCatalog && (obj.top.isNew() || state.hastoasttable)) { - return false; - } - return true; + return !(obj.inCatalog && (obj.top.isNew() || state.hastoasttable)); } }, { @@ -139,10 +129,7 @@ export default class VacuumSettingsSchema extends BaseUISchema { ], deps:['toast_autovacuum'], disabled: function(state) { - if(obj.inCatalog && state.toast_autovacuum) { - return false; - } - return true; + return !(obj.inCatalog && state.toast_autovacuum); }, depChange: function(state) { if(obj.inCatalog && state.toast_autovacuum) { diff --git a/web/pgadmin/browser/server_groups/static/js/server_group.js b/web/pgadmin/browser/server_groups/static/js/server_group.js index 086faba04..797e805cc 100644 --- a/web/pgadmin/browser/server_groups/static/js/server_group.js +++ b/web/pgadmin/browser/server_groups/static/js/server_group.js @@ -40,18 +40,14 @@ define('pgadmin.node.server_group', [ getSchema: ()=>new ServerGroupSchema(), canDrop: function(itemData) { let serverOwner = itemData.user_id; - if (serverOwner != current_user.id && !_.isUndefined(serverOwner)) - return false; - return true; }, + return !(serverOwner != current_user.id && !_.isUndefined(serverOwner)); + }, dropAsRemove: true, canDelete: function(i) { let s = pgAdmin.Browser.tree.siblings(i, true); /* This is the only server group - we can't remove it*/ - if (!s || s.length == 0) { - return false; - } - return true; + return !(!s || s.length == 0); }, }); } diff --git a/web/pgadmin/browser/static/js/datamodel.js b/web/pgadmin/browser/static/js/datamodel.js index 71f4970b5..47ecdf634 100644 --- a/web/pgadmin/browser/static/js/datamodel.js +++ b/web/pgadmin/browser/static/js/datamodel.js @@ -337,11 +337,8 @@ define([ return false; } - if ('validate' in self && _.isFunction(self.validate) && - _.isString(self.validate.apply(self))) { - return false; - } - return true; + return !('validate' in self && _.isFunction(self.validate) && + _.isString(self.validate.apply(self))); }, set: function(key, val, options) { let opts = _.isObject(key) ? val : options; @@ -445,7 +442,7 @@ define([ let self = this, res, isNew = self.isNew(); - session = (typeof(session) != 'undefined' && session == true); + session = (typeof(session) != 'undefined' && session); if (!session || isNew) { res = Backbone.Model.prototype.toJSON.call(this, arguments); @@ -1040,7 +1037,7 @@ define([ */ toJSON: function(session) { let self = this; - session = (typeof(session) != 'undefined' && session == true); + session = (typeof(session) != 'undefined' && session); if (!session) { return Backbone.Collection.prototype.toJSON.call(self); diff --git a/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js b/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js index ca20aadc4..48a295cbc 100644 --- a/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js @@ -463,10 +463,7 @@ class AzureDatabaseSchema extends BaseUISchema { } validate(data, setErrMsg) { - if (this.validateDbUserName(data, setErrMsg) || this.validateDbPassword(data, setErrMsg)) { - return true; - } - return false; + return this.validateDbUserName(data, setErrMsg) || this.validateDbPassword(data, setErrMsg); } get baseFields() { @@ -729,10 +726,7 @@ class AzureClusterSchema extends BaseUISchema { return true; } - if(this.validateProjectDetails(data, setErr) || this.validateInstanceDetails(data, setErr) || this.validateNetworkDetails(data, setErr)){ - return true; - } - return false; + return (this.validateProjectDetails(data, setErr) || this.validateInstanceDetails(data, setErr) || this.validateNetworkDetails(data, setErr)); } } diff --git a/web/pgadmin/misc/cloud/static/js/cloud_db_details_schema.ui.js b/web/pgadmin/misc/cloud/static/js/cloud_db_details_schema.ui.js index f7d1d9436..8bcd8bbbb 100644 --- a/web/pgadmin/misc/cloud/static/js/cloud_db_details_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/cloud_db_details_schema.ui.js @@ -287,8 +287,7 @@ export class StorageSchema extends BaseUISchema { id: 'storage_IOPS', label: gettext('Provisioned IOPS'), type: 'text', mode: ['create'], visible: (state) => { - if(state.storage_type === 'io1') return true; - return false; + return state.storage_type === 'io1'; } , deps: ['storage_type'], depChange: (state, source) => { if (source[0] !== 'storage_IOPS') { @@ -488,7 +487,7 @@ class BigAnimalDatabaseSchema extends BaseUISchema { setErrMsg('confirm_password', gettext('Password must be 12 characters or more.')); return true; } - if (data.high_availability == true && (isEmptyString(data.replicas) || data.replicas <= 0)) { + if (data.high_availability && (isEmptyString(data.replicas) || data.replicas <= 0)) { setErrMsg('replicas', gettext('Please select number of stand by replicas.')); return true; } @@ -630,8 +629,7 @@ class BigAnimalHighAvailSchema extends BaseUISchema { {'label': gettext('2'), 'value': 2}, ], noEmpty: true, disabled: (state) => { - if (state.high_availability == true) return false; - return true; + return !state.high_availability; } }, ]; diff --git a/web/pgadmin/static/js/SchemaView/base_schema.ui.js b/web/pgadmin/static/js/SchemaView/base_schema.ui.js index 256a67f22..34c5adbe7 100644 --- a/web/pgadmin/static/js/SchemaView/base_schema.ui.js +++ b/web/pgadmin/static/js/SchemaView/base_schema.ui.js @@ -139,18 +139,12 @@ export default class BaseUISchema { /* Check if node in catalog */ inCatalog() { - if(this.nodeInfo && 'catalog' in this.nodeInfo) { - return true; - } - return false; + return this.nodeInfo && 'catalog' in this.nodeInfo; } /* Check readonly on the basis of new state */ isReadOnly(state) { - if(!this.isNew(state)) { - return true; - } - return false; + return !this.isNew(state); } /* Get the server version */ diff --git a/web/pgadmin/static/js/codemirror/addon/fold/pgadmin-sqlfoldcode.js b/web/pgadmin/static/js/codemirror/addon/fold/pgadmin-sqlfoldcode.js index d4a94fcbb..f3fcd9171 100644 --- a/web/pgadmin/static/js/codemirror/addon/fold/pgadmin-sqlfoldcode.js +++ b/web/pgadmin/static/js/codemirror/addon/fold/pgadmin-sqlfoldcode.js @@ -117,10 +117,7 @@ //this reg will check the token should be in format as - IF condition or IF(condition) let reg = `\\b\\${startToken}\\s*\\(\\w*\\)(?!\\w)|\\b\\${startToken}\\(\\w*\\)(?!\\w)|\\b\\${startToken}\\s*(?!\\w)`; let regex = RegExp(reg, 'g'); - if(regex.exec(text) !== null) { - return true; - } - return false; + return regex.exec(text) !== null; } CodeMirror.registerHelper('fold', 'sql', function(cm, start) { diff --git a/web/pgadmin/static/js/components/PgTable.jsx b/web/pgadmin/static/js/components/PgTable.jsx index 65dd81db8..dd3062679 100644 --- a/web/pgadmin/static/js/components/PgTable.jsx +++ b/web/pgadmin/static/js/components/PgTable.jsx @@ -347,10 +347,7 @@ export default function PgTable({ columns, data, isSelectRow, caveTable=true, sc setHiddenColumns( columns .filter((column) => { - if (column.isVisible === undefined || column.isVisible === true) { - return false; - } - return true; + return !(column.isVisible === undefined || column.isVisible === true); } ) .map((column) => column.accessor) diff --git a/web/pgadmin/tools/backup/static/js/backup.ui.js b/web/pgadmin/tools/backup/static/js/backup.ui.js index 2ba3ae759..f0dfec074 100644 --- a/web/pgadmin/tools/backup/static/js/backup.ui.js +++ b/web/pgadmin/tools/backup/static/js/backup.ui.js @@ -194,9 +194,7 @@ export function getSaveOptSchema(fieldOptions) { } function isVisible () { - if (!_.isUndefined(this.backupType) && this.backupType === 'server') - return false; - return true; + return !(!_.isUndefined(this.backupType) && this.backupType === 'server'); } export class QueryOptionSchema extends BaseUISchema { @@ -240,9 +238,7 @@ export class QueryOptionSchema extends BaseUISchema { disabled: false, group: gettext('Queries'), visible: function() { - if (!_.isUndefined(obj.backupType) && obj.backupType === 'server') - return false; - return true; + return !(!_.isUndefined(obj.backupType) && obj.backupType === 'server'); }, }, { id: 'include_drop_database', diff --git a/web/pgadmin/tools/import_export_servers/static/js/import_export_selection.ui.js b/web/pgadmin/tools/import_export_servers/static/js/import_export_selection.ui.js index 06f542565..789259a0e 100644 --- a/web/pgadmin/tools/import_export_servers/static/js/import_export_selection.ui.js +++ b/web/pgadmin/tools/import_export_servers/static/js/import_export_selection.ui.js @@ -74,10 +74,7 @@ export default class ImportExportSelectionSchema extends BaseUISchema { } }, disabled: function (state) { - if (state.imp_exp == 'e') { - return true; - } - return false; + return state.imp_exp == 'e'; } }]; } diff --git a/web/pgadmin/tools/psql/static/js/psql_module.js b/web/pgadmin/tools/psql/static/js/psql_module.js index 425ed74a1..f1c06786a 100644 --- a/web/pgadmin/tools/psql/static/js/psql_module.js +++ b/web/pgadmin/tools/psql/static/js/psql_module.js @@ -331,11 +331,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, Browser) document.execCommand('copy'); } - if (e.ctrlKey && platform == 'win32') { - return false; - } - - return true; + return !(e.ctrlKey && platform == 'win32'); }); term.textarea.addEventListener('paste', function() { diff --git a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx index e107e7050..fa4808c8d 100644 --- a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx +++ b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx @@ -48,10 +48,7 @@ class UserManagementCollection extends BaseUISchema { } isUserNameEnabled(state) { - if (this.authOnlyInternal || state.auth_source == authConstant['INTERNAL']) { - return false; - } - return true; + return !(this.authOnlyInternal || state.auth_source == authConstant['INTERNAL']); } isEditable(state) { @@ -70,9 +67,7 @@ class UserManagementCollection extends BaseUISchema { first_empty: false, }, visible: function() { - if (obj.authOnlyInternal) - return false; - return true; + return !obj.authOnlyInternal; }, editable: function(state) { return (obj.isNew(state) && !obj.authOnlyInternal); @@ -96,10 +91,7 @@ class UserManagementCollection extends BaseUISchema { if (obj.isNew(state)) return true; - if (obj.isEditable(state) && state.auth_source != authConstant['INTERNAL']) - return true; - - return false; + return obj.isEditable(state) && state.auth_source != authConstant['INTERNAL']; } }, { id: 'role', label: gettext('Role'), cell: 'select', @@ -246,9 +238,7 @@ class UserManagementSchema extends BaseUISchema { id: 'userManagement', label: '', type: 'collection', schema: obj.userManagementCollObj, canAdd: true, canDelete: true, isFullTab: true, group: 'temp_user', canDeleteRow: (row)=>{ - if (row['id'] == current_user['id']) - return false; - return true; + return row['id'] != current_user['id']; }, onDelete: (row, deleteRow)=> { let deletedUser = {'id': row['id'], 'name': !isEmptyString(row['email']) ? row['email'] : row['username']};