Skip to content

Commit

Permalink
Move About pgAdmin 4 menu option to top of application menu for macOS.#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Bhati committed Sep 30, 2024
1 parent 28eb2c0 commit 51d86ff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions runtime/src/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ function buildMenu(pgadminMenus, pgAdminMainScreen, callbacks) {
});

let menuFile = pgadminMenus.shift();

if (isMac) {
// Add About pgAdmin 4 on top of menu.
const aboutIndex = menuFile.submenu.findIndex((item) => item.label === 'About pgAdmin 4');
if (aboutIndex !== -1) {
menuFile.submenu.splice(0, 0, menuFile.submenu.splice(aboutIndex, 1)[0]);
menuFile.submenu.splice(1, 0, { type: 'separator' });
}
// Remove About pgAdmin 4 from help menu.
const helpMenuIndex = pgadminMenus.findIndex((menu) => menu.label === 'Help');
if (helpMenuIndex !== -1) {
const helpMenu = pgadminMenus[helpMenuIndex];
const aboutIndexInHelpMenu = helpMenu.submenu.findIndex((item) => item.label === 'About pgAdmin 4');
if (aboutIndexInHelpMenu !== -1) {
helpMenu.submenu.splice(aboutIndexInHelpMenu, 1);
}
}
}

template.push({
...menuFile,
submenu: [
Expand Down
12 changes: 12 additions & 0 deletions web/pgadmin/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import traceback
import json
import config


from flask import Response, request, render_template, url_for, current_app
from flask_babel import gettext
Expand All @@ -30,6 +32,8 @@

class SettingsModule(PgAdminModule):
def get_own_menuitems(self):
appname = config.APP_NAME

return {
'file_items': [
MenuItem(
Expand All @@ -38,6 +42,14 @@ def get_own_menuitems(self):
module="pgAdmin.Settings",
callback='show',
label=gettext('Reset Layout')
),
MenuItem(
name='mnu_about',
priority=999,
module="pgAdmin.About",
callback='about_show',
icon='fa fa-info-circle',
label=gettext('About %(appname)s', appname=appname)
)
]
}
Expand Down

0 comments on commit 51d86ff

Please sign in to comment.