From 8d981c8f0b38f5a89f93b4f88130a02d0a03a0eb Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 18 Mar 2022 14:14:22 +0800 Subject: [PATCH] [Status Page] Fix migration and unpin incident --- server/database.js | 28 ++++++++++++++++++++++++---- src/layouts/Layout.vue | 2 +- src/pages/StatusPage.vue | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/server/database.js b/server/database.js index 0a5500ad..7b0b26c3 100644 --- a/server/database.js +++ b/server/database.js @@ -231,15 +231,28 @@ class Database { } let statusPage = R.dispense("status_page"); - statusPage.slug = ""; + statusPage.slug = "default"; statusPage.title = title; statusPage.description = await setting("description"); statusPage.icon = await setting("icon"); statusPage.theme = await setting("statusPageTheme"); - statusPage.published = await setting("statusPagePublished"); - statusPage.search_engine_index = await setting("searchEngineIndex"); - statusPage.show_tags = await setting("statusPageTags"); + statusPage.published = !!await setting("statusPagePublished"); + statusPage.search_engine_index = !!await setting("searchEngineIndex"); + statusPage.show_tags = !!await setting("statusPageTags"); statusPage.password = null; + + if (!statusPage.title) { + statusPage.title = "My Status Page"; + } + + if (!statusPage.icon) { + statusPage.icon = ""; + } + + if (!statusPage.theme) { + statusPage.theme = "light"; + } + let id = await R.store(statusPage); await R.exec("UPDATE incident SET status_page_id = ? WHERE status_page_id IS NULL", [ @@ -252,6 +265,13 @@ class Database { await R.exec("DELETE FROM setting WHERE type = 'statusPage'"); + // Migrate Entry Page if it is status page + let entryPage = await setting("entryPage"); + + if (entryPage === "statusPage") { + await setSetting("entryPage", "statusPage-default", "general"); + } + console.log("Migrating Status Page - Done"); } diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index f1f915a6..07982707 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -18,7 +18,7 @@