Ensure that the server list is alphabetically sorted in the Query Tool/PSQL workspace. #8636

pull/8658/head
Akshay Joshi 2025-04-15 16:12:49 +05:30
parent 55f36912f9
commit 934f17c65e
3 changed files with 10 additions and 2 deletions

View File

@ -41,4 +41,5 @@ Bug fixes
| `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.
| `Issue #8630 <https://github.com/pgadmin-org/pgadmin4/issues/8630>`_ - Fixed an issue where filtering on a view caused an error.
| `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.
| `Issue #8636 <https://github.com/pgadmin-org/pgadmin4/issues/8636>`_ - Ensure that the server list is alphabetically sorted in the Query Tool/PSQL workspace.
| `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.

View File

@ -14,6 +14,7 @@ import gettext from 'sources/gettext';
export default function withCheckPermission(options, callback) {
// Check if the user has permission to access the menu item
return ()=>{
options = options ?? {};
// if the permission are not provided then no restrictions.
if(!options.permission || (options.permission && current_user.permissions?.includes(options.permission))) {
callback();

View File

@ -33,7 +33,7 @@ import { getRandomInt } from '../../../../static/js/utils';
import { useWorkspace } from './WorkspaceProvider';
class AdHocConnectionSchema extends BaseUISchema {
constructor(connectExistingServer, initValues={}) {
constructor(connectExistingServer, pgAdmin, initValues={}) {
super({
sid: null,
did: null,
@ -58,6 +58,7 @@ class AdHocConnectionSchema extends BaseUISchema {
this.dbs = [];
this.api = getApiInstance();
this.connectExistingServer = connectExistingServer;
this.pgAdmin = pgAdmin;
this.paramSchema = new VariableSchema(getConnectionParameters, null, null, ['name', 'keyword', 'value']);
}
@ -84,12 +85,17 @@ class AdHocConnectionSchema extends BaseUISchema {
}
getServerList() {
let obj = this;
if(this.groupedServers?.length != 0) {
return Promise.resolve(this.groupedServers);
}
return new Promise((resolve, reject)=>{
this.api.get(url_for('sqleditor.get_new_connection_servers'))
.then(({data: respData})=>{
// Sort the server list
respData.data.result.server_list.Servers.sort(function (a, b) {
return obj.pgAdmin.natural_sort(a.label, b.label);
});
let groupedOptions = [];
_.forIn(respData.data.result.server_list, (v, k)=>{
if(v.length == 0) {
@ -499,7 +505,7 @@ export default function AdHocConnection({mode}) {
saveBtnName = gettext('Connect & Open PSQL');
}
let adHocConObj = useMemo(() => new AdHocConnectionSchema(connectExistingServer), []);
let adHocConObj = useMemo(() => new AdHocConnectionSchema(connectExistingServer, pgAdmin), []);
useEffect(()=>{
if(currentWorkspace == mode) adHocConObj.refreshServerList();