Code improvements to handle API errors gracefully in tree code. #6308

This commit is contained in:
Aditya Toshniwal
2023-05-23 14:37:16 +05:30
parent dd4639d602
commit 96f3ac8a53
2 changed files with 77 additions and 88 deletions

View File

@@ -543,6 +543,9 @@ export default function PreferencesComponent({ ...props }) {
method: 'PUT',
data: save_data,
}).then(() => {
let requiresTreeRefresh = save_data.some((s)=>{
return s.name=='show_system_objects'||s.name=='show_empty_coll_nodes'||s.name.startsWith('show_node_')||s.name=='hide_shared_server';
});
let requires_refresh = false;
/* Find the modules changed */
let modulesChanged = {};
@@ -559,25 +562,6 @@ export default function PreferencesComponent({ ...props }) {
requires_refresh = checkRefreshRequired(pref, requires_refresh);
if (pref.name == 'hide_shared_server') {
Notify.confirm(
gettext('Object explorer tree refresh required'),
gettext('The object explorer tree refresh is required. Do you wish to refresh the tree?'),
function () {
pgAdmin.Browser.tree.destroy({
success: function () {
pgAdmin.Browser.initializeBrowserTree(pgAdmin.Browser);
return true;
},
});
},
function () {
return true;
},
gettext('Refresh'),
gettext('Later')
);
}
// Sync the lock layout menu with preferences
if (pref.name == 'lock_layout') {
let fileMenu = pgAdmin.Browser.MainMenus.find((menu) => menu.name == 'file');
@@ -593,6 +577,26 @@ export default function PreferencesComponent({ ...props }) {
}
}
if (requiresTreeRefresh) {
Notify.confirm(
gettext('Object explorer tree refresh required'),
gettext('The object explorer tree refresh is required. Do you wish to refresh the tree?'),
function () {
pgAdmin.Browser.tree.destroy({
success: function () {
pgAdmin.Browser.initializeBrowserTree(pgAdmin.Browser);
return true;
},
});
},
function () {
return true;
},
gettext('Refresh'),
gettext('Later')
);
}
if (requires_refresh) {
Notify.confirm(
gettext('Refresh required'),