mirror of https://github.com/portainer/portainer
fix(ui): parse slider value correctly [EE-6225] (#10484)
parent
99b39da03d
commit
95d96e1164
|
@ -11,7 +11,7 @@ class KubernetesResourceReservationHelper {
|
|||
(acc, container) => {
|
||||
if (container.Requests) {
|
||||
if (container.Requests.memory) {
|
||||
acc.Memory += filesizeParser(container.Requests.memory, { base: 10 });
|
||||
acc.Memory += safeFilesizeParser(container.Requests.memory, { base: 10 });
|
||||
}
|
||||
|
||||
if (container.Requests.cpu) {
|
||||
|
@ -36,11 +36,19 @@ class KubernetesResourceReservationHelper {
|
|||
}
|
||||
|
||||
static megaBytesValue(value) {
|
||||
return Math.floor(filesizeParser(value) / 1000 / 1000);
|
||||
return Math.floor(safeFilesizeParser(value) / 1000 / 1000);
|
||||
}
|
||||
|
||||
static bytesValue(mem) {
|
||||
return filesizeParser(mem) * 1000 * 1000;
|
||||
return safeFilesizeParser(mem) * 1000 * 1000;
|
||||
}
|
||||
}
|
||||
export default KubernetesResourceReservationHelper;
|
||||
|
||||
function safeFilesizeParser(value, options) {
|
||||
if (!value || Number.isNaN(value)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return filesizeParser(value, options);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,9 @@ export function SliderWithInput({
|
|||
min="0"
|
||||
max={max}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.valueAsNumber)}
|
||||
onChange={({ target: { valueAsNumber: value } }) =>
|
||||
onChange(Number.isNaN(value) ? 0 : value)
|
||||
}
|
||||
className="w-32"
|
||||
data-cy={`${dataCy}Input`}
|
||||
/>
|
||||
|
|
|
@ -62,7 +62,7 @@ export function ResourceQuotaFormSection({
|
|||
className={typeof errors === 'string' ? 'visible' : 'invisible'}
|
||||
>
|
||||
{/* 'error' keeps the formerror the exact same height while hidden so there is no layout shift */}
|
||||
{errors || 'error'}
|
||||
{typeof errors === 'string' ? errors : 'error'}
|
||||
</FormError>
|
||||
<FormControl
|
||||
className="flex flex-row"
|
||||
|
|
Loading…
Reference in New Issue