From b343ef337d6b5f5f9e98217e782789127a5f8dd1 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Thu, 30 Nov 2023 05:54:45 +0100 Subject: [PATCH] made StatusRenderer less strict to allow usage of custom states (#6008) --- src/frontend/src/components/render/StatusRenderer.tsx | 2 +- src/frontend/src/states/ApiState.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/components/render/StatusRenderer.tsx b/src/frontend/src/components/render/StatusRenderer.tsx index 73c9a527a237..4b2ff2482742 100644 --- a/src/frontend/src/components/render/StatusRenderer.tsx +++ b/src/frontend/src/components/render/StatusRenderer.tsx @@ -69,7 +69,7 @@ export const StatusRenderer = ({ options }: { status: string; - type: ModelType; + type: ModelType | string; options?: renderStatusLabelOptionsInterface; }) => { const statusCodeList = useServerApiState.getState().status; diff --git a/src/frontend/src/states/ApiState.tsx b/src/frontend/src/states/ApiState.tsx index 6713f9e23db7..a5020965a086 100644 --- a/src/frontend/src/states/ApiState.tsx +++ b/src/frontend/src/states/ApiState.tsx @@ -9,7 +9,7 @@ import { ApiPaths } from '../enums/ApiEndpoints'; import { ModelType } from '../enums/ModelType'; import { ServerAPIProps } from './states'; -type StatusLookup = Record; +type StatusLookup = Record; interface ServerApiStateProps { server: ServerAPIProps; @@ -35,7 +35,8 @@ export const useServerApiState = create()( await api.get(apiUrl(ApiPaths.global_status)).then((response) => { const newStatusLookup: StatusLookup = {} as StatusLookup; for (const key in response.data) { - newStatusLookup[statusCodeList[key]] = response.data[key].values; + newStatusLookup[statusCodeList[key] || key] = + response.data[key].values; } set({ status: newStatusLookup }); });