]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
file browser: only disable button if not downloadable and add hint in tooltip
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 15 May 2022 08:37:43 +0000 (10:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 15 May 2022 08:37:44 +0000 (10:37 +0200)
To avoid to much layout jumping if the whole button disappears
(changes height of footer bar too), rather explain to the user the
why and what they can do instead.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/window/FileBrowser.js

index e21e2005d935907dcfe080752b71615cac1f2add..495538b6834dc0034602352920731e7fc6c7f35a 100644 (file)
@@ -130,7 +130,16 @@ Ext.define("Proxmox.window.FileBrowser", {
 
            let downloadBtn = view.lookup('downloadBtn');
            downloadBtn.setDisabled(!canDownload || enableMenu);
-           downloadBtn.setHidden(!canDownload || enableMenu);
+           downloadBtn.setHidden(canDownload && enableMenu);
+           let typeLabel = Proxmox.Schema.pxarFileTypes[data.type]?.label ?? Proxmox.Utils.unknownText;
+           let ttip = Ext.String.format(
+               gettext('File of type {0} cannot be downloaded directly, download a parent directory instead.'),
+               typeLabel,
+           );
+           if (!canDownload) { // ensure tooltip gets shown
+               downloadBtn.setStyle({ pointerEvents: 'all' });
+           }
+           downloadBtn.setTooltip(canDownload ? null : ttip);
 
            let menuBtn = view.lookup('menuBtn');
            menuBtn.setDisabled(!canDownload || !enableMenu);