Skip to content

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

chore: optimize setting (#15615)

ecmadaoa945c0406bd1
diff --git a/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue b/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
index 6abb71ac4f..3d3e07704d 100644
--- a/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
+++ b/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
@@ -12,116 +12,130 @@
</span>
</div>
<div class="flex-1 lg:px-4">
- <div class="mt-4 lg:mt-0">
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.enabled"
- :text="true"
- :disabled="!allowEdit || !hasAIFeature"
- @update:value="toggleAIEnabled"
- />
- <p class="textinfolabel">
- {{ $t("settings.general.workspace.ai-assistant.description") }}
- <LearnMoreLink
- url="https://www.bytebase.com/docs/ai-assistant?source=console"
- class="ml-1 text-sm"
- />
- </p>
+ <div class="mt-4 lg:mt-0 space-y-4">
+ <div>
+ <div class="flex items-center gap-x-2">
+ <Switch
+ v-model:value="state.enabled"
+ :text="true"
+ :disabled="!allowEdit || !hasAIFeature"
+ @update:value="toggleAIEnabled"
+ />
+ <span class="font-medium">
+ {{
+ $t(
+ "settings.general.workspace.ai-assistant.enable-ai-assistant"
+ )
+ }}
+ </span>
+ </div>
+ <div class="mt-1 mb-3 text-sm text-gray-400">
+ {{ $t("settings.general.workspace.ai-assistant.description") }}
+ <LearnMoreLink
+ url="https://www.bytebase.com/docs/ai-assistant?source=console"
+ class="ml-1 text-sm"
+ />
+ </div>
</div>
<template v-if="state.enabled">
- <label class="flex items-center gap-x-2">
- <span class="font-medium">{{
- $t("settings.general.workspace.ai-assistant.openai-key.self")
- }}</span>
- </label>
- <div class="mb-3 text-sm text-gray-400">
- <i18n-t
- keypath="settings.general.workspace.ai-assistant.openai-key.description"
- >
- <template #viewDoc>
- <a
- href="https://platform.openai.com/account/api-keys"
- class="normal-link"
- target="_blank"
- >{{
+ <div>
+ <label class="flex items-center gap-x-2">
+ <span class="font-medium">{{
+ $t("settings.general.workspace.ai-assistant.openai-key.self")
+ }}</span>
+ </label>
+ <div class="mb-3 text-sm text-gray-400">
+ <i18n-t
+ keypath="settings.general.workspace.ai-assistant.openai-key.description"
+ >
+ <template #viewDoc>
+ <a
+ href="https://platform.openai.com/account/api-keys"
+ class="normal-link"
+ target="_blank"
+ >{{
+ $t(
+ "settings.general.workspace.ai-assistant.openai-key.find-my-key"
+ )
+ }}
+ </a>
+ </template>
+ </i18n-t>
+ </div>
+ <NTooltip placement="top-start" :disabled="allowEdit">
+ <template #trigger>
+ <BBTextField
+ v-model:value="state.openAIKey"
+ :required="true"
+ :disabled="!allowEdit || !hasAIFeature"
+ :placeholder="
$t(
- "settings.general.workspace.ai-assistant.openai-key.find-my-key"
+ 'settings.general.workspace.ai-assistant.openai-key.placeholder'
)
- }}
- </a>
+ "
+ />
</template>
- </i18n-t>
+ <span class="text-sm text-gray-400 -translate-y-2">
+ {{ $t("settings.general.workspace.only-admin-can-edit") }}
+ </span>
+ </NTooltip>
</div>
- <NTooltip placement="top-start" :disabled="allowEdit">
- <template #trigger>
- <BBTextField
- v-model:value="state.openAIKey"
- class="mb-4 w-full"
- :required="true"
- :disabled="!allowEdit || !hasAIFeature"
- :placeholder="
+
+ <div>
+ <label class="flex items-center gap-x-2">
+ <span class="font-medium">{{
$t(
- 'settings.general.workspace.ai-assistant.openai-key.placeholder'
+ "settings.general.workspace.ai-assistant.openai-endpoint.self"
)
- "
- />
- </template>
- <span class="text-sm text-gray-400 -translate-y-2">
- {{ $t("settings.general.workspace.only-admin-can-edit") }}
- </span>
- </NTooltip>
-
- <label class="flex items-center gap-x-2">
- <span class="font-medium">{{
- $t("settings.general.workspace.ai-assistant.openai-endpoint.self")
- }}</span>
- </label>
- <div class="mb-3 text-sm text-gray-400">
- {{
- $t(
- "settings.general.workspace.ai-assistant.openai-endpoint.description"
- )
- }}
+ }}</span>
+ </label>
+ <div class="mb-3 text-sm text-gray-400">
+ {{
+ $t(
+ "settings.general.workspace.ai-assistant.openai-endpoint.description"
+ )
+ }}
+ </div>
+ <NTooltip placement="top-start" :disabled="allowEdit">
+ <template #trigger>
+ <BBTextField
+ v-model:value="state.openAIEndpoint"
+ :required="true"
+ :disabled="!allowEdit || !hasAIFeature"
+ />
+ </template>
+ <span class="text-sm text-gray-400 -translate-y-2">
+ {{ $t("settings.general.workspace.only-admin-can-edit") }}
+ </span>
+ </NTooltip>
</div>
- <NTooltip placement="top-start" :disabled="allowEdit">
- <template #trigger>
- <BBTextField
- v-model:value="state.openAIEndpoint"
- class="mb-4 w-full"
- :required="true"
- :disabled="!allowEdit || !hasAIFeature"
- />
- </template>
- <span class="text-sm text-gray-400 -translate-y-2">
- {{ $t("settings.general.workspace.only-admin-can-edit") }}
- </span>
- </NTooltip>
- <label class="flex items-center gap-x-2">
- <span class="font-medium">{{
- $t("settings.general.workspace.ai-assistant.openai-model.self")
- }}</span>
- </label>
- <div class="mb-3 text-sm text-gray-400">
- {{
- $t(
- "settings.general.workspace.ai-assistant.openai-model.description"
- )
- }}
+ <div>
+ <label class="flex items-center gap-x-2">
+ <span class="font-medium">{{
+ $t("settings.general.workspace.ai-assistant.openai-model.self")
+ }}</span>
+ </label>
+ <div class="mb-3 text-sm text-gray-400">
+ {{
+ $t(
+ "settings.general.workspace.ai-assistant.openai-model.description"
+ )
+ }}
+ </div>
+ <NTooltip placement="top-start" :disabled="allowEdit">
+ <template #trigger>
+ <BBTextField
+ v-model:value="state.openAIModel"
+ :required="true"
+ :disabled="!allowEdit || !hasAIFeature"
+ />
+ </template>
+ <span class="text-sm text-gray-400 -translate-y-2">
+ {{ $t("settings.general.workspace.only-admin-can-edit") }}
+ </span>
+ </NTooltip>
</div>
- <NTooltip placement="top-start" :disabled="allowEdit">
- <template #trigger>
- <BBTextField
- v-model:value="state.openAIModel"
- class="mb-4 w-full"
- :required="true"
- :disabled="!allowEdit || !hasAIFeature"
- />
- </template>
- <span class="text-sm text-gray-400 -translate-y-2">
- {{ $t("settings.general.workspace.only-admin-can-edit") }}
- </span>
- </NTooltip>
</template>
</div>
</div>
@@ -129,6 +143,9 @@
</template>
<script lang="ts" setup>
+import { NTooltip } from "naive-ui";
+import scrollIntoView from "scroll-into-view-if-needed";
+import { computed, onMounted, reactive, ref, watchEffect } from "vue";
import { BBTextField } from "@/bbkit";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
import { Switch } from "@/components/v2";
@@ -138,9 +155,6 @@ import {
AISetting,
AISetting_Provider,
} from "@/types/proto/v1/setting_service";
-import { NTooltip } from "naive-ui";
-import scrollIntoView from "scroll-into-view-if-needed";
-import { computed, onMounted, reactive, ref, watchEffect } from "vue";
import { FeatureBadge } from "../FeatureGuard";
interface LocalState {
@@ -193,7 +207,12 @@ const allowSave = computed((): boolean => {
const openAIEndpointUpdated =
state.openAIEndpoint !== initValue.openAIEndpoint;
const openAIModelUpdated = state.openAIModel !== initValue.openAIModel;
- return enabledUpdated || openAIKeyUpdated || openAIEndpointUpdated || openAIModelUpdated;
+ return (
+ enabledUpdated ||
+ openAIKeyUpdated ||
+ openAIEndpointUpdated ||
+ openAIModelUpdated
+ );
});
function maskKey(key: string | undefined): string {
@@ -213,22 +232,18 @@ const toggleAIEnabled = (on: boolean) => {
};
const updateAISetting = async () => {
- let setting = AISetting.fromPartial({});
- if (state.enabled) {
- setting = AISetting.fromPartial({
- ...(aiSetting.value ?? {}),
- enabled: state.enabled,
- apiKey: state.openAIKey,
- endpoint: state.openAIEndpoint,
- model: state.openAIModel,
- // TODO(ed): support change provider.
- provider: AISetting_Provider.OPEN_AI,
- });
- }
await settingV1Store.upsertSetting({
name: "bb.ai",
value: {
- aiSetting: setting,
+ aiSetting: AISetting.fromPartial({
+ ...(aiSetting.value ?? {}),
+ enabled: state.enabled,
+ apiKey: state.openAIKey,
+ endpoint: state.openAIEndpoint,
+ model: state.openAIModel,
+ // TODO(ed): support change provider.
+ provider: AISetting_Provider.OPEN_AI,
+ }),
},
});
diff --git a/frontend/src/components/GeneralSetting/AccountSetting.vue b/frontend/src/components/GeneralSetting/AccountSetting.vue
index 00ca25e2a0..7e6af15ed7 100644
--- a/frontend/src/components/GeneralSetting/AccountSetting.vue
+++ b/frontend/src/components/GeneralSetting/AccountSetting.vue
@@ -19,7 +19,7 @@
:text="true"
:disabled="!allowEdit || !hasDisallowSignupFeature"
/>
- <div class="textlabel flex items-center gap-x-2">
+ <div class="font-medium flex items-center gap-x-2">
{{ $t("settings.general.workspace.disallow-signup.enable") }}
<FeatureBadge feature="bb.feature.disallow-signup" />
</div>
@@ -45,7 +45,7 @@
:text="true"
:disabled="!allowEdit || !has2FAFeature"
/>
- <div class="textlabel flex items-center gap-x-2">
+ <div class="font-medium flex items-center gap-x-2">
{{ $t("settings.general.workspace.require-2fa.enable") }}
<FeatureBadge feature="bb.feature.2fa" />
</div>
@@ -65,7 +65,7 @@
(!state.disallowPasswordSignin && !existActiveIdentityProvider)
"
/>
- <div class="textlabel flex items-center gap-x-2">
+ <div class="font-medium flex items-center gap-x-2">
{{
$t("settings.general.workspace.disallow-password-signin.enable")
}}
diff --git a/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue b/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue
index ffa46f550d..ad87648601 100644
--- a/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue
+++ b/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue
@@ -6,7 +6,7 @@
:text="true"
:disabled="!allowEdit"
/>
- <span class="textlabel">
+ <span class="font-medium">
{{
$t(
"settings.general.workspace.restrict-issue-creation-for-sql-review.title"
diff --git a/frontend/src/components/GeneralSetting/SecuritySetting.vue b/frontend/src/components/GeneralSetting/SecuritySetting.vue
index b560f7553c..941965f15f 100644
--- a/frontend/src/components/GeneralSetting/SecuritySetting.vue
+++ b/frontend/src/components/GeneralSetting/SecuritySetting.vue
@@ -19,7 +19,7 @@
:text="true"
:disabled="!allowEdit || !hasWatermarkFeature"
/>
- <span class="textlabel">
+ <span class="font-medium">
{{ $t("settings.general.workspace.watermark.enable") }}
</span>
<FeatureBadge feature="bb.feature.watermark" />
@@ -35,7 +35,7 @@
:text="true"
:disabled="!allowEdit || !hasAccessControlFeature"
/>
- <span class="textlabel">
+ <span class="font-medium">
{{ $t("settings.general.workspace.data-export.enable") }}
</span>
<FeatureBadge feature="bb.feature.access-control" />
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 5e4177126b..9f6ba91f3f 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -555,6 +555,7 @@
"failed-to-update-setting": "Failed to update setting \"{title}\"",
"ai-assistant": {
"self": "AI Assistant",
+ "enable-ai-assistant": "Enable AI Assistant",
"description": "Use OpenAPI to assist the database development tasks.",
"openai-key": {
"self": "OpenAI API Key",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 210689b188..a34e8f37e0 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -555,6 +555,7 @@
"failed-to-update-setting": "No se pudo actualizar la configuración \"{title}\"",
"ai-assistant": {
"self": "Asistente de AI",
+ "enable-ai-assistant": "Habilitar el Asistente de IA",
"description": "Utilice OpenAPI para ayudar en las tareas de desarrollo de bases de datos.",
"openai-key": {
"self": "Clave de API de OpenAI",
@@ -2589,4 +2590,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.json
index dd88f79ddf..19529f54c0 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -555,6 +555,7 @@
"failed-to-update-setting": "設定「{title}」の更新に失敗しました",
"ai-assistant": {
"self": "AI アシスタント",
+ "enable-ai-assistant": "AIアシスタントを有効にする",
"description": "OpenAPI を使用してデータベース開発タスクを支援します。",
"openai-key": {
"self": "OpenAI APIキー",
@@ -2589,4 +2590,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.json
index 9901155291..e072fb2777 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -555,6 +555,7 @@
"failed-to-update-setting": "Không cập nhật được cài đặt \"{title}\"",
"ai-assistant": {
"self": "Trợ lý AI",
+ "enable-ai-assistant": "Bật Trợ lý AI",
"description": "Sử dụng OpenAPI để hỗ trợ các tác vụ phát triển cơ sở dữ liệu.",
"openai-key": {
"self": "Khóa API OpenAI",
@@ -2589,4 +2590,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.json
index 3c34794b37..b2dd07804c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -555,6 +555,7 @@
"failed-to-update-setting": "无法更新设置“{title}”",
"ai-assistant": {
"self": "AI 助手",
+ "enable-ai-assistant": "启用 AI 助手",
"description": "使用 OpenAPI 来辅助数据库开发任务。",
"openai-key": {
"self": "OpenAI API Key",