Fixed SonarQube code smell 'Unnecessary use of boolean literals in conditional expression'.

This commit is contained in:
Akshay Joshi 2024-04-08 17:19:51 +05:30 committed by GitHub
parent c9345ad618
commit edec9adbfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 104 additions and 108 deletions

View File

@ -40,7 +40,7 @@ export class DomainConstSchema extends BaseUISchema {
type: 'checkbox', type: 'checkbox',
readonly: function(state) { readonly: function(state) {
let currCon = _.find(obj.top.origData.constraints, (con)=>con.conoid == state.conoid); 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;
}, },
} }
]; ];

View File

@ -132,7 +132,7 @@ export default class ForeignTableSchema extends BaseUISchema {
let newColInherits = state.inherits || []; let newColInherits = state.inherits || [];
let oldColInherits = actionObj.oldState.inherits || []; let oldColInherits = actionObj.oldState.inherits || [];
let tabName = undefined; let tabName;
let tabColsResponse; let tabColsResponse;
// Add columns logic // Add columns logic
@ -199,7 +199,7 @@ export default class ForeignTableSchema extends BaseUISchema {
canAdd: true, canDelete: true, columns: ['conname','consrc', 'connoinherit', 'convalidated'], canAdd: true, canDelete: true, columns: ['conname','consrc', 'connoinherit', 'convalidated'],
canEdit: true, canEdit: true,
canDeleteRow: function(state) { canDeleteRow: function(state) {
return (state.conislocal || _.isUndefined(state.conislocal)) ? true : false; return (state.conislocal || _.isUndefined(state.conislocal));
}, },
canEditRow: function(state) { canEditRow: function(state) {
return obj.isNew(state); return obj.isNew(state);
@ -307,7 +307,7 @@ export class ColumnSchema extends BaseUISchema {
} }
editable_check_for_column(state) { 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 // Check whether the column is a generated column
@ -355,10 +355,10 @@ export class ColumnSchema extends BaseUISchema {
type: 'multiline', mode: ['properties', 'create', 'edit'], type: 'multiline', mode: ['properties', 'create', 'edit'],
}, },
{ {
id: 'cltype', id: 'cltype',
label: gettext('Data type'), label: gettext('Data type'),
minWidth: 150, minWidth: 150,
group: gettext('Definition'), group: gettext('Definition'),
noEmpty: true, noEmpty: true,
editable: obj.editable_check_for_column, editable: obj.editable_check_for_column,
disabled: (state)=>{ disabled: (state)=>{
@ -416,7 +416,7 @@ export class ColumnSchema extends BaseUISchema {
}, },
{ {
id: 'attlen', id: 'attlen',
label: gettext('Length'), label: gettext('Length'),
group: gettext('Definition'), group: gettext('Definition'),
deps: ['cltype'], deps: ['cltype'],
type: 'int', type: 'int',
@ -486,10 +486,10 @@ export class ColumnSchema extends BaseUISchema {
id: 'max_val_attprecision', skipChange: true, visible: false, type: '', id: 'max_val_attprecision', skipChange: true, visible: false, type: '',
}, },
{ {
id: 'attstattarget', id: 'attstattarget',
label: gettext('Statistics'), label: gettext('Statistics'),
cell: 'text', cell: 'text',
type: 'text', type: 'text',
readonly: obj.inSchemaWithColumnCheck, readonly: obj.inSchemaWithColumnCheck,
mode: ['properties', 'edit'], mode: ['properties', 'edit'],
group: gettext('Definition'), group: gettext('Definition'),
@ -524,12 +524,12 @@ export class ColumnSchema extends BaseUISchema {
}, },
}, },
{ {
id: 'attnotnull', id: 'attnotnull',
label: gettext('Not NULL?'), label: gettext('Not NULL?'),
cell: 'switch', cell: 'switch',
type: 'switch', type: 'switch',
minWidth: 80, minWidth: 80,
group: gettext('Constraints'), group: gettext('Constraints'),
editable: obj.editable_check_for_column, editable: obj.editable_check_for_column,
}, },
{ {
@ -540,7 +540,7 @@ export class ColumnSchema extends BaseUISchema {
type: (state)=>{ type: (state)=>{
let options = [ let options = [
{ 'label': gettext('NONE'), 'value': 'n'}, { 'label': gettext('NONE'), 'value': 'n'},
]; ];
// You can't change the existing column to Generated column. // You can't change the existing column to Generated column.
if (this.isNew(state)) { if (this.isNew(state)) {
options.push({ options.push({
@ -553,7 +553,7 @@ export class ColumnSchema extends BaseUISchema {
'value': 'g', 'value': 'g',
'disabled': true, 'disabled': true,
}); });
} }
return { return {
type: 'toggle', type: 'toggle',
options: options, options: options,
@ -561,17 +561,17 @@ export class ColumnSchema extends BaseUISchema {
}, },
disabled: function(state) { disabled: function(state) {
return (!this.isNew(state) && state.colconstype == 'g'); return (!this.isNew(state) && state.colconstype == 'g');
}, },
min_version: 120000, min_version: 120000,
}, },
{ {
id: 'genexpr', id: 'genexpr',
label: gettext('Expression'), label: gettext('Expression'),
type: 'text', type: 'text',
mode: ['properties', 'create', 'edit'], mode: ['properties', 'create', 'edit'],
group: gettext('Constraints'), group: gettext('Constraints'),
min_version: 120000, min_version: 120000,
deps: ['colconstype'], deps: ['colconstype'],
visible: this.isTypeGenerated, visible: this.isTypeGenerated,
readonly: function(state) { readonly: function(state) {
return !this.isNew(state); return !this.isNew(state);
@ -596,7 +596,7 @@ export class ColumnSchema extends BaseUISchema {
return (_.isUndefined(state.inheritedid) return (_.isUndefined(state.inheritedid)
|| _.isNull(state.inheritedid) || || _.isNull(state.inheritedid) ||
_.isUndefined(state.inheritedfrom) || _.isUndefined(state.inheritedfrom) ||
_.isNull(state.inheritedfrom)); _.isNull(state.inheritedfrom));
} }
}, },

View File

@ -132,9 +132,9 @@ export default class FTSConfigurationSchema extends BaseUISchema {
//disable parser when user select copy_config manually and vica-versa //disable parser when user select copy_config manually and vica-versa
disabled: function(state) { disabled: function(state) {
let copy_config = state.copy_config; let copy_config = state.copy_config;
return (_.isNull(copy_config) || return !(_.isNull(copy_config) ||
_.isUndefined(copy_config) || _.isUndefined(copy_config) ||
copy_config === '') ? false : true; copy_config === '');
}, },
readonly: function(state) { return !obj.isNew(state); }, 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 //disable copy_config when user select parser manually and vica-versa
disabled: function(state) { disabled: function(state) {
let parser = state.prsname; let parser = state.prsname;
return (_.isNull(parser) || return !(_.isNull(parser) ||
_.isUndefined(parser) || _.isUndefined(parser) ||
parser === '') ? false : true; parser === '');
}, },
readonly: function(state) { return !obj.isNew(state); }, readonly: function(state) { return !obj.isNew(state); },
}, { }, {

View File

@ -97,7 +97,7 @@ export default class SynonymSchema extends BaseUISchema {
}; };
}, },
readonly: function() { readonly: function() {
return !obj.inCatalog() ? false : true; return obj.inCatalog();
} }
}, { }, {
id: 'is_sys_obj', label: gettext('System synonym?'), id: 'is_sys_obj', label: gettext('System synonym?'),

View File

@ -85,7 +85,7 @@ class ForeignKeyHeaderSchema extends BaseUISchema {
optionsReloadBasis: this.fieldOptions.references?.map ? _.join(this.fieldOptions.references.map((c)=>c.label), ',') : null, optionsReloadBasis: this.fieldOptions.references?.map ? _.join(this.fieldOptions.references.map((c)=>c.label), ',') : null,
optionsLoaded: (rows)=>obj.refTables=rows, optionsLoaded: (rows)=>obj.refTables=rows,
disabled: (state) => { disabled: (state) => {
return state._disable_references ? true : false; return state._disable_references;
} }
},{ },{
id: 'referenced', label: gettext('Referencing'), editable: false, deps: ['references'], id: 'referenced', label: gettext('Referencing'), editable: false, deps: ['references'],

View File

@ -122,7 +122,7 @@ export default class PartitionTableSchema extends BaseUISchema {
this.getAttachTables = getAttachTables; this.getAttachTables = getAttachTables;
this.partitionKeysObj = new PartitionKeysSchema([], getCollations, getOperatorClass); 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(); this.constraintsObj = this.schemas.constraints();
} }
@ -236,7 +236,7 @@ export default class PartitionTableSchema extends BaseUISchema {
return { return {
type: 'select', options: this.fieldOptions.table_amname_list, type: 'select', options: this.fieldOptions.table_amname_list,
controlProps: { controlProps: {
allowClear: obj.isNew(state) ? true : false, allowClear: obj.isNew(state),
} }
}; };
}, mode: ['create', 'properties', 'edit'], min_version: 120000, }, mode: ['create', 'properties', 'edit'], min_version: 120000,

View File

@ -113,7 +113,7 @@ export class PartitionKeysSchema extends BaseUISchema {
} }
} }
export class PartitionsSchema extends BaseUISchema { export class PartitionsSchema extends BaseUISchema {
constructor(nodeInfo, getCollations, getOperatorClass, getAttachTables=()=>[], table_amname_list) { constructor(nodeInfo, getCollations, getOperatorClass, table_amname_list, getAttachTables=()=>[]) {
super({ super({
oid: undefined, oid: undefined,
is_attach: false, is_attach: false,
@ -206,7 +206,7 @@ export class PartitionsSchema extends BaseUISchema {
return { return {
type: 'select', options: this.table_amname_list, type: 'select', options: this.table_amname_list,
controlProps: { controlProps: {
allowClear: obj.isNew(state) ? true : false, allowClear: obj.isNew(state),
} }
}; };
}, min_version: 120000, disabled: state => { }, min_version: 120000, disabled: state => {

View File

@ -367,7 +367,7 @@ export default class TableSchema extends BaseUISchema {
this.nodeInfo = nodeInfo; this.nodeInfo = nodeInfo;
this.getColumns = getColumns; 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.constraintsObj = this.schemas.constraints?.() || {};
this.columnsSchema = this.schemas.columns?.() || {}; this.columnsSchema = this.schemas.columns?.() || {};
this.vacuumSettingsSchema = this.schemas.vacuum_settings?.() || {}; 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: 'oid', label: gettext('OID'), type: 'text', mode: ['properties'],
},{ },{
id: 'relowner', label: gettext('Owner'), type: 'select', 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}, mode: ['properties', 'create', 'edit'], controlProps: {allowClear: false},
readonly: this.inCatalog, visible: !this.inErd, readonly: this.inCatalog, visible: !this.inErd,
},{ },{
@ -480,7 +480,7 @@ export default class TableSchema extends BaseUISchema {
return { return {
type: 'select', options: this.fieldOptions.spcname, type: 'select', options: this.fieldOptions.spcname,
controlProps: { controlProps: {
allowClear: obj.isNew(state) ? true : false, allowClear: obj.isNew(state),
} }
}; };
} }
@ -782,7 +782,7 @@ export default class TableSchema extends BaseUISchema {
return { return {
type: 'select', options: this.fieldOptions.table_amname_list, type: 'select', options: this.fieldOptions.table_amname_list,
controlProps: { controlProps: {
allowClear: obj.isNew(state) ? true : false, allowClear: obj.isNew(state),
} }
}; };
}, mode: ['create', 'properties', 'edit'], min_version: 120000, }, mode: ['create', 'properties', 'edit'], min_version: 120000,

View File

@ -310,7 +310,7 @@ export default class TriggerSchema extends BaseUISchema {
state.tginitdeferred = false; state.tginitdeferred = false;
} }
// If constraint trigger is set then do not disable // If constraint trigger is set then do not disable
return state.is_constraint_trigger ? false : true; return !state.is_constraint_trigger;
} }
} else { } else {
// readonly it // readonly it

View File

@ -348,7 +348,7 @@ class RangeSchema extends BaseUISchema {
this.options = []; this.options = [];
} }
return disableCollNameControl ? false : true; return !disableCollNameControl;
}, },
readonly: function(state) { readonly: function(state) {
return !obj.isNew(state); return !obj.isNew(state);

View File

@ -91,7 +91,7 @@ export default class MViewSchema extends BaseUISchema {
return { return {
type: 'select', options: obj.fieldOptions.table_amname_list, type: 'select', options: obj.fieldOptions.table_amname_list,
controlProps: { controlProps: {
allowClear: obj.isNew(state) ? true : false, allowClear: obj.isNew(state),
} }
}; };
}, mode: ['create', 'properties', 'edit'], min_version: 120000, }, mode: ['create', 'properties', 'edit'], min_version: 120000,
@ -110,7 +110,7 @@ export default class MViewSchema extends BaseUISchema {
},{ },{
id: 'definition', label: gettext('Definition'), cell: 'text', id: 'definition', label: gettext('Definition'), cell: 'text',
type: 'sql', mode: ['create', 'edit'], group: gettext('Code'), 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'], type: 'nested-tab', group: gettext('Parameter'), mode: ['create', 'edit'],

View File

@ -97,7 +97,7 @@ export default class ViewSchema extends BaseUISchema {
id: 'definition', label: gettext('Code'), cell: 'text', id: 'definition', label: gettext('Code'), cell: 'text',
type: 'sql', mode: ['create', 'edit'], group: gettext('Code'), type: 'sql', mode: ['create', 'edit'], group: gettext('Code'),
isFullTab: true, isFullTab: true,
controlProps: { readOnly: obj.nodeInfo && 'catalog' in obj.nodeInfo ? true: false }, controlProps: { readOnly: obj.nodeInfo && 'catalog' in obj.nodeInfo },
}, },
{ {

View File

@ -380,7 +380,7 @@ define('pgadmin.node.database', [
// If node_info is not present in current object then it might in its // If node_info is not present in current object then it might in its
// parent in case if we used sub node control // parent in case if we used sub node control
let node_info = args.node_info || args.handler.node_info; let node_info = args.node_info || args.handler.node_info;
return 'catalog' in node_info ? false : true; return !('catalog' in node_info);
} }
return true; return true;
}, },

View File

@ -97,10 +97,7 @@ export default class SubscriptionSchema extends BaseUISchema{
return false; return false;
} }
isRefresh(state){ isRefresh(state){
if (!state.refresh_pub || _.isUndefined(state.refresh_pub)){ return !state.refresh_pub || _.isUndefined(state.refresh_pub);
return true;
}
return false;
} }
isSSL(state) { isSSL(state) {
return this.SSL_MODES.indexOf(state.sslmode) == -1; return this.SSL_MODES.indexOf(state.sslmode) == -1;
@ -336,7 +333,11 @@ export default class SubscriptionSchema extends BaseUISchema{
state.copy_data_after_refresh = false; state.copy_data_after_refresh = false;
return true; return true;
}, depChange: (state)=>{ }, 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?'), id: 'connect', label: gettext('Connect?'),

View File

@ -99,7 +99,7 @@ export default class RoleReassign extends BaseUISchema{
helpMessage: gettext('New owner of the affected objects'), helpMessage: gettext('New owner of the affected objects'),
deps: ['role_op'], deps: ['role_op'],
disabled: (state)=>{ disabled: (state)=>{
return state.role_op == 'drop'? true: false; return state.role_op == 'drop';
}, },
depChange: (state) =>{ depChange: (state) =>{
if (state.role_op == 'drop'){ if (state.role_op == 'drop'){

View File

@ -35,7 +35,7 @@ export default class BinaryPathSchema extends BaseUISchema {
width: 32, width: 32,
radioType: true, radioType: true,
disabled: function (state) { disabled: function (state) {
return state?.binaryPath && state?.binaryPath.length > 0 ? false : true; return !(state?.binaryPath && state?.binaryPath.length > 0);
}, },
cell: 'radio', cell: 'radio',
deps: ['binaryPath'], deps: ['binaryPath'],

View File

@ -498,7 +498,7 @@ define('pgadmin.browser', [
url: _m.url || '#', url: _m.url || '#',
target: _m.target, target: _m.target,
icon: _m.icon, icon: _m.icon,
enable: enable ? enable : true, enable: enable || true,
node: _m.node, node: _m.node,
checked: _m.checked, checked: _m.checked,
below: _m.below, below: _m.below,

View File

@ -412,7 +412,7 @@ function Dashboard({
disableGlobalFilter: false, disableGlobalFilter: false,
minWidth: 26, minWidth: 26,
width: 80, width: 80,
isVisible: !did ? true: false isVisible: !did
}, },
{ {
accessor: 'usename', accessor: 'usename',
@ -506,7 +506,7 @@ function Dashboard({
resizable: true, resizable: true,
disableGlobalFilter: false, disableGlobalFilter: false,
minWidth: 26, minWidth: 26,
isVisible: !did ? true: false, isVisible: !did,
width: 80 width: 80
}, },
{ {
@ -623,7 +623,7 @@ function Dashboard({
disableGlobalFilter: false, disableGlobalFilter: false,
minWidth: 26, minWidth: 26,
width: 80, width: 80,
isVisible: !did ? true: false isVisible: !did
}, },
{ {
accessor: 'Owner', accessor: 'Owner',

View File

@ -451,7 +451,7 @@ export default function CloudWizard({ nodeInfo, nodeData, onClose, cloudPanelId}
<br/>{gettext('By clicking the below button, you will be redirected to the EDB BigAnimal authentication page in a new tab.')} <br/>{gettext('By clicking the below button, you will be redirected to the EDB BigAnimal authentication page in a new tab.')}
</Box> </Box>
</Box>} </Box>}
{cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && <PrimaryButton onClick={authenticateBigAnimal} disabled={verificationIntiated ? true: false}> {cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && <PrimaryButton onClick={authenticateBigAnimal} disabled={verificationIntiated}>
{gettext('Click here to authenticate yourself to EDB BigAnimal')} {gettext('Click here to authenticate yourself to EDB BigAnimal')}
</PrimaryButton>} </PrimaryButton>}
{cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && <Box className={classes.messageBox}> {cloudProvider == CLOUD_PROVIDERS.BIGANIMAL && <Box className={classes.messageBox}>

View File

@ -67,7 +67,7 @@ class AzureCredSchema extends BaseUISchema {
value: 'azure_cli_credential', value: 'azure_cli_credential',
}, },
], ],
disabled: pgAdmin.server_mode == 'True' ? true : false, disabled: pgAdmin.server_mode == 'True',
helpMessage: gettext( 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.' '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.' 'Enter the Azure tenant ID against which the user is authenticated.'
), ),
disabled: (state) => { disabled: (state) => {
return state.auth_type == 'interactive_browser_credential' return state.auth_type !== 'interactive_browser_credential';
? false
: true;
}, },
depChange: (state) => { depChange: (state) => {
if (state.auth_type == 'azure_cli_credential') { if (state.auth_type == 'azure_cli_credential') {

View File

@ -53,7 +53,7 @@ class GoogleCredSchema extends BaseUISchema{
btnName: gettext('Click here to authenticate yourself to Google'), 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.'), helpMessage: gettext('After clicking the button above you will be redirected to the Google authentication page in a new browser tab.'),
disabled: (state)=>{ disabled: (state)=>{
return state.client_secret_file ? false : true; return !state.client_secret_file;
}, },
deferredDepChange: (state, source)=>{ deferredDepChange: (state, source)=>{
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
@ -223,7 +223,7 @@ class GoogleInstanceSchema extends BaseUISchema {
} }
]; ];
} }
} }
class GoogleStorageSchema extends BaseUISchema { class GoogleStorageSchema extends BaseUISchema {
constructor() { constructor() {
@ -235,22 +235,22 @@ class GoogleStorageSchema extends BaseUISchema {
get baseFields() { get baseFields() {
return [ return [
{ {
id: 'storage_type', id: 'storage_type',
label: gettext('Storage type'), label: gettext('Storage type'),
type: 'select', type: 'select',
mode: ['create'], mode: ['create'],
noEmpty: true, noEmpty: true,
options: [ options: [
{'label': gettext('SSD'), 'value': 'PD_SSD'}, {'label': gettext('SSD'), 'value': 'PD_SSD'},
{'label': gettext('HDD'), 'value': 'PD_HDD'}, {'label': gettext('HDD'), 'value': 'PD_HDD'},
], ],
}, },
{ {
id: 'storage_size', id: 'storage_size',
label: gettext('Storage capacity'), label: gettext('Storage capacity'),
type: 'int', type: 'int',
mode: ['create'], mode: ['create'],
noEmpty: true, noEmpty: true,
deps: ['storage_type'], deps: ['storage_type'],
helpMessage: gettext('Size in GB.'), helpMessage: gettext('Size in GB.'),
} }
@ -445,11 +445,11 @@ class GoogleClusterSchema extends BaseUISchema {
}, },
{} {}
); );
this.googleStorageDetails = new GoogleStorageSchema( this.googleStorageDetails = new GoogleStorageSchema(
{}, {},
{} {}
); );
this.googleNetworkDetails = new GoogleNetworkSchema({}, {}); this.googleNetworkDetails = new GoogleNetworkSchema({}, {});

View File

@ -34,7 +34,7 @@ class ChangePasswordSchema extends BaseUISchema {
id: 'user', label: gettext('User'), type: 'text', disabled: true, visible: this.showUser id: 'user', label: gettext('User'), type: 'text', disabled: true, visible: this.showUser
}, { }, {
id: 'password', label: gettext('Current Password'), type: 'password', id: 'password', label: gettext('Current Password'), type: 'password',
disabled: self.isPgpassFileUsed, noEmpty: self.isPgpassFileUsed ? false : true, disabled: self.isPgpassFileUsed, noEmpty: !self.isPgpassFileUsed,
controlProps: { controlProps: {
maxLength: null maxLength: null
} }

View File

@ -157,7 +157,7 @@ const dialogStyle = makeStyles((theme) => ({
function checkIsResizable(props) { function checkIsResizable(props) {
return props.isresizeable == 'true' ? true : false; return props.isresizeable == 'true';
} }
function setEnableResizing(props, resizeable) { function setEnableResizing(props, resizeable) {

View File

@ -222,7 +222,7 @@ function Wizard({ stepList, onStepChange, onSave, className, ...props }) {
<DefaultButton onClick={() => handleNext()} className={classes.buttonMargin} startIcon={<FastForwardIcon />} disabled={activeStep == steps.length - 1 || disableNext}> <DefaultButton onClick={() => handleNext()} className={classes.buttonMargin} startIcon={<FastForwardIcon />} disabled={activeStep == steps.length - 1 || disableNext}>
{gettext('Next')} {gettext('Next')}
</DefaultButton> </DefaultButton>
<PrimaryButton className={classes.buttonMargin} startIcon={<CheckIcon />} disabled={activeStep == steps.length - 1 ? false : true} onClick={onSave}> <PrimaryButton className={classes.buttonMargin} startIcon={<CheckIcon />} disabled={activeStep !== (steps.length - 1) } onClick={onSave}>
{gettext('Finish')} {gettext('Finish')}
</PrimaryButton> </PrimaryButton>
</Box> </Box>

View File

@ -25,7 +25,7 @@ export function enabled(tree, supportedNodes, treeNodeData, domTreeNode) {
if (!isValidTreeNodeData(treeNodeData)) if (!isValidTreeNodeData(treeNodeData))
return false; return false;
let _tree = tree ? tree : pgAdmin.Browser.tree; let _tree = tree || pgAdmin.Browser.tree;
let treeNode = _tree.findNodeByDomElement(domTreeNode); let treeNode = _tree.findNodeByDomElement(domTreeNode);
if (!treeNode) { if (!treeNode) {
return false; return false;

View File

@ -78,7 +78,7 @@ function manageTreeEvents(event, eventName, item) {
export class Tree { export class Tree {
constructor(tree, manageTree, pgBrowser, type) { constructor(tree, manageTree, pgBrowser, type) {
this.tree = tree; this.tree = tree;
this.tree.type = type ? type : 'browser'; this.tree.type = type || 'browser';
this.tree.onTreeEvents(manageTreeEvents); this.tree.onTreeEvents(manageTreeEvents);
this.rootNode = manageTree.tempTree; this.rootNode = manageTree.tempTree;
@ -299,7 +299,7 @@ export class Tree {
} }
hasParent(item) { hasParent(item) {
return item?.parent ? true : false; return item?.parent;
} }
isOpen(item) { isOpen(item) {
@ -332,7 +332,7 @@ export class Tree {
isInode(item) { isInode(item) {
const children = this.children(item); const children = this.children(item);
if (children === null || children === undefined) return false; if (children === null || children === undefined) return false;
return children.length > 0 ? true : false; return children.length > 0;
} }
selected() { selected() {

View File

@ -30,10 +30,7 @@ export function parseShortcutValue(obj) {
export function isShortcutValue(obj) { export function isShortcutValue(obj) {
if(!obj) return false; if(!obj) return false;
if([obj.alt, obj.control, obj?.key, obj?.key?.char].every((k)=>!_.isUndefined(k))){ return [obj.alt, obj.control, obj?.key, obj?.key?.char].every((k)=>!_.isUndefined(k));
return true;
}
return false;
} }
// Convert shortcut obj to codemirror key format // Convert shortcut obj to codemirror key format
@ -60,7 +57,7 @@ export function toCodeMirrorKey(obj) {
} }
export function getEpoch(inp_date) { 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); return parseInt(date_obj.getTime()/1000);
} }
@ -643,4 +640,4 @@ export function scrollbarWidth() {
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv); document.body.removeChild(scrollDiv);
return scrollbarWidth; return scrollbarWidth;
} }

View File

@ -576,7 +576,7 @@ export default class BackupSchema extends BaseUISchema {
state.on_conflict_do_nothing = false; state.on_conflict_do_nothing = false;
return true; return true;
}, },
inlineNext: obj.backupType == 'server'? false : true, inlineNext: obj.backupType !== 'server',
}, { }, {
id: 'include_create_database', id: 'include_create_database',
label: gettext('Include CREATE DATABASE statement'), label: gettext('Include CREATE DATABASE statement'),

View File

@ -267,10 +267,10 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
funcObj.push({ funcObj.push({
'name': argName[index], 'name': argName[index],
'type': argType[index], 'type': argType[index],
'is_null': argData['is_null'] ? true : false, 'is_null': argData['is_null'],
'expr': argData['is_expression'] ? true : false, 'expr': argData['is_expression'],
'value': values, 'value': values,
'use_default': argData['use_default'] ? true : false, 'use_default': argData['use_default'],
'default_value': defValList[index], 'default_value': defValList[index],
'disable_use_default': isUnnamedParam ? defValList[index] == DEBUGGER_ARGS.NO_DEFAULT_VALUE : defValList[index] == DEBUGGER_ARGS.NO_DEFAULT, 'disable_use_default': isUnnamedParam ? defValList[index] == DEBUGGER_ARGS.NO_DEFAULT_VALUE : defValList[index] == DEBUGGER_ARGS.NO_DEFAULT,
}); });

View File

@ -370,22 +370,22 @@ export default class MaintenanceSchema extends BaseUISchema {
{ {
'label': gettext('VACUUM'), 'label': gettext('VACUUM'),
value: 'VACUUM', value: 'VACUUM',
disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview) ? true : false disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview)
}, },
{ {
'label': gettext('ANALYZE'), 'label': gettext('ANALYZE'),
value: 'ANALYZE', value: 'ANALYZE',
disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview) ? true : false disabled: (obj.isSchemaNode() && !obj.nodeInfo?.mview)
}, },
{ {
'label': gettext('REINDEX'), 'label': gettext('REINDEX'),
value: 'REINDEX', value: 'REINDEX',
disabled: obj.nodeInfo?.mview ? true : false disabled: obj.nodeInfo?.mview
}, },
{ {
'label': gettext('CLUSTER'), 'label': gettext('CLUSTER'),
value: 'CLUSTER', value: 'CLUSTER',
disabled: obj.nodeInfo?.mview ? true : obj.isSchemaNode() ? true : false disabled: obj.nodeInfo?.mview || obj.isSchemaNode()
}, },
], ],
}, },

View File

@ -38,8 +38,8 @@ export function InputComponent({ label, serverList, databaseList, schemaList, di
const [selectedDatabase, setSelectedDatabase] = useState(selectedDid); const [selectedDatabase, setSelectedDatabase] = useState(selectedDid);
const [selectedSchema, setSelectedSchema] = useState(selectedScid); const [selectedSchema, setSelectedSchema] = useState(selectedScid);
const eventBus = useContext(SchemaDiffEventsContext); const eventBus = useContext(SchemaDiffEventsContext);
const [disableDBSelection, setDisableDBSelection] = useState(selectedSid == null ? true : false); const [disableDBSelection, setDisableDBSelection] = useState(selectedSid == null);
const [disableSchemaSelection, setDisableSchemaSelection] = useState(selectedDid == null ? true : false); const [disableSchemaSelection, setDisableSchemaSelection] = useState(selectedDid == null);
const changeServer = (selectedOption) => { const changeServer = (selectedOption) => {
setDisableDBSelection(false); setDisableDBSelection(false);
setSelectedServer(selectedOption); setSelectedServer(selectedOption);

View File

@ -174,7 +174,7 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
</PgButtonGroup> </PgButtonGroup>
</Box> </Box>
<Box className={classes.scriptBtn}> <Box className={classes.scriptBtn}>
<PgButtonGroup size="small" disabled={selectedRowIds?.length > 0 ? false : true}> <PgButtonGroup size="small" disabled={selectedRowIds?.length <= 0}>
<DefaultButton startIcon={<FeaturedPlayListRoundedIcon />} onClick={generateScript}>{gettext('Generate Script')}</DefaultButton> <DefaultButton startIcon={<FeaturedPlayListRoundedIcon />} onClick={generateScript}>{gettext('Generate Script')}</DefaultButton>
</PgButtonGroup> </PgButtonGroup>
</Box> </Box>

View File

@ -339,7 +339,7 @@ export function SchemaDiffCompare({ params }) {
const triggerGenerateScript = ({ sid, did, selectedIds, rows }) => { const triggerGenerateScript = ({ sid, did, selectedIds, rows }) => {
setLoaderText(gettext('Generating script...')); 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('-- 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'); 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, 'parentId': tempData[record.group_name]['children'][record.label].id,
'label': record.title, 'label': record.title,
'status': record.status, 'status': record.status,
'isVisible': filterParams.includes(record.status) ? true : false, 'isVisible': filterParams.includes(record.status),
'icon': `icon-${record.type}`, 'icon': `icon-${record.type}`,
'isExpanded': false, 'isExpanded': false,
'selected': false, 'selected': false,
@ -448,7 +448,7 @@ export function SchemaDiffCompare({ params }) {
'parentId': chidId, 'parentId': chidId,
'label': record.title, 'label': record.title,
'status': record.status, 'status': record.status,
'isVisible': filterParams.includes(record.status) ? true : false, 'isVisible': filterParams.includes(record.status),
'icon': `icon-${record.type}`, 'icon': `icon-${record.type}`,
'isExpanded': false, 'isExpanded': false,
'selected': false, 'selected': false,
@ -503,7 +503,7 @@ export function SchemaDiffCompare({ params }) {
'status': record.status, 'status': record.status,
'selected': false, 'selected': false,
'itemType': record.type, 'itemType': record.type,
'isVisible': filterParams.includes(record.status) ? true : false, 'isVisible': filterParams.includes(record.status),
'icon': `icon-${record.type}`, 'icon': `icon-${record.type}`,
'isExpanded': false, 'isExpanded': false,
'oid': record.oid, 'oid': record.oid,

View File

@ -51,7 +51,7 @@ export default class SQLEditor {
viewMenuEnabled(obj) { viewMenuEnabled(obj) {
let isEnabled = (() => { let isEnabled = (() => {
if (!_.isUndefined(obj) && !_.isNull(obj)) if (!_.isUndefined(obj) && !_.isNull(obj))
return (_.indexOf(this.SUPPORTED_NODES, obj._type) !== -1 ? true : false); return (_.indexOf(this.SUPPORTED_NODES, obj._type) !== -1);
else else
return false; return false;
})(); })();

View File

@ -71,7 +71,7 @@ function setPanelTitle(docker, panelId, title, qtState, dirty=false) {
docker.setInternalAttrs(panelId, { docker.setInternalAttrs(panelId, {
isDirty: dirty, 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: {
...params, ...params,
title: _.unescape(params.title), 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), node_name: retrieveNodeName(selectedNodeInfo),
dbname: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo) dbname: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo)
}, },
@ -187,7 +187,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
bgcolor: params.bgcolor, bgcolor: params.bgcolor,
conn_title: getTitle( conn_title: getTitle(
pgAdmin, null, selectedNodeInfo, true, _.unescape(params.server_name), _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo), 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), server_name: _.unescape(params.server_name),
database_name: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo), database_name: _.unescape(params.database_name) || getDatabaseLabel(selectedNodeInfo),
is_selected: true, is_selected: true,
@ -676,7 +676,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
fgcolor: connectionData.fgcolor, fgcolor: connectionData.fgcolor,
bgcolor: connectionData.bgcolor, bgcolor: connectionData.bgcolor,
}, },
connected: respData.data.trans_id ? true : false, connected: respData.data.trans_id,
obtaining_conn: false, obtaining_conn: false,
}; };
}); });

View File

@ -254,7 +254,7 @@ export function NumberEditor({row, column, onRowChange, onClose}) {
}; };
const onBlur = ()=>{ const onBlur = ()=>{
if(isValidData()) { if(isValidData()) {
onClose(column.can_edit ? true : false); onClose(column.can_edit);
return true; return true;
} }
return false; return false;

View File

@ -128,7 +128,7 @@ function GenerateGraph({graphType, graphData, ...props}) {
plugins: { plugins: {
legend: { legend: {
labels: { labels: {
usePointStyle: (showDataPoints && useDiffPointStyle) ? true : false usePointStyle: (showDataPoints && useDiffPointStyle)
}, },
}, },
}, },

View File

@ -37,7 +37,7 @@ class UserManagementCollection extends BaseUISchema {
}); });
this.authOnlyInternal = (current_user['auth_sources'].length == 1 && 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.authSources = authSources;
this.roleOptions = roleOptions; this.roleOptions = roleOptions;
} }
@ -146,7 +146,7 @@ class UserManagementCollection extends BaseUISchema {
} }
validate(state, setError) { validate(state, setError) {
let msg = undefined; let msg;
let obj = this; let obj = this;
let minPassLen = pgAdmin.password_length_min; let minPassLen = pgAdmin.password_length_min;
if (obj.isUserNameEnabled(state) && isEmptyString(state.username)) { if (obj.isUserNameEnabled(state) && isEmptyString(state.username)) {