From 094359cc5bc86e7826d4f8c964f7459fa071b6dd Mon Sep 17 00:00:00 2001 From: Moriah Kreeger Date: Wed, 4 Nov 2020 11:02:33 -0800 Subject: [PATCH] fix: add sort option to filters, sort chart list filter options (#11370) --- .../src/components/ListView/Filters.tsx | 1 + .../src/views/CRUD/chart/ChartList.tsx | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/components/ListView/Filters.tsx b/superset-frontend/src/components/ListView/Filters.tsx index 9f1ad78378..3d610f2e11 100644 --- a/superset-frontend/src/components/ListView/Filters.tsx +++ b/superset-frontend/src/components/ListView/Filters.tsx @@ -119,6 +119,7 @@ function SelectFilter({ setSelectedOption(matchingOption); } } + return { options: result, hasMore, diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index ed9953abb1..8f42b035e3 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -61,7 +61,8 @@ const createFetchDatasets = (handleError: (err: Response) => void) => async ( const queryParams = rison.encode({ columns: ['datasource_name', 'datasource_id'], keys: ['none'], - order_by: 'datasource_name', + order_column: 'table_name', + order_direction: 'asc', ...(pageIndex ? { page: pageIndex } : {}), ...(pageSize ? { page_size: pageSize } : {}), ...filters, @@ -191,6 +192,7 @@ function ChartList(props: ChartListProps) { }: any) => {dsNameTxt}, Header: t('Dataset'), accessor: 'datasource_id', + disableSortBy: true, size: 'xl', }, { @@ -352,7 +354,21 @@ function ChartList(props: ChartListProps) { unfilteredLabel: 'All', selects: getChartMetadataRegistry() .keys() - .map(k => ({ label: k, value: k })), + .map(k => ({ label: k, value: k })) + .sort((a, b) => { + if (!a.label || !b.label) { + return 0; + } + + if (a.label > b.label) { + return 1; + } + if (a.label < b.label) { + return -1; + } + + return 0; + }), }, { Header: t('Dataset'),