This is an automated email from the ASF dual-hosted git repository.
pkdotson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 3f6a24f chore: add certified columns to top of list (#16910)
3f6a24f is described below
commit 3f6a24fe1acaaa164abfea6048b431764c794648
Author: Phillip Kelley-Dotson <[email protected]>
AuthorDate: Fri Oct 1 11:50:03 2021 -0700
chore: add certified columns to top of list (#16910)
* initial commit
* inital commit
* add suggestions
* remove changes
* Update superset-frontend/src/explore/components/DatasourcePanel/index.tsx
Co-authored-by: Michael S. Molina
<[email protected]>
Co-authored-by: Michael S. Molina
<[email protected]>
---
.../src/explore/components/DatasourcePanel/index.tsx | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
b/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
index f31ec11..0a3cf7b 100644
--- a/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
+++ b/superset-frontend/src/explore/components/DatasourcePanel/index.tsx
@@ -17,7 +17,11 @@
* under the License.
*/
import React, { useEffect, useMemo, useRef, useState } from 'react';
-import { ControlConfig, DatasourceMeta } from '@superset-ui/chart-controls';
+import {
+ ControlConfig,
+ DatasourceMeta,
+ ColumnMeta,
+} from '@superset-ui/chart-controls';
import { debounce } from 'lodash';
import { matchSorter, rankings } from 'match-sorter';
import { css, styled, t } from '@superset-ui/core';
@@ -253,6 +257,9 @@ export default function DataSourcePanel({
setInputValue('');
}, [columns, datasource, metrics]);
+ const sortCertifiedFirst = (slice: ColumnMeta[]) =>
+ slice.sort((a, b) => b.is_certified - a.is_certified);
+
const metricSlice = useMemo(
() =>
showAllMetrics
@@ -263,8 +270,10 @@ export default function DataSourcePanel({
const columnSlice = useMemo(
() =>
showAllColumns
- ? lists.columns
- : lists.columns.slice(0, DEFAULT_MAX_COLUMNS_LENGTH),
+ ? sortCertifiedFirst(lists.columns)
+ : sortCertifiedFirst(
+ lists.columns.slice(0, DEFAULT_MAX_COLUMNS_LENGTH),
+ ),
[lists.columns, showAllColumns],
);