Skip to content

Commit

Permalink
made StatusRenderer less strict to allow usage of custom states (#6008)
Browse files Browse the repository at this point in the history
  • Loading branch information
matmair authored Nov 30, 2023
1 parent 0cd66fd commit b343ef3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/frontend/src/components/render/StatusRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const StatusRenderer = ({
options
}: {
status: string;
type: ModelType;
type: ModelType | string;
options?: renderStatusLabelOptionsInterface;
}) => {
const statusCodeList = useServerApiState.getState().status;
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/src/states/ApiState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ApiPaths } from '../enums/ApiEndpoints';
import { ModelType } from '../enums/ModelType';
import { ServerAPIProps } from './states';

type StatusLookup = Record<ModelType, StatusCodeListInterface>;
type StatusLookup = Record<ModelType | string, StatusCodeListInterface>;

interface ServerApiStateProps {
server: ServerAPIProps;
Expand All @@ -35,7 +35,8 @@ export const useServerApiState = create<ServerApiStateProps>()(
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 });
});
Expand Down

0 comments on commit b343ef3

Please sign in to comment.