mirror of
https://github.com/apache/superset.git
synced 2026-04-13 13:18:25 +00:00
fix: Search in folders editor with verbose names (#38101)
This commit is contained in:
committed by
GitHub
parent
86c8fa5cd7
commit
f049d3e34a
@@ -124,6 +124,43 @@ describe('folderUtils', () => {
|
||||
|
||||
expect(result.size).toBe(4);
|
||||
});
|
||||
|
||||
test('should match by verbose_name', () => {
|
||||
const metrics: Metric[] = [
|
||||
{
|
||||
uuid: 'metric-v1',
|
||||
metric_name: 'count',
|
||||
verbose_name: 'COUNT(*)',
|
||||
expression: 'COUNT(*)',
|
||||
} as Metric,
|
||||
];
|
||||
const result = filterItemsBySearch('COUNT', metrics);
|
||||
|
||||
expect(result.size).toBe(1);
|
||||
expect(result.has('metric-v1')).toBe(true);
|
||||
});
|
||||
|
||||
test('should match by expression', () => {
|
||||
const result = filterItemsBySearch('COUNT(*)', mockMetrics);
|
||||
|
||||
expect(result.size).toBe(1);
|
||||
expect(result.has('metric-1')).toBe(true);
|
||||
});
|
||||
|
||||
test('should match special characters in search term', () => {
|
||||
const metrics: Metric[] = [
|
||||
{
|
||||
uuid: 'metric-special',
|
||||
metric_name: 'count',
|
||||
verbose_name: 'COUNT(*)',
|
||||
expression: 'COUNT(*)',
|
||||
} as Metric,
|
||||
];
|
||||
const result = filterItemsBySearch('(*)', metrics);
|
||||
|
||||
expect(result.size).toBe(1);
|
||||
expect(result.has('metric-special')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDefaultFolder', () => {
|
||||
|
||||
@@ -80,7 +80,13 @@ export const filterItemsBySearch = (
|
||||
|
||||
items.forEach(item => {
|
||||
const name = 'metric_name' in item ? item.metric_name : item.column_name;
|
||||
if (name?.toLowerCase().includes(lowerSearch)) {
|
||||
const { verbose_name: verboseName, expression } = item;
|
||||
|
||||
if (
|
||||
name?.toLowerCase().includes(lowerSearch) ||
|
||||
verboseName?.toLowerCase().includes(lowerSearch) ||
|
||||
expression?.toLowerCase().includes(lowerSearch)
|
||||
) {
|
||||
matchingIds.add(item.uuid);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user