Skip to content

Commit

Permalink
[UI] Fix runs ordering and pagination (#1812)
Browse files Browse the repository at this point in the history
Fixes: #1807
  • Loading branch information
un-def authored Oct 11, 2024
1 parent d17a84a commit 59a79cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion frontend/src/pages/Runs/AdministrationList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { orderBy as _orderBy } from 'lodash';

import { Button, FormField, Header, Pagination, SelectCSD, SpaceBetween, Table, Toggle } from 'components';

Expand Down Expand Up @@ -111,7 +112,7 @@ export const AdministrationList: React.FC = () => {

if (result.length > 0) {
setPagesCount((count) => count - 1);
setData(result);
setData(_orderBy(result, ['submitted_at'], ['desc']));
} else {
setPagesCount(1);
}
Expand Down
14 changes: 4 additions & 10 deletions frontend/src/pages/Runs/MainList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useMemo, useState } from 'react';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { sortBy as _sortBy } from 'lodash';
import { orderBy as _orderBy } from 'lodash';

import { Button, FormField, Header, Pagination, SelectCSD, SpaceBetween, Table, Toggle } from 'components';
import { useProjectDropdown } from 'layouts/AppLayout/hooks';
Expand Down Expand Up @@ -101,7 +101,7 @@ export const List: React.FC = () => {

if (result.length > 0) {
setPagesCount((count) => count - 1);
setData(result);
setData(_orderBy(result, ['submitted_at'], ['desc']));
} else {
setPagesCount(1);
}
Expand All @@ -121,13 +121,7 @@ export const List: React.FC = () => {
clearFilter,
});

const sortedData = useMemo(() => {
if (!data) return [];

return _sortBy(data, [(i) => -i.submitted_at]);
}, [data]);

const { items, actions, collectionProps } = useCollection(sortedData ?? [], {
const { items, actions, collectionProps } = useCollection(data ?? [], {
filtering: {
empty: renderEmptyMessage(),
noMatch: renderNoMatchMessage(),
Expand Down

0 comments on commit 59a79cd

Please sign in to comment.