11<template >
2- <!-- TODO MIG add a skeleton loader while the page is loading. -->
3- <div v-if =" builder && currentPage && sharedPage" class =" page-editor" >
4- <PageHeader />
5- <div class =" layout__col-2-2 page-editor__content" >
6- <div :style =" { width: `calc(100% - ${panelWidth}px)` }" >
7- <PagePreview />
8- </div >
9- <div
10- class =" page-editor__side-panel"
11- :style =" { width: `${panelWidth}px` }"
12- >
13- <PageSidePanels />
14- </div >
15- </div >
16- </div >
2+ <PageEditorContent
3+ v-if =" !pending"
4+ :workspace =" workspace"
5+ :builder =" builder"
6+ :page =" currentPage"
7+ />
178</template >
189
1910<script setup>
2011import { useHead , useAsyncData } from ' #imports'
21- import { ref , computed , watch , provide } from ' vue'
12+ import { computed } from ' vue'
2213import { onBeforeRouteUpdate , onBeforeRouteLeave } from ' vue-router'
2314import { StoreItemLookupError } from ' @baserow/modules/core/errors'
24- import PageHeader from ' @baserow/modules/builder/components/page/header/PageHeader'
25- import PagePreview from ' @baserow/modules/builder/components/page/PagePreview'
26- import PageSidePanels from ' @baserow/modules/builder/components/page/PageSidePanels'
2715import { DataProviderType } from ' @baserow/modules/core/dataProviderTypes'
2816import { BuilderApplicationType } from ' @baserow/modules/builder/applicationTypes'
29- import ApplicationBuilderFormulaInput from ' @baserow/modules/builder/components/ApplicationBuilderFormulaInput'
3017import _ from ' lodash'
18+ import PageEditorContent from ' @baserow/modules/builder/components/PageEditorContent.vue'
3119
3220definePageMeta ({
3321 layout: ' app' ,
@@ -45,21 +33,16 @@ const route = useRoute()
4533const { t } = useI18n ()
4634const { $store , $registry , $i18n } = useNuxtApp ()
4735
48- const panelWidth = ref (360 )
49-
50- // Provide values for child components
51- const applicationContext = computed (() => ({
52- workspace: workspace .value ,
53- builder: builder .value ,
54- mode,
55- }))
56-
5736useHead (() => ({
5837 title: t (' pageEditor.title' ),
5938}))
6039
6140// Load page data
62- const { data: pageData , error: pageError } = await useAsyncData (
41+ const {
42+ data: pageData ,
43+ error: pageError ,
44+ pending ,
45+ } = await useAsyncData (
6346 () => ` page-editor-${ route .params .builderId } -${ route .params .pageId } ` ,
6447 async () => {
6548 // The objects are selected by the middleware
@@ -122,98 +105,16 @@ const { data: pageData, error: pageError } = await useAsyncData(
122105
123106if (pageError .value ) {
124107 // If we have an error we want to display it.
125- throw pageError .value
108+ if (pageError .value .statusCode === 404 ) {
109+ showError (pageError .value )
110+ } else {
111+ throw pageError .value
112+ }
126113}
127114
128- const workspace = computed (() => pageData .value ? .workspace ?? null )
129- const builder = computed (() => pageData .value ? .builder ?? null )
130- const currentPage = computed (() => pageData .value ? .page ?? null )
131- const sharedPage = computed (() => pageData .value ? .sharedPage ?? null )
132-
133- // Computed properties
134- const dataSources = computed (() => {
135- if (! currentPage .value ) return []
136- return $store .getters [' dataSource/getPageDataSources' ](currentPage .value )
137- })
138-
139- const sharedDataSources = computed (() => {
140- if (! sharedPage .value ) return []
141- return $store .getters [' dataSource/getPageDataSources' ](sharedPage .value )
142- })
143-
144- const dispatchContext = computed (() => {
145- if (! currentPage .value || ! applicationContext .value ) return {}
146- return DataProviderType .getAllDataSourceDispatchContext (
147- $registry .getAll (' builderDataProvider' ),
148- { ... applicationContext .value , page: currentPage .value }
149- )
150- })
151-
152- const applicationDispatchContext = computed (() => {
153- if (! builder .value ) return {}
154- return DataProviderType .getAllDataSourceDispatchContext (
155- $registry .getAll (' builderDataProvider' ),
156- { builder: builder .value , mode }
157- )
158- })
159-
160- provide (' workspace' , workspace)
161- provide (' builder' , builder)
162- provide (' currentPage' , currentPage)
163- provide (' mode' , mode)
164- provide (' formulaComponent' , ApplicationBuilderFormulaInput)
165- provide (' applicationContext' , applicationContext)
166-
167- // Watchers
168- watch (
169- dataSources,
170- () => {
171- $store .dispatch (' dataSourceContent/debouncedFetchPageDataSourceContent' , {
172- page: currentPage .value ,
173- data: dispatchContext .value ,
174- mode,
175- })
176- },
177- { deep: true }
178- )
179-
180- watch (
181- sharedDataSources,
182- () => {
183- $store .dispatch (' dataSourceContent/debouncedFetchPageDataSourceContent' , {
184- page: sharedPage .value ,
185- data: dispatchContext .value ,
186- })
187- },
188- { deep: true }
189- )
190-
191- watch (
192- dispatchContext,
193- (newDispatchContext , oldDispatchContext ) => {
194- if (! _ .isEqual (newDispatchContext, oldDispatchContext)) {
195- $store .dispatch (' dataSourceContent/debouncedFetchPageDataSourceContent' , {
196- page: currentPage .value ,
197- data: newDispatchContext,
198- mode,
199- })
200- }
201- },
202- { deep: true }
203- )
204-
205- watch (
206- applicationDispatchContext,
207- (newDispatchContext , oldDispatchContext ) => {
208- if (! _ .isEqual (newDispatchContext, oldDispatchContext)) {
209- $store .dispatch (' dataSourceContent/debouncedFetchPageDataSourceContent' , {
210- page: sharedPage .value ,
211- data: newDispatchContext,
212- })
213- }
214- },
215- { deep: true }
216- )
115+ const workspace = computed (() => pageData .value .workspace )
116+ const builder = computed (() => pageData .value .builder )
117+ const currentPage = computed (() => pageData .value .page )
217118
218119// Navigation guards
219120onBeforeRouteUpdate ((to , from ) => {
0 commit comments