change default sort on logs tables closes #1907

This commit is contained in:
miloschwartz
2025-12-03 18:20:28 -05:00
parent a61c82570a
commit 4b580105cd
5 changed files with 9 additions and 5 deletions

View File

@@ -129,7 +129,7 @@ export function queryRequest(data: Q) {
eq(requestAuditLog.resourceId, resources.resourceId) eq(requestAuditLog.resourceId, resources.resourceId)
) // TODO: Is this efficient? ) // TODO: Is this efficient?
.where(getWhere(data)) .where(getWhere(data))
.orderBy(desc(requestAuditLog.timestamp), desc(requestAuditLog.id)); .orderBy(desc(requestAuditLog.timestamp));
} }
export function countRequestQuery(data: Q) { export function countRequestQuery(data: Q) {

View File

@@ -640,7 +640,7 @@ export default function GeneralPage() {
}} }}
defaultSort={{ defaultSort={{
id: "timestamp", id: "timestamp",
desc: false desc: true
}} }}
// Server-side pagination props // Server-side pagination props
totalCount={totalCount} totalCount={totalCount}

View File

@@ -493,7 +493,7 @@ export default function GeneralPage() {
}} }}
defaultSort={{ defaultSort={{
id: "timestamp", id: "timestamp",
desc: false desc: true
}} }}
// Server-side pagination props // Server-side pagination props
totalCount={totalCount} totalCount={totalCount}

View File

@@ -778,7 +778,7 @@ export default function GeneralPage() {
}} }}
defaultSort={{ defaultSort={{
id: "timestamp", id: "timestamp",
desc: false desc: true
}} }}
// Server-side pagination props // Server-side pagination props
totalCount={totalCount} totalCount={totalCount}

View File

@@ -257,7 +257,10 @@ export function LogDataTable<TData, TValue>({
? {} ? {}
: { getPaginationRowModel: getPaginationRowModel() }), : { getPaginationRowModel: getPaginationRowModel() }),
onSortingChange: setSorting, onSortingChange: setSorting,
getSortedRowModel: getSortedRowModel(), // Disable client-side sorting for server-side pagination since data is already sorted on server
...(isServerPagination
? {}
: { getSortedRowModel: getSortedRowModel() }),
onColumnFiltersChange: setColumnFilters, onColumnFiltersChange: setColumnFilters,
getFilteredRowModel: getFilteredRowModel(), getFilteredRowModel: getFilteredRowModel(),
onGlobalFilterChange: setGlobalFilter, onGlobalFilterChange: setGlobalFilter,
@@ -269,6 +272,7 @@ export function LogDataTable<TData, TValue>({
} }
: {}), : {}),
initialState: { initialState: {
sorting: defaultSort ? [defaultSort] : [],
pagination: { pagination: {
pageSize: pageSize, pageSize: pageSize,
pageIndex: currentPage pageIndex: currentPage