Skip to content

Commit d4efae7

Browse files
nreeseelasticmachineelizabetdev
authored
[Maps] add drilldown support map embeddable (#75598) (#76236)
* [Maps] add drilldown support * filter actions view * use i18n getter * remove unused changed * tslint fixes * more tslint changes * clean-up and API doc changes * update snapshots * do not show first drilldown in tooltip * add light grey line to seperate feature property rows * Improving tooltip row styles (#36) * Improving tooltip actions row styles * Removind unecessary comment * update snapshot and add functional test * switch UiActionsActionDefinition to Action and remove unneeded checks Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co>
1 parent 97834d6 commit d4efae7

File tree

27 files changed

+608
-119
lines changed

27 files changed

+608
-119
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [ACTION\_GLOBAL\_APPLY\_FILTER](./kibana-plugin-plugins-data-public.action_global_apply_filter.md)
4+
5+
## ACTION\_GLOBAL\_APPLY\_FILTER variable
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
ACTION_GLOBAL_APPLY_FILTER = "ACTION_GLOBAL_APPLY_FILTER"
11+
```

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989

9090
| Variable | Description |
9191
| --- | --- |
92+
| [ACTION\_GLOBAL\_APPLY\_FILTER](./kibana-plugin-plugins-data-public.action_global_apply_filter.md) | |
9293
| [AggGroupLabels](./kibana-plugin-plugins-data-public.agggrouplabels.md) | |
9394
| [AggGroupNames](./kibana-plugin-plugins-data-public.agggroupnames.md) | |
9495
| [baseFormattersPublic](./kibana-plugin-plugins-data-public.baseformatterspublic.md) | |

src/plugins/data/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export {
440440

441441
export { isTimeRange, isQuery, isFilter, isFilters } from '../common';
442442

443-
export { ApplyGlobalFilterActionContext } from './actions';
443+
export { ACTION_GLOBAL_APPLY_FILTER, ApplyGlobalFilterActionContext } from './actions';
444444

445445
export * from '../common/field_mapping';
446446

src/plugins/data/public/public.api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ import { UnregisterCallback } from 'history';
7878
import { UnwrapPromiseOrReturn } from '@kbn/utility-types';
7979
import { UserProvidedValues } from 'src/core/server/types';
8080

81+
// Warning: (ae-missing-release-tag) "ACTION_GLOBAL_APPLY_FILTER" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
82+
//
83+
// @public (undocumented)
84+
export const ACTION_GLOBAL_APPLY_FILTER = "ACTION_GLOBAL_APPLY_FILTER";
85+
8186
// Warning: (ae-forgotten-export) The symbol "AggConfigSerialized" needs to be exported by the entry point index.d.ts
8287
// Warning: (ae-missing-release-tag) "AggConfigOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
8388
//

x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export type TooltipState = {
5353
};
5454

5555
export type DrawState = {
56+
actionId: string;
5657
drawType: DRAW_TYPE;
5758
filterLabel?: string; // point radius filter alias
5859
geoFieldName?: string;

x-pack/plugins/maps/public/components/__snapshots__/geometry_filter_form.test.js.snap

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.mapActionSelectIcon {
2+
margin-right: $euiSizeS;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import 'action_select';
12
@import 'metric_editors';
23
@import './geometry_filter';
34
@import 'tooltip_selector/tooltip_selector';
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React, { Component } from 'react';
8+
import { EuiFormRow, EuiSuperSelect, EuiIcon } from '@elastic/eui';
9+
import { i18n } from '@kbn/i18n';
10+
import { ActionExecutionContext, Action } from 'src/plugins/ui_actions/public';
11+
12+
interface Props {
13+
value?: string;
14+
onChange: (value: string) => void;
15+
getFilterActions?: () => Promise<Action[]>;
16+
getActionContext?: () => ActionExecutionContext;
17+
}
18+
19+
interface State {
20+
actions: Action[];
21+
}
22+
23+
export class ActionSelect extends Component<Props, State> {
24+
private _isMounted = false;
25+
state: State = {
26+
actions: [],
27+
};
28+
29+
componentDidMount() {
30+
this._isMounted = true;
31+
this._loadActions();
32+
}
33+
34+
componentWillUnmount() {
35+
this._isMounted = false;
36+
}
37+
38+
async _loadActions() {
39+
if (!this.props.getFilterActions || !this.props.getActionContext) {
40+
return;
41+
}
42+
const actions = await this.props.getFilterActions();
43+
if (this._isMounted) {
44+
this.setState({ actions });
45+
}
46+
}
47+
48+
render() {
49+
if (this.state.actions.length === 0 || !this.props.getActionContext) {
50+
return null;
51+
}
52+
53+
if (this.state.actions.length === 1 && this.props.value === this.state.actions[0].id) {
54+
return null;
55+
}
56+
57+
const actionContext = this.props.getActionContext();
58+
const options = this.state.actions.map((action) => {
59+
const iconType = action.getIconType(actionContext);
60+
return {
61+
value: action.id,
62+
inputDisplay: (
63+
<div>
64+
{iconType ? <EuiIcon className="mapActionSelectIcon" type={iconType} /> : null}
65+
{action.getDisplayName(actionContext)}
66+
</div>
67+
),
68+
};
69+
});
70+
71+
return (
72+
<EuiFormRow
73+
label={i18n.translate('xpack.maps.actionSelect.label', {
74+
defaultMessage: 'Action',
75+
})}
76+
display="rowCompressed"
77+
>
78+
<EuiSuperSelect
79+
compressed
80+
options={options}
81+
valueOfSelected={this.props.value ? this.props.value : ''}
82+
onChange={this.props.onChange}
83+
/>
84+
</EuiFormRow>
85+
);
86+
}
87+
}

x-pack/plugins/maps/public/components/distance_filter_form.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,40 @@ import {
1414
EuiTextAlign,
1515
} from '@elastic/eui';
1616
import { i18n } from '@kbn/i18n';
17+
import { ActionExecutionContext, Action } from 'src/plugins/ui_actions/public';
1718
import { MultiIndexGeoFieldSelect } from './multi_index_geo_field_select';
1819
import { GeoFieldWithIndex } from './geo_field_with_index';
20+
import { ActionSelect } from './action_select';
21+
import { ACTION_GLOBAL_APPLY_FILTER } from '../../../../../src/plugins/data/public';
1922

2023
interface Props {
2124
className?: string;
2225
buttonLabel: string;
2326
geoFields: GeoFieldWithIndex[];
27+
getFilterActions?: () => Promise<Action[]>;
28+
getActionContext?: () => ActionExecutionContext;
2429
onSubmit: ({
30+
actionId,
2531
filterLabel,
2632
indexPatternId,
2733
geoFieldName,
2834
}: {
35+
actionId: string;
2936
filterLabel: string;
3037
indexPatternId: string;
3138
geoFieldName: string;
3239
}) => void;
3340
}
3441

3542
interface State {
43+
actionId: string;
3644
selectedField: GeoFieldWithIndex | undefined;
3745
filterLabel: string;
3846
}
3947

4048
export class DistanceFilterForm extends Component<Props, State> {
41-
state = {
49+
state: State = {
50+
actionId: ACTION_GLOBAL_APPLY_FILTER,
4251
selectedField: this.props.geoFields.length ? this.props.geoFields[0] : undefined,
4352
filterLabel: '',
4453
};
@@ -53,11 +62,16 @@ export class DistanceFilterForm extends Component<Props, State> {
5362
});
5463
};
5564

65+
_onActionIdChange = (value: string) => {
66+
this.setState({ actionId: value });
67+
};
68+
5669
_onSubmit = () => {
5770
if (!this.state.selectedField) {
5871
return;
5972
}
6073
this.props.onSubmit({
74+
actionId: this.state.actionId,
6175
filterLabel: this.state.filterLabel,
6276
indexPatternId: this.state.selectedField.indexPatternId,
6377
geoFieldName: this.state.selectedField.geoFieldName,
@@ -86,6 +100,13 @@ export class DistanceFilterForm extends Component<Props, State> {
86100
onChange={this._onGeoFieldChange}
87101
/>
88102

103+
<ActionSelect
104+
getFilterActions={this.props.getFilterActions}
105+
getActionContext={this.props.getActionContext}
106+
value={this.state.actionId}
107+
onChange={this._onActionIdChange}
108+
/>
109+
89110
<EuiSpacer size="m" />
90111

91112
<EuiTextAlign textAlign="right">

0 commit comments

Comments
 (0)