Merge pull request #655 from orangemug/fix/issue-653

Added missing inline error for 'source' field
This commit is contained in:
Orange Mug 2020-04-13 10:57:01 +01:00 committed by GitHub
commit 25322a3952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View file

@ -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;

View file

@ -168,7 +168,7 @@ export default class LayerEditor extends React.Component {
)}
/>
{this.props.layer.type !== 'background' && <LayerSourceBlock
error={errorData.sources}
error={errorData.source}
sourceIds={Object.keys(this.props.sources)}
value={this.props.layer.source}
onChange={v => this.changeProperty(null, 'source', v)}

View file

@ -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 <InputBlock label={"Source"} fieldSpec={latest.layer.source}
return <InputBlock
label={"Source"}
fieldSpec={latest.layer.source}
error={this.props.error}
data-wd-key={this.props.wdKey}
>
<AutocompleteInput