msyavuz commented on code in PR #43235:
URL: https://github.com/apache/superset/pull/43235#discussion_r3978533659
##########
superset-frontend/src/explore/components/DatasourcePanel/types.ts:
##########
@@ -37,6 +48,10 @@ export function isSavedMetric(item: any): item is Metric {
return item?.metric_name;
}
+export function isSavedFilter(item: any): item is SavedFilter {
Review Comment:
New `any`; `unknown` works since only two props are read.
##########
superset-frontend/src/explore/components/optionRenderers.tsx:
##########
@@ -61,3 +64,23 @@ export const StyledColumnOption = (props: ColumnOptionProps)
=> (
<ColumnOption {...props} />
</OptionContainer>
);
+
+export const StyledSavedFilterOption = ({
+ sqlFilter,
+ showType = false,
+}: {
+ sqlFilter: SavedFilter;
+ showType?: boolean;
+}) => (
+ <OptionContainer>
+ <span>
+ {showType && <ColumnTypeLabel type="expression" />}
+ <span className="option-label">
Review Comment:
`is_certified` and `warning_text` drive the panel's search ranking but
nothing renders the certified badge or the warning here, unlike `MetricOption`.
A certified filter sorts first yet looks identical to an uncertified one.
##########
superset-frontend/src/explore/components/optionRenderers.tsx:
##########
@@ -23,7 +23,10 @@ import {
ColumnOption,
MetricOptionProps,
ColumnOptionProps,
+ ColumnTypeLabel,
} from '@superset-ui/chart-controls';
+import { SQLPopover } from '@superset-ui/chart-controls/components/SQLPopover';
Review Comment:
Deep import into chart-controls `src/` that the published `lib/` never
exposes; it works only because webpack aliases the workspace to `src`. Export
`SQLPopover` from the package index like `MetricOption`.
##########
superset-frontend/src/explore/components/DatasourcePanel/transformDatasourceFolders.ts:
##########
@@ -178,12 +181,45 @@ const transformToFolderStructure = (
return folders;
};
+const insertFiltersFolder = (
+ folders: Folder[],
+ filtersToDisplay: SavedFilter[],
+ allFiltersCount: number,
+): Folder[] => {
+ if (filtersToDisplay.length === 0) {
+ return folders;
+ }
+ const filterItems: FilterItem[] = filtersToDisplay.map(sqlFilter => ({
+ ...sqlFilter,
+ type: 'filter' as const,
+ }));
+ const filtersFolder: Folder = {
+ id: DEFAULT_FILTERS_FOLDER_UUID,
+ name: t('Filters'),
+ isCollapsed: false,
+ items: filterItems,
+ totalItems: allFiltersCount,
+ showingItems: filterItems.length,
+ };
+ const metricsIndex = folders.findIndex(
+ folder => folder.id === DEFAULT_METRICS_FOLDER_UUID,
+ );
+ const insertAt = metricsIndex >= 0 ? metricsIndex + 1 : 0;
Review Comment:
When every metric sits in a custom folder there's no default Metrics folder,
so Filters lands at index 0 above the user's own folders. Intended?
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditor.test.tsx:
##########
@@ -659,6 +659,43 @@ test('metric search is case-insensitive', async () => {
});
});
+test('can search filters by filter name', async () => {
Review Comment:
Only search is covered. Nothing exercises add, rename, delete, or the
duplicate-name and empty-expression validation at
`DatasourceEditor.tsx:982-993`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]