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 AC03D702C9 for ; Thu, 5 May 2022 15:54:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6E9F52725 for ; Thu, 5 May 2022 15:54:00 +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 43B9926CB for ; Thu, 5 May 2022 15:53:58 +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 E692143197 for ; Thu, 5 May 2022 15:53:56 +0200 (CEST) From: Stefan Sterz To: pbs-devel@lists.proxmox.com Date: Thu, 5 May 2022 15:52:48 +0200 Message-Id: <20220505135252.466838-2-s.sterz@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220505135252.466838-1-s.sterz@proxmox.com> References: <20220505135252.466838-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH widget-toolkit v1 1/3] fix #4001: FileBrowser: add menu to button and selected entry label X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 13:54:30 -0000 this commit adds a label showing the currently selected entry in the file browser and merges the "Download .tar.zst" and "Download .zip" button into one menu button. Signed-off-by: Stefan Sterz --- note: i am not really a fan of decoding the filepath via `atob()` here, but that is how the data is sent from PBS. if you have suggestions on how to improve this, feedback is appreciated. src/window/FileBrowser.js | 59 +++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index f4a22b6..bb262bc 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -76,7 +76,9 @@ Ext.define("Proxmox.window.FileBrowser", { 'd': true, // directories }, - // set to true to show the tar download button + // enable tar download, this will add a menu to the + // "Download" button when the selection can be downloaded as + // .tar files enableTar: false, }, @@ -135,13 +137,19 @@ Ext.define("Proxmox.window.FileBrowser", { if (!selection || selection.length < 1) return; let data = selection[0].data; + let st = Ext.String.format(gettext('Selected "{0}"'), atob(data.filepath)); + view.lookup('selectText').setText(st); + let canDownload = view.downloadURL && view.downloadableFileTypes[data.type]; - let zipBtn = me.lookup('downloadBtn'); - let tarBtn = me.lookup('downloadTar'); - zipBtn.setDisabled(!canDownload); - tarBtn.setDisabled(!canDownload); - zipBtn.setText(data.type === 'd' ? gettext('Download .zip') : gettext('Download')); - tarBtn.setVisible(data.type === 'd' && view.enableTar); + let enableMenu = view.enableTar && data.type === 'd'; + + let downloadBtn = view.lookup('downloadBtn'); + downloadBtn.setDisabled(!canDownload || enableMenu); + downloadBtn.setHidden(!canDownload || enableMenu); + + let menuBtn = view.lookup('menuBtn'); + menuBtn.setDisabled(!canDownload || !enableMenu); + menuBtn.setHidden(!canDownload || !enableMenu); }, errorHandler: function(error, msg) { @@ -150,7 +158,7 @@ Ext.define("Proxmox.window.FileBrowser", { return false; } me.lookup('downloadBtn').setDisabled(true); - me.lookup('downloadTar').setDisabled(true); + me.lookup('menuBtn').setDisabled(true); if (me.initialLoadDone) { Ext.Msg.alert(gettext('Error'), msg); return true; @@ -300,19 +308,40 @@ Ext.define("Proxmox.window.FileBrowser", { }, ], - buttons: [ + fbar: [ { - text: gettext('Download .tar.zst'), - handler: 'downloadTar', - reference: 'downloadTar', - hidden: true, - disabled: true, + text: '', + xtype: 'label', + reference: 'selectText', }, { - text: gettext('Download .zip'), + text: gettext('Download'), + xtype: 'button', handler: 'downloadZip', reference: 'downloadBtn', disabled: true, + hidden: true, + }, + { + text: gettext('Download as'), + xtype: 'button', + reference: 'menuBtn', + menu: { + items: [ + { + iconCls: 'fa fa-fw fa-file-zip-o', + text: gettext('.zip'), + handler: 'downloadZip', + reference: 'downloadZip', + }, + { + iconCls: 'fa fa-fw fa-archive', + text: gettext('.tar.zst'), + handler: 'downloadTar', + reference: 'downloadTar', + }, + ], + }, }, ], }); -- 2.30.2