[pve-devel] [PATCH widget-toolkit 1/2] Utils: add calculate max button width hack

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Mar 25 09:47:20 CET 2022


On 24.03.22 12:33, Matthias Heiserer wrote:
> The same code is used once in widget toolkit and twice in PVE already,
> so it makes sense to add it as a separate function.
> 

FWIW, there'd be also the possibility of adding a new button class, derived
from proxmoxButton, that would be a bit more boilerplate but also avoid having a
rather specific helper in the general utils class and avoid coupling from property
existance/behavior over such "code distance". Maybe we could also move some more
common "AltButton" behavior in there though (did not checked too closely).
What do you think?

Also, it could be great to avoid the "text at call time is the initial text"
assumption in the width calculation, e.g.,

let otherText = btn.text === btn.defaultText ? btn.altText : btn.defaultText;

currently unnecessary, but would make it more robust and to easy to not do, IMO.





More information about the pve-devel mailing list