Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add tooltips to option settings (#16381)
boojackac4fb5351114
diff --git a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vue b/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vueindex 3c2fbef2af..a89f48df42 100644--- a/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vue+++ b/frontend/src/components/Plan/components/Sidebar/GhostSection/GhostSwitch.vue@@ -1,15 +1,16 @@<template>- <NTooltip :disabled="errors.length === 0">+ <NTooltip :disabled="!tooltipMessage" :arrow="false"><template #trigger><NSwitch:value="enabled"- :disabled="!allowChange"+ :disabled="!allowChange || errors.length > 0"@update:value="toggleChecked"/></template>- <template #default>- <ErrorList :errors="errors" />- </template>+ <div class="max-w-sm">+ <p class="opacity-80">{{ tooltipMessage }}</p>+ <ErrorList v-if="errors.length > 0" :errors="errors" class="mt-2" />+ </div></NTooltip></template>@@ -18,6 +19,7 @@ import { cloneDeep } from "lodash-es";import { NSwitch, NTooltip } from "naive-ui";import { computed } from "vue";import { useI18n } from "vue-i18n";+import { targetsForSpec } from "@/components/Plan/logic";import type { ErrorItem } from "@/components/misc/ErrorList.vue";import { default as ErrorList } from "@/components/misc/ErrorList.vue";import { planServiceClient } from "@/grpcweb";@@ -62,6 +64,66 @@ const errors = computed(() => {return errors;});+// Computed properties for tooltip functionality+const specTargets = computed(() => {+ if (!selectedSpec.value) return [];+ return targetsForSpec(selectedSpec.value);+});++const checkedDatabasesCount = computed(() => {+ return databases.value.length;+});++const totalDatabasesCount = computed(() => {+ return specTargets.value.length;+});++const databasesNotMeetingRequirements = computed(() => {+ return databases.value.filter((db) => {+ // Check if database doesn't have backup available or doesn't allow ghost+ if (!db.backupAvailable || !allowGhostForDatabase(db)) return true;+ // Check if instance doesn't have activation+ if (!db.instanceResource.activation) return true;+ return false;+ });+});++const tooltipMessage = computed(() => {+ // Check if only some databases are checked+ if (+ checkedDatabasesCount.value < totalDatabasesCount.value &&+ checkedDatabasesCount.value > 0+ ) {+ return t("plan.ghost.only-some-databases-checked");+ }++ // Check if some databases don't meet requirements (show summary)+ if (databasesNotMeetingRequirements.value.length > 0) {+ // If there are specific errors, show a general summary+ if (errors.value.length > 0) {+ return t("plan.ghost.some-databases-have-issues", {+ count: databasesNotMeetingRequirements.value.length,+ });+ }+ // Otherwise show the databases that don't meet requirements+ const dbNames = databasesNotMeetingRequirements.value+ .map((db) => db.databaseName)+ .join(", ");+ return t("plan.ghost.some-databases-not-meeting-requirements", {+ databases: dbNames,+ });+ }++ // If there are errors but all databases are selected, show a general error summary+ if (errors.value.length > 0) {+ return t("plan.ghost.configuration-has-issues", {+ count: errors.value.length,+ });+ }++ return undefined;+});+const toggleChecked = async (on: boolean) => {if (errors.value.length > 0) {return;diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vueindex c650b49391..5f8531016b 100644--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue+++ b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/PreBackupSwitch.vue@@ -1,22 +1,23 @@<template><div class="flex items-center">- <NTooltip :disabled="!disallowPreBackupMessage">+ <NTooltip :disabled="!tooltipMessage" :arrow="false"><template #trigger><NSwitch:value="enabled"- :disabled="!allowChange"+ :disabled="!allowChange || errors.length > 0"@update:value="(on) => handleToggle(on)"/></template>- <template #default>- {{ disallowPreBackupMessage }}+ <div class="max-w-sm">+ <p class="opacity-80">{{ tooltipMessage }}</p>+ <ErrorList v-if="errors.length > 0" :errors="errors" class="mt-2" /><LearnMoreLink- v-if="disallowPreBackupLink"+ v-if="disallowPreBackupLink && errors.length === 0":url="disallowPreBackupLink"color="light"- class="ml-1 text-sm"+ class="mt-1 text-sm"/>- </template>+ </div></NTooltip></div></template>@@ -26,6 +27,9 @@ import { NSwitch, NTooltip } from "naive-ui";import { computed } from "vue";import { useI18n } from "vue-i18n";import LearnMoreLink from "@/components/LearnMoreLink.vue";+import { targetsForSpec } from "@/components/Plan/logic";+import type { ErrorItem } from "@/components/misc/ErrorList.vue";+import ErrorList from "@/components/misc/ErrorList.vue";import { pushNotification } from "@/store";import {PRE_BACKUP_AVAILABLE_ENGINES,@@ -33,33 +37,114 @@ import {} from "./context";const { t } = useI18n();-const { enabled, allowChange, databases, toggle } =+const { enabled, allowChange, databases, toggle, selectedSpec } =usePreBackupSettingContext();-const disallowPreBackupMessage = computed(() => {- if (allowChange.value) {+const hasBackupUnavailable = computed(() => {+ return !databases.value.some((db) => !db.backupAvailable);+});++const disallowPreBackupLink = computed(() => {+ if (allowChange.value || !hasBackupUnavailable.value) {return undefined;}- if (!databases.value.some((db) => !db.backupAvailable)) {- return t("database.create-target-database-or-schema-for-backup");+ return "https://www.bytebase.com/docs/change-database/rollback-data-changes?source=console";+});++// Compute detailed errors for ErrorList+const errors = computed(() => {+ const errors: ErrorItem[] = [];++ // Check for databases without backup available+ const backupUnavailableDatabases = databases.value.filter(+ (db) => !db.backupAvailable+ );+ if (backupUnavailableDatabases.length > 0) {+ errors.push(+ t("database.backup-unavailable-for-databases", {+ databases: backupUnavailableDatabases+ .map((db) => db.databaseName)+ .join(", "),+ })+ );}++ // Check for unsupported database engines+ const unsupportedEngineDatabases = databases.value.filter(+ (db) => !PRE_BACKUP_AVAILABLE_ENGINES.includes(db.instanceResource.engine)+ );+ if (unsupportedEngineDatabases.length > 0) {+ errors.push(+ t("database.engine-not-supported-for-backup", {+ databases: unsupportedEngineDatabases+ .map((db) => `${db.databaseName} (${db.instanceResource.engine})`)+ .join(", "),+ })+ );+ }++ return errors;+});++// Computed properties for new tooltip functionality+const specTargets = computed(() => {+ if (!selectedSpec.value) return [];+ return targetsForSpec(selectedSpec.value);+});++const checkedDatabasesCount = computed(() => {+ return databases.value.length;+});++const totalDatabasesCount = computed(() => {+ return specTargets.value.length;+});++const databasesNotMeetingRequirements = computed(() => {+ return databases.value.filter((db) => {+ // Check if database doesn't have backup available+ if (!db.backupAvailable) return true;+ // Check if database engine is not supported+ if (!PRE_BACKUP_AVAILABLE_ENGINES.includes(db.instanceResource.engine)) {+ return true;+ }+ return false;+ });+});++const tooltipMessage = computed(() => {+ // Check if only some databases are checkedif (- databases.value.some(- (db) => !PRE_BACKUP_AVAILABLE_ENGINES.includes(db.instanceResource.engine)- )+ checkedDatabasesCount.value < totalDatabasesCount.value &&+ checkedDatabasesCount.value > 0) {- return false;+ return t("plan.pre-backup.only-some-databases-checked");}- return undefined;-});-const disallowPreBackupLink = computed(() => {- if (allowChange.value) {- return undefined;+ // Check if some databases don't meet requirements (show summary)+ if (databasesNotMeetingRequirements.value.length > 0) {+ // If there are specific errors, show a general summary+ if (errors.value.length > 0) {+ return t("plan.pre-backup.some-databases-have-issues", {+ count: databasesNotMeetingRequirements.value.length,+ });+ }+ // Otherwise show the databases that don't meet requirements+ const dbNames = databasesNotMeetingRequirements.value+ .map((db) => db.databaseName)+ .join(", ");+ return t("plan.pre-backup.some-databases-not-meeting-requirements", {+ databases: dbNames,+ });}- if (!databases.value.some((db) => !db.backupAvailable)) {- return "https://www.bytebase.com/docs/change-database/rollback-data-changes?source=console";++ // If there are errors but all databases are selected, show a general error summary+ if (errors.value.length > 0) {+ return t("plan.pre-backup.configuration-has-issues", {+ count: errors.value.length,+ });}+return undefined;});diff --git a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.tsindex abf3f09fee..d5c12a2073 100644--- a/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts+++ b/frontend/src/components/Plan/components/Sidebar/PreBackupSection/context.ts@@ -201,6 +201,7 @@ export const providePreBackupSettingContext = (refs: {databases,events,toggle,+ selectedSpec,};provide(KEY, context);diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex d564438563..768df72fef 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -994,6 +994,18 @@"applies-to-all-tasks": "Applies to all tasks","applies-to-some-tasks": "Applies to some tasks {count}/{total}","split-into-multiple-issues-tip": "If you want to configure different options for each task, please split into multiple issues."+ },+ "pre-backup": {+ "only-some-databases-checked": "Only some databases are checked",+ "some-databases-not-meeting-requirements": "Some databases ({databases}) don't meet requirements",+ "some-databases-have-issues": "{count} database has issues | {count} databases have issues",+ "configuration-has-issues": "Configuration has {count} issue | Configuration has {count} issues"+ },+ "ghost": {+ "only-some-databases-checked": "Only some databases are checked",+ "some-databases-not-meeting-requirements": "Some databases ({databases}) don't meet requirements",+ "some-databases-have-issues": "{count} database has issues | {count} databases have issues",+ "configuration-has-issues": "Configuration has {count} issue | Configuration has {count} issues"}},"quick-action": {@@ -1487,7 +1499,8 @@"reference": "Reference"},"checks": "Checks",- "create-target-database-or-schema-for-backup": "Please create the target database or schema for the backup first",+ "backup-unavailable-for-databases": "Backup is not available for databases: {databases}",+ "engine-not-supported-for-backup": "Prior backup is not supported for: {databases}","revision": {"self": "Revision","applied-at": "Applied at",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex f6325ed1bc..3270458586 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -994,6 +994,18 @@"applies-to-all-tasks": "Se aplica a todas las tareas.","applies-to-some-tasks": "Se aplica a algunas tareas {count}/{total}","split-into-multiple-issues-tip": "Si desea configurar diferentes opciones para cada tarea, divídala en varios problemas."+ },+ "pre-backup": {+ "only-some-databases-checked": "Sólo se comprueban algunas bases de datos",+ "some-databases-not-meeting-requirements": "Algunas bases de datos ({databases}) no cumplen los requisitos",+ "some-databases-have-issues": "{count} la base de datos tiene problemas | {count} las bases de datos tienen problemas",+ "configuration-has-issues": "La configuración tiene {count} problemas | La configuración tiene {count} problemas"+ },+ "ghost": {+ "only-some-databases-checked": "Sólo se comprueban algunas bases de datos",+ "some-databases-not-meeting-requirements": "Algunas bases de datos ({databases}) no cumplen los requisitos",+ "some-databases-have-issues": "{count} la base de datos tiene problemas | {count} las bases de datos tienen problemas",+ "configuration-has-issues": "La configuración tiene {count} problemas | La configuración tiene {count} problemas"}},"quick-action": {@@ -1487,7 +1499,8 @@"reference": "Referencia"},"checks": "Cheques",- "create-target-database-or-schema-for-backup": "Primero cree la base de datos o el esquema de destino para la copia de seguridad",+ "backup-unavailable-for-databases": "La copia de seguridad no está disponible para las bases de datos: {databases}",+ "engine-not-supported-for-backup": "No se admite la copia de seguridad previa para: {databases}","revision": {"self": "Revisión","applied-at": "Aplicado en",@@ -2619,4 +2632,4 @@"last-visit": "Última visita","changelog-for-version": "Registro de cambios para {version}"}-}\ No newline at end of file+}diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 4cb9cf364f..714012093c 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -994,6 +994,18 @@"applies-to-all-tasks": "すべてのタスクに適用","applies-to-some-tasks": "一部のタスクに適用されます {count}/{total}","split-into-multiple-issues-tip": "タスクごとに異なるオプションを設定する場合は、複数の問題に分割してください。"+ },+ "pre-backup": {+ "only-some-databases-checked": "一部のデータベースのみがチェックされます",+ "some-databases-not-meeting-requirements": "一部のデータベース ({databases}) は要件を満たしていません",+ "some-databases-have-issues": "{count} データベースに問題があります | {count} データベースに問題があります",+ "configuration-has-issues": "構成に {count} 個の問題があります | 構成に {count} 個の問題があります"+ },+ "ghost": {+ "only-some-databases-checked": "一部のデータベースのみがチェックされます",+ "some-databases-not-meeting-requirements": "一部のデータベース ({databases}) は要件を満たしていません",+ "some-databases-have-issues": "{count} データベースに問題があります | {count} データベースに問題があります",+ "configuration-has-issues": "構成に {count} 個の問題があります | 構成に {count} 個の問題があります"}},"quick-action": {@@ -1487,7 +1499,8 @@"reference": "参照"},"checks": "チェック",- "create-target-database-or-schema-for-backup": "まずバックアップのターゲットデータベースまたはスキーマを作成してください",+ "backup-unavailable-for-databases": "データベースのバックアップは利用できません: {databases}",+ "engine-not-supported-for-backup": "以前のバックアップはサポートされていません: {databases}","revision": {"self": "リビジョン","applied-at": "申請先",@@ -2619,4 +2632,4 @@"last-visit": "最終訪問","changelog-for-version": "{version} の変更履歴"}-}\ No newline at end of file+}diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 748f3e89d1..f8ef86d6f4 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -994,6 +994,18 @@"applies-to-all-tasks": "Áp dụng cho tất cả các nhiệm vụ","applies-to-some-tasks": "Áp dụng cho một số tác vụ {count}/{total}","split-into-multiple-issues-tip": "Nếu bạn muốn cấu hình các tùy chọn khác nhau cho mỗi tác vụ, vui lòng chia thành nhiều vấn đề."+ },+ "pre-backup": {+ "only-some-databases-checked": "Chỉ một số cơ sở dữ liệu được kiểm tra",+ "some-databases-not-meeting-requirements": "Một số cơ sở dữ liệu ({databases}) không đáp ứng được yêu cầu",+ "some-databases-have-issues": "{count} cơ sở dữ liệu có vấn đề | {count} cơ sở dữ liệu có vấn đề",+ "configuration-has-issues": "Cấu hình có vấn đề {count} | Cấu hình có vấn đề {count}"+ },+ "ghost": {+ "only-some-databases-checked": "Chỉ một số cơ sở dữ liệu được kiểm tra",+ "some-databases-not-meeting-requirements": "Một số cơ sở dữ liệu ({databases}) không đáp ứng được yêu cầu",+ "some-databases-have-issues": "{count} cơ sở dữ liệu có vấn đề | {count} cơ sở dữ liệu có vấn đề",+ "configuration-has-issues": "Cấu hình có vấn đề {count} | Cấu hình có vấn đề {count}"}},"quick-action": {@@ -1487,7 +1499,8 @@"reference": "Tham chiếu"},"checks": "Kiểm tra",- "create-target-database-or-schema-for-backup": "Vui lòng tạo cơ sở dữ liệu hoặc lược đồ đích cho bản sao lưu trước",+ "backup-unavailable-for-databases": "Sao lưu không khả dụng cho cơ sở dữ liệu: {databases}",+ "engine-not-supported-for-backup": "Sao lưu trước đó không được hỗ trợ cho: {databases}","revision": {"self": "Bản sửa đổi","applied-at": "Đã áp dụng vào",@@ -2619,4 +2632,4 @@"last-visit": "Lần truy cập cuối","changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"}-}\ No newline at end of file+}diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 6f12e52667..6ff5b2718f 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -994,6 +994,18 @@"applies-to-all-tasks": "适用于所有任务","applies-to-some-tasks": "适用于某些任务 {count}/{total}","split-into-multiple-issues-tip": "如果您想为每个任务设置不同的配置项,请拆分成多个工单。"+ },+ "pre-backup": {+ "only-some-databases-checked": "仅检查部分数据库",+ "some-databases-not-meeting-requirements": "某些数据库({databases})不符合要求",+ "some-databases-have-issues": "{count} 个数据库有问题 | {count} 个数据库有问题",+ "configuration-has-issues": "配置存在 {count} 个问题 | 配置存在 {count} 个问题"+ },+ "ghost": {+ "only-some-databases-checked": "仅检查部分数据库",+ "some-databases-not-meeting-requirements": "某些数据库({databases})不符合要求",+ "some-databases-have-issues": "{count} 个数据库有问题 | {count} 个数据库有问题",+ "configuration-has-issues": "配置存在 {count} 个问题 | 配置存在 {count} 个问题"}},"quick-action": {@@ -1487,7 +1499,8 @@"reference": "引用"},"checks": "Check 约束",- "create-target-database-or-schema-for-backup": "请先创建备份的目标数据库或 Schema",+ "backup-unavailable-for-databases": "数据库无法开启备份:{databases}",+ "engine-not-supported-for-backup": "引擎不支持预备份:{databases}","revision": {"self": "版本","applied-at": "应用时间",