Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Canvas] Filters panel with filter group update functionality. #117649

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
88d7c79
Added new GlobalConfig layout.
Kuznietsov Oct 27, 2021
9e471e6
Removed not used section.
Kuznietsov Oct 27, 2021
7737f1f
Added filter components.
Kuznietsov Oct 27, 2021
24b65ae
Fixed rows of filter keys.
Kuznietsov Oct 27, 2021
6da422e
Added filterViews and their transforming.
Kuznietsov Oct 28, 2021
10d3ccd
Refactored getFilterFormatter method.
Kuznietsov Oct 28, 2021
a4c8748
Fixed typo.
Kuznietsov Oct 28, 2021
457d7ad
Added types.
Kuznietsov Oct 28, 2021
8ef909a
Added hook for connecting to the canvas store.
Kuznietsov Oct 28, 2021
6da604b
fixed import.
Kuznietsov Oct 29, 2021
6ca376f
Added filter types.
Kuznietsov Oct 29, 2021
7e6cb11
Fixed the style of filter view.
Kuznietsov Oct 29, 2021
9c6a738
Added sidebar reducer and saved groupByOption there.
Kuznietsov Oct 29, 2021
59594de
Added strict type.
Kuznietsov Oct 29, 2021
d426cd7
Added time formatting and translations.
Kuznietsov Oct 29, 2021
d3671b5
added invalid date translation.
Kuznietsov Oct 29, 2021
fa81a02
Added components to the view of filter.
Kuznietsov Oct 29, 2021
712c1de
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 1, 2021
e8d033c
Fixed some bugs and done refactoring.
Kuznietsov Nov 1, 2021
a99a555
Added unit tests for filter.ts lib.
Kuznietsov Nov 1, 2021
dbad0ca
Refactored use_canvas_filters and added unit tests for filter_adapters.
Kuznietsov Nov 1, 2021
4529463
Fixed format.
Kuznietsov Nov 1, 2021
15e781a
Added test to groupFiltersBy function.
Kuznietsov Nov 1, 2021
6acc3e1
Added default (beta) FiltersGroup story.
Kuznietsov Nov 1, 2021
8bc5220
Refactored the code.
Kuznietsov Nov 2, 2021
093845a
Storybook and snapshot for FiltersGroup component.
Kuznietsov Nov 2, 2021
52bd47f
Added utils for WorkpadFilters storybook.
Kuznietsov Nov 2, 2021
ebb1274
FilterComponent storybook and snapshot added.
Kuznietsov Nov 2, 2021
73e72e3
WorkpadFiltersComponent storybook and snapshots added.
Kuznietsov Nov 2, 2021
616d25a
WorkpadFilters redux storybook added.
Kuznietsov Nov 2, 2021
a393a57
Added element without group to the redux WorkpadFilters storybook.
Kuznietsov Nov 2, 2021
9881236
Removed useless decoration from FilterComponent storybook.
Kuznietsov Nov 2, 2021
9e6e21d
Removed useless comment.
Kuznietsov Nov 2, 2021
f44291d
Removed absent export.
Kuznietsov Nov 2, 2021
126b283
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 2, 2021
ca798e1
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 2, 2021
99e9ab2
Added Filters tab for the element.
Kuznietsov Nov 2, 2021
98e4867
Added filtering by groups, passed to the `filters` expression.
Kuznietsov Nov 2, 2021
8b255a0
Updated storybook and storyshot of WorkpadFilters.
Kuznietsov Nov 3, 2021
ea3f6cb
Added unit tests to the additional filter lib functions.
Kuznietsov Nov 3, 2021
d5d40c5
Fixed i18n check error.
Kuznietsov Nov 3, 2021
6698938
Updated snapshot for filter.component.
Kuznietsov Nov 3, 2021
8b6a2dd
Merge branch 'canvas_filters_panel' of github.com:Kunzetsov/kibana in…
Kuznietsov Nov 3, 2021
31cde8d
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 3, 2021
7e6053f
Merge branch 'canvas_filters_panel' of github.com:Kunzetsov/kibana in…
Kuznietsov Nov 3, 2021
9d9257f
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 3, 2021
2856c02
Removed unused translation
Kuznietsov Nov 3, 2021
f36076c
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 3, 2021
ed695f2
Added logic for rendering interactive components.
Kuznietsov Nov 3, 2021
b786c5b
Added updateFilter logic.
Kuznietsov Nov 3, 2021
d391d49
Added demo version of updating filters.
Kuznietsov Nov 4, 2021
7962cfd
Added synchronisation of element's expression and filter.
Kuznietsov Nov 5, 2021
f306fa1
Added global groups to the list of required.
Kuznietsov Nov 5, 2021
94f4c56
Merge branch 'main' into canvas_filters_panel_for_element
kibanamachine Nov 5, 2021
9df435b
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 5, 2021
4240d74
Bug fix.
Kuznietsov Nov 5, 2021
e15ff1d
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 8, 2021
3513384
Merge branch 'main' into canvas_filters_panel_for_element
kibanamachine Nov 8, 2021
c1ccac9
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 8, 2021
4d7e9da
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 8, 2021
5d11ba8
Moved filter views to a workpad_filters directory.
Kuznietsov Nov 8, 2021
f12871d
Fixed styles of the filter component.
Kuznietsov Nov 8, 2021
ee3ba75
One more fix.
Kuznietsov Nov 8, 2021
67443ec
One more UI fix.
Kuznietsov Nov 8, 2021
43ead7c
Fixed labels for types and order of elements.
Kuznietsov Nov 8, 2021
adc584a
Fixed stories, labels.
Kuznietsov Nov 8, 2021
2378a76
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 8, 2021
a4d5581
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 8, 2021
231ea7f
Fixed types.
Kuznietsov Nov 9, 2021
d3038f1
Merge branch 'main' into canvas_filters_panel_update_group
Kuznietsov Nov 9, 2021
da5f2fd
Added stories and storyshots.
Kuznietsov Nov 9, 2021
01c8f34
Merge branch 'canvas_filters_panel_update_group' of github.com:Kunzet…
Kuznietsov Nov 9, 2021
ed6c571
Added tests for adaptFilterToExpression.
Kuznietsov Nov 9, 2021
b8822f9
Added tests for sync methods.
Kuznietsov Nov 9, 2021
bea96d5
Fixed styles
Kuznietsov Nov 9, 2021
6f02e14
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 10, 2021
3a3c6d4
Fixed snapshots.
Kuznietsov Nov 10, 2021
93360b3
Merge branch 'main' into canvas_filters_panel_for_element
kibanamachine Nov 10, 2021
1516acd
Fixed unused import.
Kuznietsov Nov 10, 2021
d1552bf
Fixed snapshot.
Kuznietsov Nov 10, 2021
da8da2c
Merge branch 'main' into canvas_filters_panel
kibanamachine Nov 11, 2021
228e637
Changed FunctionComponent to FC.
Kuznietsov Nov 11, 2021
4f5df5c
filter_group.tsx to filter_group.component.tsx
Kuznietsov Nov 11, 2021
9c07d9a
Added default to the groupFiltersByField
Kuznietsov Nov 11, 2021
e9b8a34
Removed unused import at sidebar reducer.
Kuznietsov Nov 11, 2021
fe337fa
Replaced snake_case with camelCase.
Kuznietsov Nov 11, 2021
4ab2137
filter.tsx to filter.component.tsx
Kuznietsov Nov 11, 2021
3c43a3a
Moved hooks.
Kuznietsov Nov 11, 2021
b7df169
Updated snapshots.
Kuznietsov Nov 11, 2021
3b9aa9d
Moved sidebar to the transientState.
Kuznietsov Nov 11, 2021
88d6211
Added DEFAULT_GROUP_BY_FIELD.
Kuznietsov Nov 11, 2021
42989ee
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 11, 2021
6104f8d
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 11, 2021
6481bda
Fixed accordion id.
Kuznietsov Nov 11, 2021
804753f
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 11, 2021
0acd1e0
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 11, 2021
e86b068
Updated snapshots.
Kuznietsov Nov 11, 2021
d81fd29
filters_group.stories to filters_group.component.stories
Kuznietsov Nov 11, 2021
15f014d
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 11, 2021
e51556f
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 11, 2021
42bfbfa
updated ids at filters_group.component.stories.
Kuznietsov Nov 11, 2021
3327071
Fixed styles.
Kuznietsov Nov 11, 2021
0479eae
Merge branch 'main' into canvas_filters_panel_for_element
Kuznietsov Nov 11, 2021
272ce95
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 11, 2021
4f8eec4
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 11, 2021
7b61f0b
Updated snapshots.
Kuznietsov Nov 12, 2021
8dd937b
Merge branch 'canvas_filters_panel' into canvas_filters_panel_for_ele…
Kuznietsov Nov 12, 2021
5cd5f54
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 12, 2021
8b3b463
updated snapshots.
Kuznietsov Nov 12, 2021
624b02f
Merge branch 'main' into canvas_filters_panel_for_element
kibanamachine Nov 15, 2021
003b22e
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 15, 2021
3de80db
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 17, 2021
c56d0b3
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 17, 2021
d60ff95
Merge branch 'main' into canvas_filters_panel_for_element
Kuznietsov Nov 18, 2021
ac4cbfd
Merge branch 'main' into canvas_filters_panel_update_group
Kuznietsov Nov 18, 2021
6918c42
Fixed eslint error.
Kuznietsov Nov 18, 2021
968e3be
Removed added by merge mistake file.
Kuznietsov Nov 18, 2021
b7b9996
Merge branch 'canvas_filters_panel_for_element' into canvas_filters_p…
Kuznietsov Nov 18, 2021
93e7d8c
Fixed linting problems.
Kuznietsov Nov 18, 2021
f5ee006
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 19, 2021
59ba45a
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 22, 2021
70649d2
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 24, 2021
3d21e99
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 26, 2021
9bceb67
Merge branch 'main' into canvas_filters_panel_update_group
kibanamachine Nov 29, 2021
b3cc587
Merge branch 'main' into canvas_filters_panel_update_group
Kuznietsov Dec 6, 2021
dab8567
Fixes of merge results.
Kuznietsov Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { get } from 'lodash';
import React from 'react';
import ReactDOM from 'react-dom';
import { KibanaThemeProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { syncFilterExpression } from '../../../../public/lib/sync_filter_expression';
import { RendererFactory } from '../../../../types';
import { StartInitializer } from '../../../plugin';
import { DropdownFilter } from './component';
Expand Down Expand Up @@ -56,14 +55,6 @@ export const dropdownFilterFactory: StartInitializer<RendererFactory<Config>> =
) {
filterExpression = '';
handlers.setFilter(filterExpression);
} else if (filterExpression !== '') {
// NOTE: setFilter() will cause a data refresh, avoid calling unless required
// compare expression and filter, update filter if needed
const { changed, newAst } = syncFilterExpression(config, filterExpression, ['filterGroup']);

if (changed) {
handlers.setFilter(toExpression(newAst));
}
}

const commit = (commitValue: string) => {
Expand All @@ -79,7 +70,7 @@ export const dropdownFilterFactory: StartInitializer<RendererFactory<Config>> =
arguments: {
value: [commitValue],
column: [config.column],
filterGroup: [config.filterGroup],
...(config.filterGroup ? { filterGroup: [config.filterGroup] } : {}),
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ export interface FilterMeta {
start: string;
/** End date string of filtered date range */
end: string;
filterGroup: string;
}

function getFilterMeta(filter: string): FilterMeta {
const ast = fromExpression(filter);

const column = get(ast, 'chain[0].arguments.column[0]') as string;
const start = get(ast, 'chain[0].arguments.from[0]') as string;
const end = get(ast, 'chain[0].arguments.to[0]') as string;
return { column, start, end };
const filterGroup = get(ast, 'chain[0].arguments.filterGroup[0]') as string;
return { column, start, end, filterGroup };
}

export interface Props {
Expand All @@ -55,20 +58,22 @@ export interface Props {

export const TimeFilter = ({ filter, commit, dateFormat, commonlyUsedRanges = [] }: Props) => {
const setFilter =
(column: string) =>
(column: string, filterGroup: string) =>
({ start, end }: OnTimeChangeProps) => {
commit(`timefilter from="${start}" to=${end} column=${column}`);
const filterExpression = `timefilter from="${start}" to=${end} column=${column}`;
const filterGroupArg = filterGroup ? `filterGroup="${filterGroup}"` : '';
commit(`${filterExpression} ${filterGroupArg}`);
};

const { column, start, end } = getFilterMeta(filter);
const { column, start, end, filterGroup } = getFilterMeta(filter);

return (
<div className="canvasTimeFilter">
<EuiSuperDatePicker
start={start}
end={end}
isPaused={false}
onTimeChange={setFilter(column)}
onTimeChange={setFilter(column, filterGroup)}
showUpdateButton={false}
dateFormat={dateFormat}
commonlyUsedRanges={commonlyUsedRanges.length ? commonlyUsedRanges : defaultQuickRanges}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

import ReactDOM from 'react-dom';
import React from 'react';
import { toExpression } from '@kbn/interpreter/common';
import { UI_SETTINGS } from '../../../../../../../src/plugins/data/public';
import { KibanaThemeProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { syncFilterExpression } from '../../../../public/lib/sync_filter_expression';
import { RendererStrings } from '../../../../i18n';
import { TimeFilter } from './components';
import { StartInitializer } from '../../../plugin';
Expand Down Expand Up @@ -46,17 +44,6 @@ export const timeFilterFactory: StartInitializer<RendererFactory<Arguments>> = (
if (filterExpression === undefined || filterExpression.indexOf('timefilter') !== 0) {
filterExpression = defaultTimeFilterExpression;
handlers.setFilter(filterExpression);
} else if (filterExpression !== '') {
// NOTE: setFilter() will cause a data refresh, avoid calling unless required
// compare expression and filter, update filter if needed
const { changed, newAst } = syncFilterExpression(config, filterExpression, [
'column',
'filterGroup',
]);

if (changed) {
handlers.setFilter(toExpression(newAst));
}
}

ReactDOM.render(
Expand Down
Loading