Skip to content

Commit

Permalink
Fixes of merge results.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Dec 6, 2021
1 parent b3cc587 commit dab8567
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ export const element: CanvasElement = {
filter: '',
};

export const element: CanvasElement = {
id: '0',
position: generatePosition(0),
type: 'element',
expression: `filters group="${group2}"`,
filter: '',
};

const element1: CanvasElement = {
id: '1',
position: generatePosition(1),
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/canvas/public/functions/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getGlobalFilters, getWorkpadVariablesAsObject } from '../state/selector
import { ExpressionValueFilter } from '../../types';
import { getFunctionHelp } from '../../i18n';
import { InitializeArguments } from '.';
import { getFiltersByGroups } from '../lib/filter';

export interface Arguments {
group: string[];
Expand All @@ -36,7 +35,11 @@ function getFiltersByGroup(allFilters: string[], groups?: string[], ungrouped =
});
}

return getFiltersByGroups(allFilters, groups);
return allFilters.filter((filter) => {
const ast = fromExpression(filter);
const expGroups: string[] = get(ast, 'chain[0].arguments.filterGroup', []);
return expGroups.length > 0 && expGroups.every((expGroup) => groups.includes(expGroup));
});
}

type FiltersFunction = ExpressionFunctionDefinition<
Expand Down

0 comments on commit dab8567

Please sign in to comment.