Skip to content

Commit be28faa

Browse files
authored
Nuxt migration: Fix guided tour and remove TODOs (baserow#4551)
* Fix TODOs * Add TODO MIG to add skeleton loader. Remove unused router.
1 parent 716d43a commit be28faa

File tree

8 files changed

+13
-57
lines changed

8 files changed

+13
-57
lines changed

web-frontend/modules/builder/pageActionTypes.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class PublishPageActionType extends PageActionType {
6767
}
6868

6969
isActive({ workspace, page }) {
70-
if (!page || !workspace) return false // TODO MIG remove this
7170
return this.app.$hasPermission('builder.domain.publish', page, workspace.id)
7271
}
7372

@@ -98,8 +97,6 @@ export class PreviewPageActionType extends PageActionType {
9897
* @param page The Page object.
9998
*/
10099

101-
if (!page || !page.path) return '' // TODO MIG remove this
102-
103100
const toPath = compile(page.path, { encode: encodeURIComponent })
104101
const pageParams = Object.fromEntries(
105102
page.path_params.map(({ name, value }) => [name, page.parameters[name]])
@@ -120,7 +117,6 @@ export class PreviewPageActionType extends PageActionType {
120117
}
121118

122119
isActive({ workspace, page }) {
123-
if (!page || !workspace) return false // TODO MIG remove this
124120
return this.app.$hasPermission('builder.domain.publish', page, workspace.id)
125121
}
126122

web-frontend/modules/builder/pages/pageEditor.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
2-
<div class="page-editor">
2+
<!-- TODO MIG add a skeleton loader while the page is loading. -->
3+
<div v-if="builder && currentPage && sharedPage" class="page-editor">
34
<PageHeader />
45
<div class="layout__col-2-2 page-editor__content">
56
<div :style="{ width: `calc(100% - ${panelWidth}px)` }">
@@ -41,7 +42,6 @@ definePageMeta({
4142
4243
const mode = 'editing'
4344
const route = useRoute()
44-
const router = useRouter()
4545
const { $store, $registry, $i18n } = useNuxtApp()
4646
4747
const panelWidth = ref(360)
@@ -129,7 +129,6 @@ const currentPage = computed(() => pageData.value?.page ?? null)
129129
130130
// Computed properties
131131
const dataSources = computed(() => {
132-
if (!currentPage.value) return []
133132
return $store.getters['dataSource/getPageDataSources'](currentPage.value)
134133
})
135134
@@ -139,7 +138,6 @@ const sharedPage = computed(() => {
139138
})
140139
141140
const sharedDataSources = computed(() => {
142-
if (!sharedPage.value) return []
143141
return $store.getters['dataSource/getPageDataSources'](sharedPage.value)
144142
})
145143
@@ -219,19 +217,16 @@ watch(
219217
220218
// Navigation guards
221219
onBeforeRouteUpdate((to, from) => {
222-
// TODO MIG Somehow this hook is called when we leave the route for another component
223-
// This tests avoid navigation errors.
224-
if (from.params.builderId === undefined) {
225-
return
226-
}
227220
// Unselect previously selected element
228221
const currentBuilder = $store.getters['application/get'](
229222
parseInt(from.params.builderId)
230223
)
231-
$store.dispatch('element/select', {
232-
builder: currentBuilder,
233-
element: null,
234-
})
224+
if (currentBuilder) {
225+
$store.dispatch('element/select', {
226+
builder: currentBuilder,
227+
element: null,
228+
})
229+
}
235230
if (from.params.builderId !== to.params?.builderId) {
236231
// When we switch from one application to another we want to logoff the current user
237232
if (currentBuilder) {

web-frontend/modules/builder/pages/publicPage.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ const { data: asyncDataResult, error } = await useAsyncData(
8080
`publicPage_${requestHostname}_${route.fullPath}`,
8181
async () => {
8282
let mode = 'public'
83-
//const params = route.params
8483
const query = route.query
8584
8685
const builderId = route.params.builderId
@@ -119,13 +118,10 @@ const { data: asyncDataResult, error } = await useAsyncData(
119118
)
120119
}
121120
} catch (e) {
122-
console.log(e)
123-
throw e
124-
// TODO MIG doesn't work
125-
/*throw createError({
121+
throw createError({
126122
statusCode: 404,
127123
statusMessage: $i18n.t('publicPage.siteNotFound'),
128-
})*/
124+
})
129125
}
130126
131127
needPostBuilderLoading = true
@@ -215,7 +211,6 @@ const { data: asyncDataResult, error } = await useAsyncData(
215211
216212
// Handle 404
217213
if (!found) {
218-
// TODO MIG this doesn't work
219214
throw createError({
220215
statusCode: 404,
221216
statusMessage: $i18n.t('publicPage.pageNotFound'),
@@ -226,7 +221,6 @@ const { data: asyncDataResult, error } = await useAsyncData(
226221
// Handle 404
227222
if (pageFound.shared) {
228223
throw createError({
229-
// TODO MIG this doesn't work
230224
statusCode: 404,
231225
statusMessage: $i18n.t('publicPage.pageNotFound'),
232226
})
@@ -404,10 +398,6 @@ const sharedPage = computed(() =>
404398
store.getters['page/getSharedPage'](builder.value)
405399
)
406400
407-
const sharedDataSources = computed(() =>
408-
store.getters['dataSource/getPageDataSources'](sharedPage.value)
409-
)
410-
411401
const sharedElements = computed(() =>
412402
store.getters['element/getRootElements'](sharedPage.value)
413403
)
@@ -443,8 +433,6 @@ const headConfig = computed(() => {
443433
bodyAttrs: {
444434
class: 'public-page',
445435
},
446-
// TODO MIG it shouldn't be necessary anymore but need to check
447-
//__dangerouslyDisableSanitizers: ['style'],
448436
style: [{ children: `:root { ${cssVars} }`, type: 'text/css' }],
449437
}
450438

web-frontend/modules/builder/store/dataSource.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,10 @@ const actions = {
388388

389389
const getters = {
390390
getPageDataSources: (state) => (page) => {
391-
if (!page || !page.dataSources) return [] // TODO MIG: remove this
392391
return page.dataSources
393392
},
394393
getPagesDataSources: (state) => (pages) => {
395-
if (!pages) return [] // TODO MIG: remove this
396-
// TODO MIG: this is a fix for the fact that pages.dataSources is not an array, might not be useful at the.
397-
// Replace it with the original return below
398-
return pages
399-
.filter((page) => page && page.dataSources)
400-
.map(({ dataSources }) => dataSources)
401-
.flat()
402-
// TODO MIG: original return is the following
403-
// return pages.map(({ dataSources }) => dataSources).flat()
394+
return pages.map(({ dataSources }) => dataSources).flat()
404395
},
405396
getPagesDataSourceById: (state, getters) => (pages, id) => {
406397
return getters
@@ -411,7 +402,6 @@ const getters = {
411402
return getters.getPagesDataSourceById([page], id)
412403
},
413404
getLoading: (state) => (page) => {
414-
if (!page || !page._) return false // TODO MIG: remove this
415405
return page._.dataSourceLoading
416406
},
417407
}

web-frontend/modules/builder/store/element.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ const actions = {
504504

505505
const getters = {
506506
getElementById: (state, getters) => (page, id) => {
507-
if (!page || !page.elementMap) return null // TODO MIG remove this
508507
if (id && Object.prototype.hasOwnProperty.call(page.elementMap, `${id}`)) {
509508
return page.elementMap[`${id}`]
510509
}
@@ -520,7 +519,6 @@ const getters = {
520519
return null
521520
},
522521
getElementsOrdered: (state, getters) => (page) => {
523-
if (!page || !page.orderedElements) return [] // TODO MIG remove this
524522
return page.orderedElements
525523
},
526524
getRootElements: (state, getters) => (page) => {

web-frontend/modules/builder/store/page.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ const actions = {
182182

183183
const getters = {
184184
getAllPages: (state) => (builder) => {
185-
if (!builder || !builder.pages) return [] // TODO MIG remove this
186185
return builder.pages
187186
},
188187
getById: (state, getters) => (builder, pageId) => {
@@ -205,9 +204,7 @@ const getters = {
205204
.sort((a, b) => a.order - b.order)
206205
},
207206
getSharedPage: (state, getters) => (builder) => {
208-
return (
209-
getters.getAllPages(builder).find((page) => page.shared === true) || null // TODO MIG remove the || null
210-
)
207+
return getters.getAllPages(builder).find((page) => page.shared === true)
211208
},
212209
getSelected(state) {
213210
return state.selected

web-frontend/modules/core/assets/scss/colors.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,5 @@ $colors: (
240240
'darker-gray': $color-neutral-400,
241241

242242
'deep-dark-green': $color-success-500,
243-
'deep-dark-orange': $color-warning-500
243+
'deep-dark-orange': $color-warning-500,
244244
);

web-frontend/modules/core/plugins/routeMounted.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,5 @@ export default defineNuxtPlugin((nuxtApp) => {
5252
})
5353
}
5454
},
55-
beforeUnmount() {
56-
if (this.$route && this.$route.meta.layout !== undefined) {
57-
this.$store.commit('routeMounted/SET_ROUTE_MOUNTED', {
58-
mounted: false,
59-
route: null,
60-
})
61-
}
62-
},
6355
})
6456
})

0 commit comments

Comments
 (0)