Skip to content

Commit

Permalink
Merge pull request #13478 from torchiaf/13477-event-schema
Browse files Browse the repository at this point in the history
Add Event schema null checks
  • Loading branch information
torchiaf authored Feb 26, 2025
2 parents b3d7079 + 68e9820 commit 753469f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
28 changes: 15 additions & 13 deletions shell/components/form/ResourceTabs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,25 @@ export default {
const inStore = this.$store.getters['currentStore'](EVENT);
const eventSchema = this.$store.getters[`${ inStore }/schemaFor`](EVENT); // @TODO be smarter about which resources actually ever have events
const paginationHeaders = eventSchema ? [
STEVE_EVENT_LAST_SEEN,
STEVE_EVENT_TYPE,
REASON,
headerFromSchemaColString('Subobject', eventSchema, this.$store.getters, true),
headerFromSchemaColString('Source', eventSchema, this.$store.getters, true),
MESSAGE,
headerFromSchemaColString('First Seen', eventSchema, this.$store.getters, true),
headerFromSchemaColString('Count', eventSchema, this.$store.getters, true),
STEVE_NAME_COL,
] : [];
return {
eventSchema,
EVENT,
selectedTab: this.defaultTab,
selectedTab: this.defaultTab,
inStore,
showConditions: false,
paginationHeaders: [
STEVE_EVENT_LAST_SEEN,
STEVE_EVENT_TYPE,
REASON,
headerFromSchemaColString('Subobject', eventSchema, this.$store.getters, true),
headerFromSchemaColString('Source', eventSchema, this.$store.getters, true),
MESSAGE,
headerFromSchemaColString('First Seen', eventSchema, this.$store.getters, true),
headerFromSchemaColString('Count', eventSchema, this.$store.getters, true),
STEVE_NAME_COL,
]
showConditions: false,
paginationHeaders
};
},
Expand Down
5 changes: 3 additions & 2 deletions shell/pages/c/_cluster/explorer/EventsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
const schema = this.$store.getters['cluster/schemaFor'](EVENT);
const paginationHeaders = [
const paginationHeaders = schema ? [
reason,
STEVE_EVENT_OBJECT,
MESSAGE,
Expand All @@ -49,7 +49,7 @@ export default {
defaultSort: true,
},
headerFromSchemaColString('Count', schema, this.$store.getters, true),
];
] : [];
return {
schema,
Expand Down Expand Up @@ -88,6 +88,7 @@ export default {

<template>
<PaginatedResourceTable
v-if="!!schema"
:schema="schema"
:headers="eventHeaders"
:pagination-headers="paginationHeaders"
Expand Down
4 changes: 4 additions & 0 deletions shell/store/type-map.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export function createHeaders(
* Given a schema's attribute.column value create a header
*/
export function headerFromSchemaColString(colName: string, schema: Schema, rootGetters: VuexStoreGetters, pagination: boolean, ageColumn: TableColumn): TableColumn {
if (!schema) {
throw new Error(`Unable to create header for column '${ colName }' from schema: schema is missing`);
}

const col = schema.attributes.columns.find((c) => c.name === colName);

if (!col) {
Expand Down

0 comments on commit 753469f

Please sign in to comment.