Skip to content

Commit

Permalink
feat: implement Filter dnd (apache#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored and zhaoyongjie committed Nov 17, 2021
1 parent 4e5bbe4 commit 24cae1a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,18 @@ export const dndEntity: typeof dndGroupByControl = {
validators: [validateNonEmpty],
description: t('This defines the element to be plotted on the chart'),
};

export const dnd_adhoc_filters: SharedControlConfig<'DndFilterSelect'> = {
type: 'DndFilterSelect',
label: t('Filters'),
default: null,
description: '',
mapStateToProps: ({ datasource, form_data }) => ({
columns: datasource?.columns.filter(c => c.filterable) || [],
savedMetrics: datasource?.metrics || [],
// current active adhoc metrics
selectedMetrics: form_data.metrics || (form_data.metric ? [form_data.metric] : []),
datasource,
}),
provideFormDataToProps: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ import {
SelectControlConfig,
} from '../types';
import { ColumnOption } from '../components/ColumnOption';
import { dndColumnsControl, dndEntity, dndGroupByControl, dndSeries } from './dndControls';
import {
dnd_adhoc_filters,
dndColumnsControl,
dndEntity,
dndGroupByControl,
dndSeries,
} from './dndControls';

const categoricalSchemeRegistry = getCategoricalSchemeRegistry();
const sequentialSchemeRegistry = getSequentialSchemeRegistry();
Expand Down Expand Up @@ -510,7 +516,7 @@ const sharedControls = {
size,
y_axis_format,
x_axis_time_format,
adhoc_filters,
adhoc_filters: enableExploreDnd ? dnd_adhoc_filters : adhoc_filters,
color_scheme,
label_colors,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export type InternalControlType =
| 'AdhocFilterControl'
| 'FilterBoxItemControl'
| 'DndColumnSelectControl'
| 'DndFilterSelect'
| keyof SharedControlComponents; // expanded in `expandControlConfig`

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 24cae1a

Please sign in to comment.