import React from 'react' import PropTypes from 'prop-types' import {formatLayerId} from './util/format'; class MessagePanel extends React.Component { static propTypes = { errors: PropTypes.array, infos: PropTypes.array, mapStyle: PropTypes.object, onLayerSelect: PropTypes.func, currentLayer: PropTypes.object, selectedLayerIndex: PropTypes.number, } static defaultProps = { onLayerSelect: () => {}, } render() { const {selectedLayerIndex} = this.props; const errors = this.props.errors.map((error, idx) => { let content; if (error.parsed && error.parsed.type === "layer") { const {parsed} = error; const {mapStyle, currentLayer} = this.props; const layerId = mapStyle.layers[parsed.data.index].id; content = ( <> Layer {formatLayerId(layerId)}: {parsed.data.message} {selectedLayerIndex !== parsed.data.index && <>  —  } ); } else { content = error.message; } return

{content}

}) const infos = this.props.infos.map((m, i) => { return

{m}

}) return
{errors} {infos}
} } export default MessagePanel