Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: prompt to refresh if versions mismatch (#16230)

p0ny2819dc30153f
diff --git a/frontend/index.html b/frontend/index.html
index e7a66f9d2d..67e723c9d7 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -4,6 +4,9 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/*" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Expires" content="0" />
<title>Bytebase</title>
<meta name="color-scheme" content="light only" />
</head>
diff --git a/frontend/src/components/misc/Version.vue b/frontend/src/components/misc/Version.vue
index 4d1ad8472c..626b040b15 100644
--- a/frontend/src/components/misc/Version.vue
+++ b/frontend/src/components/misc/Version.vue
@@ -139,10 +139,9 @@ const version = computed(() => {
});
const gitCommitBE = computed(() => {
- return `${actuatorStore.gitCommit.substring(0, 7)}`;
+ return `${actuatorStore.gitCommitBE.substring(0, 7)}`;
});
const gitCommitFE = computed(() => {
- const commitHash = import.meta.env.GIT_COMMIT as string | undefined;
- return (commitHash ?? "unknown").substring(0, 7);
+ return `${actuatorStore.gitCommitFE.substring(0, 7)}`;
});
</script>
diff --git a/frontend/src/components/misc/Watermark.vue b/frontend/src/components/misc/Watermark.vue
index aa75752564..ca1bdc607a 100644
--- a/frontend/src/components/misc/Watermark.vue
+++ b/frontend/src/components/misc/Watermark.vue
@@ -44,7 +44,7 @@ const SIZE = 16;
const PADDING = 6;
const currentUserV1 = useCurrentUserV1();
-const version = computed(() => useActuatorV1Store().version + "-" + useActuatorV1Store().gitCommit.substring(0, 7));
+const version = computed(() => useActuatorV1Store().version + "-" + useActuatorV1Store().gitCommitBE.substring(0, 7));
const setting = computed(() =>
useSettingV1Store().getSettingByName("bb.workspace.watermark")
);
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index 34822ee1fd..d38f2d1868 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -138,16 +138,18 @@
<script lang="ts" setup>
import { useMounted, useWindowSize } from "@vueuse/core";
-import { computed, reactive, ref } from "vue";
+import { computed, onMounted, onUnmounted, reactive, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import ReleaseRemindModal from "@/components/ReleaseRemindModal.vue";
import TrialModal from "@/components/TrialModal.vue";
+import { t } from "@/plugins/i18n";
import { WORKSPACE_ROOT_MODULE } from "@/router/dashboard/workspaceRoutes";
import {
useActuatorV1Store,
useAppFeature,
useSubscriptionV1Store,
usePermissionStore,
+ pushNotification,
} from "@/store";
import { PresetRoleType } from "@/types";
import { PlanType } from "@/types/proto/v1/subscription_service";
@@ -159,6 +161,7 @@ interface LocalState {
showMobileOverlay: boolean;
showTrialModal: boolean;
showReleaseModal: boolean;
+ showRefreshRemindModal: boolean;
}
const actuatorStore = useActuatorV1Store();
@@ -172,6 +175,7 @@ const state = reactive<LocalState>({
showMobileOverlay: false,
showTrialModal: false,
showReleaseModal: false,
+ showRefreshRemindModal: false,
});
const mainContainerRef = ref<HTMLDivElement>();
@@ -199,6 +203,42 @@ actuatorStore.tryToRemindRelease().then((openRemindModal) => {
state.showReleaseModal = openRemindModal;
});
+// compare BE and FE commit hash every 30 minutes.
+// if they are different, show the refresh remind modal.
+const refreshRemindTimer = ref<NodeJS.Timeout>();
+onMounted(async () => {
+ const remind = await actuatorStore.tryToRemindRefresh();
+ if (remind) {
+ pushNotification({
+ module: "bytebase",
+ style: "WARN",
+ title: t("refresh-remind.title"),
+ description: t("refresh-remind.description"),
+ manualHide: true,
+ });
+ }
+ refreshRemindTimer.value = setInterval(
+ async () => {
+ const remind = await actuatorStore.tryToRemindRefresh();
+ if (remind) {
+ pushNotification({
+ module: "bytebase",
+ style: "WARN",
+ title: t("refresh-remind.title"),
+ description: t("refresh-remind.description"),
+ manualHide: true,
+ });
+ }
+ },
+ 1000 * 60 * 30
+ );
+});
+onUnmounted(() => {
+ if (refreshRemindTimer.value) {
+ clearInterval(refreshRemindTimer.value);
+ }
+});
+
const { mainContainerClasses } = provideBodyLayoutContext({
mainContainerRef,
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index dd23add4ea..bfcd23da15 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -231,6 +231,10 @@
"error-page": {
"go-back-home": "Go back home"
},
+ "refresh-remind": {
+ "title": "Outdated version detected",
+ "description": "Detect outdated version. Please refresh the page."
+ },
"task": {
"current-task": "Current task",
"checking": "Checking...",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 2833478057..3ccd32c15a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -231,6 +231,10 @@
"error-page": {
"go-back-home": "Volver al inicio"
},
+ "refresh-remind": {
+ "title": "Versión obsoleta detectada",
+ "description": "Se ha detectado una versión obsoleta. Por favor, actualice la página."
+ },
"task": {
"current-task": "Tarea actual",
"checking": "Comprobando...",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index b62f4eaa51..4ba7615309 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -231,6 +231,10 @@
"error-page": {
"go-back-home": "ホームページに戻る"
},
+ "refresh-remind": {
+ "title": "古いバージョンが検出されました",
+ "description": "古いバージョンが検出されました。ページを更新してください。"
+ },
"task": {
"current-task": "現在のタスク",
"checking": "検査中…",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index ec1bf3b102..f38592ca93 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -231,6 +231,10 @@
"error-page": {
"go-back-home": "Về trang chủ"
},
+ "refresh-remind": {
+ "title": "Đã phát hiện phiên bản lỗi thời",
+ "description": "Đã phát hiện phiên bản lỗi thời. Vui lòng làm mới trang."
+ },
"task": {
"current-task": "Nhiệm vụ hiện tại",
"checking": "Đang kiểm tra...",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 9de7d49362..9cc22b6b0a 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -231,6 +231,10 @@
"error-page": {
"go-back-home": "回到主页"
},
+ "refresh-remind": {
+ "title": "检测到过时版本",
+ "description": "检测到过时版本。请刷新页面。"
+ },
"task": {
"current-task": "当前任务",
"checking": "检查中…",
diff --git a/frontend/src/store/modules/v1/actuator.ts b/frontend/src/store/modules/v1/actuator.ts
index 4554d7a5aa..ea53d63a63 100644
--- a/frontend/src/store/modules/v1/actuator.ts
+++ b/frontend/src/store/modules/v1/actuator.ts
@@ -31,6 +31,8 @@ interface ActuatorState {
// Whether the app is initialized or not.
initialized: boolean;
serverInfo?: ActuatorInfo;
+ // Last time when we fetched the server info.
+ serverInfoTs: number;
resourcePackage?: ResourcePackage;
releaseInfo: RemovableRef<ReleaseInfo>;
appProfile: AppProfile;
@@ -44,6 +46,7 @@ export const useActuatorV1Store = defineStore("actuator_v1", {
state: (): ActuatorState => ({
initialized: false,
serverInfo: undefined,
+ serverInfoTs: 0,
resourcePackage: undefined,
releaseInfo: useLocalStorage("bytebase_release", {
ignoreRemindModalTillNextRelease: false,
@@ -79,8 +82,13 @@ export const useActuatorV1Store = defineStore("actuator_v1", {
version: (state) => {
return state.serverInfo?.version || "";
},
- gitCommit: (state) => {
- return state.serverInfo?.gitCommit || "";
+ gitCommitBE: (state) => {
+ const commit = state.serverInfo?.gitCommit ?? "";
+ return commit === "" ? "unknown": commit;
+ },
+ gitCommitFE: () => {
+ const commit = import.meta.env.GIT_COMMIT ?? "";
+ return commit === "" ? "unknown": commit;
},
isDemo: (state) => {
return state.serverInfo?.demo;
@@ -162,6 +170,7 @@ export const useActuatorV1Store = defineStore("actuator_v1", {
},
setServerInfo(serverInfo: ActuatorInfo) {
this.serverInfo = serverInfo;
+ this.serverInfoTs = Date.now();
},
async fetchServerInfo() {
const [serverInfo, resourcePackage] = await Promise.all([
@@ -217,6 +226,16 @@ export const useActuatorV1Store = defineStore("actuator_v1", {
return this.hasNewRelease;
},
+ async tryToRemindRefresh(): Promise<boolean> {
+ // refetch after 30 minutes to keep the info fresh.
+ if (Date.now() - this.serverInfoTs >= 1000 * 60 * 30) {
+ await this.fetchServerInfo();
+ }
+ if (this.gitCommitBE === 'unknown' || this.gitCommitFE === 'unknown') {
+ return false;
+ }
+ return (this.gitCommitBE !== this.gitCommitFE)
+ },
async fetchLatestRelease(): Promise<Release | undefined> {
try {
const { data: releaseList } = await useSilentRequest(() =>