mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed code smell 'Prefer using an optional chain expression instead, as it's more concise and easier to read'.
This commit is contained in:
@@ -24,7 +24,6 @@ from pgadmin.utils import PgAdminModule, get_storage_directory, html, \
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request, unauthorized
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.model import Server, SharedServer
|
||||
from pgadmin.misc.bgprocess import escape_dquotes_process_arg
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
from pgadmin.tools.grant_wizard import _get_rows_for_type, \
|
||||
@@ -545,7 +544,6 @@ def objects(sid, did, scid=None):
|
||||
Returns:
|
||||
list of objects
|
||||
"""
|
||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||
server = get_server(sid)
|
||||
|
||||
if server is None:
|
||||
@@ -555,7 +553,6 @@ def objects(sid, did, scid=None):
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
from flask_babel import gettext
|
||||
from pgadmin.utils.ajax import precondition_required
|
||||
|
||||
server_info = {}
|
||||
|
||||
@@ -219,15 +219,12 @@ export default class DebuggerModule {
|
||||
let treeInfo = tree.getTreeNodeHierarchy(info);
|
||||
|
||||
// For indirect debugging user must be super user
|
||||
if (data && data.debug_type && data.debug_type == 'indirect' &&
|
||||
!treeInfo.server.user.is_superuser)
|
||||
if (data?.debug_type == 'indirect' && !treeInfo.server.user.is_superuser)
|
||||
return false;
|
||||
|
||||
// Fetch object owner
|
||||
let obj_owner = treeInfo.function && treeInfo.function.funcowner ||
|
||||
treeInfo.procedure && treeInfo.procedure.funcowner ||
|
||||
treeInfo.edbfunc && treeInfo.edbfunc.funcowner ||
|
||||
treeInfo.edbproc && treeInfo.edbproc.funcowner;
|
||||
let obj_owner = treeInfo.function?.funcowner || treeInfo.procedure?.funcowner ||
|
||||
treeInfo.edbfunc?.funcowner || treeInfo.edbproc?.funcowner;
|
||||
|
||||
// Must be a super user or object owner to create breakpoints of any kind
|
||||
if (!(treeInfo.server.user.is_superuser || obj_owner == treeInfo.server.user.name))
|
||||
@@ -312,7 +309,7 @@ export default class DebuggerModule {
|
||||
}
|
||||
|
||||
checkDbNameChange(data, dbNode, newTreeInfo, db_label) {
|
||||
if (data && data.data_obj && data.data_obj.db_name != _.unescape(newTreeInfo.database.label)) {
|
||||
if (data?.data_obj?.db_name != _.unescape(newTreeInfo.database.label)) {
|
||||
db_label = data.data_obj.db_name;
|
||||
let message = `Current database has been moved or renamed to ${db_label}. Click on the OK button to refresh the database name.`;
|
||||
refresh_db_node(message, dbNode);
|
||||
|
||||
@@ -596,7 +596,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
||||
|
||||
function checkTypeAndGetUrl(d, treeInfo) {
|
||||
let baseUrl;
|
||||
if (d && d._type == 'function') {
|
||||
if (d?._type == 'function') {
|
||||
baseUrl = url_for('debugger.initialize_target_for_function', {
|
||||
'debug_type': 'direct',
|
||||
'trans_id': transId,
|
||||
@@ -605,7 +605,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
||||
'scid': treeInfo.schema._id,
|
||||
'func_id': treeInfo.function._id,
|
||||
});
|
||||
} else if (d && d._type == 'procedure') {
|
||||
} else if (d?._type == 'procedure') {
|
||||
baseUrl = url_for('debugger.initialize_target_for_function', {
|
||||
'debug_type': 'direct',
|
||||
'trans_id': transId,
|
||||
@@ -614,7 +614,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
||||
'scid': treeInfo.schema._id,
|
||||
'func_id': treeInfo.procedure._id,
|
||||
});
|
||||
} else if (d && d._type == 'edbfunc') {
|
||||
} else if (d?._type == 'edbfunc') {
|
||||
baseUrl = url_for('debugger.initialize_target_for_function', {
|
||||
'debug_type': 'direct',
|
||||
'trans_id': transId,
|
||||
@@ -623,7 +623,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
|
||||
'scid': treeInfo.schema._id,
|
||||
'func_id': treeInfo.edbfunc._id,
|
||||
});
|
||||
} else if (d && d._type == 'edbproc') {
|
||||
} else if (d?._type == 'edbproc') {
|
||||
baseUrl = url_for('debugger.initialize_target_for_function', {
|
||||
'debug_type': 'direct',
|
||||
'trans_id': transId,
|
||||
|
||||
@@ -12,9 +12,9 @@ import {generateTitle} from '../../../sqleditor/static/js/sqleditor_title';
|
||||
function getFunctionId(treeInfoObject) {
|
||||
let objectId;
|
||||
if(treeInfoObject) {
|
||||
if (treeInfoObject.function && treeInfoObject.function._id) {
|
||||
if (treeInfoObject.function?._id) {
|
||||
objectId = treeInfoObject.function._id;
|
||||
} else if (treeInfoObject.edbfunc && treeInfoObject.edbfunc._id) {
|
||||
} else if (treeInfoObject.edbfunc?._id) {
|
||||
objectId = treeInfoObject.edbfunc._id;
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ function getFunctionId(treeInfoObject) {
|
||||
function getProcedureId(treeInfoObject) {
|
||||
let objectId;
|
||||
if(treeInfoObject) {
|
||||
if (treeInfoObject.procedure && treeInfoObject.procedure._id) {
|
||||
if (treeInfoObject.procedure?._id) {
|
||||
objectId = treeInfoObject.procedure._id;
|
||||
} else if (treeInfoObject.edbproc && treeInfoObject.edbproc._id) {
|
||||
} else if (treeInfoObject.edbproc?._id) {
|
||||
objectId = treeInfoObject.edbproc._id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ define([
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
let treeInfo = t && t.getTreeNodeHierarchy(i);
|
||||
let treeInfo = t?.getTreeNodeHierarchy(i);
|
||||
|
||||
const baseUrlUtilitCheck = url_for('import_export.utility_exists', {
|
||||
'sid': server_data._id,
|
||||
|
||||
@@ -158,7 +158,7 @@ define([
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
let treeInfo = t && t.getTreeNodeHierarchy(i);
|
||||
let treeInfo = t?.getTreeNodeHierarchy(i);
|
||||
|
||||
if (treeInfo.database._label.indexOf('=') >= 0) {
|
||||
pgAdmin.Browser.notifier.alert(
|
||||
|
||||
@@ -149,7 +149,7 @@ export function initialize(gettext, url_for, _, pgAdmin, csrfToken, Browser) {
|
||||
+`&server_type=${pData.server.server_type}`
|
||||
+ `&theme=${theme}`;
|
||||
|
||||
if(pData.database && pData.database._id) {
|
||||
if(pData.database?._id) {
|
||||
openUrl += `&db=${encodeURIComponent(pData.database._label)}`;
|
||||
} else {
|
||||
openUrl += `&db=${''}`;
|
||||
|
||||
@@ -293,7 +293,7 @@ function TheMap({data}) {
|
||||
infoControl.current.addTo(mapObj);
|
||||
}
|
||||
resetLayersKey.current++;
|
||||
return ()=>{infoControl.current && infoControl.current.remove();};
|
||||
return ()=>{infoControl.current?.remove();};
|
||||
}, [data]);
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -82,8 +82,7 @@ export class ResultSetUtils {
|
||||
|
||||
static extractErrorMessage(httpMessage) {
|
||||
let msg = httpMessage.errormsg;
|
||||
if (httpMessage.responseJSON !== undefined &&
|
||||
httpMessage.responseJSON.errormsg !== undefined)
|
||||
if (httpMessage.responseJSON?.errormsg !== undefined)
|
||||
msg = httpMessage.responseJSON.errormsg;
|
||||
|
||||
return msg;
|
||||
@@ -633,7 +632,7 @@ export class ResultSetUtils {
|
||||
&& data.types[0] && data.types[0].typname === 'json') {
|
||||
/* json is sent as text, parse it */
|
||||
let planJson = JSON.parse(data.result[0][0]);
|
||||
if (planJson && planJson[0] && planJson[0].hasOwnProperty('Plan') &&
|
||||
if (planJson?.[0] && planJson?.[0].hasOwnProperty('Plan') &&
|
||||
_.isObject(planJson[0]['Plan'])
|
||||
) {
|
||||
return planJson;
|
||||
|
||||
Reference in New Issue
Block a user