From ff18bedca7b75416a8dfdea6906eddd3ccceb316 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 29 Aug 2024 11:20:44 -0400 Subject: [PATCH] Fix column visibility toggles --- src/apps/dashboard/routes/activity.tsx | 33 +++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/apps/dashboard/routes/activity.tsx b/src/apps/dashboard/routes/activity.tsx index a827c88ebf..630cd4ba95 100644 --- a/src/apps/dashboard/routes/activity.tsx +++ b/src/apps/dashboard/routes/activity.tsx @@ -82,6 +82,19 @@ const Activity = () => { const isLoading = isUsersLoading || isLogEntriesLoading; + const userColumn: MRT_ColumnDef[] = useMemo(() => + (activityView === ActivityView.System) ? [] : [{ + id: 'User', + accessorFn: row => row.UserId && users[row.UserId]?.Name, + header: globalize.translate('LabelUser'), + size: 75, + Cell: UserCell, + enableResizing: false, + muiTableBodyCellProps: { + align: 'center' + } + }], [ activityView, users, UserCell ]); + const columns = useMemo[]>(() => [ { id: 'Date', @@ -100,18 +113,7 @@ const Activity = () => { align: 'center' } }, - { - id: 'User', - accessorFn: row => row.UserId && users[row.UserId]?.Name, - header: globalize.translate('LabelUser'), - size: 75, - Cell: UserCell, - enableResizing: false, - visibleInShowHideMenu: activityView !== ActivityView.System, - muiTableBodyCellProps: { - align: 'center' - } - }, + ...userColumn, { accessorKey: 'Name', header: globalize.translate('LabelName'), @@ -140,7 +142,7 @@ const Activity = () => { enableResizing: false, enableSorting: false } - ], [ UserCell, activityView, users ]); + ], [ userColumn ]); const onViewChange = useCallback((_e: React.MouseEvent, newView: ActivityView | null) => { if (newView !== null) { @@ -183,10 +185,7 @@ const Activity = () => { }, state: { isLoading, - pagination, - columnVisibility: { - User: activityView !== ActivityView.System - } + pagination }, // Server pagination