Skip to content

Commit 22b7ae6

Browse files
committed
1) Fixed an issue where loadingText message is not shown in SchemaView.
2) Fixed SonarQube Bugs and Code Smells.
1 parent 684818d commit 22b7ae6

File tree

29 files changed

+67
-82
lines changed

29 files changed

+67
-82
lines changed

web/pgadmin/browser/server_groups/servers/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,6 @@ def update(self, gid, sid):
777777
request.data
778778
)
779779

780-
old_server_name = ''
781-
if 'name' in data:
782-
old_server_name = server.name
783780
if 'db_res' in data:
784781
data['db_res'] = ','.join(data['db_res'])
785782

web/pgadmin/browser/server_groups/servers/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def migrate_saved_passwords(master_key, master_password):
425425
servers_with_pwd_in_os_secret)
426426
# Update driver manager with new passwords
427427
try:
428-
update_session_manager(saved_password_servers)
428+
update_session_manager(current_user.id, saved_password_servers)
429429
except Exception:
430430
current_app.logger.warning(
431431
'Error while updating session manger')
@@ -497,7 +497,7 @@ def delete_saved_passwords_from_os_secret_storage(servers):
497497

498498
if len(servers) > 0:
499499
for ser in servers:
500-
server, is_password_saved, is_tunnel_password_saved = ser
500+
server, _, _ = ser
501501
server_name = KEY_RING_USERNAME_FORMAT.format(server.name,
502502
server.id)
503503
server_password = keyring.get_password(
@@ -550,7 +550,7 @@ def update_session_manager(user_id=None, servers=None):
550550
return True
551551
except Exception:
552552
db.session.rollback()
553-
raise
553+
raise
554554

555555

556556
def get_replication_type(conn, sversion):

web/pgadmin/browser/static/js/MainMenuFactory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export default class MainMenuFactory {
187187
const mi = getNewMenuItem(i);
188188
if(!mi) return;
189189

190-
if(i.category??'common' != 'common') {
190+
if((i.category??'common') != 'common') {
191191
const cmi = getMenuCategory(i.category);
192192
if(cmi) {
193193
cmi.addMenuItems([...applySeparators(mi)]);

web/pgadmin/browser/static/js/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ define('pgadmin.browser', [
349349
const getFullPath = (currPath, currMenu)=>{
350350
if(currMenu.node) {
351351
return currPath.concat([currMenu.node]);
352-
} else if(currMenu.category??'common' != 'common') {
352+
} else if((currMenu.category??'common') != 'common') {
353353
const currCat = self.menu_categories[currMenu.category];
354354
if(currCat?.category) {
355355
return getFullPath(currPath.concat([currMenu.category]), currCat);

web/pgadmin/dashboard/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def logs(log_format=None, disp_format=None, sid=None, page=0):
551551
status, res = g.conn.execute_scalar(sql)
552552
if not status:
553553
return internal_server_error(errormsg=res)
554-
if not res or len(res) < 0:
554+
if not res or len(res) <= 0:
555555
return ajax_response(
556556
response={'logs_disabled': True},
557557
status=200
@@ -594,7 +594,7 @@ def logs(log_format=None, disp_format=None, sid=None, page=0):
594594
{"error_severity": _tmp_log['error_severity'],
595595
"timestamp": _tmp_log['timestamp'],
596596
"message": _tmp_log['message']})
597-
except Exception as e:
597+
except Exception:
598598
pass
599599

600600
# CSV format
@@ -605,12 +605,10 @@ def logs(log_format=None, disp_format=None, sid=None, page=0):
605605
final_cols.append({"error_severity": _tmp_log[11],
606606
"timestamp": _tmp_log[0],
607607
"message": _tmp_log[13]})
608-
except Exception as e:
608+
except Exception:
609609
pass
610610

611611
else:
612-
col1 = []
613-
col2 = []
614612
_pattern = re.compile(LOG_STATEMENTS)
615613
for f in final_res:
616614
tmp = re.search(LOG_STATEMENTS, f)

web/pgadmin/dashboard/static/js/Dashboard.jsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ function ActiveOnlyHeader({activeOnly, setActiveOnly}) {
272272
ActiveOnlyHeader.propTypes = {
273273
activeOnly: PropTypes.bool,
274274
setActiveOnly: PropTypes.func,
275-
refresh: PropTypes.bool,
276-
setRefresh: PropTypes.func,
277275
};
278276

279277
function Dashboard({
@@ -533,7 +531,7 @@ function Dashboard({
533531
maxSize: 35,
534532
minSize: 35,
535533
id: 'btn-terminate',
536-
cell: getTerminateCell(pgAdmin, sid, did, canTakeAction, setRefresh, ()=>setRefresh(!refresh)),
534+
cell: getTerminateCell(pgAdmin, sid, did, canTakeAction, ()=>setRefresh(!refresh)),
537535
},
538536
{
539537
header: () => null,
@@ -544,7 +542,7 @@ function Dashboard({
544542
maxSize: 35,
545543
minSize: 35,
546544
id: 'btn-cancel',
547-
cell: getCancelCell(pgAdmin, sid, did, canTakeAction, setRefresh, ()=>setRefresh(!refresh)),
545+
cell: getCancelCell(pgAdmin, sid, did, canTakeAction, ()=>setRefresh(!refresh)),
548546
},
549547
{
550548
header: () => null,
@@ -886,7 +884,7 @@ function Dashboard({
886884
type: 'GET',
887885
})
888886
.then((res) => {
889-
if (res.data && res.data['logs_disabled']) {
887+
if (res?.data?.['logs_disabled']) {
890888
setSsMsg(gettext('Please enable the logging to view the server logs or check the log file is in place or not.'));
891889
} else {
892890
setDashData(parseData(res.data));
@@ -938,7 +936,7 @@ function Dashboard({
938936
// we want to show 'idle in transaction', 'active', 'active in transaction', and future non-blank, non-"idle" status values
939937
return dashData[0]['activity']?.filter((r)=>(r.state && r.state != '' && r.state != 'idle'));
940938
}
941-
return dashData && dashData[0] && dashData[0]['activity'] || [];
939+
return dashData?.[0]?.['activity'] || [];
942940
}, [dashData, activeOnly, mainTabVal]);
943941

944942
const showDefaultContents = () => {
@@ -1089,7 +1087,7 @@ function Dashboard({
10891087
tableNoBorder={false}
10901088
customHeader={<ActiveOnlyHeader activeOnly={activeOnly} setActiveOnly={setActiveOnly} refresh={refresh} setRefresh={setRefresh}/>}
10911089
columns={activityColumns}
1092-
data={(dashData !== undefined && dashData[0] && filteredDashData) || []}
1090+
data={(dashData?.[0] && filteredDashData) || []}
10931091
schema={activeQSchemaObj}
10941092
></PgTable>
10951093
</SectionContainer>
@@ -1098,15 +1096,15 @@ function Dashboard({
10981096
caveTable={false}
10991097
tableNoBorder={false}
11001098
columns={databaseLocksColumns}
1101-
data={(dashData !== undefined && dashData[0] && dashData[0]['locks']) || []}
1099+
data={(dashData?.[0]?.['locks']) || []}
11021100
></PgTable>
11031101
</SectionContainer>
11041102
<SectionContainer title={gettext('Prepared Transactions')} style={{height: 'auto', minHeight: '200px', maxHeight:'400px', paddingBottom: '20px'}}>
11051103
<PgTable
11061104
caveTable={false}
11071105
tableNoBorder={false}
11081106
columns={databasePreparedColumns}
1109-
data={(dashData !== undefined && dashData[0] && dashData[0]['prepared']) || []}
1107+
data={(dashData?.[0]?.['prepared']) || []}
11101108
></PgTable>
11111109
</SectionContainer>
11121110
</Fragment>

web/pgadmin/misc/cloud/static/js/azure_schema.ui.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ class AzureCredSchema extends BaseUISchema {
122122
auth_code: ''
123123
});
124124
}).catch((err) => {
125-
// TODO:: Show error message.
126125
console.error(
127126
err instanceof Error ?
128127
err : Error(gettext('Something went wrong'))

web/pgadmin/misc/cloud/static/js/google_schema.ui.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class GoogleCredSchema extends BaseUISchema{
6868
obj.fieldOptions.verification_ack();
6969
}
7070
}).catch((err) => {
71-
// FIXME:: Show error message.
7271
console.error(
7372
err instanceof Error ?
7473
err : Error(gettext('Something went wrong'))
@@ -505,7 +504,7 @@ class GoogleClusterSchema extends BaseUISchema {
505504
}
506505

507506
validate(data, setErr) {
508-
if ( !isEmptyString(data.name) && (!/^(?=[a-z])[a-z0-9\-]*$/.test(data.name) || data.name.length > 97)) {
507+
if ( !isEmptyString(data.name) && (!/^(?=[a-z])[a-z0-9-]*$/.test(data.name) || data.name.length > 97)) {
509508
setErr('name',gettext('Name must only contain lowercase letters, numbers, and hyphens.Should start with a letter and must be 97 characters or less'));
510509
return true;
511510
}

web/pgadmin/misc/file_manager/static/js/FileManagerModule.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ export default class FileManagerModule {
111111
}
112112
}
113113

114-
show(params, onOK, onCancel, modalObj) {
114+
async show(params, onOK, onCancel, modalObj) {
115115
let {name: browser} = getBrowser();
116116
if(browser == 'Electron') {
117117
try {
118-
this.showNative(params, onOK, onCancel);
118+
await this.showNative(params, onOK, onCancel);
119119
} catch {
120120
// Fall back to internal
121121
this.showInternal(params, onOK, onCancel, modalObj);

web/pgadmin/misc/properties/ObjectNodeProperties.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { usePgAdmin } from '../../static/js/PgAdminProvider';
1818
import { LAYOUT_EVENTS, LayoutDockerContext } from '../../static/js/helpers/Layout';
1919
import usePreferences from '../../preferences/static/js/store';
2020
import PropTypes from 'prop-types';
21+
import _ from 'lodash';
2122

2223
export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeData, actionType, formType, onEdit, onSave, onClose,
2324
isActive, setIsStale, isStale}) {
@@ -44,7 +45,7 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
4445
let updatedData = ['table', 'partition'].includes(nodeType) && !_.isEmpty(nodeData.rows_cnt) ? {rows_cnt: nodeData.rows_cnt} : undefined;
4546

4647
const objToString = (obj) => (
47-
(obj && typeof obj === 'object') ? Object.keys(obj).sort().reduce(
48+
(obj && typeof obj === 'object') ? Object.keys(obj).sort((a, b)=>a.localeCompare(b)).reduce(
4849
(acc, key) => (acc + `${key}=` + objToString(obj[key])), ''
4950
) : String(obj)
5051
);

0 commit comments

Comments
 (0)