From 8d8ec91be8d054fb429d744d01dbfe6a92079eed Mon Sep 17 00:00:00 2001
From: FlaminWrap <97764630+FlaminWrap@users.noreply.github.com>
Date: Mon, 23 Jan 2023 23:24:44 +0000
Subject: [PATCH] Resolve merge problems (#9420)
---
.../builder/portal/settings/version.svelte | 61 ++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)
diff --git a/packages/builder/src/pages/builder/portal/settings/version.svelte b/packages/builder/src/pages/builder/portal/settings/version.svelte
index 694475edcc..c9b2f618e3 100644
--- a/packages/builder/src/pages/builder/portal/settings/version.svelte
+++ b/packages/builder/src/pages/builder/portal/settings/version.svelte
@@ -8,6 +8,8 @@
Divider,
notifications,
Label,
+ Modal,
+ ModalContent,
} from "@budibase/bbui"
import { API } from "api"
import { auth, admin } from "stores/portal"
@@ -15,6 +17,11 @@
let version
let loaded = false
+ let githubVersion
+ let githubPublishedDate
+ let githubPublishedTime
+ let needsUpdate = true
+ let updateModal
// Only admins allowed here
$: {
@@ -47,8 +54,37 @@
}
}
+ async function getLatestVersion() {
+ try {
+ //Check github API for the latest release
+ const githubCheck = await fetch(
+ "https://api.github.com/repos/Budibase/budibase/releases/latest"
+ )
+ const githubResponse = await githubCheck.json()
+
+ //Get tag and remove the v infront of the tage name e.g. v1.0.0 is 1.0.0
+ githubVersion = githubResponse.tag_name.slice(1)
+
+ //Get the release date and output it in the local time format
+ githubPublishedDate = new Date(githubResponse.published_at)
+ githubPublishedTime = githubPublishedDate.toLocaleTimeString()
+ githubPublishedDate = githubPublishedDate.toLocaleDateString()
+
+ //Does Budibase need to be updated?
+ if (githubVersion === version) {
+ needsUpdate = false
+ } else {
+ needsUpdate = true
+ }
+ } catch (error) {
+ notifications.error("Error getting the latest Budibase version")
+ githubVersion = null
+ }
+ }
+
onMount(async () => {
await getVersion()
+ await getLatestVersion()
loaded = true
})
@@ -69,9 +105,32 @@