From 10616017142891c1138fb5cb7768bbb6bee3444d Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:07:26 -0300 Subject: [PATCH] feat(activity-log): set descending timestamps as the default sorting order BE-11343 (#66) --- app/react/components/datatables/useTableState.ts | 5 +++-- .../portainer/logs/ActivityLogsView/ActivityLogsView.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/react/components/datatables/useTableState.ts b/app/react/components/datatables/useTableState.ts index daa01e51e..bd4d3957e 100644 --- a/app/react/components/datatables/useTableState.ts +++ b/app/react/components/datatables/useTableState.ts @@ -33,7 +33,8 @@ export function useTableStateWithStorage( } export function useTableStateWithoutStorage( - defaultSortKey?: string + defaultSortKey?: string, + defaultSortDesc: boolean = false ): BasicTableSettings & { setSearch: (search: string) => void; search: string; @@ -41,7 +42,7 @@ export function useTableStateWithoutStorage( const [search, setSearch] = useState(''); const [pageSize, setPageSize] = useState(10); const [sortBy, setSortBy] = useState( - defaultSortKey ? { id: defaultSortKey, desc: false } : undefined + defaultSortKey ? { id: defaultSortKey, desc: defaultSortDesc } : undefined ); return { diff --git a/app/react/portainer/logs/ActivityLogsView/ActivityLogsView.tsx b/app/react/portainer/logs/ActivityLogsView/ActivityLogsView.tsx index cae9d0702..240f29701 100644 --- a/app/react/portainer/logs/ActivityLogsView/ActivityLogsView.tsx +++ b/app/react/portainer/logs/ActivityLogsView/ActivityLogsView.tsx @@ -17,7 +17,7 @@ export function ActivityLogsView() { { start: Date; end: Date | null } | undefined >(undefined); const [page, setPage] = useState(0); - const tableState = useTableStateWithoutStorage('Timestamp'); + const tableState = useTableStateWithoutStorage('Timestamp', true); const offset = page * tableState.pageSize; const query = {