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 00c7f0814..5e5238f02 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 @@ -61,7 +61,7 @@ export default class CollationSchema extends BaseUISchema { filter: (options) => { let res = []; options.forEach((d) => { - if (!(d && d.label.match(/^pg_/))) + if (!(d?.label.match(/^pg_/))) res.push(d); }); return res; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.ui.js index c1e8187e7..5f19ec329 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.ui.js @@ -74,7 +74,7 @@ export default class PackageSchema extends BaseUISchema { if (state && packageSchemaObj.isNew(state)) { options.forEach((option) => { // If schema name start with pg_* then we need to exclude them - if(option && option.label.match(/^pg_/)) { + if(option?.label.match(/^pg_/)) { return; } res.push({ label: option.label, value: option.value, image: 'icon-schema' }); 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 c419fd75d..02098c1b7 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 @@ -33,7 +33,7 @@ export function getNodePartitionTableSchema(treeNodeInfo, itemNodeData, pgBrowse cacheLevel: 'database' }, (d)=>{ // If schema name start with pg_* then we need to exclude them - return !(d && d.label.match(/^pg_/)); + return !(d?.label.match(/^pg_/)); }), spcname: spcname, coll_inherits: ()=>getNodeAjaxOptions('get_inherits', partNode, treeNodeInfo, itemNodeData), 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 a38faffe6..a9afd37ea 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 @@ -38,7 +38,7 @@ export function getNodeTableSchema(treeNodeInfo, itemNodeData, pgBrowser) { cacheLevel: 'database' }, (d)=>{ // If schema name start with pg_* then we need to exclude them - return !(d && d.label.match(/^pg_/)); + return !(d?.label.match(/^pg_/)); }), spcname: spcname, coll_inherits: ()=>getNodeAjaxOptions('get_inherits', tableNode, treeNodeInfo, itemNodeData), @@ -368,9 +368,9 @@ export default class TableSchema extends BaseUISchema { this.getColumns = getColumns; this.partitionsObj = new PartitionsSchema(this.nodeInfo, getCollations, getOperatorClass, getAttachTables, fieldOptions.table_amname_list); - this.constraintsObj = this.schemas.constraints && this.schemas.constraints() || {}; - this.columnsSchema = this.schemas.columns && this.schemas.columns() || {}; - this.vacuumSettingsSchema = this.schemas.vacuum_settings && this.schemas.vacuum_settings() || {}; + this.constraintsObj = this.schemas.constraints?.() || {}; + this.columnsSchema = this.schemas.columns?.() || {}; + this.vacuumSettingsSchema = this.schemas.vacuum_settings?.() || {}; this.partitionKeysObj = new PartitionKeysSchema([], getCollations, getOperatorClass); this.inErd = inErd; } 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 0bf96e96e..29381850f 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 @@ -262,7 +262,7 @@ class RangeSchema extends BaseUISchema { state.subtypes = options; } options.forEach((option) => { - if(option && option.label == '') { + if(option?.label == '') { return; } res.push({ label: option.label, value: option.value }); @@ -473,7 +473,7 @@ class ExternalSchema extends BaseUISchema { let result = []; _.each(control, function(item) { - if(item && item.label == '') { + if(item?.label == '') { return; } // if type from selected from combobox matches in options @@ -608,7 +608,7 @@ class ExternalSchema extends BaseUISchema { let res = []; if (state && obj.isNew(state)) { _.each(options, function(item) { - if(item && item.label == '') { + if(item?.label == '') { return; } // if type from selected from combobox matches in options @@ -646,7 +646,7 @@ class ExternalSchema extends BaseUISchema { let res = []; if (state && obj.isNew(state)) { _.each(options, function(item) { - if(item && item.label == '') { + if(item?.label == '') { return; } // if type from selected from combobox matches in options @@ -750,7 +750,7 @@ class ExternalSchema extends BaseUISchema { let res = []; if (state && obj.isNew(state)) { _.each(options, function(item) { - if(item && item.label == '') { + if(item?.label == '') { return; } // if type from selected from combobox matches in options @@ -972,7 +972,7 @@ class CompositeSchema extends BaseUISchema { let self = this, errmsg = null; - if(self.top && self.top.sessData && self.top.sessData.typtype === 'c') { + if(self.top?.sessData?.typtype === 'c') { if (isEmptyString(state.member_name)) { errmsg = gettext('Please specify the value for member name.'); setError('member_name', errmsg); @@ -1197,7 +1197,7 @@ export default class TypeSchema extends BaseUISchema { } schemaCheck(state) { - if(this.fieldOptions.node_info && this.fieldOptions.node_info?.schema) { + if(this.fieldOptions?.node_info?.schema) { if(!state) return true; if (this.isNew(state)) { @@ -1245,7 +1245,7 @@ export default class TypeSchema extends BaseUISchema { if (state && obj.isNew(state)) { options.forEach((option) => { // If schema name start with pg_* then we need to exclude them - if(option && option.label.match(/^pg_/)) { + if(option?.label.match(/^pg_/)) { return; } res.push({ label: option.label, value: option.value, image: 'icon-schema' }); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js index 53b5e7179..e07dbd5f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js @@ -201,7 +201,7 @@ define('pgadmin.node.mview', [ api.put(obj.generate_url(i, 'refresh_data' , d, true), {'concurrent': args.concurrent, 'with_data': args.with_data}) .then(({data: refreshed_res})=>{ - if (refreshed_res.data && refreshed_res.data.status) { + if (refreshed_res.data?.status) { //Do nothing as we are creating the job and exiting from the main dialog pgBrowser.BgProcessManager.startProcess(refreshed_res.data.job_id, refreshed_res.data.desc); } else { @@ -228,7 +228,7 @@ define('pgadmin.node.mview', [ is_version_supported: function(data, item) { let t = pgAdmin.Browser.tree, i = item || t.selected(), - info = t && t.getTreeNodeHierarchy(i), + info = t?.getTreeNodeHierarchy(i), version = _.isUndefined(info) ? 0 : info.server.version; // disable refresh concurrently if server version is 9.3 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 2d03f3d42..9bab5973c 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 @@ -145,8 +145,7 @@ export default class ViewSchema extends BaseUISchema { return false; } - let old_def = obj.origData.definition && - obj.origData.definition.replace( + let old_def = obj.origData.definition?.replace( /\s/gi, '' ).split('FROM'), new_def = []; 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 4d65eaca2..9831d6314 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 @@ -140,13 +140,13 @@ define('pgadmin.node.database', [ return (node && !node.connected && node.allowConn); }, is_connected: function(node) { - return (node && node.connected && node.canDisconn); + return (node?.connected && node?.canDisconn); }, is_psql_enabled: function(node) { - return (node && node.connected) && pgAdmin['enable_psql']; + return node?.connected && pgAdmin['enable_psql']; }, is_conn_allow: function(node) { - return (node && node.allowConn); + return (node?.allowConn); }, connection_lost: function(i, resp, server_connected) { if (pgBrowser.tree) { @@ -154,7 +154,7 @@ define('pgadmin.node.database', [ d = i && t.itemData(i), self = this; - while (d && d._type != 'database') { + while (d?._type != 'database') { i = t.parent(i); d = i && t.itemData(i); } @@ -216,7 +216,7 @@ define('pgadmin.node.database', [ i = input.item || t.selected(), d = i ? t.itemData(i) : undefined; - if (d && d.label != 'template0') { + if (d?.label != 'template0') { connect_to_database(obj, d, t, i, true); } return false; @@ -436,7 +436,7 @@ define('pgadmin.node.database', [ res, model, _data, _tree, _item, _connected ) { _data.is_connecting = false; - if (res && res.data) { + if (res?.data) { if(typeof res.data.connected == 'boolean') { _data.connected = res.data.connected; } 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 1e8d453aa..0d479e403 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/server.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js @@ -39,7 +39,7 @@ define('pgadmin.node.server', [ hasStatistics: true, hasCollectiveStatistics: true, can_expand: function(d) { - return d && d.connected; + return d?.connected; }, title: function(d, action) { if(action == 'create') { @@ -139,8 +139,8 @@ define('pgadmin.node.server', [ label: gettext('Clear Saved Password'), priority: 11, enable: function(node) { - return (node && node._type === 'server' && - node.is_password_saved); + return (node?._type === 'server' && + node?.is_password_saved); }, },{ name: 'clear_sshtunnel_password', node: 'server', module: this, @@ -148,8 +148,8 @@ define('pgadmin.node.server', [ label: gettext('Clear SSH Tunnel Password'), priority: 12, enable: function(node) { - return (node && node._type === 'server' && - node.is_tunnel_password_saved); + return (node?._type === 'server' && + node?.is_tunnel_password_saved); }, data: { data_disabled: gettext('SSH Tunnel password is not saved for selected server.'), @@ -175,30 +175,30 @@ define('pgadmin.node.server', [ }, is_connected: function(node) { - return (node && node.connected); + return node?.connected; }, enable_reload_config: function(node) { // Must be connected & is Super user - return (node && node._type == 'server' && - node.connected && node.user.is_superuser); + return (node?._type == 'server' && + node?.connected && node?.user?.is_superuser); }, is_applicable: function(node) { // Must be connected & super user & not in recovery mode - return (node && node._type == 'server' && - node.connected && node.user.is_superuser + return (node?._type == 'server' && + node?.connected && node?.user?.is_superuser && !(node.in_recovery??true)); }, wal_pause_enabled: function(node) { // Must be connected & is Super user & in Recovery mode - return (node && node._type == 'server' && - node.connected && node.user.is_superuser - && node.in_recovery && !(node.wal_pause??true)); + return (node?._type == 'server' && + node?.connected && node?.user?.is_superuser + && node?.in_recovery && !(node?.wal_pause??true)); }, wal_resume_enabled: function(node) { // Must be connected & is Super user & in Recovery mode - return (node && node._type == 'server' && - node.connected && node.user.is_superuser - && node.in_recovery && node.wal_pause); + return (node?._type == 'server' && + node?.connected && node?.user?.is_superuser + && node?.in_recovery && node?.wal_pause); }, callbacks: { /* Connect the server */ @@ -540,12 +540,12 @@ define('pgadmin.node.server', [ d = i && t.itemData(i), self = this; - while (d && d._type != 'server') { + while (d?._type != 'server') { i = t.parent(i); d = i && t.itemData(i); } - if (i && d && d._type == 'server') { + if (i && d?._type == 'server') { if (_.isUndefined(d.is_connecting) || !d.is_connecting) { d.is_connecting = true; @@ -682,7 +682,7 @@ define('pgadmin.node.server', [ } }, onSuccess = function(res, node, _data, _tree, _item, _wasConnected) { - if (res && res.data) { + if (res?.data) { if (typeof res.data.icon == 'string') { _tree.removeIcon(_item); _data.icon = res.data.icon; @@ -789,7 +789,7 @@ define('pgadmin.node.server', [ getApiInstance().get(url) .then(({data: res})=>{ tree.setInode(item); - if (res && res.data) { + if (res?.data) { if (typeof res.data.icon == 'string') { tree.removeIcon(item); data.icon = res.data.icon; diff --git a/web/pgadmin/browser/static/js/MainMenuFactory.js b/web/pgadmin/browser/static/js/MainMenuFactory.js index 2dcd7b753..0176ea941 100644 --- a/web/pgadmin/browser/static/js/MainMenuFactory.js +++ b/web/pgadmin/browser/static/js/MainMenuFactory.js @@ -86,7 +86,7 @@ export default class MainMenuFactory { // Some callbacks registered in 'callbacks' check and call specifiec callback function if (options.module && 'callbacks' in options.module && options.module.callbacks[options.callback]) { options.module.callbacks[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree?.selected()]); - } else if (options.module && options.module[options.callback]) { + } else if (options?.module[options.callback]) { options.module[options.callback].apply(options.module, [options.data, pgAdmin.Browser.tree?.selected()]); } else if (options?.callback) { options.callback(options); diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 9f6aa0057..847d1a045 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -557,7 +557,7 @@ define('pgadmin.browser', [ n = _o.b.Nodes[d._type]; // Are we looking at the collection node for the given node? if ( - n && n.collection_node && d.nodes && + n?.collection_node && d.nodes && _.indexOf(d.nodes, _d._type) != -1 ) { _o.i = i; @@ -583,7 +583,7 @@ define('pgadmin.browser', [ onLoad(); }, () => { - let fail = _o && _o.o && _o.o.fail; + let fail = _o?.o?.fail; if (fail && typeof(fail) == 'function') { fail.apply(_o.t, []); } @@ -654,9 +654,7 @@ define('pgadmin.browser', [ selectNode = function() { this.t.openPath(this.i); this.t.select(this.i); - if ( - _ctx.o && _ctx.o.success && typeof(_ctx.o.success) == 'function' - ) { + if (typeof(_ctx?.o?.success) == 'function') { _ctx.o.success.apply(_ctx.t, [_ctx.i, _data]); } }.bind(_ctx), @@ -744,18 +742,14 @@ define('pgadmin.browser', [ if (binarySearch()) { __ctx.t.before(i, _data).then((_item) => { - if ( - __ctx.o && __ctx.o.success && typeof(__ctx.o.success) == 'function' - ) { + if (typeof(__ctx?.o?.success) == 'function') { __ctx.o.success.apply(__ctx.t, [i, _data]); } else { __ctx.t.select(_item); } }, () => { console.warn('Failed to add before...', arguments); - if ( - __ctx.o && __ctx.o.fail && typeof(__ctx.o.fail) == 'function' - ) { + if (typeof(__ctx.o?.fail) == 'function') { __ctx.o.fail.apply(__ctx.t, [i, _data]); } }); @@ -787,19 +781,13 @@ define('pgadmin.browser', [ ); } } - if ( - ___ctx.o && ___ctx.o.success && - typeof(___ctx.o.success) == 'function' - ) { + if (typeof(___ctx?.o?.success) == 'function') { ___ctx.o.success.apply(___ctx.t, [_i, _data]); } }, () => { console.warn('Failed to append...', arguments); - if ( - ___ctx.o && ___ctx.o.fail && - typeof(___ctx.o.fail) == 'function' - ) { + if (typeof(___ctx?.o?.fail) == 'function') { ___ctx.o.fail.apply(___ctx.t, [___ctx.i, _data]); } } @@ -827,9 +815,7 @@ define('pgadmin.browser', [ selectNode, function() { let o = this && this.o; - if ( - o && o.fail && typeof(o.fail) == 'function' - ) { + if (typeof(o?.fail) == 'function') { o.fail.apply(this.t, [this.i, _data]); } }.bind(this) @@ -837,9 +823,7 @@ define('pgadmin.browser', [ }, () => { let o = this && this.o; - if ( - o && o.fail && typeof(o.fail) == 'function' - ) { + if (typeof(o?.fail) == 'function') { o.fail.apply(this.t, [this.i, _data]); } }); @@ -881,7 +865,7 @@ define('pgadmin.browser', [ op: null, }, errorOut = function() { - let fail = this.o && this.o.fail; + let fail = this.o?.fail; if (fail && typeof(fail) == 'function') { fail.apply(this.t, [this.i, _new, _old]); } @@ -981,7 +965,7 @@ define('pgadmin.browser', [ onLoad(); }, () => { - let fail = self && self.o && self.o.fail; + let fail = self?.o?.fail; if ( fail && typeof(fail) == 'function' ) { @@ -1110,7 +1094,7 @@ define('pgadmin.browser', [ self.t.select(self.i); } } - let success = this.o && this.o.success; + let success = this.o?.success; if (success && typeof(success) == 'function') { success.apply(this.t, [this.i, _old, _new]); } @@ -1241,16 +1225,12 @@ define('pgadmin.browser', [ __ctx.t.before(i, _new).then((new_item) => { __ctx.t.openPath(new_item); __ctx.t.select(new_item); - if ( - __ctx.o && __ctx.o.success && typeof(__ctx.o.success) == 'function' - ) { + if (typeof(__ctx?.o?.success) == 'function') { __ctx.o.success.apply(__ctx.t, [i, _old, _new]); } }, () => { console.warn('Failed to add before..', arguments); - if ( - __ctx.o && __ctx.o.fail && typeof(__ctx.o.fail) == 'function' - ) { + if (typeof(__ctx?.o?.fail) == 'function') { __ctx.o.fail.apply(__ctx.t, [i, _old, _new]); } }); @@ -1260,17 +1240,13 @@ define('pgadmin.browser', [ (new_item) => { __ctx.t.openPath(new_item); __ctx.t.select(new_item); - if ( - __ctx.o && __ctx.o.success && typeof(__ctx.o.success) == 'function' - ) { + if (typeof(__ctx?.o?.success) == 'function') { __ctx.o.success.apply(__ctx.t, [__ctx.i, _old, _new]); } }, () => { console.warn('Failed to append...', arguments); - if ( - __ctx.o && __ctx.o.fail && typeof(__ctx.o.fail) == 'function' - ) { + if (typeof(__ctx?.o?.fail) == 'function') { __ctx.o.fail.apply(__ctx.t, [__ctx.i, _old, _new]); } }, @@ -1298,9 +1274,7 @@ define('pgadmin.browser', [ selectNode, function() { let o = this && this.o; - if ( - o && o.fail && typeof(o.fail) == 'function' - ) { + if (typeof(o?.fail) == 'function') { o.fail.apply(this.t, [this.i, _old, _new]); } } @@ -1308,9 +1282,7 @@ define('pgadmin.browser', [ }, () => { let o = this && this.o; - if ( - o && o.fail && typeof(o.fail) == 'function' - ) { + if (typeof(o?.fail) == 'function') { o.fail.apply(this.t, [this.i, _old, _new]); } } @@ -1355,13 +1327,13 @@ define('pgadmin.browser', [ onRefreshTreeNodeReact: function(_i, _opts) { this.tree.refresh(_i).then(() =>{ - if (_opts && _opts.success) _opts.success(); + if (_opts?.success) _opts.success(); }); }, onRefreshTreeNode: function(_i, _opts) { let _d = _i && this.tree.itemData(_i), - n = _d && _d._type && this.Nodes[_d._type], + n = this.Nodes[_d?._type], ctx = { b: this, // Browser d: _d, // current parent @@ -1445,7 +1417,7 @@ define('pgadmin.browser', [ } } ctx.b._refreshNode(ctx, ctx.branch); - let success = (ctx.o && ctx.o.success) || ctx.success; + let success = (ctx?.o?.success) || ctx.success; if (success && typeof(success) == 'function') { success(); } @@ -1484,7 +1456,7 @@ define('pgadmin.browser', [ }); }.bind(this); - if (n && n.collection_node) { + if (n?.collection_node) { let p = ctx.i = this.tree.parent(_i), unloadNode = function() { this.tree.unload(_i, { @@ -1638,7 +1610,7 @@ define('pgadmin.browser', [ node, children = _node && tree_local.children(_node); - if (!children || !children.length) + if (!children?.length) return null; for(; idx < children.length; idx++) { diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index a9f87f6ac..db8d9d80a 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -273,14 +273,8 @@ define('pgadmin.browser.node', [ parentData.server.user.can_create_role) { return true; } else if ( - ( - parentData.server && ( - parentData.server.user.is_superuser || - parentData.server.user.can_create_db) - ) || - ( - parentData.schema && parentData.schema.can_create - ) + ( parentData.server?.user.is_superuser || parentData.server?.user.can_create_db) || + (parentData.schema?.can_create) ) { return true; } else { @@ -347,7 +341,7 @@ define('pgadmin.browser.node', [ **/ show_obj_properties: function(args, item) { let t = pgBrowser.tree, - nodeItem = (args && args.item) || item || t.selected(), + nodeItem = args?.item || item || t.selected(), nodeData = nodeItem ? t.itemData(nodeItem) : undefined, panelTitle = this.title(nodeData, args.action), treeNodeInfo = pgBrowser.tree.getTreeNodeHierarchy(nodeItem); @@ -770,7 +764,7 @@ define('pgadmin.browser.node', [ let tree = pgBrowser.tree, auto_expand = usePreferences.getState().getPreferences('browser', 'auto_expand_sole_children'); - if (auto_expand && auto_expand.value && tree.children(item).length == 1) { + if (auto_expand?.value && tree.children(item).length == 1) { // Automatically expand the child node, if a treeview node has only a single child. const first_child = tree.first(item); @@ -946,7 +940,7 @@ define('pgadmin.browser.node', [ let cached = this.cached = this.cached || {}, hash = url, min_priority = ( - node_info && node_info[level] && node_info[level].priority + node_info?.[level] && node_info?.[level].priority ) || 0; if (node_info) { diff --git a/web/pgadmin/dashboard/static/js/Dashboard.jsx b/web/pgadmin/dashboard/static/js/Dashboard.jsx index 64aa4031c..1f724ef60 100644 --- a/web/pgadmin/dashboard/static/js/Dashboard.jsx +++ b/web/pgadmin/dashboard/static/js/Dashboard.jsx @@ -691,24 +691,15 @@ function Dashboard({ current_user; let can_signal_backend = - treeNodeInfo.server && treeNodeInfo.server.user - ? treeNodeInfo.server.user.can_signal_backend - : false; + treeNodeInfo.server?.user ? treeNodeInfo.server?.user?.can_signal_backend : false; let maintenanceActiveSessions = dashData.filter((data) => data.state === 'active'&& maintenance_database === data.datname); - if ( - treeNodeInfo.server && - treeNodeInfo.server.user && - treeNodeInfo.server.user.is_superuser - ) { + if (treeNodeInfo.server?.user?.is_superuser) { is_super_user = true; } else { is_super_user = false; - current_user = - treeNodeInfo.server && treeNodeInfo.server.user - ? treeNodeInfo.server.user.name - : null; + current_user = treeNodeInfo.server?.user ? treeNodeInfo.server?.user?.name : null; } // With PG10, We have background process showing on dashboard diff --git a/web/pgadmin/dashboard/static/js/WelcomeDashboard.jsx b/web/pgadmin/dashboard/static/js/WelcomeDashboard.jsx index b371813ea..6c6bd9c4d 100644 --- a/web/pgadmin/dashboard/static/js/WelcomeDashboard.jsx +++ b/web/pgadmin/dashboard/static/js/WelcomeDashboard.jsx @@ -88,7 +88,7 @@ const useStyles = makeStyles((theme) => ({ function AddNewServer(pgBrowser) { - if (pgBrowser && pgBrowser.tree) { + if (pgBrowser?.tree) { let i = _.isUndefined(pgBrowser.tree.selected()) ? pgBrowser.tree.first(null, false) : pgBrowser.tree.selected(), diff --git a/web/pgadmin/misc/cloud/static/js/biganimal_schema.ui.js b/web/pgadmin/misc/cloud/static/js/biganimal_schema.ui.js index bbecb153d..f376de9c0 100644 --- a/web/pgadmin/misc/cloud/static/js/biganimal_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/biganimal_schema.ui.js @@ -319,14 +319,14 @@ class BigAnimalVolumeSchema extends BaseUISchema { } }, visible: (state) => { - return state.provider && state.provider.includes(CLOUD_PROVIDERS.AWS); + return state.provider?.includes(CLOUD_PROVIDERS.AWS); }, helpMessage: obj.volumeType == 'io2' ? gettext('Size (4-16,384 GiB)') : gettext('Size (1-16,384 GiB)') }, { id: 'volume_IOPS', label: gettext('IOPS'), type: 'text', mode: ['create'], visible: (state) => { - return state.provider && state.provider.includes(CLOUD_PROVIDERS.AWS); + return state.provider?.includes(CLOUD_PROVIDERS.AWS); }, deps: ['volume_type'], depChange: (state, source) => { obj.volumeType = state.volume_type; @@ -347,7 +347,7 @@ class BigAnimalVolumeSchema extends BaseUISchema { mode: ['create'], deps : ['volume_type'], visible: (state) => { - return state.provider && state.provider.includes(CLOUD_PROVIDERS.AWS) && state.volume_type === 'gp3'; + return state.provider?.includes(CLOUD_PROVIDERS.AWS) && state.volume_type === 'gp3'; } } ]; diff --git a/web/pgadmin/misc/cloud/static/js/google.js b/web/pgadmin/misc/cloud/static/js/google.js index 8ec8a0660..c594d7383 100644 --- a/web/pgadmin/misc/cloud/static/js/google.js +++ b/web/pgadmin/misc/cloud/static/js/google.js @@ -88,7 +88,7 @@ export function GoogleCredentials(props) { _eventBus.fireEvent('SET_CRED_VERIFICATION_INITIATED',false); clearInterval(interval); resolve(false); - } else if (child && child.closed || countdown <= 0) { + } else if (child?.closed || countdown <= 0) { _eventBus.fireEvent('SET_ERROR_MESSAGE_FOR_CLOUD_WIZARD',[MESSAGE_TYPE.ERROR, 'Authentication is aborted.']); _eventBus.fireEvent('SET_CRED_VERIFICATION_INITIATED',false); clearInterval(interval); diff --git a/web/pgadmin/misc/file_manager/static/js/components/FileManager.jsx b/web/pgadmin/misc/file_manager/static/js/components/FileManager.jsx index 1b0a338c1..f6d72d635 100644 --- a/web/pgadmin/misc/file_manager/static/js/components/FileManager.jsx +++ b/web/pgadmin/misc/file_manager/static/js/components/FileManager.jsx @@ -674,9 +674,7 @@ export default function FileManager({params, closeModal, onOK, onCancel, sharedS (params?.dialog_type != 'storage_dialog' && params?.path) && fmUtilsObj.setLastVisitedDir(params?.path, selectedSS); }; init(); - setTimeout(()=>{ - saveAsRef.current && saveAsRef.current.focus(); - }, 300); + setTimeout(()=>{ saveAsRef.current?.focus(); }, 300); return ()=>{ fmUtilsObj.destroy(); }; diff --git a/web/pgadmin/misc/properties/CollectionNodeProperties.jsx b/web/pgadmin/misc/properties/CollectionNodeProperties.jsx index 275067088..ed4260dfd 100644 --- a/web/pgadmin/misc/properties/CollectionNodeProperties.jsx +++ b/web/pgadmin/misc/properties/CollectionNodeProperties.jsx @@ -121,7 +121,7 @@ export default function CollectionNodeProperties({ msg = undefined, title = undefined; - if (selNode && selNode.type && selNode.type == 'coll-constraints') { + if (selNode?.type == 'coll-constraints') { // In order to identify the constraint type, the type should be passed to the server selRows = selRowModels.map((row) => ({ id: row.original.oid, diff --git a/web/pgadmin/misc/statistics/static/js/Statistics.jsx b/web/pgadmin/misc/statistics/static/js/Statistics.jsx index ea9d2ce7c..b4724fd64 100644 --- a/web/pgadmin/misc/statistics/static/js/Statistics.jsx +++ b/web/pgadmin/misc/statistics/static/js/Statistics.jsx @@ -123,7 +123,7 @@ function createSingleLineStatistics(data, prettifyFields) { for (let idx in columns) { name = columns[idx]['name']; - if (row && row[name]) { + if (row?.[name]) { value = _.indexOf(prettifyFields, name) != -1 ? toPrettySize(row[name]) diff --git a/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx b/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx index 121f39a3e..8133e5804 100644 --- a/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx +++ b/web/pgadmin/preferences/static/js/components/PreferencesComponent.jsx @@ -455,7 +455,7 @@ export default function PreferencesComponent({ ...props }) { case 'threshold': return 'threshold'; default: - if (console && console.warn) { + if (console?.warn) { // Warning for developer only. console.warn( 'Hmm.. We don\'t know how to render this type - \'\'' + type + '\' of control.' diff --git a/web/pgadmin/static/bundle/app.js b/web/pgadmin/static/bundle/app.js index 41b862817..af67f2e92 100644 --- a/web/pgadmin/static/bundle/app.js +++ b/web/pgadmin/static/bundle/app.js @@ -20,7 +20,7 @@ define('app', [ for (let key in obj) { let module = obj[key]; - if (module && module.init && typeof module.init == 'function') { + if (typeof module?.init == 'function') { try { module.init(); } @@ -28,7 +28,7 @@ define('app', [ console.warn(e.stack || e); } } - else if (module && module.Init && typeof module.Init == 'function') { + else if (typeof module?.Init == 'function') { try { module.Init(); } diff --git a/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx b/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx index 0599455eb..745bbe2f9 100644 --- a/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx +++ b/web/pgadmin/static/js/Dialogs/MasterPasswordContent.jsx @@ -49,7 +49,7 @@ export default function MasterPasswordContent({ closeModal, onResetPassowrd, onO useEffect(() => { setTimeout(() => { - firstEleRef.current && firstEleRef.current.focus(); + firstEleRef.current?.focus(); }, 350); }, [firstEleRef.current]); diff --git a/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx b/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx index e640cd05e..c57499d3f 100644 --- a/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx +++ b/web/pgadmin/static/js/Dialogs/NamedRestoreContent.jsx @@ -44,7 +44,7 @@ export default function NamedRestoreContent({closeModal, onOK, setHeight}) { useEffect(()=>{ setTimeout(()=>{ - firstEleRef.current && firstEleRef.current.focus(); + firstEleRef.current?.focus(); }, 275); }, []); diff --git a/web/pgadmin/static/js/Explain/Graphical.jsx b/web/pgadmin/static/js/Explain/Graphical.jsx index 114cbc78d..5f27440c2 100644 --- a/web/pgadmin/static/js/Explain/Graphical.jsx +++ b/web/pgadmin/static/js/Explain/Graphical.jsx @@ -300,7 +300,7 @@ PlanContent.propTypes = { function PlanSVG({planData, zoomFactor, fitZoomFactor, ...props}) { const theme = useTheme(); useEffect(()=>{ - fitZoomFactor && fitZoomFactor(planData.width); + fitZoomFactor?.(planData.width); }, [planData.width]); return ( diff --git a/web/pgadmin/static/js/Explain/index.jsx b/web/pgadmin/static/js/Explain/index.jsx index c72dec293..1c0d8dd44 100644 --- a/web/pgadmin/static/js/Explain/index.jsx +++ b/web/pgadmin/static/js/Explain/index.jsx @@ -505,7 +505,7 @@ export default function Explain({plans=[]}) { // indicatorColor="primary" variant="scrollable" scrollButtons="auto" - action={(ref)=>ref && ref.updateIndicator()} + action={(ref)=>ref?.updateIndicator()} > diff --git a/web/pgadmin/static/js/QuickSearch/online_help.js b/web/pgadmin/static/js/QuickSearch/online_help.js index 3fef3e739..62b767730 100644 --- a/web/pgadmin/static/js/QuickSearch/online_help.js +++ b/web/pgadmin/static/js/QuickSearch/online_help.js @@ -54,7 +54,7 @@ export function onlineHelpSearch(param, props) { let pooling = window.pooling; if(resultEl) { let searchResultsH2Tags = resultEl.getElementsByTagName('h2'); - let list = resultEl && resultEl.getElementsByTagName('LI'); + let list = resultEl?.getElementsByTagName('LI'); if ((list && list.length > 0 )) { let res = extractSearchResult(list); // After getting the data, we need to call the Parent component function diff --git a/web/pgadmin/static/js/SchemaView/DepListener.js b/web/pgadmin/static/js/SchemaView/DepListener.js index cc414cbff..4bebe0148 100644 --- a/web/pgadmin/static/js/SchemaView/DepListener.js +++ b/web/pgadmin/static/js/SchemaView/DepListener.js @@ -39,7 +39,7 @@ export default class DepListener { if(dataPath.length > 0) { data = _.get(state, dataPath); } - _.assign(data, listener.callback && listener.callback(data, listener.source, state, actionObj) || {}); + _.assign(data, listener.callback?.(data, listener.source, state, actionObj) || {}); return state; } @@ -50,7 +50,7 @@ export default class DepListener { if(dataPath.length > 0) { data = _.get(state, dataPath); } - return (listener.defCallback && listener.defCallback(data, listener.source, state, actionObj)); + return (listener.defCallback?.(data, listener.source, state, actionObj)); } /* Called when any field changed and trigger callbacks */ diff --git a/web/pgadmin/static/js/SchemaView/FormView.jsx b/web/pgadmin/static/js/SchemaView/FormView.jsx index 20a7ca762..f454f3c51 100644 --- a/web/pgadmin/static/js/SchemaView/FormView.jsx +++ b/web/pgadmin/static/js/SchemaView/FormView.jsx @@ -421,7 +421,7 @@ export default function FormView({ } useEffect(()=>{ - onTabChange && onTabChange(tabValue, Object.keys(tabs)[tabValue], sqlTabActive); + onTabChange?.(tabValue, Object.keys(tabs)[tabValue], sqlTabActive); }, [tabValue]); /* check whether form is kept hidden by visible prop */ @@ -441,7 +441,7 @@ export default function FormView({ }} variant="scrollable" scrollButtons="auto" - action={(ref)=>ref && ref.updateIndicator()} + action={(ref)=>ref?.updateIndicator()} > {Object.keys(finalTabs).map((tabName)=>{ return ; diff --git a/web/pgadmin/static/js/SchemaView/MappedControl.jsx b/web/pgadmin/static/js/SchemaView/MappedControl.jsx index 6028bffb2..bcb1eb2a5 100644 --- a/web/pgadmin/static/js/SchemaView/MappedControl.jsx +++ b/web/pgadmin/static/js/SchemaView/MappedControl.jsx @@ -28,15 +28,15 @@ function MappedFormControlBase({ type, value, id, onChange, className, visible, if(e?.target) { val = e.target.value; } - onChange && onChange(val); + onChange?.(val); }, []); const onSqlChange = useCallback((changedValue) => { - onChange && onChange(changedValue); + onChange?.(changedValue); }, []); const onTreeSelection = useCallback((selectedValues)=> { - onChange && onChange(selectedValues); + onChange?.(selectedValues); }, []); if (!visible) { @@ -128,7 +128,7 @@ function MappedCellControlBase({ cell, value, id, optionsLoaded, onCellChange, v val = e.target.value; } - onCellChange && onCellChange(val); + onCellChange?.(val); }, []); const onRadioChange = useCallback((e) => { @@ -136,11 +136,11 @@ function MappedCellControlBase({ cell, value, id, optionsLoaded, onCellChange, v if(e?.target) { val = e.target.checked; } - onCellChange && onCellChange(val); + onCellChange?.(val); }); const onSqlChange = useCallback((val) => { - onCellChange && onCellChange(val); + onCellChange?.(val); }, []); /* Some grid cells are based on options selected in other cells. @@ -148,8 +148,8 @@ function MappedCellControlBase({ cell, value, id, optionsLoaded, onCellChange, v */ const optionsLoadedRerender = useCallback((res) => { /* optionsLoaded is called when select options are fetched */ - optionsLoaded && optionsLoaded(res); - reRenderRow && reRenderRow(); + optionsLoaded?.(res); + reRenderRow?.(); }, []); if (!visible) { diff --git a/web/pgadmin/static/js/SchemaView/base_schema.ui.js b/web/pgadmin/static/js/SchemaView/base_schema.ui.js index bb960f3f3..c2985954c 100644 --- a/web/pgadmin/static/js/SchemaView/base_schema.ui.js +++ b/web/pgadmin/static/js/SchemaView/base_schema.ui.js @@ -158,7 +158,7 @@ export default class BaseUISchema { let res = []; if (state && this.isNew(state)) { options.forEach((option) => { - if(option && option.label == '') { + if(option?.label == '') { return; } res.push({ label: option.label, value: option.value }); diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx index e4ecf0229..19cee4271 100644 --- a/web/pgadmin/static/js/SchemaView/index.jsx +++ b/web/pgadmin/static/js/SchemaView/index.jsx @@ -538,7 +538,7 @@ function SchemaDialogView({ changedData = _.assign({}, schema.origData, changedData); } - props.onDataChange && props.onDataChange(isDataChanged, changedData); + props.onDataChange?.(isDataChanged, changedData); }, [sessData, formReady]); useEffect(()=>{ @@ -568,7 +568,7 @@ function SchemaDialogView({ let unmounted = false; /* Docker on load focusses itself, so our focus should execute later */ let focusTimeout = setTimeout(()=>{ - firstEleRef.current && firstEleRef.current.focus(); + firstEleRef.current?.focus(); }, 250); setLoaderText('Loading...'); @@ -577,7 +577,7 @@ function SchemaDialogView({ if(!getInitData && viewHelperProps.mode === 'edit') { throw new Error('getInitData must be passed for edit'); } - let initDataPromise = (getInitData && getInitData()) || Promise.resolve({}); + let initDataPromise = getInitData?.() || Promise.resolve({}); initDataPromise.then((data)=>{ if(unmounted) { return; @@ -628,7 +628,7 @@ function SchemaDialogView({ const onResetClick = ()=>{ const resetIt = ()=>{ - firstEleRef.current && firstEleRef.current.focus(); + firstEleRef.current?.focus(); setFormResetKey((prev)=>prev+1); sessDispatch({ type: SCHEMA_STATE_ACTIONS.INIT, diff --git a/web/pgadmin/static/js/UtilityView.jsx b/web/pgadmin/static/js/UtilityView.jsx index 18cd7d8ec..faf9dd85a 100644 --- a/web/pgadmin/static/js/UtilityView.jsx +++ b/web/pgadmin/static/js/UtilityView.jsx @@ -93,7 +93,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType }).then((res)=>{ /* Don't warn the user before closing dialog */ resolve(res.data); - onSave && onSave(res.data); + onSave?.(res.data); onClose(); }).catch((err)=>{ reject(err); diff --git a/web/pgadmin/static/js/chartjs/index.jsx b/web/pgadmin/static/js/chartjs/index.jsx index 60fb0c41e..f316aafbc 100644 --- a/web/pgadmin/static/js/chartjs/index.jsx +++ b/web/pgadmin/static/js/chartjs/index.jsx @@ -113,12 +113,12 @@ export default function BaseChart({type='line', id, options, data, redraw=false, plugins: [plugins], options: options, }); - props.onInit && props.onInit(chartObj.current); + props.onInit?.(chartObj.current); }; const destroyChart = function() { chartObj.current?.resetZoom?.(); - chartObj.current && chartObj.current.destroy(); + chartObj.current?.destroy(); }; useEffect(()=>{ @@ -137,7 +137,7 @@ export default function BaseChart({type='line', id, options, data, redraw=false, } chartObj.current.options = options; chartObj.current.update(props.updateOptions || {}); - props.onUpdate && props.onUpdate(chartObj.current); + props.onUpdate?.(chartObj.current); } }, [data, options]); diff --git a/web/pgadmin/static/js/components/CodeMirror.jsx b/web/pgadmin/static/js/components/CodeMirror.jsx index 097fb9495..a1e73ae6d 100644 --- a/web/pgadmin/static/js/components/CodeMirror.jsx +++ b/web/pgadmin/static/js/components/CodeMirror.jsx @@ -169,7 +169,7 @@ export function FindDialog({editor, show, replace, onClose, selFindVal}) { if(selText.length != 0) { setFindVal(selText); } - findInputRef.current && findInputRef.current.select(); + findInputRef.current?.select(); search(); } }, [show]); @@ -217,7 +217,7 @@ export function FindDialog({editor, show, replace, onClose, selFindVal}) { }; const onFindNext = ()=>{ - if(searchCursor.current && searchCursor.current.find()) { + if(searchCursor.current?.find()) { editor.setSelection(searchCursor.current.from(), searchCursor.current.to()); editor.scrollIntoView({ from: searchCursor.current.from(), @@ -227,7 +227,7 @@ export function FindDialog({editor, show, replace, onClose, selFindVal}) { }; const onFindPrev = ()=>{ - if(searchCursor.current && searchCursor.current.find(true)) { + if(searchCursor.current?.find(true)) { editor.setSelection(searchCursor.current.from(), searchCursor.current.to()); editor.scrollIntoView({ from: searchCursor.current.from(), @@ -441,7 +441,7 @@ export default function CodeMirror({currEditor, name, value, options, events, re } else { editor.current.setValue(''); } - currEditor && currEditor(editor.current); + currEditor?.(editor.current); if(editor.current) { try { cmWrapper.current = editor.current.getWrapperElement(); diff --git a/web/pgadmin/static/js/components/FormComponents.jsx b/web/pgadmin/static/js/components/FormComponents.jsx index 77d5dfdac..f8f97675a 100644 --- a/web/pgadmin/static/js/components/FormComponents.jsx +++ b/web/pgadmin/static/js/components/FormComponents.jsx @@ -198,7 +198,7 @@ export function InputSQL({ value, options, onChange, className, controlProps, in className={clsx(classes.sql, className)} events={{ change: (cm) => { - onChange && onChange(cm.getValue()); + onChange?.(cm.getValue()); }, }} {...controlProps} @@ -370,7 +370,7 @@ export const InputText = forwardRef(({ if (controlProps?.formatter) { changeVal = controlProps.formatter.toRaw(changeVal); } - onChange && onChange(changeVal); + onChange?.(changeVal); }; let finalValue = (_.isNull(value) || _.isUndefined(value)) ? '' : value; @@ -461,7 +461,7 @@ export function InputFileSelect({ controlProps, onChange, disabled, readonly, is btn_primary: controlProps.btnPrimary || '', }; showFileManager(params, (fileName)=>{ - onChange && onChange(decodeURI(fileName)); + onChange?.(decodeURI(fileName)); inpRef.current.focus(); }); }; @@ -909,7 +909,7 @@ export const InputSelect = forwardRef(({ .then((res) => { /* If component unmounted, dont update state */ if (!umounted) { - optionsLoaded && optionsLoaded(res, value); + optionsLoaded?.(res, value); /* Auto select if any option has key as selected */ const flatRes = flattenSelectOptions(res || []); let selectedVal; @@ -920,7 +920,7 @@ export const InputSelect = forwardRef(({ } if ((!_.isUndefined(selectedVal) && !_.isArray(selectedVal)) || (_.isArray(selectedVal) && selectedVal.length != 0)) { - onChange && onChange(selectedVal); + onChange?.(selectedVal); } setFinalOptions([res || [], false]); } @@ -930,7 +930,7 @@ export const InputSelect = forwardRef(({ /* Apply filter if any */ - const filteredOptions = (controlProps.filter && controlProps.filter(finalOptions)) || finalOptions; + const filteredOptions = (controlProps.filter?.(finalOptions)) || finalOptions; const flatFiltered = flattenSelectOptions(filteredOptions); let realValue = getRealValue(flatFiltered, value, controlProps.creatable, controlProps.formatter); if (realValue && _.isPlainObject(realValue) && _.isUndefined(realValue.value)) { @@ -956,9 +956,9 @@ export const InputSelect = forwardRef(({ } else { selectVal = selectVal.map((option) => option.value); } - onChange && onChange(selectVal); + onChange?.(selectVal); } else { - onChange && onChange(selectVal ? selectVal.value : null); + onChange?.(selectVal ? selectVal.value : null); } }, [onChange, filteredOptions]); diff --git a/web/pgadmin/static/js/components/SelectRefresh.jsx b/web/pgadmin/static/js/components/SelectRefresh.jsx index 429bb1766..766151e23 100644 --- a/web/pgadmin/static/js/components/SelectRefresh.jsx +++ b/web/pgadmin/static/js/components/SelectRefresh.jsx @@ -29,7 +29,7 @@ export function SelectRefresh({ required, className, label, helpMessage, testcid const {getOptionsOnRefresh, ...selectControlProps} = controlProps; const onRefreshClick = ()=>{ - getOptionsOnRefresh && getOptionsOnRefresh() + getOptionsOnRefresh?.() .then((res)=>{ setOptions(res); setOptionsReloadBasis((prevVal)=>!prevVal); diff --git a/web/pgadmin/static/js/helpers/ModalProvider.jsx b/web/pgadmin/static/js/helpers/ModalProvider.jsx index 660b4f2bf..751eca40a 100644 --- a/web/pgadmin/static/js/helpers/ModalProvider.jsx +++ b/web/pgadmin/static/js/helpers/ModalProvider.jsx @@ -68,7 +68,7 @@ function alert(title, text, onOkClick, okLabel = gettext('OK')) { // bind the modal provider before calling this.showModal(title, (closeModal) => { const onOkClickClose = () => { - onOkClick && onOkClick(); + onOkClick?.(); closeModal(); }; return ( @@ -81,11 +81,11 @@ function confirm(title, text, onOkClick, onCancelClick, okLabel = gettext('Yes') // bind the modal provider before calling this.showModal(title, (closeModal) => { const onCancelClickClose = () => { - onCancelClick && onCancelClick(); + onCancelClick?.(); closeModal(); }; const onOkClickClose = () => { - onOkClick && onOkClick(); + onOkClick?.(); closeModal(); }; return ( diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js index ca120981e..ffb9a516a 100644 --- a/web/pgadmin/static/js/keyboard_shortcuts.js +++ b/web/pgadmin/static/js/keyboard_shortcuts.js @@ -45,7 +45,7 @@ function isCtrlAltBoth(event) { /* Returns the key of shortcut */ function shortcut_key(shortcut) { let key = ''; - if(shortcut && shortcut['key'] && shortcut['key']['char']) { + if(shortcut?.['key'] && shortcut?.['key']['char']) { key = shortcut['key']['char'].toUpperCase(); } return key; diff --git a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js index 0c2601eb8..daa8bf945 100644 --- a/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js +++ b/web/pgadmin/static/js/tree/pgadmin_tree_save_state.js @@ -97,7 +97,7 @@ _.extend(pgBrowser.browserTreeState, { offRemoveFromTreeState?.(); offUpdateTreeState?.(); }; - + }, save_state: function() { @@ -198,8 +198,8 @@ _.extend(pgBrowser.browserTreeState, { if (treeHierarchy === null || !pgBrowser.tree.hasParent(item) || !(treeHierarchy.hasOwnProperty(self.parent))) return; - let topParent = treeHierarchy && treeHierarchy[self.parent]['_id'], - origParent = treeHierarchy && treeHierarchy[self.orig_parent]['id']; + let topParent = treeHierarchy?.[self.parent]['_id'], + origParent = treeHierarchy?.[self.orig_parent]['id']; this.update_database_status(item); @@ -308,7 +308,7 @@ _.extend(pgBrowser.browserTreeState, { if (treeHierarchy.hasOwnProperty('database')) { let databaseItem = treeHierarchy['database']['id'], - topParent = treeHierarchy && treeHierarchy[this.parent]['_id']; + topParent = treeHierarchy?.[this.parent]['_id']; if (topParent in this.current_state && 'selected' in this.current_state[topParent]) { if (treeHierarchy['database'].connected) { @@ -333,7 +333,7 @@ _.extend(pgBrowser.browserTreeState, { if (!(this.parent in treeHierarchy)) return; - let topParent = treeHierarchy && treeHierarchy[this.parent]['_id'], + let topParent = treeHierarchy?.[this.parent]['_id'], selectedItem = pgBrowser.tree.itemData(pgBrowser.tree.selected()), databaseItem = undefined; diff --git a/web/pgadmin/static/js/tree/tree.js b/web/pgadmin/static/js/tree/tree.js index f0d110ac8..d53660515 100644 --- a/web/pgadmin/static/js/tree/tree.js +++ b/web/pgadmin/static/js/tree/tree.js @@ -20,7 +20,7 @@ function manageTreeEvents(event, eventName, item) { let obj = pgAdmin.Browser; // Events for preferences tree. - if (node_metadata.parent && node_metadata.parent.includes('/preferences') && obj.ptree.tree.type == 'preferences') { + if (node_metadata.parent?.includes('/preferences') && obj.ptree.tree.type == 'preferences') { try { obj.Events.trigger( 'preferences:tree:' + eventName, event, item, d @@ -191,7 +191,7 @@ export class Tree { } async addIcon(item, icon) { - if (item !== undefined && item.getMetadata('data') !== undefined) { + if (item?.getMetadata('data') !== undefined) { item.getMetadata('data').icon = icon.icon; } await this.tree.addIcon(item, icon); @@ -231,7 +231,7 @@ export class Tree { } wasLoad(item) { - if (item && item.type === FileType.Directory) { + if (item?.type === FileType.Directory) { return item.isExpanded && item.children != null && item.children.length > 0; } return true; @@ -247,7 +247,7 @@ export class Tree { return model.root.children[0]; } - if (item !== undefined && item !== null && item.branchSize > 0) { + if (item?.branchSize > 0) { return item.children[0]; } @@ -301,7 +301,7 @@ export class Tree { } hasParent(item) { - return item && item.parent ? true : false; + return item?.parent ? true : false; } isOpen(item) { @@ -319,11 +319,11 @@ export class Tree { } itemData(item) { - return (item !== undefined && item !== null && item.getMetadata('data') !== undefined) ? item._metadata.data : []; + return (item?.getMetadata('data') !== undefined) ? item?._metadata.data : []; } getData(item) { - return (item !== undefined && item.getMetadata('data') !== undefined) ? item._metadata.data : []; + return (item?.getMetadata('data') !== undefined) ? item?._metadata.data : []; } isRootNode(item) { @@ -411,7 +411,7 @@ export class Tree { findNodeByDomElement(domElement) { const path = domElement.path; - if (!path || !path[0]) { + if (!path?.[0]) { return undefined; } @@ -433,7 +433,7 @@ export class Tree { createOrUpdateNode(id, data, parent, domNode) { let oldNodePath = id; - if (parent !== null && parent !== undefined && parent.path !== undefined && parent.path != '/browser') { + if (parent?.path != '/browser') { oldNodePath = parent.path + '/' + id; } const oldNode = this.findNode(oldNodePath); diff --git a/web/pgadmin/static/js/window.js b/web/pgadmin/static/js/window.js index 301ed998c..9cb04094c 100644 --- a/web/pgadmin/static/js/window.js +++ b/web/pgadmin/static/js/window.js @@ -8,18 +8,18 @@ ////////////////////////////////////////////////////////////// let getWindowOpener = (opener) => { - return opener.opener && opener.opener.pgAdmin ? getWindowOpener(opener.opener) : opener; + return opener.opener?.pgAdmin ? getWindowOpener(opener.opener) : opener; }; let pgWindow = function() { let localPgWindow = null; try { - if(window.opener && window.opener.pgAdmin) { + if(window.opener?.pgAdmin) { /* Windows can be opened at multiple levels */ localPgWindow = getWindowOpener(window.opener); - } else if(window.parent && window.parent.pgAdmin){ + } else if(window.parent?.pgAdmin){ localPgWindow = window.parent; - } else if(window.top && window.top.pgAdmin){ + } else if(window.top?.pgAdmin){ localPgWindow = window.top; } else { localPgWindow = window; diff --git a/web/pgadmin/static/vendor/require/require.js b/web/pgadmin/static/vendor/require/require.js index 07acbc3ac..9735b94be 100644 --- a/web/pgadmin/static/vendor/require/require.js +++ b/web/pgadmin/static/vendor/require/require.js @@ -1237,7 +1237,7 @@ var requirejs, require, define; return { node: node, - id: node && node.getAttribute('data-requiremodule') + id: node?.getAttribute('data-requiremodule') }; } diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index cbc379aa9..d55ccf092 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -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 = {} diff --git a/web/pgadmin/tools/debugger/static/js/DebuggerModule.js b/web/pgadmin/tools/debugger/static/js/DebuggerModule.js index 68b21acfb..7408477c0 100644 --- a/web/pgadmin/tools/debugger/static/js/DebuggerModule.js +++ b/web/pgadmin/tools/debugger/static/js/DebuggerModule.js @@ -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); diff --git a/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx b/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx index 8467031e4..10e532263 100644 --- a/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx +++ b/web/pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent.jsx @@ -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, diff --git a/web/pgadmin/tools/debugger/static/js/debugger_utils.js b/web/pgadmin/tools/debugger/static/js/debugger_utils.js index 5d24c641e..90ebd823a 100644 --- a/web/pgadmin/tools/debugger/static/js/debugger_utils.js +++ b/web/pgadmin/tools/debugger/static/js/debugger_utils.js @@ -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; } } diff --git a/web/pgadmin/tools/import_export/static/js/import_export.js b/web/pgadmin/tools/import_export/static/js/import_export.js index 32a01df45..a22acb307 100644 --- a/web/pgadmin/tools/import_export/static/js/import_export.js +++ b/web/pgadmin/tools/import_export/static/js/import_export.js @@ -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, diff --git a/web/pgadmin/tools/maintenance/static/js/maintenance.js b/web/pgadmin/tools/maintenance/static/js/maintenance.js index c9f13dbe9..244281321 100644 --- a/web/pgadmin/tools/maintenance/static/js/maintenance.js +++ b/web/pgadmin/tools/maintenance/static/js/maintenance.js @@ -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( diff --git a/web/pgadmin/tools/psql/static/js/psql_module.js b/web/pgadmin/tools/psql/static/js/psql_module.js index d613391d8..0086cb2a1 100644 --- a/web/pgadmin/tools/psql/static/js/psql_module.js +++ b/web/pgadmin/tools/psql/static/js/psql_module.js @@ -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=${''}`; diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/GeometryViewer.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/GeometryViewer.jsx index 43062b20b..ac9014275 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/GeometryViewer.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/GeometryViewer.jsx @@ -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 ( <> diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx index c6a221aca..e334fc4c3 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx @@ -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; diff --git a/web/regression/javascript/tree/tree_fake.js b/web/regression/javascript/tree/tree_fake.js index a071dbab8..df12743f9 100644 --- a/web/regression/javascript/tree/tree_fake.js +++ b/web/regression/javascript/tree/tree_fake.js @@ -99,7 +99,7 @@ export class TreeFake extends Tree { findNodeByDomElement(domElement) { const path = this.translateTreeNodeIdFromReactTree(domElement); - if(!path || !path[0]) { + if(!path?.[0]) { return undefined; }