Skip to content

Commit 934f17c

Browse files
committed
Ensure that the server list is alphabetically sorted in the Query Tool/PSQL workspace. pgadmin-org#8636
1 parent 55f3691 commit 934f17c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

docs/en_US/release_notes_9_3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ Bug fixes
4141
| `Issue #8628 <https://github.com/pgadmin-org/pgadmin4/issues/8628>`_ - Change the shortcut for canceling a running query as it conflicts with the shortcut to open a new query tool.
4242
| `Issue #8630 <https://github.com/pgadmin-org/pgadmin4/issues/8630>`_ - Fixed an issue where filtering on a view caused an error.
4343
| `Issue #8632 <https://github.com/pgadmin-org/pgadmin4/issues/8632>`_ - Fixed an issue where the query tool went blank when converting history dates to the appropriate locale format.
44+
| `Issue #8636 <https://github.com/pgadmin-org/pgadmin4/issues/8636>`_ - Ensure that the server list is alphabetically sorted in the Query Tool/PSQL workspace.
4445
| `Issue #8651 <https://github.com/pgadmin-org/pgadmin4/issues/8651>`_ - Fixed an issue where the user management tab is not opening in the classic layout.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import gettext from 'sources/gettext';
1414
export default function withCheckPermission(options, callback) {
1515
// Check if the user has permission to access the menu item
1616
return ()=>{
17+
options = options ?? {};
1718
// if the permission are not provided then no restrictions.
1819
if(!options.permission || (options.permission && current_user.permissions?.includes(options.permission))) {
1920
callback();

web/pgadmin/misc/workspaces/static/js/AdHocConnection.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { getRandomInt } from '../../../../static/js/utils';
3333
import { useWorkspace } from './WorkspaceProvider';
3434

3535
class AdHocConnectionSchema extends BaseUISchema {
36-
constructor(connectExistingServer, initValues={}) {
36+
constructor(connectExistingServer, pgAdmin, initValues={}) {
3737
super({
3838
sid: null,
3939
did: null,
@@ -58,6 +58,7 @@ class AdHocConnectionSchema extends BaseUISchema {
5858
this.dbs = [];
5959
this.api = getApiInstance();
6060
this.connectExistingServer = connectExistingServer;
61+
this.pgAdmin = pgAdmin;
6162
this.paramSchema = new VariableSchema(getConnectionParameters, null, null, ['name', 'keyword', 'value']);
6263
}
6364

@@ -84,12 +85,17 @@ class AdHocConnectionSchema extends BaseUISchema {
8485
}
8586

8687
getServerList() {
88+
let obj = this;
8789
if(this.groupedServers?.length != 0) {
8890
return Promise.resolve(this.groupedServers);
8991
}
9092
return new Promise((resolve, reject)=>{
9193
this.api.get(url_for('sqleditor.get_new_connection_servers'))
9294
.then(({data: respData})=>{
95+
// Sort the server list
96+
respData.data.result.server_list.Servers.sort(function (a, b) {
97+
return obj.pgAdmin.natural_sort(a.label, b.label);
98+
});
9399
let groupedOptions = [];
94100
_.forIn(respData.data.result.server_list, (v, k)=>{
95101
if(v.length == 0) {
@@ -499,7 +505,7 @@ export default function AdHocConnection({mode}) {
499505
saveBtnName = gettext('Connect & Open PSQL');
500506
}
501507

502-
let adHocConObj = useMemo(() => new AdHocConnectionSchema(connectExistingServer), []);
508+
let adHocConObj = useMemo(() => new AdHocConnectionSchema(connectExistingServer, pgAdmin), []);
503509

504510
useEffect(()=>{
505511
if(currentWorkspace == mode) adHocConObj.refreshServerList();

0 commit comments

Comments
 (0)