From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9BCC575DB5; Thu, 22 Apr 2021 17:35:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2DE9F1EBF7; Thu, 22 Apr 2021 17:35:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1F27F1EB33; Thu, 22 Apr 2021 17:35:05 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id ECBC546351; Thu, 22 Apr 2021 17:35:04 +0200 (CEST) From: Stefan Reiter To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Date: Thu, 22 Apr 2021 17:34:57 +0200 Message-Id: <20210422153457.12265-14-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210422153457.12265-1-s.reiter@proxmox.com> References: <20210422153457.12265-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 proxmox-widget-toolkit 13/13] FileBrowser: show errors in messagebox and allow expand 'all' X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2021 15:35:39 -0000 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 --- 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