feat(activity-log): set descending timestamps as the default sorting order BE-11343 (#66)

pull/12292/merge
andres-portainer 2024-10-31 18:07:26 -03:00 committed by GitHub
parent 2f3d4a5511
commit 1061601714
2 changed files with 4 additions and 3 deletions

View File

@ -33,7 +33,8 @@ export function useTableStateWithStorage<T extends BasicTableSettings>(
} }
export function useTableStateWithoutStorage( export function useTableStateWithoutStorage(
defaultSortKey?: string defaultSortKey?: string,
defaultSortDesc: boolean = false
): BasicTableSettings & { ): BasicTableSettings & {
setSearch: (search: string) => void; setSearch: (search: string) => void;
search: string; search: string;
@ -41,7 +42,7 @@ export function useTableStateWithoutStorage(
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const [pageSize, setPageSize] = useState(10); const [pageSize, setPageSize] = useState(10);
const [sortBy, setSortBy] = useState( const [sortBy, setSortBy] = useState(
defaultSortKey ? { id: defaultSortKey, desc: false } : undefined defaultSortKey ? { id: defaultSortKey, desc: defaultSortDesc } : undefined
); );
return { return {

View File

@ -17,7 +17,7 @@ export function ActivityLogsView() {
{ start: Date; end: Date | null } | undefined { start: Date; end: Date | null } | undefined
>(undefined); >(undefined);
const [page, setPage] = useState(0); const [page, setPage] = useState(0);
const tableState = useTableStateWithoutStorage('Timestamp'); const tableState = useTableStateWithoutStorage('Timestamp', true);
const offset = page * tableState.pageSize; const offset = page * tableState.pageSize;
const query = { const query = {