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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-15 10:37:43 +02:00
parent 9aa3d15708
commit 8812650c8b

View 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);