[pve-devel] [PATCH v2 proxmox-widget-toolkit 13/13] FileBrowser: show errors in messagebox and allow expand 'all'
Stefan Reiter
s.reiter at proxmox.com
Thu Apr 22 17:34:57 CEST 2021
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 <s.reiter at proxmox.com>
---
new in v2
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.20.1
More information about the pve-devel
mailing list