From d236abfc959bf266a2f7690e652804eab3459d78 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 8 Apr 2024 13:30:48 +0530 Subject: [PATCH] Fixed SonarQube code smell 'Unnecessary use of boolean literals in conditional expression'. --- .../schemas/domains/static/js/domain.ui.js | 2 +- .../static/js/foreign_table.ui.js | 46 +++++++++---------- .../static/js/fts_configuration.ui.js | 8 ++-- .../schemas/synonyms/static/js/synonym.ui.js | 2 +- .../foreign_key/static/js/foreign_key.ui.js | 2 +- .../partitions/static/js/partition.ui.js | 4 +- .../tables/static/js/partition.utils.ui.js | 4 +- .../schemas/tables/static/js/table.ui.js | 8 ++-- .../tables/triggers/static/js/trigger.ui.js | 2 +- .../schemas/types/static/js/type.ui.js | 2 +- .../schemas/views/static/js/mview.ui.js | 4 +- .../schemas/views/static/js/view.ui.js | 2 +- .../servers/databases/static/js/database.js | 2 +- .../static/js/subscription.ui.js | 11 +++-- .../servers/roles/static/js/roleReassign.js | 2 +- .../servers/static/js/binary_path.ui.js | 2 +- web/pgadmin/browser/static/js/browser.js | 2 +- web/pgadmin/dashboard/static/js/Dashboard.jsx | 6 +-- .../misc/cloud/static/js/CloudWizard.jsx | 2 +- .../misc/cloud/static/js/azure_schema.ui.js | 6 +-- .../misc/cloud/static/js/google_schema.ui.js | 22 ++++----- .../js/Dialogs/ChangePasswordContent.jsx | 2 +- .../static/js/helpers/ModalProvider.jsx | 2 +- .../static/js/helpers/wizard/Wizard.jsx | 2 +- .../js/nodes/supported_database_node.js | 2 +- web/pgadmin/static/js/tree/tree.js | 6 +-- web/pgadmin/static/js/utils.js | 9 ++-- .../tools/backup/static/js/backup.ui.js | 2 +- .../components/DebuggerArgumentComponent.jsx | 6 +-- .../maintenance/static/js/maintenance.ui.js | 8 ++-- .../static/js/components/InputComponent.jsx | 4 +- .../components/SchemaDiffButtonComponent.jsx | 2 +- .../js/components/SchemaDiffCompare.jsx | 8 ++-- .../sqleditor/static/js/SQLEditorModule.js | 2 +- .../js/components/QueryToolComponent.jsx | 8 ++-- .../components/QueryToolDataGrid/Editors.jsx | 2 +- .../components/sections/GraphVisualiser.jsx | 2 +- .../static/js/UserManagementDialog.jsx | 4 +- 38 files changed, 104 insertions(+), 108 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.ui.js index b0ddf8318b1..c5db4e78b41 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.ui.js @@ -40,7 +40,7 @@ export class DomainConstSchema extends BaseUISchema { type: 'checkbox', readonly: function(state) { let currCon = _.find(obj.top.origData.constraints, (con)=>con.conoid == state.conoid); - return !obj.isNew(state) && currCon.convalidated ? true : false; + return !obj.isNew(state) && currCon.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 867a69f8c79..4bbb8f6672b 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 @@ -132,7 +132,7 @@ export default class ForeignTableSchema extends BaseUISchema { let newColInherits = state.inherits || []; let oldColInherits = actionObj.oldState.inherits || []; - let tabName = undefined; + let tabName; let tabColsResponse; // Add columns logic @@ -199,7 +199,7 @@ export default class ForeignTableSchema extends BaseUISchema { canAdd: true, canDelete: true, columns: ['conname','consrc', 'connoinherit', 'convalidated'], canEdit: true, canDeleteRow: function(state) { - return (state.conislocal || _.isUndefined(state.conislocal)) ? true : false; + return (state.conislocal || _.isUndefined(state.conislocal)); }, canEditRow: function(state) { return obj.isNew(state); @@ -307,7 +307,7 @@ export class ColumnSchema extends BaseUISchema { } editable_check_for_column(state) { - return (_.isUndefined(state.inheritedid) || _.isNull(state.inheritedid) || _.isUndefined(state.inheritedfrom) || _.isNull(state.inheritedfrom)) ? true : false; + return (_.isUndefined(state.inheritedid) || _.isNull(state.inheritedid) || _.isUndefined(state.inheritedfrom) || _.isNull(state.inheritedfrom)); } // Check whether the column is a generated column @@ -355,10 +355,10 @@ export class ColumnSchema extends BaseUISchema { type: 'multiline', mode: ['properties', 'create', 'edit'], }, { - id: 'cltype', - label: gettext('Data type'), + id: 'cltype', + label: gettext('Data type'), minWidth: 150, - group: gettext('Definition'), + group: gettext('Definition'), noEmpty: true, editable: obj.editable_check_for_column, disabled: (state)=>{ @@ -416,7 +416,7 @@ export class ColumnSchema extends BaseUISchema { }, { id: 'attlen', - label: gettext('Length'), + label: gettext('Length'), group: gettext('Definition'), deps: ['cltype'], type: 'int', @@ -486,10 +486,10 @@ export class ColumnSchema extends BaseUISchema { id: 'max_val_attprecision', skipChange: true, visible: false, type: '', }, { - id: 'attstattarget', - label: gettext('Statistics'), + id: 'attstattarget', + label: gettext('Statistics'), cell: 'text', - type: 'text', + type: 'text', readonly: obj.inSchemaWithColumnCheck, mode: ['properties', 'edit'], group: gettext('Definition'), @@ -524,12 +524,12 @@ export class ColumnSchema extends BaseUISchema { }, }, { - id: 'attnotnull', - label: gettext('Not NULL?'), + id: 'attnotnull', + label: gettext('Not NULL?'), cell: 'switch', - type: 'switch', + type: 'switch', minWidth: 80, - group: gettext('Constraints'), + group: gettext('Constraints'), editable: obj.editable_check_for_column, }, { @@ -540,7 +540,7 @@ export class ColumnSchema extends BaseUISchema { type: (state)=>{ let options = [ { 'label': gettext('NONE'), 'value': 'n'}, - ]; + ]; // You can't change the existing column to Generated column. if (this.isNew(state)) { options.push({ @@ -553,7 +553,7 @@ export class ColumnSchema extends BaseUISchema { 'value': 'g', 'disabled': true, }); - } + } return { type: 'toggle', options: options, @@ -561,17 +561,17 @@ export class ColumnSchema extends BaseUISchema { }, disabled: function(state) { return (!this.isNew(state) && state.colconstype == 'g'); - }, + }, min_version: 120000, }, { - id: 'genexpr', - label: gettext('Expression'), + id: 'genexpr', + label: gettext('Expression'), type: 'text', - mode: ['properties', 'create', 'edit'], + mode: ['properties', 'create', 'edit'], group: gettext('Constraints'), - min_version: 120000, - deps: ['colconstype'], + min_version: 120000, + deps: ['colconstype'], visible: this.isTypeGenerated, readonly: function(state) { return !this.isNew(state); @@ -596,7 +596,7 @@ export class ColumnSchema extends BaseUISchema { return (_.isUndefined(state.inheritedid) || _.isNull(state.inheritedid) || - _.isUndefined(state.inheritedfrom) || + _.isUndefined(state.inheritedfrom) || _.isNull(state.inheritedfrom)); } }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.ui.js index 3b5d1d8e32a..14fc2ec096b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.ui.js @@ -132,9 +132,9 @@ export default class FTSConfigurationSchema extends BaseUISchema { //disable parser when user select copy_config manually and vica-versa disabled: function(state) { let copy_config = state.copy_config; - return (_.isNull(copy_config) || + return !(_.isNull(copy_config) || _.isUndefined(copy_config) || - copy_config === '') ? false : true; + copy_config === ''); }, readonly: function(state) { return !obj.isNew(state); }, }, { @@ -145,9 +145,9 @@ export default class FTSConfigurationSchema extends BaseUISchema { //disable copy_config when user select parser manually and vica-versa disabled: function(state) { let parser = state.prsname; - return (_.isNull(parser) || + return !(_.isNull(parser) || _.isUndefined(parser) || - parser === '') ? false : true; + parser === ''); }, readonly: function(state) { return !obj.isNew(state); }, }, { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui.js index b8a4c1ff9c2..4ab31aa9084 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui.js @@ -97,7 +97,7 @@ export default class SynonymSchema extends BaseUISchema { }; }, readonly: function() { - return !obj.inCatalog() ? false : true; + return obj.inCatalog(); } }, { id: 'is_sys_obj', label: gettext('System synonym?'), 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 2b33d14f876..22eead1669a 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 @@ -85,7 +85,7 @@ class ForeignKeyHeaderSchema extends BaseUISchema { optionsReloadBasis: this.fieldOptions.references?.map ? _.join(this.fieldOptions.references.map((c)=>c.label), ',') : null, optionsLoaded: (rows)=>obj.refTables=rows, disabled: (state) => { - return state._disable_references ? true : false; + return state._disable_references; } },{ id: 'referenced', label: gettext('Referencing'), editable: false, deps: ['references'], 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 02098c1b748..25b1701cc58 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 @@ -122,7 +122,7 @@ export default class PartitionTableSchema extends BaseUISchema { this.getAttachTables = getAttachTables; this.partitionKeysObj = new PartitionKeysSchema([], getCollations, getOperatorClass); - this.partitionsObj = new PartitionsSchema(this.nodeInfo, getCollations, getOperatorClass, getAttachTables, fieldOptions.table_amname_list); + this.partitionsObj = new PartitionsSchema(this.nodeInfo, getCollations, getOperatorClass, fieldOptions.table_amname_list, getAttachTables); this.constraintsObj = this.schemas.constraints(); } @@ -236,7 +236,7 @@ export default class PartitionTableSchema extends BaseUISchema { return { type: 'select', options: this.fieldOptions.table_amname_list, controlProps: { - allowClear: obj.isNew(state) ? true : false, + allowClear: obj.isNew(state), } }; }, mode: ['create', 'properties', 'edit'], min_version: 120000, 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 176d4309660..52c819ae217 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 @@ -113,7 +113,7 @@ export class PartitionKeysSchema extends BaseUISchema { } } export class PartitionsSchema extends BaseUISchema { - constructor(nodeInfo, getCollations, getOperatorClass, getAttachTables=()=>[], table_amname_list) { + constructor(nodeInfo, getCollations, getOperatorClass, table_amname_list, getAttachTables=()=>[]) { super({ oid: undefined, is_attach: false, @@ -206,7 +206,7 @@ export class PartitionsSchema extends BaseUISchema { return { type: 'select', options: this.table_amname_list, controlProps: { - allowClear: obj.isNew(state) ? true : false, + allowClear: obj.isNew(state), } }; }, min_version: 120000, disabled: state => { 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 a1e8a5d3da5..d79d2e8a7a1 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 @@ -367,7 +367,7 @@ export default class TableSchema extends BaseUISchema { this.nodeInfo = nodeInfo; this.getColumns = getColumns; - this.partitionsObj = new PartitionsSchema(this.nodeInfo, getCollations, getOperatorClass, getAttachTables, fieldOptions.table_amname_list); + this.partitionsObj = new PartitionsSchema(this.nodeInfo, getCollations, getOperatorClass, fieldOptions.table_amname_list, getAttachTables); this.constraintsObj = this.schemas.constraints?.() || {}; this.columnsSchema = this.schemas.columns?.() || {}; this.vacuumSettingsSchema = this.schemas.vacuum_settings?.() || {}; @@ -464,7 +464,7 @@ export default class TableSchema extends BaseUISchema { id: 'oid', label: gettext('OID'), type: 'text', mode: ['properties'], },{ id: 'relowner', label: gettext('Owner'), type: 'select', - options: this.fieldOptions.relowner, noEmpty: this.inErd ? false : true, + options: this.fieldOptions.relowner, noEmpty: !this.inErd, mode: ['properties', 'create', 'edit'], controlProps: {allowClear: false}, readonly: this.inCatalog, visible: !this.inErd, },{ @@ -480,7 +480,7 @@ export default class TableSchema extends BaseUISchema { return { type: 'select', options: this.fieldOptions.spcname, controlProps: { - allowClear: obj.isNew(state) ? true : false, + allowClear: obj.isNew(state), } }; } @@ -782,7 +782,7 @@ export default class TableSchema extends BaseUISchema { return { type: 'select', options: this.fieldOptions.table_amname_list, controlProps: { - allowClear: obj.isNew(state) ? true : false, + allowClear: obj.isNew(state), } }; }, mode: ['create', 'properties', 'edit'], min_version: 120000, 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 2522c0baa52..42db0b0a296 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 @@ -310,7 +310,7 @@ export default class TriggerSchema extends BaseUISchema { state.tginitdeferred = false; } // If constraint trigger is set then do not disable - return state.is_constraint_trigger ? false : true; + return !state.is_constraint_trigger; } } else { // readonly it 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 29381850f88..6d4a6daacb1 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 @@ -348,7 +348,7 @@ class RangeSchema extends BaseUISchema { this.options = []; } - return disableCollNameControl ? false : true; + return !disableCollNameControl; }, readonly: function(state) { return !obj.isNew(state); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.ui.js index 670e4d7e7a5..96d477ecad1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.ui.js @@ -91,7 +91,7 @@ export default class MViewSchema extends BaseUISchema { return { type: 'select', options: obj.fieldOptions.table_amname_list, controlProps: { - allowClear: obj.isNew(state) ? true : false, + allowClear: obj.isNew(state), } }; }, mode: ['create', 'properties', 'edit'], min_version: 120000, @@ -110,7 +110,7 @@ export default class MViewSchema extends BaseUISchema { },{ id: 'definition', label: gettext('Definition'), cell: 'text', type: 'sql', mode: ['create', 'edit'], group: gettext('Code'), - isFullTab: true, controlProps: { readOnly: this.nodeInfo && 'catalog' in this.nodeInfo ? true: false }, + isFullTab: true, controlProps: { readOnly: this.nodeInfo && 'catalog' in this.nodeInfo }, }, { type: 'nested-tab', group: gettext('Parameter'), mode: ['create', 'edit'], 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 9bab5973c4d..7885792d0dd 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 @@ -97,7 +97,7 @@ export default class ViewSchema extends BaseUISchema { id: 'definition', label: gettext('Code'), cell: 'text', type: 'sql', mode: ['create', 'edit'], group: gettext('Code'), isFullTab: true, - controlProps: { readOnly: obj.nodeInfo && 'catalog' in obj.nodeInfo ? true: false }, + controlProps: { readOnly: obj.nodeInfo && 'catalog' in obj.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 9831d6314a6..b1b0f4e8b37 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 @@ -380,7 +380,7 @@ define('pgadmin.node.database', [ // If node_info is not present in current object then it might in its // parent in case if we used sub node control let node_info = args.node_info || args.handler.node_info; - return 'catalog' in node_info ? false : true; + return !('catalog' in node_info); } return true; }, 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 71e3b5346c3..ef6181e17c9 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 @@ -97,10 +97,7 @@ export default class SubscriptionSchema extends BaseUISchema{ return false; } isRefresh(state){ - if (!state.refresh_pub || _.isUndefined(state.refresh_pub)){ - return true; - } - return false; + return !state.refresh_pub || _.isUndefined(state.refresh_pub); } isSSL(state) { return this.SSL_MODES.indexOf(state.sslmode) == -1; @@ -336,7 +333,11 @@ export default class SubscriptionSchema extends BaseUISchema{ state.copy_data_after_refresh = false; return true; }, depChange: (state)=>{ - state.copy_data_after_refresh = state.refresh_pub ? state.copy_data_after_refresh ? false : true : false; + let copy_data_after_refresh = false; + if (state.refresh_pub && !state.copy_data_after_refresh) { + copy_data_after_refresh = true; + } + state.copy_data_after_refresh = copy_data_after_refresh; }, },{ id: 'connect', label: gettext('Connect?'), diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/roleReassign.js b/web/pgadmin/browser/server_groups/servers/roles/static/js/roleReassign.js index 66344164167..8ebdfbe55a0 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/static/js/roleReassign.js +++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/roleReassign.js @@ -99,7 +99,7 @@ export default class RoleReassign extends BaseUISchema{ helpMessage: gettext('New owner of the affected objects'), deps: ['role_op'], disabled: (state)=>{ - return state.role_op == 'drop'? true: false; + return state.role_op == 'drop'; }, depChange: (state) =>{ if (state.role_op == 'drop'){ diff --git a/web/pgadmin/browser/server_groups/servers/static/js/binary_path.ui.js b/web/pgadmin/browser/server_groups/servers/static/js/binary_path.ui.js index 5c57351d157..dac196f8a14 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/binary_path.ui.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/binary_path.ui.js @@ -35,7 +35,7 @@ export default class BinaryPathSchema extends BaseUISchema { width: 32, radioType: true, disabled: function (state) { - return state?.binaryPath && state?.binaryPath.length > 0 ? false : true; + return !(state?.binaryPath && state?.binaryPath.length > 0); }, cell: 'radio', deps: ['binaryPath'], diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index d246dc88f3e..0b4209e272c 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -498,7 +498,7 @@ define('pgadmin.browser', [ url: _m.url || '#', target: _m.target, icon: _m.icon, - enable: enable ? enable : true, + enable: enable || true, node: _m.node, checked: _m.checked, below: _m.below, diff --git a/web/pgadmin/dashboard/static/js/Dashboard.jsx b/web/pgadmin/dashboard/static/js/Dashboard.jsx index b3055dda87c..a2f8604d0ba 100644 --- a/web/pgadmin/dashboard/static/js/Dashboard.jsx +++ b/web/pgadmin/dashboard/static/js/Dashboard.jsx @@ -412,7 +412,7 @@ function Dashboard({ disableGlobalFilter: false, minWidth: 26, width: 80, - isVisible: !did ? true: false + isVisible: !did }, { accessor: 'usename', @@ -506,7 +506,7 @@ function Dashboard({ resizable: true, disableGlobalFilter: false, minWidth: 26, - isVisible: !did ? true: false, + isVisible: !did, width: 80 }, { @@ -623,7 +623,7 @@ function Dashboard({ disableGlobalFilter: false, minWidth: 26, width: 80, - isVisible: !did ? true: false + isVisible: !did }, { accessor: 'Owner', diff --git a/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx b/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx index 37c710a7f3a..99a872ea1a7 100644 --- a/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx +++ b/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx @@ -451,7 +451,7 @@ export default function CloudWizard({ nodeInfo, nodeData, onClose, cloudPanelId}
{gettext('By clicking the below button, you will be redirected to the EDB BigAnimal authentication page in a new tab.')} } - {cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && + {cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && {gettext('Click here to authenticate yourself to EDB BigAnimal')} } {cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && 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 078659b4274..64d068c6d50 100644 --- a/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js @@ -67,7 +67,7 @@ class AzureCredSchema extends BaseUISchema { value: 'azure_cli_credential', }, ], - disabled: pgAdmin.server_mode == 'True' ? true : false, + disabled: pgAdmin.server_mode == 'True', helpMessage: gettext( 'Azure CLI will use the currently logged in identity through the Azure CLI on the local machine. Interactive Browser will open a browser window to authenticate a user interactively.' ), @@ -82,9 +82,7 @@ class AzureCredSchema extends BaseUISchema { 'Enter the Azure tenant ID against which the user is authenticated.' ), disabled: (state) => { - return state.auth_type == 'interactive_browser_credential' - ? false - : true; + return state.auth_type !== 'interactive_browser_credential'; }, depChange: (state) => { if (state.auth_type == 'azure_cli_credential') { diff --git a/web/pgadmin/misc/cloud/static/js/google_schema.ui.js b/web/pgadmin/misc/cloud/static/js/google_schema.ui.js index 84cba9c430a..db5eaadfff1 100644 --- a/web/pgadmin/misc/cloud/static/js/google_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/google_schema.ui.js @@ -53,7 +53,7 @@ class GoogleCredSchema extends BaseUISchema{ btnName: gettext('Click here to authenticate yourself to Google'), helpMessage: gettext('After clicking the button above you will be redirected to the Google authentication page in a new browser tab.'), disabled: (state)=>{ - return state.client_secret_file ? false : true; + return !state.client_secret_file; }, deferredDepChange: (state, source)=>{ return new Promise((resolve, reject)=>{ @@ -223,7 +223,7 @@ class GoogleInstanceSchema extends BaseUISchema { } ]; } -} +} class GoogleStorageSchema extends BaseUISchema { constructor() { @@ -235,22 +235,22 @@ class GoogleStorageSchema extends BaseUISchema { get baseFields() { return [ { - id: 'storage_type', - label: gettext('Storage type'), + id: 'storage_type', + label: gettext('Storage type'), type: 'select', mode: ['create'], noEmpty: true, options: [ {'label': gettext('SSD'), 'value': 'PD_SSD'}, {'label': gettext('HDD'), 'value': 'PD_HDD'}, - ], + ], }, { - id: 'storage_size', - label: gettext('Storage capacity'), + id: 'storage_size', + label: gettext('Storage capacity'), type: 'int', - mode: ['create'], - noEmpty: true, + mode: ['create'], + noEmpty: true, deps: ['storage_type'], helpMessage: gettext('Size in GB.'), } @@ -445,11 +445,11 @@ class GoogleClusterSchema extends BaseUISchema { }, {} ); - + this.googleStorageDetails = new GoogleStorageSchema( {}, {} - ); + ); this.googleNetworkDetails = new GoogleNetworkSchema({}, {}); diff --git a/web/pgadmin/static/js/Dialogs/ChangePasswordContent.jsx b/web/pgadmin/static/js/Dialogs/ChangePasswordContent.jsx index 7e6a3747d0c..8f00f30d9c8 100644 --- a/web/pgadmin/static/js/Dialogs/ChangePasswordContent.jsx +++ b/web/pgadmin/static/js/Dialogs/ChangePasswordContent.jsx @@ -34,7 +34,7 @@ class ChangePasswordSchema extends BaseUISchema { id: 'user', label: gettext('User'), type: 'text', disabled: true, visible: this.showUser }, { id: 'password', label: gettext('Current Password'), type: 'password', - disabled: self.isPgpassFileUsed, noEmpty: self.isPgpassFileUsed ? false : true, + disabled: self.isPgpassFileUsed, noEmpty: !self.isPgpassFileUsed, controlProps: { maxLength: null } diff --git a/web/pgadmin/static/js/helpers/ModalProvider.jsx b/web/pgadmin/static/js/helpers/ModalProvider.jsx index ba95c1e0d28..ff0912a45e5 100644 --- a/web/pgadmin/static/js/helpers/ModalProvider.jsx +++ b/web/pgadmin/static/js/helpers/ModalProvider.jsx @@ -157,7 +157,7 @@ const dialogStyle = makeStyles((theme) => ({ function checkIsResizable(props) { - return props.isresizeable == 'true' ? true : false; + return props.isresizeable == 'true'; } function setEnableResizing(props, resizeable) { diff --git a/web/pgadmin/static/js/helpers/wizard/Wizard.jsx b/web/pgadmin/static/js/helpers/wizard/Wizard.jsx index ede7f74df05..532073ab42c 100644 --- a/web/pgadmin/static/js/helpers/wizard/Wizard.jsx +++ b/web/pgadmin/static/js/helpers/wizard/Wizard.jsx @@ -222,7 +222,7 @@ function Wizard({ stepList, onStepChange, onSave, className, ...props }) { handleNext()} className={classes.buttonMargin} startIcon={} disabled={activeStep == steps.length - 1 || disableNext}> {gettext('Next')} - } disabled={activeStep == steps.length - 1 ? false : true} onClick={onSave}> + } disabled={activeStep !== (steps.length - 1) } onClick={onSave}> {gettext('Finish')} diff --git a/web/pgadmin/static/js/nodes/supported_database_node.js b/web/pgadmin/static/js/nodes/supported_database_node.js index 45a8d90adc6..7f70faff4e8 100644 --- a/web/pgadmin/static/js/nodes/supported_database_node.js +++ b/web/pgadmin/static/js/nodes/supported_database_node.js @@ -25,7 +25,7 @@ export function enabled(tree, supportedNodes, treeNodeData, domTreeNode) { if (!isValidTreeNodeData(treeNodeData)) return false; - let _tree = tree ? tree : pgAdmin.Browser.tree; + let _tree = tree || pgAdmin.Browser.tree; let treeNode = _tree.findNodeByDomElement(domTreeNode); if (!treeNode) { return false; diff --git a/web/pgadmin/static/js/tree/tree.js b/web/pgadmin/static/js/tree/tree.js index 269bcd5e86c..eb78419cee4 100644 --- a/web/pgadmin/static/js/tree/tree.js +++ b/web/pgadmin/static/js/tree/tree.js @@ -78,7 +78,7 @@ function manageTreeEvents(event, eventName, item) { export class Tree { constructor(tree, manageTree, pgBrowser, type) { this.tree = tree; - this.tree.type = type ? type : 'browser'; + this.tree.type = type || 'browser'; this.tree.onTreeEvents(manageTreeEvents); this.rootNode = manageTree.tempTree; @@ -299,7 +299,7 @@ export class Tree { } hasParent(item) { - return item?.parent ? true : false; + return item?.parent; } isOpen(item) { @@ -332,7 +332,7 @@ export class Tree { isInode(item) { const children = this.children(item); if (children === null || children === undefined) return false; - return children.length > 0 ? true : false; + return children.length > 0; } selected() { diff --git a/web/pgadmin/static/js/utils.js b/web/pgadmin/static/js/utils.js index 1608031218b..6396ed0ce4c 100644 --- a/web/pgadmin/static/js/utils.js +++ b/web/pgadmin/static/js/utils.js @@ -30,10 +30,7 @@ export function parseShortcutValue(obj) { export function isShortcutValue(obj) { if(!obj) return false; - if([obj.alt, obj.control, obj?.key, obj?.key?.char].every((k)=>!_.isUndefined(k))){ - return true; - } - return false; + return [obj.alt, obj.control, obj?.key, obj?.key?.char].every((k)=>!_.isUndefined(k)); } // Convert shortcut obj to codemirror key format @@ -60,7 +57,7 @@ export function toCodeMirrorKey(obj) { } export function getEpoch(inp_date) { - let date_obj = inp_date ? inp_date : new Date(); + let date_obj = inp_date || new Date(); return parseInt(date_obj.getTime()/1000); } @@ -643,4 +640,4 @@ export function scrollbarWidth() { const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; document.body.removeChild(scrollDiv); return scrollbarWidth; -} \ No newline at end of file +} diff --git a/web/pgadmin/tools/backup/static/js/backup.ui.js b/web/pgadmin/tools/backup/static/js/backup.ui.js index 8b2f5ca7fa3..b7bedc894c1 100644 --- a/web/pgadmin/tools/backup/static/js/backup.ui.js +++ b/web/pgadmin/tools/backup/static/js/backup.ui.js @@ -576,7 +576,7 @@ export default class BackupSchema extends BaseUISchema { state.on_conflict_do_nothing = false; return true; }, - inlineNext: obj.backupType == 'server'? false : true, + inlineNext: obj.backupType !== 'server', }, { id: 'include_create_database', label: gettext('Include CREATE DATABASE statement'), diff --git a/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx b/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx index 6bd1c2dbbb3..d4f899ef84a 100644 --- a/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx +++ b/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx @@ -267,10 +267,10 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug, funcObj.push({ 'name': argName[index], 'type': argType[index], - 'is_null': argData['is_null'] ? true : false, - 'expr': argData['is_expression'] ? true : false, + 'is_null': argData['is_null'], + 'expr': argData['is_expression'], 'value': values, - 'use_default': argData['use_default'] ? true : false, + 'use_default': argData['use_default'], 'default_value': defValList[index], 'disable_use_default': isUnnamedParam ? defValList[index] == DEBUGGER_ARGS.NO_DEFAULT_VALUE : defValList[index] == DEBUGGER_ARGS.NO_DEFAULT, }); diff --git a/web/pgadmin/tools/maintenance/static/js/maintenance.ui.js b/web/pgadmin/tools/maintenance/static/js/maintenance.ui.js index 346ae7625b3..fea91b7dd98 100644 --- a/web/pgadmin/tools/maintenance/static/js/maintenance.ui.js +++ b/web/pgadmin/tools/maintenance/static/js/maintenance.ui.js @@ -370,22 +370,22 @@ export default class MaintenanceSchema extends BaseUISchema { { 'label': gettext('VACUUM'), value: 'VACUUM', - disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview) ? true : false + disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview) }, { 'label': gettext('ANALYZE'), value: 'ANALYZE', - disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview) ? true : false + disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview) }, { 'label': gettext('REINDEX'), value: 'REINDEX', - disabled: obj.nodeInfo?.mview ? true : false + disabled: obj.nodeInfo?.mview }, { 'label': gettext('CLUSTER'), value: 'CLUSTER', - disabled: obj.nodeInfo?.mview ? true : obj.isSchemaNode() ? true : false + disabled: obj.nodeInfo?.mview || obj.isSchemaNode() }, ], }, diff --git a/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx b/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx index b8af0c8f1e4..ec948b8a5a0 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx @@ -38,8 +38,8 @@ export function InputComponent({ label, serverList, databaseList, schemaList, di const [selectedDatabase, setSelectedDatabase] = useState(selectedDid); const [selectedSchema, setSelectedSchema] = useState(selectedScid); const eventBus = useContext(SchemaDiffEventsContext); - const [disableDBSelection, setDisableDBSelection] = useState(selectedSid == null ? true : false); - const [disableSchemaSelection, setDisableSchemaSelection] = useState(selectedDid == null ? true : false); + const [disableDBSelection, setDisableDBSelection] = useState(selectedSid == null); + const [disableSchemaSelection, setDisableSchemaSelection] = useState(selectedDid == null); const changeServer = (selectedOption) => { setDisableDBSelection(false); setSelectedServer(selectedOption); diff --git a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx index 3bbf8c3981c..52acdaafdba 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx @@ -174,7 +174,7 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI - 0 ? false : true}> + } onClick={generateScript}>{gettext('Generate Script')} diff --git a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx index d028d21ed24..368a7d1b5ea 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx @@ -339,7 +339,7 @@ export function SchemaDiffCompare({ params }) { const triggerGenerateScript = ({ sid, did, selectedIds, rows }) => { setLoaderText(gettext('Generating script...')); - let generatedScript = undefined, scriptHeader; + let generatedScript, scriptHeader; scriptHeader = gettext('-- This script was generated by the Schema Diff utility in pgAdmin 4. \n'); scriptHeader += gettext('-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated \n'); @@ -406,7 +406,7 @@ export function SchemaDiffCompare({ params }) { 'parentId': tempData[record.group_name]['children'][record.label].id, 'label': record.title, 'status': record.status, - 'isVisible': filterParams.includes(record.status) ? true : false, + 'isVisible': filterParams.includes(record.status), 'icon': `icon-${record.type}`, 'isExpanded': false, 'selected': false, @@ -448,7 +448,7 @@ export function SchemaDiffCompare({ params }) { 'parentId': chidId, 'label': record.title, 'status': record.status, - 'isVisible': filterParams.includes(record.status) ? true : false, + 'isVisible': filterParams.includes(record.status), 'icon': `icon-${record.type}`, 'isExpanded': false, 'selected': false, @@ -503,7 +503,7 @@ export function SchemaDiffCompare({ params }) { 'status': record.status, 'selected': false, 'itemType': record.type, - 'isVisible': filterParams.includes(record.status) ? true : false, + 'isVisible': filterParams.includes(record.status), 'icon': `icon-${record.type}`, 'isExpanded': false, 'oid': record.oid, diff --git a/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js b/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js index 3dacfe54d0a..159004bb42b 100644 --- a/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js +++ b/web/pgadmin/tools/sqleditor/static/js/SQLEditorModule.js @@ -51,7 +51,7 @@ export default class SQLEditor { viewMenuEnabled(obj) { let isEnabled = (() => { if (!_.isUndefined(obj) && !_.isNull(obj)) - return (_.indexOf(this.SUPPORTED_NODES, obj._type) !== -1 ? true : false); + return (_.indexOf(this.SUPPORTED_NODES, obj._type) !== -1); else return false; })(); diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index ce4c373ca7c..a7ef945233a 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -71,7 +71,7 @@ function setPanelTitle(docker, panelId, title, qtState, dirty=false) { docker.setInternalAttrs(panelId, { isDirty: dirty, }); - setQueryToolDockerTitle(docker, panelId, true, title, qtState.current_file ? true : false); + setQueryToolDockerTitle(docker, panelId, true, title, qtState.current_file); } } @@ -172,7 +172,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN params: { ...params, title: _.unescape(params.title), - is_query_tool: params.is_query_tool == 'true' ? true : false, + is_query_tool: params.is_query_tool == 'true', node_name: retrieveNodeName(selectedNodeInfo), dbname: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo) }, @@ -187,7 +187,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN bgcolor: params.bgcolor, conn_title: getTitle( pgAdmin, null, selectedNodeInfo, true, _.unescape(params.server_name), _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo), - _.unescape(params.role) || _.unescape(params.user), params.is_query_tool == 'true' ? true : false), + _.unescape(params.role) || _.unescape(params.user), params.is_query_tool == 'true'), server_name: _.unescape(params.server_name), database_name: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo), is_selected: true, @@ -676,7 +676,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN fgcolor: connectionData.fgcolor, bgcolor: connectionData.bgcolor, }, - connected: respData.data.trans_id ? true : false, + connected: respData.data.trans_id, obtaining_conn: false, }; }); diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx index 49cbbcc3195..0f5ab89e6a8 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/Editors.jsx @@ -254,7 +254,7 @@ export function NumberEditor({row, column, onRowChange, onClose}) { }; const onBlur = ()=>{ if(isValidData()) { - onClose(column.can_edit ? true : false); + onClose(column.can_edit); return true; } return false; diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx index c4ae343dd5c..2fd4fefe53e 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx @@ -128,7 +128,7 @@ function GenerateGraph({graphType, graphData, ...props}) { plugins: { legend: { labels: { - usePointStyle: (showDataPoints && useDiffPointStyle) ? true : false + usePointStyle: (showDataPoints && useDiffPointStyle) }, }, }, diff --git a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx index 104d23f3181..c8d9a8a6790 100644 --- a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx +++ b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx @@ -37,7 +37,7 @@ class UserManagementCollection extends BaseUISchema { }); this.authOnlyInternal = (current_user['auth_sources'].length == 1 && - current_user['auth_sources'].includes(AUTH_METHODS['INTERNAL'])) ? true : false; + current_user['auth_sources'].includes(AUTH_METHODS['INTERNAL'])); this.authSources = authSources; this.roleOptions = roleOptions; } @@ -146,7 +146,7 @@ class UserManagementCollection extends BaseUISchema { } validate(state, setError) { - let msg = undefined; + let msg; let obj = this; let minPassLen = pgAdmin.password_length_min; if (obj.isUserNameEnabled(state) && isEmptyString(state.username)) {