allow designs with no measurements to draft
This commit is contained in:
parent
30d75d694d
commit
744b00455d
2 changed files with 9 additions and 3 deletions
|
@ -80,6 +80,7 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
|
||||||
// protect against loops
|
// protect against loops
|
||||||
if (!mounted) return
|
if (!mounted) return
|
||||||
|
|
||||||
|
setMounted(true)
|
||||||
const [ok, missing] = hasRequiredMeasurements(Design, settings.measurements)
|
const [ok, missing] = hasRequiredMeasurements(Design, settings.measurements)
|
||||||
if (ok) setMissingMeasurements(false)
|
if (ok) setMissingMeasurements(false)
|
||||||
// Force the measurements view if we have missing measurements
|
// Force the measurements view if we have missing measurements
|
||||||
|
@ -117,8 +118,11 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
|
||||||
setControl: controlState.update,
|
setControl: controlState.update,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't bother without a Design
|
// wait for mount. this helps prevent hydration issues
|
||||||
if (!Design) return <ModalSpinner />
|
if (!mounted) return <ModalSpinner />
|
||||||
|
|
||||||
|
// Warn that the design is somehow missing
|
||||||
|
if (!Design) return <ErrorView>{t('workbench.noDesignFound')}</ErrorView>
|
||||||
|
|
||||||
// Short-circuit errors early
|
// Short-circuit errors early
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -163,7 +167,8 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
|
||||||
const layout = ui.layouts?.[view] || settings.layout || true
|
const layout = ui.layouts?.[view] || settings.layout || true
|
||||||
// Generate the pattern here so we can pass it down to both the view and the options menu
|
// Generate the pattern here so we can pass it down to both the view and the options menu
|
||||||
const pattern =
|
const pattern =
|
||||||
settings.measurements !== undefined && new Design({ layout, embed: true, ...settings })
|
(Design.patternConfig.measurements.length === 0 || settings.measurements !== undefined) &&
|
||||||
|
new Design({ layout, embed: true, ...settings })
|
||||||
|
|
||||||
// Return early if the pattern is not initialized yet
|
// Return early if the pattern is not initialized yet
|
||||||
if (typeof pattern.getConfig !== 'function') return null
|
if (typeof pattern.getConfig !== 'function') return null
|
||||||
|
|
|
@ -31,3 +31,4 @@ patternInspector: Pattern Inspector
|
||||||
docs: Documentation
|
docs: Documentation
|
||||||
configurePattern: Configure pattern
|
configurePattern: Configure pattern
|
||||||
measies: Pattern Measurements
|
measies: Pattern Measurements
|
||||||
|
noDesignFound: We could not find this design. This shouldn't happen, so we'd really appreciate you reporting it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue