From 090a26bb406f5f3200cb4ec456b6413e67b4905b Mon Sep 17 00:00:00 2001 From: orangemug Date: Mon, 13 Apr 2020 09:10:30 +0100 Subject: [PATCH] Added missing inline error for 'source' field. --- src/components/App.jsx | 19 ++++++++++++++++++- src/components/layers/LayerEditor.jsx | 2 +- src/components/layers/LayerSourceBlock.jsx | 6 +++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index 690c46e..02b2212 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -345,6 +345,7 @@ export default class App extends React.Component { } const mappedErrors = layerErrors.concat(errors).map(error => { + // Special case: Duplicate layer id const dupMatch = error.message.match(/layers\[(\d+)\]: (duplicate layer id "?(.*)"?, previously used)/); if (dupMatch) { const [matchStr, index, message] = dupMatch; @@ -361,7 +362,23 @@ export default class App extends React.Component { } } - // duplicate layer id + // Special case: Invalid source + const invalidSourceMatch = error.message.match(/layers\[(\d+)\]: (source "(?:.*)" not found)/); + if (invalidSourceMatch) { + const [matchStr, index, message] = invalidSourceMatch; + return { + message: error.message, + parsed: { + type: "layer", + data: { + index: parseInt(index, 10), + key: "source", + message, + } + } + } + } + const layerMatch = error.message.match(/layers\[(\d+)\]\.(?:(\S+)\.)?(\S+): (.*)/); if (layerMatch) { const [matchStr, index, group, property, message] = layerMatch; diff --git a/src/components/layers/LayerEditor.jsx b/src/components/layers/LayerEditor.jsx index 7ee3ff4..ac9bd97 100644 --- a/src/components/layers/LayerEditor.jsx +++ b/src/components/layers/LayerEditor.jsx @@ -168,7 +168,7 @@ export default class LayerEditor extends React.Component { )} /> {this.props.layer.type !== 'background' && this.changeProperty(null, 'source', v)} diff --git a/src/components/layers/LayerSourceBlock.jsx b/src/components/layers/LayerSourceBlock.jsx index 7147735..b40053e 100644 --- a/src/components/layers/LayerSourceBlock.jsx +++ b/src/components/layers/LayerSourceBlock.jsx @@ -11,6 +11,7 @@ class LayerSourceBlock extends React.Component { wdKey: PropTypes.string, onChange: PropTypes.func, sourceIds: PropTypes.array, + error: PropTypes.object, } static defaultProps = { @@ -19,7 +20,10 @@ class LayerSourceBlock extends React.Component { } render() { - return