Rename "value" to "step" in resolution state

Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
Julius Volz 2024-08-28 14:59:17 +02:00
parent f195046b4d
commit d3b6b0f288
2 changed files with 9 additions and 9 deletions

View file

@ -27,7 +27,7 @@ const ResolutionInput: FC<ResolutionInputProps> = ({
const onChangeCustomResolutionInput = (resText: string): void => {
const newResolution = parsePrometheusDuration(resText);
if (resolution.type === "custom" && newResolution === resolution.value) {
if (resolution.type === "custom" && newResolution === resolution.step) {
// Nothing changed.
return;
}
@ -37,7 +37,7 @@ const ResolutionInput: FC<ResolutionInputProps> = ({
formatPrometheusDuration(getEffectiveResolution(resolution, range))
);
} else {
onChangeResolution({ type: "custom", value: newResolution });
onChangeResolution({ type: "custom", step: newResolution });
}
};
@ -77,7 +77,7 @@ const ResolutionInput: FC<ResolutionInputProps> = ({
resolution.type === "auto"
? resolution.density
: resolution.type === "fixed"
? resolution.value.toString()
? resolution.step.toString()
: "custom"
}
onChange={(_value, option) => {
@ -97,7 +97,7 @@ const ResolutionInput: FC<ResolutionInputProps> = ({
);
onChangeResolution({
type: "custom",
value: effectiveResolution,
step: effectiveResolution,
});
setCustomResolutionInput(
formatPrometheusDuration(effectiveResolution)
@ -109,7 +109,7 @@ const ResolutionInput: FC<ResolutionInputProps> = ({
if (!isNaN(value)) {
onChangeResolution({
type: "fixed",
value,
step: value,
});
} else {
throw new Error("Invalid resolution value");

View file

@ -15,11 +15,11 @@ export type GraphResolution =
}
| {
type: "fixed";
value: number; // Resolution step in milliseconds.
step: number; // Resolution step in milliseconds.
}
| {
type: "custom";
value: number; // Resolution step in milliseconds.
step: number; // Resolution step in milliseconds.
};
// From the UI settings, compute the effective resolution
@ -39,9 +39,9 @@ export const getEffectiveResolution = (
return Math.max(Math.floor(range / factor / 1000) * 1000, 1000);
}
case "fixed":
return resolution.value;
return resolution.step;
case "custom":
return resolution.value;
return resolution.step;
}
};