[Maps] show maps webgl error in generated reports (#36133)

* [Maps] show maps webgl error in generated reports

* add data-shared-item prop
This commit is contained in:
Nathan Reese 2019-05-09 11:20:42 -06:00 committed by GitHub
parent a3eaa8fb13
commit c57d7c5892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 15 deletions

View file

@ -59,6 +59,7 @@ export const DRAW_TYPE = {
POLYGON: 'POLYGON'
};
export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM';
export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR';
function getLayerLoadingCallbacks(dispatch, layerId) {
return {
@ -87,6 +88,13 @@ async function syncDataForAllLayers(getState, dispatch, dataFilters) {
await Promise.all(syncs);
}
export function setMapInitError(errorMessage) {
return {
type: SET_MAP_INIT_ERROR,
errorMessage
};
}
export function trackCurrentLayerState(layerId) {
return {
type: TRACK_CURRENT_LAYER_STATE,

View file

@ -8,7 +8,7 @@ import { connect } from 'react-redux';
import { GisMap } from './view';
import { getFlyoutDisplay, getIsFullScreen, exitFullScreen, FLYOUT_STATE } from '../../store/ui';
import { triggerRefreshTimer } from '../../actions/store_actions';
import { getRefreshConfig } from '../../selectors/map_selectors';
import { getRefreshConfig, getMapInitError } from '../../selectors/map_selectors';
function mapStateToProps(state = {}) {
const flyoutDisplay = getFlyoutDisplay(state);
@ -18,6 +18,7 @@ function mapStateToProps(state = {}) {
noFlyoutVisible: flyoutDisplay === FLYOUT_STATE.NONE,
isFullScreen: getIsFullScreen(state),
refreshConfig: getRefreshConfig(state),
mapInitError: getMapInitError(state),
};
}

View file

@ -10,8 +10,9 @@ import { WidgetOverlay } from '../widget_overlay/index';
import { ToolbarOverlay } from '../toolbar_overlay/index';
import { LayerPanel } from '../layer_panel/index';
import { AddLayerPanel } from '../layer_addpanel/index';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiCallOut } from '@elastic/eui';
import { ExitFullScreenButton } from 'ui/exit_full_screen';
import { i18n } from '@kbn/i18n';
export class GisMap extends Component {
@ -63,11 +64,29 @@ export class GisMap extends Component {
noFlyoutVisible,
isFullScreen,
exitFullScreen,
mapInitError,
} = this.props;
if (mapInitError) {
return (
<div data-render-complete data-shared-item>
<EuiCallOut
title={i18n.translate('xpack.maps.map.initializeErrorTitle', {
defaultMessage: 'Unable to initialize map'
})}
color="danger"
iconType="cross"
>
<p>
{mapInitError}
</p>
</EuiCallOut>
</div>
);
}
let currentPanel;
let currentPanelClassName;
if (noFlyoutVisible) {
currentPanel = null;
} else if (addLayerVisible) {

View file

@ -14,6 +14,7 @@ import {
clearMouseCoordinates,
clearGoto,
setTooltipState,
setMapInitError,
updateDrawState
} from '../../../actions/store_actions';
import {
@ -65,6 +66,9 @@ function mapDispatchToProps(dispatch) {
setTooltipState(tooltipState) {
dispatch(setTooltipState(tooltipState));
},
setMapInitError(errorMessage) {
dispatch(setMapInitError(errorMessage));
},
disableDrawState() {
dispatch(updateDrawState(null));
}

View file

@ -250,10 +250,12 @@ export class MBMapContainer extends React.Component {
}
componentDidUpdate() {
// do not debounce syncing of map-state and tooltip
this._syncMbMapWithMapState();
this._syncTooltipState();
this._debouncedSync();
if (this._mbMap) {
// do not debounce syncing of map-state and tooltip
this._syncMbMapWithMapState();
this._syncTooltipState();
this._debouncedSync();
}
}
componentDidMount() {
@ -299,12 +301,16 @@ export class MBMapContainer extends React.Component {
}
async _initializeMap() {
this._mbMap = await createMbMapInstance({
node: this.refs.mapContainer,
initialView: this.props.goto ? this.props.goto.center : null,
scrollZoom: this.props.scrollZoom
});
try {
this._mbMap = await createMbMapInstance({
node: this.refs.mapContainer,
initialView: this.props.goto ? this.props.goto.center : null,
scrollZoom: this.props.scrollZoom
});
} catch(error) {
this.props.setMapInitError(error.message);
return;
}
if (!this._isMounted) {
return;

View file

@ -67,6 +67,8 @@ export const getTooltipState = ({ map }) => {
export const getMapReady = ({ map }) => map && map.ready;
export const getMapInitError = ({ map }) => map.mapInitError;
export const getGoto = ({ map }) => map && map.goto;
export const getSelectedLayerId = ({ map }) => {
@ -150,7 +152,6 @@ export const getDataFilters = createSelector(
}
);
export const getLayerList = createSelector(
getLayerListRaw,
getInspectorAdapters,

View file

@ -38,8 +38,9 @@ import {
REMOVE_TRACKED_LAYER_STATE,
UPDATE_SOURCE_DATA_REQUEST,
SET_TOOLTIP_STATE,
SET_SCROLL_ZOOM,
SET_MAP_INIT_ERROR,
UPDATE_DRAW_STATE,
SET_SCROLL_ZOOM
} from '../actions/store_actions';
import { copyPersistentState, TRACKED_LAYER_DESCRIPTOR } from './util';
@ -87,6 +88,7 @@ const updateLayerSourceDescriptorProp = (state, layerId, propName, value) => {
const INITIAL_STATE = {
ready: false,
mapInitError: null,
goto: null,
tooltipState: null,
mapState: {
@ -317,6 +319,11 @@ export function map(state = INITIAL_STATE, action) {
scrollZoom: action.scrollZoom,
}
};
case SET_MAP_INIT_ERROR:
return {
...state,
mapInitError: action.errorMessage
};
default:
return state;
}