diff --git a/hivemq-edge/src/frontend/src/modules/EventLog/components/table/EventLogTable.tsx b/hivemq-edge/src/frontend/src/modules/EventLog/components/table/EventLogTable.tsx index d299dccac5..b569c7a268 100644 --- a/hivemq-edge/src/frontend/src/modules/EventLog/components/table/EventLogTable.tsx +++ b/hivemq-edge/src/frontend/src/modules/EventLog/components/table/EventLogTable.tsx @@ -49,7 +49,7 @@ const EventLogTable: FC = ({ return data.items }, [data, globalSourceFilter, maxEvents]) - const columns = useMemo[]>(() => { + const allColumns = useMemo[]>(() => { return [ { accessorKey: 'identifier.identifier', @@ -119,6 +119,13 @@ const EventLogTable: FC = ({ ] }, [isLoading, onOpen, t]) + const displayColumns = useMemo(() => { + const [, createdColumn, severityColumn, idColumn, messageColumn] = allColumns + if (variant === 'full') return allColumns + if (isSingleSource) return [createdColumn, severityColumn, messageColumn] + else return [createdColumn, idColumn, severityColumn, messageColumn] + }, [allColumns, isSingleSource, variant]) + if (error) { return ( @@ -130,9 +137,6 @@ const EventLogTable: FC = ({ ) } - // TODO[NVL] Not the best approach; destructure within memo - const [, a, b, d, c] = columns - return ( <> {variant === 'full' && ( @@ -152,7 +156,7 @@ const EventLogTable: FC = ({ aria-label={t('eventLog.title')} data={safeData} - columns={variant === 'full' ? columns : isSingleSource ? [a, b, c] : [a, d, b, c]} + columns={displayColumns} enablePaginationGoTo={variant === 'full'} enablePaginationSizes={variant === 'full'} enableColumnFilters={variant === 'full'}