Skip to content

Commit

Permalink
fix(28974): fix the magic code
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Jan 10, 2025
1 parent e9750cb commit 8894c66
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const EventLogTable: FC<EventLogTableProps> = ({
return data.items
}, [data, globalSourceFilter, maxEvents])

const columns = useMemo<ColumnDef<Event>[]>(() => {
const allColumns = useMemo<ColumnDef<Event>[]>(() => {
return [
{
accessorKey: 'identifier.identifier',
Expand Down Expand Up @@ -119,6 +119,13 @@ const EventLogTable: FC<EventLogTableProps> = ({
]
}, [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 (
<Box mt="20%" mx="20%" alignItems="center">
Expand All @@ -130,9 +137,6 @@ const EventLogTable: FC<EventLogTableProps> = ({
)
}

// TODO[NVL] Not the best approach; destructure within memo
const [, a, b, d, c] = columns

return (
<>
{variant === 'full' && (
Expand All @@ -152,7 +156,7 @@ const EventLogTable: FC<EventLogTableProps> = ({
<PaginatedTable<Event>
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'}
Expand Down

0 comments on commit 8894c66

Please sign in to comment.