From 6f9f9c71b384c6840659a08a5f0d2aa1a53640ae Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Thu, 22 Apr 2021 17:34:57 +0200 Subject: [PATCH] FileBrowser: show errors in messagebox and allow expand 'all' If an error is received upon expanding a node, chances are the rest of the tree is still valid (i.e. opening a partition fails because it doesn't contain a supported filesystem). Only show an error box for the user, but don't mask the component in that case. Additionally, disable the download button. Also support an archive set to 'all' to expand all children, useful for initializing a file-restore VM on initial load. Signed-off-by: Stefan Reiter --- src/window/FileBrowser.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index d138d1b..99a7a85 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -123,6 +123,16 @@ Ext.define("Proxmox.window.FileBrowser", { me.lookup('downloadBtn').setDisabled(!canDownload); }, + errorHandler: function(error, msg) { + let me = this; + me.lookup('downloadBtn').setDisabled(true); + if (me.initialLoadDone) { + Ext.Msg.alert(gettext('Error'), msg); + return true; + } + return false; + }, + init: function(view) { let me = this; let tree = me.lookup('tree'); @@ -134,13 +144,16 @@ Ext.define("Proxmox.window.FileBrowser", { let store = tree.getStore(); let proxy = store.getProxy(); - Proxmox.Utils.monStoreErrors(tree, store, true); + let errorCallback = (error, msg) => me.errorHandler(error, msg); + Proxmox.Utils.monStoreErrors(tree, store, true, errorCallback); proxy.setUrl(view.listURL); proxy.setExtraParams(view.extraParams); - store.load(() => { + store.load((rec, op, success) => { let root = store.getRoot(); root.expand(); // always expand invisible root node - if (view.archive) { + if (view.archive === 'all') { + root.expandChildren(false); + } else if (view.archive) { let child = root.findChild('text', view.archive); if (child) { child.expand(); @@ -152,6 +165,7 @@ Ext.define("Proxmox.window.FileBrowser", { } else if (root.childNodes.length === 1) { root.firstChild.expand(); } + me.initialLoadDone = success; }); }, -- 2.39.2