From 947c80d5341d4cce64cf3716e01127374d279b07 Mon Sep 17 00:00:00 2001 From: fedepini Date: Thu, 9 Jul 2026 17:37:47 +0200 Subject: [PATCH] fix: remove enum constraint on event_type in EventList to allow non-standard Kubernetes event types Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 4 ++ .../widgets/EventList/EventList.example.yaml | 42 ++++++++++++++ .../widgets/EventList/EventList.menu.yaml | 35 ++++++++++-- src/widgets/Button/Button.type.d.ts | 56 +++++++++++++++++++ src/widgets/EventList/EventList.schema.json | 3 +- src/widgets/EventList/EventList.tsx | 7 ++- src/widgets/Form/Form.type.d.ts | 56 +++++++++++++++++++ src/widgets/Panel/Panel.type.d.ts | 56 +++++++++++++++++++ src/widgets/Table/Table.type.d.ts | 56 +++++++++++++++++++ 9 files changed, 308 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0183d17..3c98097 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Previous changes not listed in this document can be traced using Git history. - Added persistence of active tab in `TabList` - Added `externalNavigate` and `refresh` actions +### Fixed + +- Removed `enum` constraint on `event_type` in `EventList` to allow non-standard Kubernetes event types (e.g. `Error`) + ## [1.0.26] - 2026-06-16 ### Added diff --git a/src/examples/widgets/EventList/EventList.example.yaml b/src/examples/widgets/EventList/EventList.example.yaml index f199ef2..f95f550 100644 --- a/src/examples/widgets/EventList/EventList.example.yaml +++ b/src/examples/widgets/EventList/EventList.example.yaml @@ -89,6 +89,48 @@ spec: - resource_name type: string --- +# Mixed event types including non-standard type +# Expected behavior: Displays three events with different event_type values — Normal (blue), Warning (orange), and Error (grey). +# Verifies that unknown event types do not cause errors and fall back to the default grey color. +kind: EventList +apiVersion: widgets.templates.krateo.io/v1beta1 +metadata: + name: example-eventlist-mixed-types + namespace: krateo-system +spec: + widgetData: + events: + - global_uid: "mock-cluster-1:event-normal" + cluster_name: "mock-cluster-1" + namespace: "default" + resource_kind: "Pod" + resource_name: "nginx-pod" + event_type: "Normal" + reason: "Started" + message: "Started container nginx" + created_at: "2024-04-21T08:20:00Z" + raw: "" + - global_uid: "mock-cluster-1:event-warning" + cluster_name: "mock-cluster-1" + namespace: "default" + resource_kind: "Pod" + resource_name: "my-pod" + event_type: "Warning" + reason: "FailedScheduling" + message: "0/1 nodes are available: 1 Insufficient memory." + created_at: "2024-04-20T12:34:56Z" + raw: "" + - global_uid: "mock-cluster-1:event-error" + cluster_name: "mock-cluster-1" + namespace: "default" + resource_kind: "Deployment" + resource_name: "my-deployment" + event_type: "Error" + reason: "BackoffLimitExceeded" + message: "Job has reached the specified backoff limit" + created_at: "2024-04-22T09:15:00Z" + raw: "" +--- # Live updates via SSE # Expected behavior: The widget connects to the provided SSE endpoint and updates in real time as new events are received. # Use this configuration to test streaming behavior from a live backend. diff --git a/src/examples/widgets/EventList/EventList.menu.yaml b/src/examples/widgets/EventList/EventList.menu.yaml index 94fe332..5c1724b 100644 --- a/src/examples/widgets/EventList/EventList.menu.yaml +++ b/src/examples/widgets/EventList/EventList.menu.yaml @@ -49,6 +49,7 @@ spec: - resourceRefId: example-eventlist-empty-panel - resourceRefId: example-eventlist-basic-panel - resourceRefId: example-eventlist-with-prefix-panel + - resourceRefId: example-eventlist-mixed-types-panel - resourceRefId: example-eventlist-sse-panel resourcesRefs: items: @@ -57,19 +58,25 @@ spec: name: example-eventlist-empty-panel namespace: krateo-system resource: panels - verb: GET + verb: GET - id: example-eventlist-basic-panel apiVersion: widgets.templates.krateo.io/v1beta1 name: example-eventlist-basic-panel namespace: krateo-system resource: panels - verb: GET + verb: GET - id: example-eventlist-with-prefix-panel apiVersion: widgets.templates.krateo.io/v1beta1 name: example-eventlist-with-prefix-panel namespace: krateo-system resource: panels - verb: GET + verb: GET + - id: example-eventlist-mixed-types-panel + apiVersion: widgets.templates.krateo.io/v1beta1 + name: example-eventlist-mixed-types-panel + namespace: krateo-system + resource: panels + verb: GET - id: example-eventlist-sse-panel apiVersion: widgets.templates.krateo.io/v1beta1 name: example-eventlist-sse-panel @@ -146,6 +153,26 @@ spec: --- kind: Panel apiVersion: widgets.templates.krateo.io/v1beta1 +metadata: + name: example-eventlist-mixed-types-panel + namespace: krateo-system +spec: + widgetData: + actions: {} + title: 'Mixed event types (Normal, Warning, Error)' + items: + - resourceRefId: example-eventlist-mixed-types + resourcesRefs: + items: + - id: example-eventlist-mixed-types + apiVersion: widgets.templates.krateo.io/v1beta1 + name: example-eventlist-mixed-types + namespace: krateo-system + resource: eventlists + verb: GET +--- +kind: Panel +apiVersion: widgets.templates.krateo.io/v1beta1 metadata: name: example-eventlist-sse-panel namespace: krateo-system @@ -162,4 +189,4 @@ spec: name: example-eventlist-sse namespace: krateo-system resource: eventlists - verb: GET \ No newline at end of file + verb: GET \ No newline at end of file diff --git a/src/widgets/Button/Button.type.d.ts b/src/widgets/Button/Button.type.d.ts index eb4e727..474ed69 100644 --- a/src/widgets/Button/Button.type.d.ts +++ b/src/widgets/Button/Button.type.d.ts @@ -202,6 +202,62 @@ export interface Button { */ size?: 'default' | 'large' | 'fullscreen' | 'custom' }[] + /** + * actions to navigate to an external URL + */ + externalNavigate?: { + /** + * unique identifier for the action + */ + id: string + /** + * type of action to execute + */ + type: 'externalNavigate' + /** + * the external URL to navigate to; supports JQ expressions using ${ } syntax + */ + url: string + /** + * specifies where to open the URL (default: _blank) + */ + target?: '_blank' | '_self' | '_parent' | '_top' + /** + * whether user confirmation is required before navigating + */ + requireConfirmation?: boolean + loading?: { + display: boolean + } + }[] + /** + * actions to invalidate and reload cached data + */ + refresh?: { + /** + * unique identifier for the action + */ + id: string + /** + * type of action to execute + */ + type: 'refresh' + /** + * list of resourcesRefs item IDs whose widget queries should be invalidated; each ID must match an entry in resourcesRefs.items + */ + resourcesRefsIds?: string[] + /** + * list of widget kind names (e.g. Table, Panel) whose queries should be invalidated; all widgets of those kinds on the page are re-fetched + */ + widgetKinds?: string[] + /** + * whether user confirmation is required before refreshing + */ + requireConfirmation?: boolean + loading?: { + display: boolean + } + }[] } /** * the background color of the button diff --git a/src/widgets/EventList/EventList.schema.json b/src/widgets/EventList/EventList.schema.json index d13a84d..c45479b 100644 --- a/src/widgets/EventList/EventList.schema.json +++ b/src/widgets/EventList/EventList.schema.json @@ -59,8 +59,7 @@ }, "event_type": { "type": "string", - "enum": ["Normal", "Warning"], - "description": "type of the event, e.g., normal or warning" + "description": "type of the event, e.g., Normal, Warning, or Error" }, "reason": { "type": "string", diff --git a/src/widgets/EventList/EventList.tsx b/src/widgets/EventList/EventList.tsx index fdbd7a7..9a26d10 100644 --- a/src/widgets/EventList/EventList.tsx +++ b/src/widgets/EventList/EventList.tsx @@ -125,6 +125,11 @@ const EventList = ({ uid, widgetData }: WidgetProps) => { return } + const eventTypeColor: Record = { + Normal: 'blue', + Warning: 'orange', + } + return (
{filteredEventList.map( @@ -139,7 +144,7 @@ const EventList = ({ uid, widgetData }: WidgetProps) => { resource_name: name, }) => (