1
0
Fork 0

allow designs with no measurements to draft

This commit is contained in:
Enoch Riese 2023-06-28 13:04:45 -05:00
parent 30d75d694d
commit 744b00455d
2 changed files with 9 additions and 3 deletions

View file

@ -80,6 +80,7 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
// protect against loops
if (!mounted) return
setMounted(true)
const [ok, missing] = hasRequiredMeasurements(Design, settings.measurements)
if (ok) setMissingMeasurements(false)
// Force the measurements view if we have missing measurements
@ -117,8 +118,11 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
setControl: controlState.update,
}
// Don't bother without a Design
if (!Design) return <ModalSpinner />
// wait for mount. this helps prevent hydration issues
if (!mounted) return <ModalSpinner />
// Warn that the design is somehow missing
if (!Design) return <ErrorView>{t('workbench.noDesignFound')}</ErrorView>
// Short-circuit errors early
if (error)
@ -163,7 +167,8 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
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
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
if (typeof pattern.getConfig !== 'function') return null

View file

@ -31,3 +31,4 @@ patternInspector: Pattern Inspector
docs: Documentation
configurePattern: Configure pattern
measies: Pattern Measurements
noDesignFound: We could not find this design. This shouldn't happen, so we'd really appreciate you reporting it.