From 93db47901d347f1250c2737f2529d166ad2f24c8 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Tue, 28 Jan 2025 11:12:48 +0100 Subject: [PATCH] fix(ui): co-browser (assist) list sorting --- .../LiveSessionList/LiveSessionList.tsx | 2 +- .../SortOrderButton/SortOrderButton.tsx | 26 +++++++------------ frontend/app/mstore/searchStoreLive.ts | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx b/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx index 001777698..dd5d5a0a4 100644 --- a/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx +++ b/frontend/app/components/shared/LiveSessionList/LiveSessionList.tsx @@ -30,7 +30,7 @@ function LiveSessionList() { let timeoutId: any; const { filters } = filter; const hasUserFilter = filters.map((i: any) => i.key).includes(KEYS.USERID); - const sortOptions = [{ label: 'Start Time', value: 'timestamp' }].concat( + const sortOptions = [{ label: 'Start Time', value: 'timestamp' }, { label: 'Duration', value: 'duration' }].concat( metaList .map(({ key }: any) => ({ label: capitalize(key), diff --git a/frontend/app/components/shared/SortOrderButton/SortOrderButton.tsx b/frontend/app/components/shared/SortOrderButton/SortOrderButton.tsx index ce585fc0b..79c2b1144 100644 --- a/frontend/app/components/shared/SortOrderButton/SortOrderButton.tsx +++ b/frontend/app/components/shared/SortOrderButton/SortOrderButton.tsx @@ -6,28 +6,22 @@ interface Props { sortOrder: string; onChange?: (sortOrder: string) => void; } + export default React.memo(function SortOrderButton(props: Props) { const { sortOrder, onChange = () => null } = props; const isAscending = sortOrder === 'asc'; return (
- - }, - { label: 'Descending', value: 'Descending', icon: }, - ]} - defaultValue="Ascending" - onChange={(value) => { - if (value === 'Ascending') { - onChange('asc'); - } else if (value === 'Descending') { - onChange('desc'); - } - }} - /> + }, + { label: 'Descending', value: 'desc', icon: } + ]} + defaultValue={sortOrder} + onChange={onChange} + />
); }); diff --git a/frontend/app/mstore/searchStoreLive.ts b/frontend/app/mstore/searchStoreLive.ts index ac042de14..c02e6eef4 100644 --- a/frontend/app/mstore/searchStoreLive.ts +++ b/frontend/app/mstore/searchStoreLive.ts @@ -49,7 +49,7 @@ class SearchStoreLive { latestRequestTime: number | null = null; latestList = List(); alertMetricId: number | null = null; - instance = new Search(); + instance = new Search({ sort: 'timestamp', order: 'desc' }); instanceLive = new Search(); savedSearch = new Search(); filterSearchList: any = {};