You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by su...@apache.org on 2021/06/18 17:33:36 UTC
[superset] 03/04: add a catch-all category
This is an automated email from the ASF dual-hosted git repository.
suddjian pushed a commit to branch viz-picker-categories
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 67ca2c65ef643a909705808273def2df14d00c95
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Fri Jun 18 10:25:44 2021 -0700
add a catch-all category
---
.../components/controls/VizTypeControl/index.tsx | 23 +++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/superset-frontend/src/explore/components/controls/VizTypeControl/index.tsx b/superset-frontend/src/explore/components/controls/VizTypeControl/index.tsx
index a46fc4f..103ecac 100644
--- a/superset-frontend/src/explore/components/controls/VizTypeControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/VizTypeControl/index.tsx
@@ -309,19 +309,20 @@ const VizTypeControl = (props: VizTypeControlProps) => {
})
.filter(({ key }) => !typesWithDefaultOrder.has(key)),
)
- .filter(entry =>
- filterStringParts.every(
- part => entry.value?.name.toLowerCase().indexOf(part) !== -1,
- ),
+ .filter(
+ entry =>
+ !!entry.value &&
+ filterStringParts.every(
+ part => entry.value?.name.toLowerCase().indexOf(part) !== -1,
+ ),
)
- .reduce((acc, entry: VizEntry) => {
- const category = entry.value?.categories?.[0];
- if (entry.value && category) {
- if (!acc[category]) {
- acc[category] = [];
- }
- acc[category].push(entry);
+ .reduce((acc, entry) => {
+ const category = entry.value?.categories?.[0] || 'Other';
+ if (!acc[category]) {
+ acc[category] = [];
}
+ // typecast is safe because we filtered out falsy value already
+ acc[category].push(entry as VizEntry);
return acc;
}, {} as Record<string, VizEntry[]>);