mirror of
https://github.com/maputnik/editor.git
synced 2025-12-06 06:10:00 +00:00
Added ability to switch to layer from global error panel.
This commit is contained in:
@@ -732,6 +732,7 @@ export default class App extends React.Component {
|
||||
/> : null
|
||||
|
||||
const bottomPanel = (this.state.errors.length + this.state.infos.length) > 0 ? <MessagePanel
|
||||
onLayerSelect={this.onLayerSelect}
|
||||
mapStyle={this.state.mapStyle}
|
||||
errors={this.state.errors}
|
||||
infos={this.state.infos}
|
||||
|
||||
@@ -6,6 +6,11 @@ class MessagePanel extends React.Component {
|
||||
errors: PropTypes.array,
|
||||
infos: PropTypes.array,
|
||||
mapStyle: PropTypes.object,
|
||||
onLayerSelect: PropTypes.func,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
onLayerSelect: () => {},
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -14,9 +19,16 @@ class MessagePanel extends React.Component {
|
||||
if (error.parsed && error.parsed.type === "layer") {
|
||||
const {parsed} = error;
|
||||
const {mapStyle} = this.props;
|
||||
const layerId = mapStyle.layers[parsed.data.index].id;
|
||||
content = (
|
||||
<>
|
||||
Layer <span>'{mapStyle.layers[parsed.data.index].id}'</span>: {parsed.data.message}
|
||||
Layer <span>'{layerId}'</span>: {parsed.data.message} —
|
||||
<button
|
||||
className="maputnik-message-panel__switch-button"
|
||||
onClick={() => this.props.onLayerSelect(layerId)}
|
||||
>
|
||||
switch to layer
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,6 +212,12 @@
|
||||
&-error {
|
||||
color: $color-red;
|
||||
}
|
||||
|
||||
&__switch-button {
|
||||
all: unset;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.maputnik-dialog {
|
||||
|
||||
Reference in New Issue
Block a user