Fixed an issue where lock layout menu was not in sync with preferences. #5758

This commit is contained in:
Pravesh Sharma 2023-02-10 10:31:02 +05:30 committed by GitHub
parent 713ddb5f62
commit ff6f0825b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -565,6 +565,8 @@ def utils():
# This will be opposite of use_space option
editor_indent_with_tabs = False if editor_use_spaces else True
prefs = Preferences.module('browser')
current_ui_lock = prefs.preference('lock_layout').get()
# Try to fetch current libpq version from the driver
try:
from config import PG_DEFAULT_DRIVER
@ -627,7 +629,8 @@ def utils():
username=current_user.username,
auth_source=auth_source,
heartbeat_timeout=config.SERVER_HEARTBEAT_TIMEOUT,
password_length_min=config.PASSWORD_LENGTH_MIN
password_length_min=config.PASSWORD_LENGTH_MIN,
current_ui_lock=current_ui_lock
),
200, {'Content-Type': MIMETYPE_APP_JS})

View File

@ -20,7 +20,7 @@
{% endif %}label: "{{ item.label }}", applies: ["{{ key.lower() }}"],
priority: {{ item.priority }},
enable: "{{ item.enable }}",
{% if item.checked is defined %}checked: {% if item.checked %}true{% else %}false{% endif %},
{% if item.checked is defined %}checked: {% if (item.checked || item.name == 'mnu_lock_'+current_ui_lock) %}true{% else %}false{% endif %},
{% endif %}
{% if item.below is defined %}below: {% if item.below %}true{% else %}false{% endif %},
{% endif %}

View File

@ -574,6 +574,19 @@ export default function PreferencesComponent({ ...props }) {
gettext('Later')
);
}
// Sync the lock layout menu with preferences
if (pref.name == 'lock_layout') {
let fileMenu = pgAdmin.Browser.MainMenus.find((menu) => menu.name == 'file');
let layoutSubMenu = fileMenu['menuItems'].find(menu => menu.name == 'mnu_locklayout');
layoutSubMenu['menu_items'].forEach(item => {
if (item.name === 'mnu_lock_'+save_data[0]['value']) {
item.checked = true;
} else {
item.checked = false;
}
});
pgAdmin.Browser.Events.trigger('pgadmin:nw-refresh-menu-item', 'lock_layout');
}
}
if (requires_refresh) {