Skip to content

Commit d1b3d09

Browse files
[Maps] move map embeddable display properties to map settings (#86395) (#87944)
* [Maps] move map embeddable display properties to map settings * update uptime EmbeddedMap * tslint * more cleanup Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent aa42cee commit d1b3d09

17 files changed

Lines changed: 36 additions & 303 deletions

File tree

x-pack/plugins/maps/public/actions/map_action_constants.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ export const SET_OPEN_TOOLTIPS = 'SET_OPEN_TOOLTIPS';
3838
export const UPDATE_DRAW_STATE = 'UPDATE_DRAW_STATE';
3939
export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM';
4040
export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR';
41-
export const SET_INTERACTIVE = 'SET_INTERACTIVE';
42-
export const DISABLE_TOOLTIP_CONTROL = 'DISABLE_TOOLTIP_CONTROL';
43-
export const HIDE_TOOLBAR_OVERLAY = 'HIDE_TOOLBAR_OVERLAY';
44-
export const HIDE_LAYER_CONTROL = 'HIDE_LAYER_CONTROL';
45-
export const HIDE_VIEW_CONTROL = 'HIDE_VIEW_CONTROL';
4641
export const SET_WAITING_FOR_READY_HIDDEN_LAYERS = 'SET_WAITING_FOR_READY_HIDDEN_LAYERS';
4742
export const SET_MAP_SETTINGS = 'SET_MAP_SETTINGS';
4843
export const ROLLBACK_MAP_SETTINGS = 'ROLLBACK_MAP_SETTINGS';

x-pack/plugins/maps/public/actions/map_actions.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@ import {
2424
CLEAR_GOTO,
2525
CLEAR_MOUSE_COORDINATES,
2626
CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST,
27-
DISABLE_TOOLTIP_CONTROL,
28-
HIDE_LAYER_CONTROL,
29-
HIDE_TOOLBAR_OVERLAY,
30-
HIDE_VIEW_CONTROL,
3127
MAP_DESTROYED,
3228
MAP_EXTENT_CHANGED,
3329
MAP_READY,
3430
ROLLBACK_MAP_SETTINGS,
3531
SET_GOTO,
36-
SET_INTERACTIVE,
3732
SET_MAP_INIT_ERROR,
3833
SET_MAP_SETTINGS,
3934
SET_MOUSE_COORDINATES,
@@ -73,7 +68,7 @@ export function setMapInitError(errorMessage: string) {
7368
};
7469
}
7570

76-
export function setMapSettings(settings: MapSettings) {
71+
export function setMapSettings(settings: Partial<MapSettings>) {
7772
return {
7873
type: SET_MAP_SETTINGS,
7974
settings,
@@ -316,22 +311,3 @@ export function updateDrawState(drawState: DrawState | null) {
316311
});
317312
};
318313
}
319-
320-
export function disableInteractive() {
321-
return { type: SET_INTERACTIVE, disableInteractive: true };
322-
}
323-
324-
export function disableTooltipControl() {
325-
return { type: DISABLE_TOOLTIP_CONTROL, disableTooltipControl: true };
326-
}
327-
328-
export function hideToolbarOverlay() {
329-
return { type: HIDE_TOOLBAR_OVERLAY, hideToolbarOverlay: true };
330-
}
331-
332-
export function hideLayerControl() {
333-
return { type: HIDE_LAYER_CONTROL, hideLayerControl: true };
334-
}
335-
export function hideViewControl() {
336-
return { type: HIDE_VIEW_CONTROL, hideViewControl: true };
337-
}

x-pack/plugins/maps/public/connected_components/map_container/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
getMapInitError,
1717
getMapSettings,
1818
getQueryableUniqueIndexPatternIds,
19-
isToolbarOverlayHidden,
2019
} from '../../selectors/map_selectors';
2120
import { MapStoreState } from '../../reducers/store';
2221
import { getCoreChrome } from '../../kibana_services';
@@ -29,8 +28,7 @@ function mapStateToProps(state: MapStoreState) {
2928
refreshConfig: getRefreshConfig(state),
3029
mapInitError: getMapInitError(state),
3130
indexPatternIds: getQueryableUniqueIndexPatternIds(state),
32-
hideToolbarOverlay: isToolbarOverlayHidden(state),
33-
backgroundColor: getMapSettings(state).backgroundColor,
31+
settings: getMapSettings(state),
3432
};
3533
}
3634

x-pack/plugins/maps/public/connected_components/map_container/map_container.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getIndexPatternsFromIds } from '../../index_pattern_util';
2525
import { ES_GEO_FIELD_TYPE, RawValue } from '../../../common/constants';
2626
import { indexPatterns as indexPatternsUtils } from '../../../../../../src/plugins/data/public';
2727
import { FLYOUT_STATE } from '../../reducers/ui';
28+
import { MapSettings } from '../../reducers/map';
2829
import { MapSettingsPanel } from '../map_settings_panel';
2930
import { registerLayerWizards } from '../../classes/layers/load_layer_wizards';
3031
import { RenderToolTipContent } from '../../classes/tooltips/tooltip_property';
@@ -36,15 +37,13 @@ const RENDER_COMPLETE_EVENT = 'renderComplete';
3637

3738
interface Props {
3839
addFilters: ((filters: Filter[]) => Promise<void>) | null;
39-
backgroundColor: string;
4040
getFilterActions?: () => Promise<Action[]>;
4141
getActionContext?: () => ActionExecutionContext;
4242
onSingleValueTrigger?: (actionId: string, key: string, value: RawValue) => void;
4343
areLayersLoaded: boolean;
4444
cancelAllInFlightRequests: () => void;
4545
exitFullScreen: () => void;
4646
flyoutDisplay: FLYOUT_STATE;
47-
hideToolbarOverlay: boolean;
4847
isFullScreen: boolean;
4948
indexPatternIds: string[];
5049
mapInitError: string | null | undefined;
@@ -53,6 +52,7 @@ interface Props {
5352
triggerRefreshTimer: () => void;
5453
title?: string;
5554
description?: string;
55+
settings: MapSettings;
5656
}
5757

5858
interface State {
@@ -245,7 +245,7 @@ export class MapContainer extends Component<Props, State> {
245245
>
246246
<EuiFlexItem
247247
className="mapMapWrapper"
248-
style={{ backgroundColor: this.props.backgroundColor }}
248+
style={{ backgroundColor: this.props.settings.backgroundColor }}
249249
>
250250
<MBMap
251251
addFilters={addFilters}
@@ -255,7 +255,7 @@ export class MapContainer extends Component<Props, State> {
255255
geoFields={this.state.geoFields}
256256
renderTooltipContent={renderTooltipContent}
257257
/>
258-
{!this.props.hideToolbarOverlay && (
258+
{!this.props.settings.hideToolbarOverlay && (
259259
<ToolbarOverlay
260260
addFilters={addFilters}
261261
geoFields={this.state.geoFields}

x-pack/plugins/maps/public/connected_components/mb_map/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import {
2323
getMapReady,
2424
getGoto,
2525
getScrollZoom,
26-
isInteractiveDisabled,
27-
isTooltipControlDisabled,
28-
isViewControlHidden,
2926
getSpatialFiltersLayer,
3027
getMapSettings,
3128
} from '../../selectors/map_selectors';
@@ -41,9 +38,6 @@ function mapStateToProps(state: MapStoreState) {
4138
goto: getGoto(state),
4239
inspectorAdapters: getInspectorAdapters(state),
4340
scrollZoom: getScrollZoom(state),
44-
disableInteractive: isInteractiveDisabled(state),
45-
disableTooltipControl: isTooltipControlDisabled(state),
46-
hideViewControl: isViewControlHidden(state),
4741
};
4842
}
4943

x-pack/plugins/maps/public/connected_components/mb_map/mb_map.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ interface Props {
5656
goto?: Goto | null;
5757
inspectorAdapters: Adapters;
5858
scrollZoom: boolean;
59-
disableInteractive: boolean;
60-
disableTooltipControl: boolean;
61-
hideViewControl: boolean;
6259
extentChanged: (mapExtentState: MapExtentState) => void;
6360
onMapReady: (mapExtentState: MapExtentState) => void;
6461
onMapDestroyed: () => void;
@@ -181,7 +178,7 @@ export class MBMap extends Component<Props, State> {
181178
style: mbStyle,
182179
scrollZoom: this.props.scrollZoom,
183180
preserveDrawingBuffer: getPreserveDrawingBuffer(),
184-
interactive: !this.props.disableInteractive,
181+
interactive: !this.props.settings.disableInteractive,
185182
maxZoom: this.props.settings.maxZoom,
186183
minZoom: this.props.settings.minZoom,
187184
};
@@ -197,7 +194,7 @@ export class MBMap extends Component<Props, State> {
197194
const mbMap = new mapboxgl.Map(options);
198195
mbMap.dragRotate.disable();
199196
mbMap.touchZoomRotate.disableRotation();
200-
if (!this.props.disableInteractive) {
197+
if (!this.props.settings.disableInteractive) {
201198
mbMap.addControl(new mapboxgl.NavigationControl({ showCompass: false }), 'top-left');
202199
}
203200

@@ -260,7 +257,7 @@ export class MBMap extends Component<Props, State> {
260257
}, 100)
261258
);
262259
// Attach event only if view control is visible, which shows lat/lon
263-
if (!this.props.hideViewControl) {
260+
if (!this.props.settings.hideViewControl) {
264261
const throttledSetMouseCoordinates = _.throttle((e: MapMouseEvent) => {
265262
this.props.setMouseCoordinates({
266263
lat: e.lngLat.lat,
@@ -386,7 +383,7 @@ export class MBMap extends Component<Props, State> {
386383
let tooltipControl;
387384
if (this.state.mbMap) {
388385
drawControl = <DrawControl mbMap={this.state.mbMap} addFilters={this.props.addFilters} />;
389-
tooltipControl = !this.props.disableTooltipControl ? (
386+
tooltipControl = !this.props.settings.disableTooltipControl ? (
390387
<TooltipControl
391388
mbMap={this.state.mbMap}
392389
addFilters={this.props.addFilters}

x-pack/plugins/maps/public/connected_components/widget_overlay/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
import { connect } from 'react-redux';
88
import { WidgetOverlay } from './widget_overlay';
99

10-
import { isLayerControlHidden, isViewControlHidden } from '../../selectors/map_selectors';
10+
import { getMapSettings } from '../../selectors/map_selectors';
1111

1212
function mapStateToProps(state = {}) {
1313
return {
14-
hideLayerControl: isLayerControlHidden(state),
15-
hideViewControl: isViewControlHidden(state),
14+
settings: getMapSettings(state),
1615
};
1716
}
1817

x-pack/plugins/maps/public/connected_components/widget_overlay/widget_overlay.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { LayerControl } from './layer_control';
1010
import { ViewControl } from './view_control';
1111
import { AttributionControl } from './attribution_control';
1212

13-
export function WidgetOverlay({ hideLayerControl, hideViewControl }) {
13+
export function WidgetOverlay({ settings }) {
1414
return (
1515
<EuiFlexGroup
1616
className="mapWidgetOverlay"
@@ -20,9 +20,9 @@ export function WidgetOverlay({ hideLayerControl, hideViewControl }) {
2020
gutterSize="s"
2121
>
2222
<EuiFlexItem className="mapWidgetOverlay__layerWrapper">
23-
{!hideLayerControl && <LayerControl />}
23+
{!settings.hideLayerControl && <LayerControl />}
2424
</EuiFlexItem>
25-
<EuiFlexItem grow={false}>{!hideViewControl && <ViewControl />}</EuiFlexItem>
25+
<EuiFlexItem grow={false}>{!settings.hideViewControl && <ViewControl />}</EuiFlexItem>
2626
<EuiFlexItem grow={false}>
2727
<AttributionControl />
2828
</EuiFlexItem>

x-pack/plugins/maps/public/embeddable/README.md

Lines changed: 0 additions & 143 deletions
This file was deleted.

0 commit comments

Comments
 (0)