Enhancement: Better handle some beszel errors (#4493)

This commit is contained in:
shamoon 2024-12-25 12:17:10 -08:00 committed by GitHub
parent cc9b4782f2
commit fd05ae377c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 8 deletions

View file

@ -20,8 +20,20 @@ export default function Component({ service }) {
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
}
if (systemsError) {
return <Container service={service} error={systemsError} />;
let system = null;
let finalError = systemsError;
if (systems && !systems.items) {
finalError = { message: "No items returned from beszel API" };
} else if (systems && systems.items && systemId) {
system = systems.items.find((item) => item.id === systemId);
if (!system) {
finalError = { message: `System with id ${systemId} not found` };
}
}
if (finalError) {
return <Container service={service} error={finalError} />;
}
if (!systems) {
@ -33,9 +45,7 @@ export default function Component({ service }) {
);
}
if (systemId) {
const system = systems.items.find((item) => item.id === systemId);
if (system) {
return (
<Container service={service}>
<Block label="beszel.name" value={system.name} />