mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-08 22:48:14 -05:00
Added support for disabled blocks, throw warning at runtime
This commit is contained in:
@@ -320,7 +320,7 @@ export class Executor {
|
||||
const path = match.slice(1, -1) // remove < and >
|
||||
const [blockRef, ...pathParts] = path.split('.')
|
||||
|
||||
// Try blockRef as ID, then as normalized name
|
||||
// Try referencing as an ID, then as a normalized name.
|
||||
let sourceBlock = blockById.get(blockRef)
|
||||
if (!sourceBlock) {
|
||||
const normalized = blockRef.toLowerCase().replace(/\s+/g, '')
|
||||
@@ -332,6 +332,12 @@ export class Executor {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if the referenced block is disabled.
|
||||
if (sourceBlock.enabled === false) {
|
||||
console.warn(`Block "${sourceBlock.metadata?.title}" is disabled, and block "${block.metadata?.title}" depends on it.`)
|
||||
continue
|
||||
}
|
||||
|
||||
const sourceState = context.blockStates.get(sourceBlock.id)
|
||||
if (!sourceState) {
|
||||
console.warn(`No state found for block ID "${sourceBlock.id}".`)
|
||||
|
||||
@@ -53,7 +53,8 @@ export class Serializer {
|
||||
description: blockConfig.toolbar.description,
|
||||
category: blockConfig.toolbar.category,
|
||||
color: blockConfig.toolbar.bgColor
|
||||
}
|
||||
},
|
||||
enabled: block.enabled
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,4 +30,5 @@ export interface SerializedBlock {
|
||||
icon?: string
|
||||
color?: string
|
||||
}
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user