From: Thomas Lamprecht Date: Sun, 15 May 2022 08:37:43 +0000 (+0200) Subject: file browser: only disable button if not downloadable and add hint in tooltip X-Git-Url: https://git.proxmox.com/?p=proxmox-widget-toolkit.git;a=commitdiff_plain;h=8812650c8b87c89a9227f8eb89c58b73c9723896 file browser: only disable button if not downloadable and add hint in tooltip 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 --- diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index e21e200..495538b 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -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);