Skip to content

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

chore: add tooltip for backup switch (#13585)

boojack8160d74999db
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSwitch.vue b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
index 3bf15bf7ff..e8927ebe04 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSwitch.vue
@@ -1,27 +1,70 @@
<template>
<div class="flex items-center">
- <NSwitch
- :value="preBackupEnabled"
- class="bb-pre-backup-switch"
- :disabled="!allowPreBackup"
- @update:value="togglePreBackup"
- >
- <template #checked>
- <span style="font-size: 10px">{{ $t("common.on") }}</span>
+ <NTooltip :disabled="!disallowPreBackupMessage">
+ <template #trigger>
+ <NSwitch
+ :value="preBackupEnabled"
+ class="bb-pre-backup-switch"
+ :disabled="!allowPreBackup"
+ @update:value="togglePreBackup"
+ >
+ <template #checked>
+ <span style="font-size: 10px">{{ $t("common.on") }}</span>
+ </template>
+ <template #unchecked>
+ <span style="font-size: 10px">{{ $t("common.off") }}</span>
+ </template>
+ </NSwitch>
</template>
- <template #unchecked>
- <span style="font-size: 10px">{{ $t("common.off") }}</span>
+ <template #default>
+ {{ disallowPreBackupMessage }}
+ <LearnMoreLink
+ v-if="disallowPreBackupLink"
+ :url="disallowPreBackupLink"
+ color="light"
+ class="ml-1 text-sm"
+ />
</template>
- </NSwitch>
+ </NTooltip>
</div>
</template>
<script lang="ts" setup>
-import { NSwitch } from "naive-ui";
+import { NSwitch, NTooltip } from "naive-ui";
+import { computed } from "vue";
+import { useI18n } from "vue-i18n";
+import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import LearnMoreLink from "@/components/LearnMoreLink.vue";
import { usePreBackupContext } from "./common";
+const { t } = useI18n();
+const { issue, selectedTask } = useIssueContext();
const { preBackupEnabled, allowPreBackup, togglePreBackup } =
usePreBackupContext();
+
+const database = computed(() =>
+ databaseForTask(issue.value, selectedTask.value)
+);
+
+const disallowPreBackupMessage = computed(() => {
+ if (allowPreBackup.value) {
+ return undefined;
+ }
+ if (!database.value.backupAvailable) {
+ return t("database.create-target-database-or-schema-for-backup");
+ }
+ return undefined;
+});
+
+const disallowPreBackupLink = computed(() => {
+ if (allowPreBackup.value) {
+ return undefined;
+ }
+ if (!database.value.backupAvailable) {
+ return "https://www.bytebase.com/docs/change-database/rollback-data-changes?source=console";
+ }
+ return undefined;
+});
</script>
<style>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
index ac6f6832cf..9ece03c384 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
@@ -66,7 +66,12 @@ export const usePreBackupContext = () => {
});
const allowPreBackup = computed((): boolean => {
- // Always allow pre-backup when creating.
+ // Disallow pre-backup if no backup available for the target database.
+ if (!database.value.backupAvailable) {
+ return false;
+ }
+
+ // Allow toggle pre-backup when creating.
if (isCreating.value) {
return true;
}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 8ddc665436..71408e317b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1771,22 +1771,6 @@
"row-count-est": "Row count est.",
"incorrect-project-warning": "SQL editor can only query databases in projects available to the user. You should first transfer this database into a project.",
"go-to-transfer": "Go to transfer",
- "pitr": {
- "restore": "@:common.restore @:common.database",
- "no-available-backup": "No available backup",
- "point-in-time": "Point in time",
- "help-info": "Restore the database state to a point in time. {link}.",
- "minimum-supported-engine-and-version": "{engine} >= {min_version} required",
- "restore-to-point-in-time": "Restore to point in time",
- "no-earlier-than": "Restore point-in-time cannot be earlier than [{earliest}] (the earliest available backup).",
- "no-later-than-now": "Restore point-in-time cannot be later than now.",
- "will-overwrite-current-database": "Will overwrite current database",
- "restore-before-last-migration": "Restore to the point before last migration",
- "restore-before-last-migration-help-info": "@:{'database.pitr.restore-before-last-migration'}. {link}.",
- "restore-to": "Restore",
- "restore-to-new-db": "To new database",
- "restore-to-in-place": "In place"
- },
"show-reserved-tables": "Show Bytebase reserved tables",
"show-reserved-databases": "Show Bytebase reserved databases",
"synced-at": "Synced at {time}",
@@ -1896,7 +1880,8 @@
"foreign-keys": "Foreign keys",
"foreign-key": {
"reference": "Reference"
- }
+ },
+ "create-target-database-or-schema-for-backup": "Please create the target database or schema for the backup first"
},
"repository": {
"our-webhook-link": "The webhook created by Bytebase can be found at {webhookLink}.",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index f0c506abb3..021ac2e68c 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1771,22 +1771,6 @@
"row-count-est": "Cantidad est. de filas",
"incorrect-project-warning": "El editor de SQL solo puede consultar bases de datos en proyectos disponibles para el usuario. Primero debe transferir esta base de datos a un proyecto.",
"go-to-transfer": "Ir a transferir",
- "pitr": {
- "restore": "@:common.restore @:common.database",
- "no-available-backup": "No hay copia de seguridad disponible",
- "point-in-time": "Punto en el tiempo",
- "help-info": "Restaurar el estado de la base de datos a un punto en el tiempo. {link}.",
- "minimum-supported-engine-and-version": "Se requiere {engine} >= {min_version}",
- "restore-to-point-in-time": "Restaurar a un punto en el tiempo",
- "no-earlier-than": "El punto de restauración no puede ser anterior a [{earliest}] (la copia de seguridad más antigua disponible).",
- "no-later-than-now": "El punto de restauración no puede ser posterior a ahora.",
- "will-overwrite-current-database": "Se sobrescribirá la base de datos actual",
- "restore-before-last-migration": "Restaurar al punto antes de la última migración",
- "restore-before-last-migration-help-info": "@:{'database.pitr.restore-before-last-migration'}. {link}.",
- "restore-to": "Restaurar a",
- "restore-to-new-db": "A una nueva base de datos",
- "restore-to-in-place": "En el mismo lugar"
- },
"show-reserved-tables": "Mostrar tablas reservadas de Bytebase",
"show-reserved-databases": "Mostrar bases de datos reservadas de Bytebase",
"synced-at": "Sincronizado en {time}",
@@ -1896,7 +1880,8 @@
"foreign-keys": "claves foráneas",
"foreign-key": {
"reference": "Referencia"
- }
+ },
+ "create-target-database-or-schema-for-backup": "Primero cree la base de datos o el esquema de destino para la copia de seguridad"
},
"repository": {
"our-webhook-link": "El webhook creado por Bytebase se puede encontrar en {webhookLink}.",
@@ -3700,4 +3685,4 @@
"worksheet": {
"self": "Hoja de trabajo"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index e20c8abeda..51b7912217 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1771,22 +1771,6 @@
"row-count-est": "推定行数",
"incorrect-project-warning": "SQL エディターは、ユーザーが使用できるプロジェクト内のデータベースのみをクエリできます。まず、このデータベースを作業中のプロジェクトに転送する必要があります。",
"go-to-transfer": "転送に行く",
- "pitr": {
- "restore": "@:common.restore@:common.database",
- "no-available-backup": "利用可能なバックアップがありません",
- "point-in-time": "時点",
- "help-info": "データベースの状態を特定の時点に復元します。 {link}。",
- "minimum-supported-engine-and-version": "{engine} >= {min_version} が必要です",
- "restore-to-point-in-time": "指定した時点に復元する",
- "no-earlier-than": "[{earliest}] (利用可能な最も古いバックアップ) よりも古い時点から復元することはできません。",
- "no-later-than-now": "回復時刻を現在時刻より遅くすることはできません。",
- "will-overwrite-current-database": "既存のデータベースを上書きします",
- "restore-before-last-migration": "最後の変更前の履歴に戻す",
- "restore-before-last-migration-help-info": "@:{'database.pitr.restore-before-last-migration'}。 {link}。",
- "restore-to": "再開しました",
- "restore-to-new-db": "新しいデータベース",
- "restore-to-in-place": "オリジナルデータベース"
- },
"show-reserved-tables": "バイトベース予約テーブルを表示",
"show-reserved-databases": "Bytebase によって保持されているデータベースを表示する",
"synced-at": "{time} と同期しました",
@@ -1896,7 +1880,8 @@
"foreign-keys": "外部キー",
"foreign-key": {
"reference": "参照"
- }
+ },
+ "create-target-database-or-schema-for-backup": "まずバックアップのターゲットデータベースまたはスキーマを作成してください"
},
"repository": {
"our-webhook-link": "Bytebase によって作成された Webhook は、{webhookLink} にあります。",
@@ -3700,4 +3685,4 @@
"worksheet": {
"self": "ワークシート"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 7854efa25f..f1d3530bb6 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1771,22 +1771,6 @@
"row-count-est": "估计行数",
"incorrect-project-warning": "SQL 编辑器只能查询用户可用的项目中的数据库。您应该首先将此数据库转移到一个可用的项目中。",
"go-to-transfer": "前去转移",
- "pitr": {
- "restore": "@:common.restore@:common.database",
- "no-available-backup": "没有可用的备份",
- "point-in-time": "时间点",
- "help-info": "将数据库的状态恢复到一个时间点。{link}。",
- "minimum-supported-engine-and-version": "需要 {engine} >= {min_version}",
- "restore-to-point-in-time": "恢复到指定时间点",
- "no-earlier-than": "恢复的时间点不能早于 [{earliest}] (最早可用的备份)。",
- "no-later-than-now": "恢复的时间点不能晚于当前时间。",
- "will-overwrite-current-database": "会覆盖现有数据库",
- "restore-before-last-migration": "恢复到上次变更历史之前",
- "restore-before-last-migration-help-info": "@:{'database.pitr.restore-before-last-migration'}。{link}。",
- "restore-to": "恢复到",
- "restore-to-new-db": "新数据库",
- "restore-to-in-place": "原数据库"
- },
"show-reserved-tables": "显示 Bytebase 保留的表",
"show-reserved-databases": "显示 Bytebase 保留的数据库",
"synced-at": "同步于 {time}",
@@ -1896,7 +1880,8 @@
"foreign-keys": "外键",
"foreign-key": {
"reference": "引用"
- }
+ },
+ "create-target-database-or-schema-for-backup": "请先创建备份的目标数据库或 Schema"
},
"repository": {
"our-webhook-link": "Bytebase 创建的 webhook 可以在 {webhookLink} 中找到。",