Skip to content

Commit

Permalink
[form-builder] Disable generate slug when no source
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofferjs committed Feb 26, 2018
1 parent 350f804 commit cc92dfb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/@sanity/form-builder/src/inputs/Slug/SlugInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export default withDocument(
const validation = markers.filter(marker => marker.type === 'validation')
const errors = validation.filter(marker => marker.level === 'error')

const source = get(type, 'options.source')

const hasSource = !!(typeof source === 'function' ? source(document) : get(document, source))

return (
<FormField {...formFieldProps}>
<div className={styles.wrapper}>
Expand All @@ -156,7 +160,11 @@ export default withDocument(

<div className={styles.button}>
{hasSourceField && (
<Button disabled={loading} loading={loading} onClick={this.handleGenerateSlug}>
<Button
disabled={loading || !hasSource}
loading={loading}
onClick={this.handleGenerateSlug}
>
Generate slug
</Button>
)}
Expand Down

0 comments on commit cc92dfb

Please sign in to comment.