Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/AppComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const props = defineProps<{
const componentName = computed(() => {
if (props.block.isContainer()) return props.block.originalElement || "div"
let name = props.block.componentName
if (props.block.isCustomVueComponent) {
if (window.is_preview && props.block.isCustomVueComponent) {
name = customVueComponentsRegistry.value[name]
if (!name) return h(MissingComponent, { componentName: props.block.componentName })
}
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ app.use(spritePlugin)
registerGlobalComponents(app)
window.__APP_COMPONENTS__ = app._context.components

declare global {
interface Window {
is_developer_mode?: boolean
is_preview?: boolean
__APP_COMPONENTS__: any
[key: string]: string
}
}

if (window.is_preview && typeof window.is_preview === "string") {
window.is_preview = window.is_preview === "1" || window.is_preview === "True"
}

const frappeApp = (window as any).frappe_app
if (frappeApp) {
registerCustomVueComponents(frappeApp).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
"./node_modules/frappe-ui/frappe/**/*.{vue,js,ts,jsx,tsx}",
"../node_modules/frappe-ui/frappe/**/*.{vue,js,ts,jsx,tsx}",
"../../*/studio/**/*.{vue,js,ts,jsx,tsx}",
"!../../**/node_modules/**",
"!../../*/studio/**/node_modules/**",
],
theme: {
extend: {},
Expand Down
17 changes: 7 additions & 10 deletions studio/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,12 @@ def _add_custom_vue_component(self, componentName: str):
break


def build_standard_apps(app: str | None = None) -> None:
"""Scan all apps on the bench for studio/ folders and build each exported app.
def build_standard_apps(apps: list[str] | None = None) -> None:
"""Scan passed apps on the bench for studio/ folders and build each exported app.

This function works without DB access — it reads component data from
exported JSON files on disk.

Args:
app: Only build studio apps exported to this specific frappe app
"""
apps = [app] if app else frappe.get_all_apps()

for frappe_app in apps:
studio_folder = get_studio_folder(frappe_app)
if not os.path.exists(studio_folder):
Expand Down Expand Up @@ -272,7 +267,9 @@ def get_studio_folder(frappe_app: str) -> str | None:
return frappe.get_app_source_path(frappe_app, "studio")


def after_build() -> None:
"""Hook called after `bench build`. Builds all standard studio apps"""
def after_app_build(built_apps: list[str]) -> None:
"""Hook called after any app is built. Builds studio apps for the built apps."""
if not built_apps:
return
click.secho("\nBuilding Studio Apps...", fg="cyan")
build_standard_apps()
build_standard_apps(built_apps)
2 changes: 1 addition & 1 deletion studio/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
# before_install = "studio.install.before_install"
# after_install = "studio.install.after_install"
after_migrate = "studio.sync.after_migrate"
after_build = "studio.build.after_build"
after_app_build = "studio.build.after_app_build"

# Uninstallation
# ------------
Expand Down
Loading