Skip to content

Commit

Permalink
[form-builder] Fix error causing form-builder to fail on patches incl…
Browse files Browse the repository at this point in the history
…uding ifRevisionID (#747)
  • Loading branch information
bjoerge committed Apr 23, 2018
1 parent 8f35178 commit 99b52fe
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ export function toFormBuilder(origin: Origin, patches: GradientPatch[]): Patch[]
return flatten(patches.map(patch => toFormBuilderPatch(origin, patch)))
}

const notIn = values => value => !values.includes(value)

function toFormBuilderPatch(origin: Origin, patch: GradientPatch): Patch {
return flatten(
Object.keys(patch)
.filter(key => key !== 'id')
.filter(notIn(['id', 'ifRevisionID', 'query']))
.map(type => {
if (type === 'unset') {
return patch.unset.map(path => {
Expand Down Expand Up @@ -73,13 +75,6 @@ function toFormBuilderPatch(origin: Origin, patch: GradientPatch): Patch {
origin
}
}
if (type === 'ifRevisionID') {
return {
type: 'ifRevisionID',
value: patch[type],
origin
}
}
console.warn(new Error(`Unsupported patch type: ${type}`))
return null
})
Expand Down

0 comments on commit 99b52fe

Please sign in to comment.