Render screenslot when showing legacy layouts and remove concept of preview type
This commit is contained in:
parent
4d7666fea2
commit
5f7940d9a1
|
@ -42,7 +42,6 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
messagePassing: false,
|
messagePassing: false,
|
||||||
continueIfAction: false,
|
continueIfAction: false,
|
||||||
},
|
},
|
||||||
currentFrontEndType: "none",
|
|
||||||
errors: [],
|
errors: [],
|
||||||
hasAppPackage: false,
|
hasAppPackage: false,
|
||||||
libraries: null,
|
libraries: null,
|
||||||
|
@ -191,7 +190,6 @@ export const getFrontendStore = () => {
|
||||||
screens.find(screen => screen._id === screenId) || screens[0]
|
screens.find(screen => screen._id === screenId) || screens[0]
|
||||||
if (!screen) return state
|
if (!screen) return state
|
||||||
|
|
||||||
state.currentFrontEndType = FrontendTypes.SCREEN
|
|
||||||
state.selectedScreenId = screen._id
|
state.selectedScreenId = screen._id
|
||||||
state.currentView = "detail"
|
state.currentView = "detail"
|
||||||
state.selectedComponentId = screen.props?._id
|
state.selectedComponentId = screen.props?._id
|
||||||
|
@ -287,13 +285,8 @@ export const getFrontendStore = () => {
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
saveSelected: async () => {
|
saveSelected: async () => {
|
||||||
const state = get(store)
|
|
||||||
const selectedAsset = get(currentAsset)
|
const selectedAsset = get(currentAsset)
|
||||||
if (state.currentFrontEndType !== FrontendTypes.LAYOUT) {
|
|
||||||
return await store.actions.screens.save(selectedAsset)
|
return await store.actions.screens.save(selectedAsset)
|
||||||
} else {
|
|
||||||
return await store.actions.layouts.save(selectedAsset)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setDevice: device => {
|
setDevice: device => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
|
@ -308,8 +301,6 @@ export const getFrontendStore = () => {
|
||||||
const layout =
|
const layout =
|
||||||
store.actions.layouts.find(layoutId) || get(store).layouts[0]
|
store.actions.layouts.find(layoutId) || get(store).layouts[0]
|
||||||
if (!layout) return
|
if (!layout) return
|
||||||
state.currentFrontEndType = FrontendTypes.LAYOUT
|
|
||||||
state.currentView = "detail"
|
|
||||||
state.selectedLayoutId = layout._id
|
state.selectedLayoutId = layout._id
|
||||||
state.selectedComponentId = layout.props?._id
|
state.selectedComponentId = layout.props?._id
|
||||||
return state
|
return state
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
import ErrorSVG from "@budibase/frontend-core/assets/error.svg?raw"
|
import ErrorSVG from "@budibase/frontend-core/assets/error.svg?raw"
|
||||||
import { findComponent, findComponentPath } from "builderStore/componentUtils"
|
import { findComponent, findComponentPath } from "builderStore/componentUtils"
|
||||||
import { isActive, goto } from "@roxi/routify"
|
import { isActive, goto } from "@roxi/routify"
|
||||||
|
import { Screen } from "builderStore/store/screenTemplates/utils/Screen"
|
||||||
|
|
||||||
let iframe
|
let iframe
|
||||||
let layout
|
let layout
|
||||||
|
@ -42,14 +43,22 @@
|
||||||
$store.clientLibPath
|
$store.clientLibPath
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const placeholderScreen = new Screen()
|
||||||
|
.name("Screen Placeholder")
|
||||||
|
.route("/")
|
||||||
|
.component("@budibase/standard-components/screenslot")
|
||||||
|
.instanceName("Content Placeholder")
|
||||||
|
.normalStyle({ flex: "1 1 auto" })
|
||||||
|
.json()
|
||||||
|
|
||||||
// Extract data to pass to the iframe
|
// Extract data to pass to the iframe
|
||||||
$: {
|
$: {
|
||||||
screen = $selectedScreen
|
|
||||||
|
|
||||||
// If viewing legacy layouts, always show the custom layout
|
// If viewing legacy layouts, always show the custom layout
|
||||||
if ($isActive("./layouts")) {
|
if ($isActive("./layouts")) {
|
||||||
|
screen = placeholderScreen
|
||||||
layout = $selectedLayout
|
layout = $selectedLayout
|
||||||
} else {
|
} else {
|
||||||
|
screen = $selectedScreen
|
||||||
layout = $store.layouts.find(layout => layout._id === screen?.layoutId)
|
layout = $store.layouts.find(layout => layout._id === screen?.layoutId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +72,6 @@
|
||||||
layout,
|
layout,
|
||||||
screen,
|
screen,
|
||||||
selectedComponentId,
|
selectedComponentId,
|
||||||
previewType: $store.currentFrontEndType,
|
|
||||||
theme: $store.theme,
|
theme: $store.theme,
|
||||||
customTheme: $store.customTheme,
|
customTheme: $store.customTheme,
|
||||||
previewDevice: $store.previewDevice,
|
previewDevice: $store.previewDevice,
|
||||||
|
|
|
@ -61,7 +61,6 @@ export default `
|
||||||
selectedComponentId,
|
selectedComponentId,
|
||||||
layout,
|
layout,
|
||||||
screen,
|
screen,
|
||||||
previewType,
|
|
||||||
appId,
|
appId,
|
||||||
theme,
|
theme,
|
||||||
customTheme,
|
customTheme,
|
||||||
|
@ -76,7 +75,6 @@ export default `
|
||||||
window["##BUDIBASE_PREVIEW_SCREEN##"] = screen
|
window["##BUDIBASE_PREVIEW_SCREEN##"] = screen
|
||||||
window["##BUDIBASE_SELECTED_COMPONENT_ID##"] = selectedComponentId
|
window["##BUDIBASE_SELECTED_COMPONENT_ID##"] = selectedComponentId
|
||||||
window["##BUDIBASE_PREVIEW_ID##"] = Math.random()
|
window["##BUDIBASE_PREVIEW_ID##"] = Math.random()
|
||||||
window["##BUDIBASE_PREVIEW_TYPE##"] = previewType
|
|
||||||
window["##BUDIBASE_PREVIEW_THEME##"] = theme
|
window["##BUDIBASE_PREVIEW_THEME##"] = theme
|
||||||
window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"] = customTheme
|
window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"] = customTheme
|
||||||
window["##BUDIBASE_PREVIEW_DEVICE##"] = previewDevice
|
window["##BUDIBASE_PREVIEW_DEVICE##"] = previewDevice
|
||||||
|
|
|
@ -156,7 +156,7 @@
|
||||||
|
|
||||||
<div id="app-body">
|
<div id="app-body">
|
||||||
<CustomThemeWrapper>
|
<CustomThemeWrapper>
|
||||||
{#key `${$screenStore.activeLayout._id}-${$builderStore.previewType}`}
|
{#key $screenStore.activeLayout._id}
|
||||||
<Component
|
<Component
|
||||||
isLayout
|
isLayout
|
||||||
instance={$screenStore.activeLayout.props}
|
instance={$screenStore.activeLayout.props}
|
||||||
|
|
|
@ -106,9 +106,7 @@
|
||||||
// Interactive components can be selected, dragged and highlighted inside
|
// Interactive components can be selected, dragged and highlighted inside
|
||||||
// the builder preview
|
// the builder preview
|
||||||
$: builderInteractive =
|
$: builderInteractive =
|
||||||
$builderStore.inBuilder &&
|
$builderStore.inBuilder && insideScreenslot && !isBlock
|
||||||
($builderStore.previewType === "layout" || insideScreenslot) &&
|
|
||||||
!isBlock
|
|
||||||
$: devToolsInteractive = $devToolsStore.allowSelection && !isBlock
|
$: devToolsInteractive = $devToolsStore.allowSelection && !isBlock
|
||||||
$: interactive = builderInteractive || devToolsInteractive
|
$: interactive = builderInteractive || devToolsInteractive
|
||||||
$: editing = editable && selected && $builderStore.editMode
|
$: editing = editable && selected && $builderStore.editMode
|
||||||
|
@ -210,7 +208,7 @@
|
||||||
const getComponentConstructor = component => {
|
const getComponentConstructor = component => {
|
||||||
const split = component?.split("/")
|
const split = component?.split("/")
|
||||||
const name = split?.[split.length - 1]
|
const name = split?.[split.length - 1]
|
||||||
if (name === "screenslot" && $builderStore.previewType !== "layout") {
|
if (name === "screenslot" && !insideScreenslot) {
|
||||||
return Router
|
return Router
|
||||||
}
|
}
|
||||||
return AppComponents[name]
|
return AppComponents[name]
|
||||||
|
|
|
@ -15,7 +15,6 @@ const loadBudibase = () => {
|
||||||
screen: window["##BUDIBASE_PREVIEW_SCREEN##"],
|
screen: window["##BUDIBASE_PREVIEW_SCREEN##"],
|
||||||
selectedComponentId: window["##BUDIBASE_SELECTED_COMPONENT_ID##"],
|
selectedComponentId: window["##BUDIBASE_SELECTED_COMPONENT_ID##"],
|
||||||
previewId: window["##BUDIBASE_PREVIEW_ID##"],
|
previewId: window["##BUDIBASE_PREVIEW_ID##"],
|
||||||
previewType: window["##BUDIBASE_PREVIEW_TYPE##"],
|
|
||||||
theme: window["##BUDIBASE_PREVIEW_THEME##"],
|
theme: window["##BUDIBASE_PREVIEW_THEME##"],
|
||||||
customTheme: window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"],
|
customTheme: window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"],
|
||||||
previewDevice: window["##BUDIBASE_PREVIEW_DEVICE##"],
|
previewDevice: window["##BUDIBASE_PREVIEW_DEVICE##"],
|
||||||
|
|
|
@ -13,7 +13,6 @@ const createBuilderStore = () => {
|
||||||
selectedComponentId: null,
|
selectedComponentId: null,
|
||||||
editMode: false,
|
editMode: false,
|
||||||
previewId: null,
|
previewId: null,
|
||||||
previewType: null,
|
|
||||||
selectedPath: [],
|
selectedPath: [],
|
||||||
theme: null,
|
theme: null,
|
||||||
customTheme: null,
|
customTheme: null,
|
||||||
|
|
|
@ -18,9 +18,9 @@ const createComponentStore = () => {
|
||||||
|
|
||||||
// Derive the selected component instance and definition
|
// Derive the selected component instance and definition
|
||||||
let asset
|
let asset
|
||||||
const { layout, screen, previewType, selectedComponentId } = $builderState
|
const { screen, selectedComponentId } = $builderState
|
||||||
if ($builderState.inBuilder) {
|
if ($builderState.inBuilder) {
|
||||||
asset = previewType === "layout" ? layout : screen
|
asset = screen
|
||||||
} else {
|
} else {
|
||||||
asset = $screenState.activeScreen
|
asset = $screenState.activeScreen
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue