fix: add sort option to filters, sort chart list filter options (#11370)

This commit is contained in:
Moriah Kreeger 2020-11-04 11:02:33 -08:00 committed by GitHub
parent ec054e1fac
commit 094359cc5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -119,6 +119,7 @@ function SelectFilter({
setSelectedOption(matchingOption);
}
}
return {
options: result,
hasMore,

View File

@ -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) => <a href={dsUrl}>{dsNameTxt}</a>,
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'),