mirror of
https://github.com/maputnik/editor.git
synced 2025-12-25 07:30:00 +00:00
Only show 'switch to layer' button if layer not already selected.
This commit is contained in:
@@ -7,6 +7,7 @@ class MessagePanel extends React.Component {
|
||||
infos: PropTypes.array,
|
||||
mapStyle: PropTypes.object,
|
||||
onLayerSelect: PropTypes.func,
|
||||
currentLayer: PropTypes.object,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
@@ -18,17 +19,22 @@ class MessagePanel extends React.Component {
|
||||
let content;
|
||||
if (error.parsed && error.parsed.type === "layer") {
|
||||
const {parsed} = error;
|
||||
const {mapStyle} = this.props;
|
||||
const {mapStyle, currentLayer} = this.props;
|
||||
const layerId = mapStyle.layers[parsed.data.index].id;
|
||||
content = (
|
||||
<>
|
||||
Layer <span>'{layerId}'</span>: {parsed.data.message} —
|
||||
<button
|
||||
className="maputnik-message-panel__switch-button"
|
||||
onClick={() => this.props.onLayerSelect(layerId)}
|
||||
>
|
||||
switch to layer
|
||||
</button>
|
||||
Layer <span>'{layerId}'</span>: {parsed.data.message}
|
||||
{currentLayer.id !== layerId &&
|
||||
<>
|
||||
—
|
||||
<button
|
||||
className="maputnik-message-panel__switch-button"
|
||||
onClick={() => this.props.onLayerSelect(layerId)}
|
||||
>
|
||||
switch to layer
|
||||
</button>
|
||||
</>
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user