all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH widget-toolkit v1 1/3] fix #4001: FileBrowser: add menu to button and selected entry label
Date: Thu,  5 May 2022 15:52:48 +0200	[thread overview]
Message-ID: <20220505135252.466838-2-s.sterz@proxmox.com> (raw)
In-Reply-To: <20220505135252.466838-1-s.sterz@proxmox.com>

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 <s.sterz@proxmox.com>
---
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





  reply	other threads:[~2022-05-05 13:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 13:52 [pbs-devel] [PATCH proxmox-backup v1] fixes #4001: file explorer/download UX improvements Stefan Sterz
2022-05-05 13:52 ` Stefan Sterz [this message]
2022-05-05 13:52 ` [pbs-devel] [PATCH widget-toolkit v1 2/3] fix #4001: FileBrowser: show number of items in a directory as size Stefan Sterz
2022-05-05 13:52 ` [pbs-devel] [PATCH widget-toolkit v1 3/3] fix #4001: FileBrowser: add a configurable prefix to downloaded files Stefan Sterz
2022-05-05 13:52 ` [pbs-devel] [PATCH proxmox-backup v1 1/2] fix #4001: datastore/catalog: add number of files to directory entry Stefan Sterz
2022-05-12 15:27   ` Thomas Lamprecht
2022-05-13  7:18     ` Stefan Sterz
2022-05-05 13:52 ` [pbs-devel] [PATCH proxmox-backup v1 2/2] fix #4001: ui: add prefix to files downloaded through the pxar browser Stefan Sterz
2022-05-16 13:31 ` [pbs-devel] applied-series: [PATCH proxmox-backup v1] fixes #4001: file explorer/download UX improvements Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220505135252.466838-2-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal