Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions x-pack/plugins/maps/public/angular/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import {
FLYOUT_STATE
} from '../store/ui';
import { getUniqueIndexPatternIds } from '../selectors/map_selectors';
import { getInspectorAdapters } from '../store/non_serializable_instances';
import { Inspector } from 'ui/inspector';
import { DocTitleProvider } from 'ui/doc_title';
import { inspectorAdapters, indexPatternService } from '../kibana_services';
import { indexPatternService } from '../kibana_services';
import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
import { toastNotifications } from 'ui/notify';
Expand All @@ -49,7 +50,6 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage
let unsubscribe;

const store = createMapStore();
inspectorAdapters.requests.reset();

$scope.$listen(globalState, 'fetch_with_changes', (diff) => {
if (diff.includes('time')) {
Expand Down Expand Up @@ -252,6 +252,7 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage
description: 'Open Inspector',
testId: 'openInspectorButton',
run() {
const inspectorAdapters = getInspectorAdapters(store.getState());
Inspector.open(inspectorAdapters, {});
}
}, {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/maps/public/components/layer_addpanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { connect } from 'react-redux';
import { AddLayerPanel } from './view';
import { getFlyoutDisplay, updateFlyout, FLYOUT_STATE } from '../../store/ui';
import { getTemporaryLayers, getMapColors } from '../../selectors/map_selectors';
import { getInspectorAdapters } from '../../store/non_serializable_instances';
import {
addLayer,
removeLayer,
Expand All @@ -23,6 +24,7 @@ function mapStateToProps(state = {}) {
return tmp.some((layer) => layer.isLayerLoading());
}
return {
inspectorAdapters: getInspectorAdapters(state),
flyoutVisible: getFlyoutDisplay(state) !== FLYOUT_STATE.NONE,
layerLoading: isLoading(),
temporaryLayers: !_.isEmpty(getTemporaryLayers(state)),
Expand Down
11 changes: 4 additions & 7 deletions x-pack/plugins/maps/public/components/layer_addpanel/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ import {

export class AddLayerPanel extends Component {

constructor() {
super();

this.state = {
sourceType: null,
};
state = {
sourceType: null,
}

_previewLayer = (source) => {
Expand Down Expand Up @@ -107,7 +103,8 @@ export class AddLayerPanel extends Component {

_renderSourceEditor() {
const editorProperties = {
onPreviewSource: this._previewLayer
onPreviewSource: this._previewLayer,
inspectorAdapters: this.props.inspectorAdapters,
};

const Source = ALL_SOURCES.find((Source) => {
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/maps/public/components/map/mb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import {
setLayerErrorStatus,
} from '../../../actions/store_actions';
import { getLayerList, getMapReady, getGoto } from '../../../selectors/map_selectors';
import { getInspectorAdapters } from '../../../store/non_serializable_instances';

function mapStateToProps(state = {}) {
return {
isMapReady: getMapReady(state),
layerList: getLayerList(state),
goto: getGoto(state)
goto: getGoto(state),
inspectorAdapters: getInspectorAdapters(state),
};
}

Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/maps/public/components/map/mb/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import _ from 'lodash';
import React from 'react';
import { ResizeChecker } from 'ui/resize_checker';
import { syncLayerOrder, removeOrphanedSourcesAndLayers, createMbMapInstance } from './utils';
import { inspectorAdapters } from '../../../kibana_services';
import { DECIMAL_DEGREES_PRECISION, ZOOM_PRECISION } from '../../../../common/constants';
import mapboxgl from 'mapbox-gl';

Expand Down Expand Up @@ -217,7 +216,7 @@ export class MBMapContainer extends React.Component {
};

_syncMbMapWithInspector = () => {
if (!this.props.isMapReady || !inspectorAdapters.map) {
if (!this.props.isMapReady || !this.props.inspectorAdapters.map) {
return;
}

Expand All @@ -226,7 +225,7 @@ export class MBMapContainer extends React.Component {
zoom: this._mbMap.getZoom(),

};
inspectorAdapters.map.setMapState({
this.props.inspectorAdapters.map.setMapState({
stats,
style: this._mbMap.getStyle(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import {

export class AttributionControl extends React.Component {

constructor() {
super();
this.state = {
uniqueAttributions: []
};
state = {
uniqueAttributions: []
}

componentDidMount() {
Expand Down
12 changes: 1 addition & 11 deletions x-pack/plugins/maps/public/kibana_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import chrome from 'ui/chrome';
import { uiModules } from 'ui/modules';
import { SearchSourceProvider } from 'ui/courier';
import { RequestAdapter } from 'ui/inspector/adapters';
import { MapAdapter } from './inspector/adapters/map_adapter';
import { timefilter } from 'ui/timefilter/timefilter';
import { getRequestInspectorStats, getResponseInspectorStats } from 'ui/courier/utils/courier_inspector_utils';

Expand All @@ -17,14 +14,7 @@ export let indexPatternService;
export let SearchSource;
export let emsServiceSettings;

export const inspectorAdapters = {
requests: new RequestAdapter(),
};
if (chrome.getInjected('showMapsInspectorAdapter', false)) {
inspectorAdapters.map = new MapAdapter();
}

export async function fetchSearchSourceAndRecordWithInspector({ searchSource, requestId, requestName, requestDesc }) {
export async function fetchSearchSourceAndRecordWithInspector({ searchSource, requestId, requestName, requestDesc, inspectorAdapters }) {
const inspectorRequest = inspectorAdapters.requests.start(
requestName,
{ id: requestId, description: requestDesc });
Expand Down
15 changes: 8 additions & 7 deletions x-pack/plugins/maps/public/selectors/map_selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { VectorStyle } from '../shared/layers/styles/vector_style';
import { HeatmapStyle } from '../shared/layers/styles/heatmap_style';
import { TileStyle } from '../shared/layers/styles/tile_style';
import { timefilter } from 'ui/timefilter';

import { getInspectorAdapters } from '../store/non_serializable_instances';
import { copyPersistentState, TRACKED_LAYER_DESCRIPTOR } from '../store/util';

function createLayerInstance(layerDescriptor) {
const source = createSourceInstance(layerDescriptor.sourceDescriptor);
function createLayerInstance(layerDescriptor, inspectorAdapters) {
const source = createSourceInstance(layerDescriptor.sourceDescriptor, inspectorAdapters);
const style = createStyleInstance(layerDescriptor.style);
switch (layerDescriptor.type) {
case TileLayer.type:
Expand All @@ -32,14 +32,14 @@ function createLayerInstance(layerDescriptor) {
}
}

function createSourceInstance(sourceDescriptor) {
function createSourceInstance(sourceDescriptor, inspectorAdapters) {
const Source = ALL_SOURCES.find(Source => {
return Source.type === sourceDescriptor.type;
});
if (!Source) {
throw new Error(`Unrecognized sourceType ${sourceDescriptor.type}`);
}
return new Source(sourceDescriptor);
return new Source(sourceDescriptor, inspectorAdapters);
}


Expand Down Expand Up @@ -131,9 +131,10 @@ export const getDataFilters = createSelector(

export const getLayerList = createSelector(
getLayerListRaw,
(layerDescriptorList) => {
getInspectorAdapters,
(layerDescriptorList, inspectorAdapters) => {
return layerDescriptorList.map(layerDescriptor =>
createLayerInstance(layerDescriptor));
createLayerInstance(layerDescriptor, inspectorAdapters));
});

export const getSelectedLayer = createSelector(
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/maps/public/selectors/map_selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

jest.mock('../shared/layers/vector_layer', () => {});
jest.mock('../shared/layers/sources/all_sources', () => {});
jest.mock('../store/non_serializable_instances', () => ({
getInspectorAdapters: () => {
return {};
}
}));
jest.mock('ui/timefilter', () => ({
timefilter: {
getTime: () => {
Expand Down
24 changes: 10 additions & 14 deletions x-pack/plugins/maps/public/shared/components/map_listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,16 @@ export const EMPTY_FILTER = '';

export class MapListing extends React.Component {

constructor(props) {
super(props);

this.state = {
hasInitialFetchReturned: false,
isFetchingItems: false,
showDeleteModal: false,
showLimitError: false,
filter: EMPTY_FILTER,
items: [],
selectedIds: [],
page: 0,
perPage: 20,
};
state = {
hasInitialFetchReturned: false,
isFetchingItems: false,
showDeleteModal: false,
showLimitError: false,
filter: EMPTY_FILTER,
items: [],
selectedIds: [],
page: 0,
perPage: 20,
}

componentWillMount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class LeftInnerJoin {
return JSON.stringify(descriptor);
}

constructor(joinDescriptor) {
constructor(joinDescriptor, inspectorAdapters) {
this._descriptor = joinDescriptor;
this._rightSource = new ESJoinSource(joinDescriptor.right);
this._rightSource = new ESJoinSource(joinDescriptor.right, inspectorAdapters);
}

destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ export class EMSFileSource extends AbstractVectorSource {
};
}

static renderEditor({ onPreviewSource }) {
static renderEditor({ onPreviewSource, inspectorAdapters }) {
const onChange = (selectedId) => {
const emsFileSourceDescriptor = EMSFileSource.createDescriptor(selectedId);
const emsFileSource = new EMSFileSource(emsFileSourceDescriptor);
const emsFileSource = new EMSFileSource(emsFileSourceDescriptor, inspectorAdapters);
onPreviewSource(emsFileSource);
};
return <EMSFileCreateSourceEditor onChange={onChange}/>;
}

constructor(descriptor) {
super(descriptor);
}

async _getEmsVectorFileMeta() {
const emsFiles = await getEmsVectorFilesMeta();
const meta = emsFiles.find((source => source.id === this._descriptor.id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,18 @@ export class EMSTMSSource extends AbstractTMSSource {
};
}

static renderEditor({ onPreviewSource }) {
static renderEditor({ onPreviewSource, inspectorAdapters }) {

const onChange = ({ target }) => {
const selectedId = target.options[target.selectedIndex].value;
const emsTMSSourceDescriptor = EMSTMSSource.createDescriptor(selectedId);
const emsTMSSource = new EMSTMSSource(emsTMSSourceDescriptor);
const emsTMSSource = new EMSTMSSource(emsTMSSourceDescriptor, inspectorAdapters);
onPreviewSource(emsTMSSource);
};

return <EMSTMSCreateSourceEditor onChange={onChange}/>;
}

constructor(descriptor) {
super(descriptor);
}

async getImmutableProperties() {
return [
{ label: 'Data source', value: EMSTMSSource.title },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export class ESGeoGridSource extends AbstractESSource {
};
}

static renderEditor({ onPreviewSource }) {
static renderEditor({ onPreviewSource, inspectorAdapters }) {
const onSelect = (sourceConfig) => {
const sourceDescriptor = ESGeoGridSource.createDescriptor(sourceConfig);
const source = new ESGeoGridSource(sourceDescriptor);
const source = new ESGeoGridSource(sourceDescriptor, inspectorAdapters);
onPreviewSource(source);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { AbstractESSource } from './es_source';
import { Schemas } from 'ui/vis/editors/default/schemas';
import {
fetchSearchSourceAndRecordWithInspector,
inspectorAdapters,
SearchSource,
} from '../../../kibana_services';
import { AggConfigs } from 'ui/vis/agg_configs';
Expand Down Expand Up @@ -74,10 +73,6 @@ export class ESJoinSource extends AbstractESSource {
return false;
}

destroy() {
inspectorAdapters.requests.resetRequest(this._descriptor.id);
}

getIndexPatternIds() {
return [this._descriptor.indexPatternId];
}
Expand Down Expand Up @@ -111,6 +106,7 @@ export class ESJoinSource extends AbstractESSource {
const dsl = aggConfigs.toDsl();
searchSource.setField('aggs', dsl);
resp = await fetchSearchSourceAndRecordWithInspector({
inspectorAdapters: this._inspectorAdapters,
searchSource,
requestName: `${this._descriptor.indexPatternTitle}.${this._descriptor.term}`,
requestId: this._descriptor.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ export class ESSearchSource extends AbstractESSource {
static title = 'Documents';
static description = 'Geospatial data from a Kibana index pattern';

static renderEditor({ onPreviewSource }) {
static renderEditor({ onPreviewSource, inspectorAdapters }) {
const onSelect = (layerConfig) => {
const layerSource = new ESSearchSource({
id: uuid(),
...layerConfig
});
}, inspectorAdapters);
onPreviewSource(layerSource);
};
return (<CreateSourceEditor onSelect={onSelect}/>);
}

constructor(descriptor) {
constructor(descriptor, inspectorAdapters) {
super({
id: descriptor.id,
type: ESSearchSource.type,
Expand All @@ -41,7 +41,7 @@ export class ESSearchSource extends AbstractESSource {
limit: _.get(descriptor, 'limit', DEFAULT_LIMIT),
filterByMapBounds: _.get(descriptor, 'filterByMapBounds', true),
tooltipProperties: _.get(descriptor, 'tooltipProperties', []),
});
}, inspectorAdapters);
}

renderSourceSettingsEditor({ onChange }) {
Expand Down
Loading