Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): migrate MCP page to React and generalize React bridge (#19759)
Danny Xu0f1e3fac7a80
diff --git a/CLAUDE.md b/CLAUDE.mdindex 30ca0acce9..8f5db1809a 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -127,6 +127,35 @@ psql -U bbdev bbdev- **No Empty Objects**: Do not add empty JSON objects (e.g., `"key": {}`) to locale files. Remove any empty objects you encounter- **Button Spacing**: Use `gap-x-2` for ALL button groups (modals, drawers, toolbars, inline actions). Never use `space-x` for buttons. See `./frontend/.claude/BUTTON_SPACING_STANDARDIZATION.md` for full guidelines+### React (New Code)++The frontend is migrating from Vue to React. **All new UI code should be written in React.**++**Stack**: React + [Base UI](https://base-ui.com/) (`@base-ui/react`) + Tailwind CSS v4 + shadcn-style component patterns++**Component patterns**:+- Build UI components in the shadcn style — `class-variance-authority` (cva) for variant props, `clsx`/`tailwind-merge` for class merging+- Wrap Base UI primitives (Button, Tabs, Input, etc.) with styled variants in `./frontend/src/react/components/ui/`+- Use `useTranslation()` from `react-i18next` for i18n+- Use CSS custom properties (`--color-accent`, `--color-error`, `--color-control-border`, etc.) for theme tokens shared with the Vue layer++**Tailwind CSS v4**:+- CSS-first config in `./frontend/src/assets/css/tailwind.css` — no JS config file+- Custom utilities use `@utility`, design tokens use `@theme`+- Default border color is `currentcolor` (compat shim in `tailwind.css` preserves v3 behavior)++**Accessing Vue state from React**:+- `useVueState(getter)` — React hook that subscribes to Vue reactive state (Pinia stores, refs, computed) via `useSyncExternalStore`. React components access stores directly — no bridge layer needed+- React pages are self-contained: import Pinia stores, `router`, utility functions directly+- React `.tsx` is compiled by esbuild (`react-tsx-transform` Vite plugin) and type-checked separately via `tsconfig.react.json` (excluded from vue-tsc)++**Mount system** (temporary — removed after full migration):+- React source lives in `./frontend/src/react/`+- `ReactPageMount.vue` — generic Vue wrapper that mounts/unmounts the React root and syncs locale. Used by most pages+- Pages that still depend on Vue components (modals, drawers not yet migrated) get a thin page-specific mount (e.g., `SubscriptionPageMount.vue`) — these are removed once those Vue deps are rebuilt in React+- `mount.ts` lazy-loads pages via `import.meta.glob` — exported function name must match the file name+- To add a new React page: (1) create `.tsx` in `pages/`, (2) point route to `ReactPageMount.vue` with `props: () => ({ page: "PageName" })`+### Naming- Use American Englishdiff --git a/frontend/src/react/ReactBridge.vue b/frontend/src/react/ReactBridge.vuedeleted file mode 100644index 1f27695125..0000000000--- a/frontend/src/react/ReactBridge.vue+++ /dev/null@@ -1,173 +0,0 @@-<template>- <div ref="container" />- <WeChatQRModal- v-if="showQRCodeModal"- :title="$t('subscription.request-with-qr')"- @close="showQRCodeModal = false"- />- <InstanceAssignment- :show="showInstanceAssignmentDrawer"- @dismiss="showInstanceAssignmentDrawer = false"- />-</template>--<script lang="ts" setup>-import { storeToRefs } from "pinia";-import { onMounted, onUnmounted, ref, watch } from "vue";-import { useI18n } from "vue-i18n";-import InstanceAssignment from "@/components/InstanceAssignment.vue";-import WeChatQRModal from "@/components/WeChatQRModal.vue";-import {- getWorkspaceId,- pushNotification,- useActuatorV1Store,- useSubscriptionV1Store,-} from "@/store";-import { ENTERPRISE_INQUIRE_LINK } from "@/types";-import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";-import { hasWorkspacePermissionV2 } from "@/utils";--const props = defineProps<{- allowEdit: boolean;-}>();--const { t, locale } = useI18n();-const subscriptionStore = useSubscriptionV1Store();-const actuatorStore = useActuatorV1Store();--const container = ref<HTMLElement>();-// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import-let root: any = null; // eslint-disable-line @typescript-eslint/no-explicit-any--const { expireAt, isTrialing, isExpired } = storeToRefs(subscriptionStore);--const showQRCodeModal = ref(false);-const showInstanceAssignmentDrawer = ref(false);--const handleRequireEnterprise = () => {- if (locale.value === "zh-CN") {- showQRCodeModal.value = true;- } else {- window.open(ENTERPRISE_INQUIRE_LINK, "_blank");- }-};--function getPlanType(): "FREE" | "TEAM" | "ENTERPRISE" {- switch (subscriptionStore.currentPlan) {- case PlanType.TEAM:- return "TEAM";- case PlanType.ENTERPRISE:- return "ENTERPRISE";- default:- return "FREE";- }-}--function getCurrentPlanLabel(): string {- switch (subscriptionStore.currentPlan) {- case PlanType.TEAM:- return t("subscription.plan.team.title");- case PlanType.ENTERPRISE:- return t("subscription.plan.enterprise.title");- default:- return t("subscription.plan.free.title");- }-}--function buildData() {- return {- currentPlan: getCurrentPlanLabel(),- planType: getPlanType(),- isFreePlan: subscriptionStore.isFreePlan,- isTrialing: isTrialing.value,- isExpired: isExpired.value,- isSelfHostLicense: subscriptionStore.isSelfHostLicense,- showTrial: subscriptionStore.showTrial,- trialingDays: subscriptionStore.trialingDays,- expireAt: expireAt.value,- instanceCountLimit: subscriptionStore.instanceCountLimit,- instanceLicenseCount: subscriptionStore.instanceLicenseCount,- userCountLimit: subscriptionStore.userCountLimit,- activeUserCount: actuatorStore.activeUserCount,- activatedInstanceCount: actuatorStore.activatedInstanceCount,- workspaceId: getWorkspaceId(actuatorStore.workspaceResourceName),- };-}--async function handleUploadLicense(license: string): Promise<boolean> {- try {- await subscriptionStore.patchSubscription(license);- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("subscription.update.success.title"),- description: t("subscription.update.success.description"),- });- return true;- } catch {- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("subscription.update.failure.title"),- description: t("subscription.update.failure.description"),- });- return false;- }-}--async function renderReact() {- if (!container.value) return;- const [{ mountSubscriptionPage, updateSubscriptionPage }, i18nModule] =- await Promise.all([import("./mount"), import("./i18n")]);- // Sync Vue locale to React i18next- if (i18nModule.default.language !== locale.value) {- await i18nModule.default.changeLanguage(locale.value);- }- const opts = {- data: buildData(),- allowEdit: props.allowEdit,- allowManageInstanceLicenses:- props.allowEdit && hasWorkspacePermissionV2("bb.instances.list"),- onUploadLicense: handleUploadLicense,- onRequireEnterprise: handleRequireEnterprise,- onManageInstanceLicenses: () => {- showInstanceAssignmentDrawer.value = true;- },- };- if (!root) {- root = await mountSubscriptionPage(container.value, opts);- } else {- await updateSubscriptionPage(root, opts);- }-}--onMounted(() => {- renderReact();-});--// Re-render when reactive data changes-watch(- () => [- subscriptionStore.currentPlan,- subscriptionStore.isFreePlan,- isTrialing.value,- isExpired.value,- expireAt.value,- subscriptionStore.instanceCountLimit,- subscriptionStore.instanceLicenseCount,- subscriptionStore.userCountLimit,- actuatorStore.activeUserCount,- actuatorStore.activatedInstanceCount,- props.allowEdit,- locale.value,- ],- () => {- renderReact();- }-);--onUnmounted(() => {- root?.unmount();- root = null;-});-</script>diff --git a/frontend/src/react/ReactPageMount.vue b/frontend/src/react/ReactPageMount.vuenew file mode 100644index 0000000000..1ce01c7e00--- /dev/null+++ b/frontend/src/react/ReactPageMount.vue@@ -0,0 +1,38 @@+<template>+ <div ref="container" />+</template>++<script lang="ts" setup>+import { onMounted, onUnmounted, ref, watch } from "vue";+import { useI18n } from "vue-i18n";++const props = defineProps<{+ page: string;+}>();++const { locale } = useI18n();+const container = ref<HTMLElement>();+// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import+let root: any = null; // eslint-disable-line @typescript-eslint/no-explicit-any++async function render() {+ if (!container.value) return;+ const [{ mountReactPage }, i18nModule] = await Promise.all([+ import("./mount"),+ import("./i18n"),+ ]);+ if (i18nModule.default.language !== locale.value) {+ await i18nModule.default.changeLanguage(locale.value);+ }+ if (!root) {+ root = await mountReactPage(container.value, props.page);+ }+}++onMounted(() => render());+watch(locale, () => render());+onUnmounted(() => {+ root?.unmount();+ root = null;+});+</script>diff --git a/frontend/src/react/SubscriptionPageMount.vue b/frontend/src/react/SubscriptionPageMount.vuenew file mode 100644index 0000000000..576d5112d9--- /dev/null+++ b/frontend/src/react/SubscriptionPageMount.vue@@ -0,0 +1,64 @@+<template>+ <div ref="container" />+ <WeChatQRModal+ v-if="showQRCodeModal"+ :title="$t('subscription.request-with-qr')"+ @close="showQRCodeModal = false"+ />+ <InstanceAssignment+ :show="showInstanceAssignmentDrawer"+ @dismiss="showInstanceAssignmentDrawer = false"+ />+</template>++<script lang="ts" setup>+import { onMounted, onUnmounted, ref, watch } from "vue";+import { useI18n } from "vue-i18n";+import InstanceAssignment from "@/components/InstanceAssignment.vue";+import WeChatQRModal from "@/components/WeChatQRModal.vue";+import { ENTERPRISE_INQUIRE_LINK } from "@/types";++const { locale } = useI18n();+const container = ref<HTMLElement>();+// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import+let root: any = null; // eslint-disable-line @typescript-eslint/no-explicit-any++const showQRCodeModal = ref(false);+const showInstanceAssignmentDrawer = ref(false);++const props = {+ onRequireEnterprise: () => {+ if (locale.value === "zh-CN") {+ showQRCodeModal.value = true;+ } else {+ window.open(ENTERPRISE_INQUIRE_LINK, "_blank");+ }+ },+ onManageInstanceLicenses: () => {+ showInstanceAssignmentDrawer.value = true;+ },+};++async function render() {+ if (!container.value) return;+ const [{ mountReactPage, updateReactPage }, i18nModule] = await Promise.all([+ import("./mount"),+ import("./i18n"),+ ]);+ if (i18nModule.default.language !== locale.value) {+ await i18nModule.default.changeLanguage(locale.value);+ }+ if (!root) {+ root = await mountReactPage(container.value, "SubscriptionPage", props);+ } else {+ await updateReactPage(root, "SubscriptionPage", props);+ }+}++onMounted(() => render());+watch(locale, () => render());+onUnmounted(() => {+ root?.unmount();+ root = null;+});+</script>diff --git a/frontend/src/react/components/ui/alert.tsx b/frontend/src/react/components/ui/alert.tsxnew file mode 100644index 0000000000..9f450e026c--- /dev/null+++ b/frontend/src/react/components/ui/alert.tsx@@ -0,0 +1,71 @@+import { cva, type VariantProps } from "class-variance-authority";+import {+ AlertCircle,+ AlertTriangle,+ Info,+ type LucideIcon,+} from "lucide-react";+import type { ComponentProps } from "react";+import { cn } from "@/react/lib/utils";++const alertVariants = cva(+ "relative w-full rounded-md border px-4 py-3 text-sm flex gap-x-3",+ {+ variants: {+ variant: {+ info: "border-accent/30 bg-accent/5 text-accent",+ warning: "border-warning/30 bg-warning/5 text-warning",+ error: "border-error/30 bg-error/5 text-error",+ },+ },+ defaultVariants: {+ variant: "info",+ },+ }+);++const iconMap: Record<string, LucideIcon> = {+ info: Info,+ warning: AlertTriangle,+ error: AlertCircle,+};++type AlertProps = ComponentProps<"div"> &+ VariantProps<typeof alertVariants> & {+ showIcon?: boolean;+ };++function Alert({+ className,+ variant = "info",+ showIcon = true,+ children,+ ...props+}: AlertProps) {+ const Icon = iconMap[variant ?? "info"];+ return (+ <div+ role="alert"+ className={cn(alertVariants({ variant, className }))}+ {...props}+ >+ {showIcon && <Icon className="h-5 w-5 shrink-0 mt-0.5" />}+ <div>{children}</div>+ </div>+ );+}++function AlertTitle({ className, ...props }: ComponentProps<"h5">) {+ return (+ <h5 className={cn("font-medium leading-tight", className)} {...props} />+ );+}++function AlertDescription({ className, ...props }: ComponentProps<"div">) {+ return (+ <div className={cn("mt-1 text-sm opacity-90", className)} {...props} />+ );+}++export { Alert, AlertTitle, AlertDescription, alertVariants };+export type { AlertProps };diff --git a/frontend/src/react/components/ui/tabs.tsx b/frontend/src/react/components/ui/tabs.tsxnew file mode 100644index 0000000000..2c10110619--- /dev/null+++ b/frontend/src/react/components/ui/tabs.tsx@@ -0,0 +1,50 @@+import { Tabs as BaseTabs } from "@base-ui/react/tabs";+import type { ComponentProps } from "react";+import { cn } from "@/react/lib/utils";++function Tabs({ className, ...props }: ComponentProps<typeof BaseTabs.Root>) {+ return <BaseTabs.Root className={cn("w-full", className)} {...props} />;+}++function TabsList({+ className,+ ...props+}: ComponentProps<typeof BaseTabs.List>) {+ return (+ <BaseTabs.List+ className={cn("flex border-b border-control-border gap-x-4", className)}+ {...props}+ />+ );+}++function TabsTrigger({+ className,+ ...props+}: ComponentProps<typeof BaseTabs.Tab>) {+ return (+ <BaseTabs.Tab+ className={cn(+ "relative px-1 pb-2 text-sm font-medium text-control-light transition-colors hover:text-control cursor-pointer",+ "aria-selected:text-accent aria-selected:after:absolute aria-selected:after:inset-x-0 aria-selected:after:bottom-[-1px] aria-selected:after:h-0.5 aria-selected:after:bg-accent",+ "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",+ className+ )}+ {...props}+ />+ );+}++function TabsPanel({+ className,+ ...props+}: ComponentProps<typeof BaseTabs.Panel>) {+ return (+ <BaseTabs.Panel+ className={cn("mt-3 focus-visible:outline-hidden", className)}+ {...props}+ />+ );+}++export { Tabs, TabsList, TabsTrigger, TabsPanel };diff --git a/frontend/src/react/hooks/useVueState.ts b/frontend/src/react/hooks/useVueState.tsnew file mode 100644index 0000000000..66bcc3ea51--- /dev/null+++ b/frontend/src/react/hooks/useVueState.ts@@ -0,0 +1,41 @@+import { useCallback, useRef, useSyncExternalStore } from "react";+import { watch } from "vue";++/**+ * Subscribe a React component to a Vue reactive getter.+ * Re-renders whenever the getter's tracked dependencies change.+ *+ * @param getter — A function that reads Vue reactive state (Pinia store, ref, computed, etc.)+ * @returns The current value of the getter, kept in sync with Vue reactivity.+ *+ * @example+ * const externalUrl = useVueState(() => useActuatorV1Store().serverInfo?.externalUrl ?? "");+ */+export function useVueState<T>(getter: () => T): T {+ // Cache the latest snapshot so getSnapshot returns a stable reference+ // between renders when the value hasn't changed.+ const snapshotRef = useRef<T>(getter());++ const subscribe = useCallback(+ (onStoreChange: () => void) => {+ const stop = watch(+ getter,+ (newVal) => {+ snapshotRef.current = newVal;+ onStoreChange();+ },+ { flush: "sync" }+ );+ // Initialize with current value+ snapshotRef.current = getter();+ return stop;+ },+ // getter is typically an inline arrow — we intentionally omit it from deps+ // to keep subscribe stable. The watch() inside tracks Vue deps automatically.+ []+ );++ const getSnapshot = useCallback(() => snapshotRef.current, []);++ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);+}diff --git a/frontend/src/react/mount.ts b/frontend/src/react/mount.tsindex ae7c9c4244..4f11e22f49 100644--- a/frontend/src/react/mount.ts+++ b/frontend/src/react/mount.ts@@ -1,88 +1,104 @@-import type { SubscriptionData } from "@/react/types";--export type { SubscriptionData };--export interface MountOptions {- data: SubscriptionData;- allowEdit: boolean;- allowManageInstanceLicenses: boolean;- onUploadLicense: (license: string) => Promise<boolean>;- onRequireEnterprise: () => void;- onManageInstanceLicenses: () => void;-}-// Use import.meta.glob so vue-tsc does not follow the import into React .tsx files.// Vite resolves the glob at build time and creates a lazy chunk for the matched module.-const pageLoaders = import.meta.glob("./pages/settings/SubscriptionPage.tsx");-const loadSubscriptionPage = pageLoaders[- "./pages/settings/SubscriptionPage.tsx"-] as () => Promise<{- // biome-ignore lint/suspicious/noExplicitAny: Component type checked by tsconfig.react.json- SubscriptionPage: (props: any) => any; // eslint-disable-line @typescript-eslint/no-explicit-any-}>;+const pageLoaders = import.meta.glob("./pages/settings/*.tsx");++// biome-ignore lint/suspicious/noExplicitAny: React types conflict with Vue JSX in vue-tsc+type ReactDeps = any; // eslint-disable-line @typescript-eslint/no-explicit-any+// biome-ignore lint/suspicious/noExplicitAny: Component type checked by tsconfig.react.json+type ReactComponent = (props: any) => any; // eslint-disable-line @typescript-eslint/no-explicit-any-async function loadDeps() {+let cachedDeps: ReactDeps | null = null;+const cachedPages = new Map<string, ReactComponent>();++async function loadCoreDeps() {+ if (cachedDeps) return cachedDeps;const [{ createElement, StrictMode },{ createRoot },{ I18nextProvider },i18nModule,- { SubscriptionPage },] = await Promise.all([import("react"),import("react-dom/client"),import("react-i18next"),import("@/react/i18n"),- loadSubscriptionPage(),]);- // Ensure i18n is fully initialized before renderingawait i18nModule.i18nReady;- return {+ cachedDeps = {createElement,StrictMode,createRoot,I18nextProvider,i18n: i18nModule.default,- SubscriptionPage,};+ return cachedDeps;+}++async function loadPage(name: string): Promise<ReactComponent> {+ const hit = cachedPages.get(name);+ if (hit) return hit;+ const path = `./pages/settings/${name}.tsx`;+ const loader = pageLoaders[path] as+ | (() => Promise<Record<string, unknown>>)+ | undefined;+ if (!loader) throw new Error(`Unknown React page: ${name}`);+ const mod = await loader();+ const Component = mod[name] as ReactComponent;+ cachedPages.set(name, Component);+ return Component;}+/**+ * Mount a self-contained React page into the given container element.+ * @param page — file name without extension, must match the exported function name+ * (e.g. "MCPPage", "SubscriptionPage")+ */// eslint-disable-next-line @typescript-eslint/ban-ts-comment-// @ts-ignore -- React createElement types conflict with Vue JSX in vue-tsc; checked by tsconfig.react.json+// @ts-ignore -- React createElement types conflict with Vue JSX in vue-tscfunction buildTree(- deps: Awaited<ReturnType<typeof loadDeps>>,- opts: MountOptions+ deps: ReactDeps,+ Component: ReactComponent,+ // biome-ignore lint/suspicious/noExplicitAny: Props type varies per page+ props?: any // eslint-disable-line @typescript-eslint/no-explicit-any) {- const { createElement, StrictMode, I18nextProvider, i18n, SubscriptionPage } =- deps;- return createElement(- StrictMode,+ return deps.createElement(+ deps.StrictMode,null,- createElement(- I18nextProvider,- { i18n },- createElement(SubscriptionPage, opts)+ deps.createElement(+ deps.I18nextProvider,+ { i18n: deps.i18n },+ deps.createElement(Component, props)));}-let cached: Awaited<ReturnType<typeof loadDeps>> | null = null;--export async function mountSubscriptionPage(+/**+ * Mount a React page into the given container element.+ * @param page — file name without extension, must match the exported function name+ * @param props — optional props for pages that need Vue callbacks (e.g. SubscriptionPage)+ */+export async function mountReactPage(container: HTMLElement,- opts: MountOptions+ page: string,+ // biome-ignore lint/suspicious/noExplicitAny: Props type varies per page+ props?: any // eslint-disable-line @typescript-eslint/no-explicit-any) {- cached = await loadDeps();- const root = cached.createRoot(container);- root.render(buildTree(cached, opts));+ const [deps, Component] = await Promise.all([loadCoreDeps(), loadPage(page)]);+ const root = deps.createRoot(container);+ root.render(buildTree(deps, Component, props));return root;}-export async function updateSubscriptionPage(+/**+ * Re-render an already-mounted React page with new props.+ */+export async function updateReactPage(// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic importroot: any, // eslint-disable-line @typescript-eslint/no-explicit-any- opts: MountOptions+ page: string,+ // biome-ignore lint/suspicious/noExplicitAny: Props type varies per page+ props?: any // eslint-disable-line @typescript-eslint/no-explicit-any) {- if (!cached) cached = await loadDeps();- root.render(buildTree(cached, opts));+ const [deps, Component] = await Promise.all([loadCoreDeps(), loadPage(page)]);+ root.render(buildTree(deps, Component, props));}diff --git a/frontend/src/react/pages/settings/IMPage.tsx b/frontend/src/react/pages/settings/IMPage.tsxnew file mode 100644index 0000000000..5fc0ab849a--- /dev/null+++ b/frontend/src/react/pages/settings/IMPage.tsx@@ -0,0 +1,519 @@+import { clone, create } from "@bufbuild/protobuf";+import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";+import { Plus, Trash2 } from "lucide-react";+import { type ChangeEvent, useCallback, useEffect, useState } from "react";+import { useTranslation } from "react-i18next";+// Static image imports — Vite cannot resolve dynamic src in <img>+import dingtalkIcon from "@/assets/im/dingtalk.png";+import feishuIcon from "@/assets/im/feishu.webp";+import slackIcon from "@/assets/im/slack.png";+import teamsIcon from "@/assets/im/teams.svg";+import wecomIcon from "@/assets/im/wecom.png";+import { Button } from "@/react/components/ui/button";+import { Input } from "@/react/components/ui/input";+import { useVueState } from "@/react/hooks/useVueState";+import { pushNotification, useSettingV1Store } from "@/store";+import { WebhookType } from "@/types/proto-es/v1/common_pb";+import {+ AppIMSetting_DingTalkSchema,+ AppIMSetting_FeishuSchema,+ type AppIMSetting_IMSetting,+ AppIMSetting_IMSettingSchema,+ AppIMSetting_LarkSchema,+ AppIMSetting_SlackSchema,+ AppIMSetting_TeamsSchema,+ AppIMSetting_WecomSchema,+ AppIMSettingSchema,+ Setting_SettingName,+ SettingValueSchema,+} from "@/types/proto-es/v1/setting_service_pb";+import { hasWorkspacePermissionV2 } from "@/utils";++// --- Constants ---++const IM_TYPES = [+ WebhookType.SLACK,+ WebhookType.FEISHU,+ WebhookType.LARK,+ WebhookType.WECOM,+ WebhookType.DINGTALK,+ WebhookType.TEAMS,+] as const;++const IM_TYPE_KEY: Record<number, string> = {+ [WebhookType.SLACK]: "SLACK",+ [WebhookType.FEISHU]: "FEISHU",+ [WebhookType.LARK]: "LARK",+ [WebhookType.WECOM]: "WECOM",+ [WebhookType.DINGTALK]: "DINGTALK",+ [WebhookType.TEAMS]: "TEAMS",+};++const IM_LABELS: Record<number, string> = {+ [WebhookType.SLACK]: "Slack",+ [WebhookType.FEISHU]: "Feishu",+ [WebhookType.LARK]: "Lark",+ [WebhookType.WECOM]: "WeCom",+ [WebhookType.DINGTALK]: "DingTalk",+ [WebhookType.TEAMS]: "Teams",+};++const IM_ICON_MAP: Record<string, string> = {+ SLACK: slackIcon,+ FEISHU: feishuIcon,+ LARK: feishuIcon,+ WECOM: wecomIcon,+ DINGTALK: dingtalkIcon,+ TEAMS: teamsIcon,+};++const IM_FIELDS: Record<number, { key: string; label: string }[]> = {+ [WebhookType.SLACK]: [{ key: "token", label: "Token" }],+ [WebhookType.FEISHU]: [+ { key: "appId", label: "App ID" },+ { key: "appSecret", label: "App Secret" },+ ],+ [WebhookType.LARK]: [+ { key: "appId", label: "App ID" },+ { key: "appSecret", label: "App Secret" },+ ],+ [WebhookType.WECOM]: [+ { key: "corpId", label: "Corp ID" },+ { key: "agentId", label: "Agent ID" },+ { key: "secret", label: "Secret" },+ ],+ [WebhookType.DINGTALK]: [+ { key: "clientId", label: "Client ID" },+ { key: "clientSecret", label: "Client Secret" },+ { key: "robotCode", label: "Robot Code" },+ ],+ [WebhookType.TEAMS]: [+ { key: "tenantId", label: "Tenant ID" },+ { key: "clientId", label: "Client ID" },+ { key: "clientSecret", label: "Client Secret" },+ ],+};++const UPDATE_MASKS: Record<number, string> = {+ [WebhookType.SLACK]: "value.app_im.slack",+ [WebhookType.FEISHU]: "value.app_im.feishu",+ [WebhookType.LARK]: "value.app_im.lark",+ [WebhookType.WECOM]: "value.app_im.wecom",+ [WebhookType.DINGTALK]: "value.app_im.dingtalk",+ [WebhookType.TEAMS]: "value.app_im_setting_value.teams",+};++// --- Protobuf helpers ---++function webhookTypeFromKey(key: string): WebhookType {+ for (const [num, k] of Object.entries(IM_TYPE_KEY)) {+ if (k === key) return Number(num) as WebhookType;+ }+ return WebhookType.WEBHOOK_TYPE_UNSPECIFIED;+}++function createIMSetting(+ wt: WebhookType,+ init?: Record<string, string>+): AppIMSetting_IMSetting {+ switch (wt) {+ case WebhookType.SLACK:+ return create(AppIMSetting_IMSettingSchema, {+ type: wt,+ payload: {+ case: "slack",+ value: create(AppIMSetting_SlackSchema, init),+ },+ });+ case WebhookType.FEISHU:+ return create(AppIMSetting_IMSettingSchema, {+ type: wt,+ payload: {+ case: "feishu",+ value: create(AppIMSetting_FeishuSchema, init),+ },+ });+ case WebhookType.LARK:+ return create(AppIMSetting_IMSettingSchema, {+ type: wt,+ payload: {+ case: "lark",+ value: create(AppIMSetting_LarkSchema, init),+ },+ });+ case WebhookType.WECOM:+ return create(AppIMSetting_IMSettingSchema, {+ type: wt,+ payload: {+ case: "wecom",+ value: create(AppIMSetting_WecomSchema, init),+ },+ });+ case WebhookType.DINGTALK:+ return create(AppIMSetting_IMSettingSchema, {+ type: wt,+ payload: {+ case: "dingtalk",+ value: create(AppIMSetting_DingTalkSchema, init),+ },+ });+ case WebhookType.TEAMS:+ return create(AppIMSetting_IMSettingSchema, {+ type: wt,+ payload: {+ case: "teams",+ value: create(AppIMSetting_TeamsSchema, init),+ },+ });+ default:+ return create(AppIMSetting_IMSettingSchema, { type: wt });+ }+}++function maskValues(payload: Record<string, unknown>): Record<string, string> {+ const result: Record<string, string> = {};+ for (const [k, v] of Object.entries(payload)) {+ if (k === "$typeName" || k === "$unknown") continue;+ result[k] = typeof v === "string" && v !== "" ? "*********" : "";+ }+ return result;+}++function getStoredIMSetting(+ settingStore: ReturnType<typeof useSettingV1Store>+) {+ const setting = settingStore.getSettingByName(Setting_SettingName.APP_IM);+ if (setting?.value?.value?.case !== "appIm") {+ return create(AppIMSettingSchema, { settings: [] });+ }+ return setting.value.value.value;+}++// --- Derived view model ---++interface IMSettingView {+ type: string;+ typeLabel: string;+ isConfigured: boolean;+ fields: { key: string; label: string }[];+ values: Record<string, string>;+}++function buildSettingsView(+ localSettings: AppIMSetting_IMSetting[],+ configuredTypes: Set<number>+): IMSettingView[] {+ return localSettings.map((item) => {+ const typeKey = IM_TYPE_KEY[item.type] ?? "";+ const fields = IM_FIELDS[item.type] ?? [];+ const payloadObj = (item.payload?.value ?? {}) as Record<string, unknown>;+ return {+ type: typeKey,+ typeLabel: IM_LABELS[item.type] ?? typeKey,+ isConfigured: configuredTypes.has(item.type),+ fields,+ values: configuredTypes.has(item.type)+ ? maskValues(payloadObj)+ : Object.fromEntries(+ fields.map((f) => [f.key, String(payloadObj[f.key] ?? "")])+ ),+ };+ });+}++// --- Component ---++export function IMPage() {+ const { t } = useTranslation();+ const settingStore = useSettingV1Store();+ const allowEdit = hasWorkspacePermissionV2("bb.settings.set");++ // Subscribe to store changes+ const storedSetting = useVueState(() => getStoredIMSetting(settingStore));++ // Local state+ const [localSettings, setLocalSettings] = useState<AppIMSetting_IMSetting[]>(+ []+ );+ const [localValues, setLocalValues] = useState<Record<string, string>[]>([]);+ const [pendingSaveType, setPendingSaveType] = useState<string | null>(null);+ const [initialized, setInitialized] = useState(false);++ // Fetch on mount+ useEffect(() => {+ settingStore+ .getOrFetchSettingByName(Setting_SettingName.APP_IM)+ .then(() => setInitialized(true));+ }, [settingStore]);++ // Sync local state from store+ const syncFromStore = useCallback(() => {+ const stored = getStoredIMSetting(settingStore);+ const cloned = stored.settings.map((s) =>+ clone(AppIMSetting_IMSettingSchema, s)+ );+ setLocalSettings(cloned);+ }, [settingStore]);++ useEffect(() => {+ if (initialized) syncFromStore();+ }, [initialized, storedSetting, syncFromStore]);++ // Derive view model+ const configuredTypes = new Set(storedSetting.settings.map((s) => s.type));+ const settingsView = buildSettingsView(localSettings, configuredTypes);++ // Sync form values when settings view changes+ useEffect(() => {+ setLocalValues(settingsView.map((s) => ({ ...s.values })));+ }, [settingsView.length, initialized]);++ const existingTypes = new Set(localSettings.map((s) => s.type));+ const availableTypes = IM_TYPES.filter(+ (wt) => !configuredTypes.has(wt) && !existingTypes.has(wt)+ ).map((wt) => ({ type: IM_TYPE_KEY[wt], label: IM_LABELS[wt] }));++ // --- Handlers ---++ const handleAdd = (typeKey: string) => {+ const wt = webhookTypeFromKey(typeKey);+ setLocalSettings((prev) => [...prev, createIMSetting(wt)]);+ };++ const handleChangeType = (index: number, newTypeKey: string) => {+ const wt = webhookTypeFromKey(newTypeKey);+ setLocalSettings((prev) => {+ const next = [...prev];+ next[index] = createIMSetting(wt);+ return next;+ });+ };++ const updateField = (index: number, key: string, value: string) => {+ setLocalValues((prev) => {+ const next = [...prev];+ next[index] = { ...next[index], [key]: value };+ return next;+ });+ };++ const isDirty = (index: number) => {+ const local = localValues[index];+ const original = settingsView[index]?.values;+ if (!local || !original) return false;+ return Object.keys(original).some((k) => local[k] !== original[k]);+ };++ const handleDiscard = (index: number) => {+ const original = settingsView[index];+ if (!original) return;+ // If not configured (new item), remove it+ if (!original.isConfigured) {+ setLocalSettings((prev) => prev.filter((_, i) => i !== index));+ } else {+ setLocalValues((prev) => {+ const next = [...prev];+ next[index] = { ...original.values };+ return next;+ });+ }+ };++ const handleSave = async (index: number, typeKey: string) => {+ const wt = webhookTypeFromKey(typeKey);+ const values = localValues[index] ?? {};+ setPendingSaveType(typeKey);+ try {+ const reconstructed = createIMSetting(wt, values);+ const current = clone(+ AppIMSettingSchema,+ getStoredIMSetting(settingStore)+ );+ const existingIdx = current.settings.findIndex((s) => s.type === wt);+ if (existingIdx >= 0) {+ current.settings[existingIdx] = reconstructed;+ } else {+ current.settings.push(reconstructed);+ }+ await settingStore.upsertSetting({+ name: Setting_SettingName.APP_IM,+ value: create(SettingValueSchema, {+ value: { case: "appIm", value: current },+ }),+ updateMask: create(FieldMaskSchema, { paths: [UPDATE_MASKS[wt]] }),+ });+ syncFromStore();+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+ } finally {+ setPendingSaveType(null);+ }+ };++ const handleDelete = async (index: number, typeKey: string) => {+ if (!window.confirm(t("bbkit.confirm-button.sure-to-delete"))) return;+ const wt = webhookTypeFromKey(typeKey);+ const stored = getStoredIMSetting(settingStore);+ const wasConfigured = stored.settings.some((s) => s.type === wt);+ if (wasConfigured) {+ await settingStore.upsertSetting({+ name: Setting_SettingName.APP_IM,+ value: create(SettingValueSchema, {+ value: {+ case: "appIm",+ value: create(AppIMSettingSchema, {+ settings: stored.settings.filter((s) => s.type !== wt),+ }),+ },+ }),+ });+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.deleted"),+ });+ }+ syncFromStore();+ };++ // --- Render ---++ if (!initialized) return null;++ if (settingsView.length === 0) {+ return (+ <div className="w-full px-4 flex flex-col gap-y-4 py-4">+ <Description />+ <div className="py-12 border rounded-sm flex flex-col items-center justify-center gap-y-4 text-control-light">+ <span>{t("common.no-data")}</span>+ {availableTypes.length > 0 && allowEdit && (+ <Button onClick={() => handleAdd(availableTypes[0].type)}>+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.im.add-im-integration")}+ </Button>+ )}+ </div>+ </div>+ );+ }++ return (+ <div className="w-full px-4 flex flex-col gap-y-4 py-4">+ <Description />++ {settingsView.map((item, i) => (+ <div key={item.type} className="border rounded-sm p-4">+ {item.isConfigured ? (+ <IMTypeLabel type={item.type} label={item.typeLabel} />+ ) : (+ <select+ value={item.type}+ className="flex h-9 w-full max-w-xs rounded-md border border-control-border bg-transparent px-3 py-1 text-sm cursor-pointer"+ onChange={(e) => handleChangeType(i, e.target.value)}+ >+ <option value={item.type}>{item.typeLabel}</option>+ {availableTypes+ .filter((opt) => opt.type !== item.type)+ .map((opt) => (+ <option key={opt.type} value={opt.type}>+ {opt.label}+ </option>+ ))}+ </select>+ )}++ <div className="mt-4 flex flex-col gap-y-4">+ {item.fields.map((field) => (+ <div key={field.key}>+ <label className="textlabel">{field.label}</label>+ <Input+ className="mt-2"+ disabled={!allowEdit}+ placeholder={t("common.sensitive-placeholder")}+ value={localValues[i]?.[field.key] ?? ""}+ onChange={(e: ChangeEvent<HTMLInputElement>) =>+ updateField(i, field.key, e.target.value)+ }+ />+ </div>+ ))}+ </div>++ <div className="flex items-center justify-between mt-4 gap-x-2">+ <div>+ {item.isConfigured && allowEdit && (+ <Button+ variant="ghost"+ size="icon"+ className="text-error hover:text-error hover:bg-error/10"+ onClick={() => handleDelete(i, item.type)}+ >+ <Trash2 className="w-4 h-4" />+ </Button>+ )}+ </div>+ {isDirty(i) && (+ <div className="flex items-center gap-x-2">+ <Button+ variant="outline"+ disabled={!!pendingSaveType}+ onClick={() => handleDiscard(i)}+ >+ {t("common.discard-changes")}+ </Button>+ <Button+ disabled={!!pendingSaveType || !allowEdit}+ onClick={() => handleSave(i, item.type)}+ >+ {t("common.save")}+ </Button>+ </div>+ )}+ </div>+ </div>+ ))}++ {availableTypes.length > 0 && allowEdit && (+ <div className="flex justify-end">+ <Button+ variant="outline"+ onClick={() => handleAdd(availableTypes[0].type)}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.im.add-another-im")}+ </Button>+ </div>+ )}+ </div>+ );+}++function Description() {+ const { t } = useTranslation();+ return (+ <div className="textinfolabel">+ {t("settings.im-integration.description")}{" "}+ <a+ href="https://docs.bytebase.com/change-database/webhook?source=console"+ target="_blank"+ rel="noopener noreferrer"+ className="text-accent hover:underline"+ >+ {t("common.learn-more")} >+ </a>+ </div>+ );+}++function IMTypeLabel({ type, label }: { type: string; label: string }) {+ const icon = IM_ICON_MAP[type];+ return (+ <div className="flex items-center gap-x-2">+ {icon && <img src={icon} alt={label} className="h-5 w-5" />}+ <span className="text-sm font-medium">{label}</span>+ </div>+ );+}diff --git a/frontend/src/react/pages/settings/MCPPage.tsx b/frontend/src/react/pages/settings/MCPPage.tsxnew file mode 100644index 0000000000..636197f526--- /dev/null+++ b/frontend/src/react/pages/settings/MCPPage.tsx@@ -0,0 +1,237 @@+import { Check, Copy } from "lucide-react";+import { useMemo, useState } from "react";+import { useTranslation } from "react-i18next";+import {+ Alert,+ AlertDescription,+ AlertTitle,+} from "@/react/components/ui/alert";+import { Button } from "@/react/components/ui/button";+import { Input } from "@/react/components/ui/input";+import {+ Tabs,+ TabsList,+ TabsPanel,+ TabsTrigger,+} from "@/react/components/ui/tabs";+import { Textarea } from "@/react/components/ui/textarea";+import { useVueState } from "@/react/hooks/useVueState";+import { router } from "@/router";+import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";+import { useActuatorV1Store } from "@/store";+import { hasWorkspacePermissionV2 } from "@/utils";++export function MCPPage() {+ const { t } = useTranslation();+ const actuatorStore = useActuatorV1Store();++ const externalUrl = useVueState(+ () => actuatorStore.serverInfo?.externalUrl ?? ""+ );+ const needConfigureExternalUrl = useVueState(+ () => actuatorStore.needConfigureExternalUrl+ );+ const canConfigureExternalUrl = hasWorkspacePermissionV2(+ "bb.settings.setWorkspaceProfile"+ );++ const mcpEndpointUrl = useMemo(() => {+ if (needConfigureExternalUrl || !externalUrl) {+ return "{https://your-bytebase-url.com}/mcp";+ }+ const base = externalUrl.replace(/\/$/, "");+ return `${base}/mcp`;+ }, [externalUrl, needConfigureExternalUrl]);++ const generalConfig = useMemo(() => {+ return JSON.stringify(+ {+ mcpServers: {+ bytebase: {+ type: "http",+ url: mcpEndpointUrl,+ },+ },+ },+ null,+ 2+ );+ }, [mcpEndpointUrl]);++ const tabs = useMemo(+ () => [+ {+ id: "claude-code",+ title: "Claude Code",+ content: `claude mcp add bytebase --transport http ${mcpEndpointUrl}`,+ },+ {+ id: "codex",+ title: "Codex",+ content: `codex mcp add --name bytebase --transport http --url ${mcpEndpointUrl}`,+ },+ {+ id: "copilot-cli",+ title: "Copilot CLI",+ content: `gh copilot mcp add bytebase --transport http --url ${mcpEndpointUrl}`,+ },+ {+ id: "gemini-cli",+ title: "Gemini CLI",+ content: `gemini mcp add --name bytebase --transport http --url ${mcpEndpointUrl}`,+ },+ {+ id: "vscode",+ title: "VS Code",+ content: `code --add-mcp '{"name":"bytebase","type":"http","url":"${mcpEndpointUrl}"}'`,+ },+ ],+ [mcpEndpointUrl]+ );++ const firstPromptExample = t("settings.mcp.first-prompt.example");++ return (+ <div className="w-full px-4 flex flex-col gap-y-6 py-4">+ {/* Header */}+ <div>+ <h2 className="text-lg font-medium">{t("settings.mcp.title")}</h2>+ <p className="textinfolabel mt-1">{t("settings.mcp.description")}</p>+ </div>++ {/* Warning if external URL not configured */}+ {needConfigureExternalUrl && (+ <Alert variant="error">+ <AlertTitle>{t("banner.external-url")}</AlertTitle>+ <AlertDescription>+ <span>+ {t("settings.general.workspace.external-url.description")}+ </span>+ {canConfigureExternalUrl && (+ <Button+ variant="outline"+ size="sm"+ className="ml-3"+ onClick={() =>+ router.push({ name: SETTING_ROUTE_WORKSPACE_GENERAL })+ }+ >+ {t("common.configure-now")}+ </Button>+ )}+ </AlertDescription>+ </Alert>+ )}++ {/* Authentication Notice */}+ <Alert variant="info">+ <AlertTitle>{t("settings.mcp.auth.title")}</AlertTitle>+ <AlertDescription>+ {t("settings.mcp.auth.description")}+ </AlertDescription>+ </Alert>++ {/* Section 1: General Config */}+ <div className="flex flex-col gap-y-3">+ <div className="flex flex-col gap-y-1">+ <div className="flex items-center gap-x-2">+ <h3 className="text-base font-medium">+ {t("settings.mcp.general-config.title")}+ </h3>+ <CopyButton content={generalConfig} />+ </div>+ <p className="text-sm text-control-light">+ {t("settings.mcp.setup.add-to-config")}+ </p>+ </div>+ <Textarea+ readOnly+ value={generalConfig}+ rows={7}+ className="font-mono text-sm"+ />+ </div>++ {/* Section 2: Quick Start CLI Commands */}+ <div className="flex flex-col gap-y-3">+ <div className="flex flex-col gap-y-1">+ <h3 className="text-base font-medium">+ {t("settings.mcp.quick-start.title")}+ </h3>+ <p className="text-sm text-control-light">+ {t("settings.mcp.quick-start.description")}+ </p>+ </div>+ <Tabs defaultValue="claude-code">+ <TabsList>+ {tabs.map((tab) => (+ <TabsTrigger key={tab.id} value={tab.id}>+ {tab.title}+ </TabsTrigger>+ ))}+ </TabsList>+ {tabs.map((tab) => (+ <TabsPanel key={tab.id} value={tab.id}>+ <div className="flex items-center gap-x-2">+ <Input+ readOnly+ value={tab.content}+ className="flex-1 font-mono"+ onClick={(e) => (e.target as HTMLInputElement).select()}+ />+ <CopyButton content={tab.content} />+ </div>+ </TabsPanel>+ ))}+ </Tabs>+ </div>++ {/* Section 3: Your First Prompt */}+ <div className="flex flex-col gap-y-3">+ <div className="flex flex-col gap-y-1">+ <div className="flex items-center gap-x-2">+ <h3 className="text-base font-medium">+ {t("settings.mcp.first-prompt.title")}+ </h3>+ <CopyButton content={firstPromptExample} />+ </div>+ <p className="text-sm text-control-light">+ {t("settings.mcp.first-prompt.description")}+ </p>+ </div>+ <code className="text-sm bg-gray-100 px-3 py-2 rounded">+ {firstPromptExample}+ </code>+ </div>+ </div>+ );+}++function CopyButton({ content }: { content: string }) {+ const [copied, setCopied] = useState(false);++ const handleCopy = async () => {+ try {+ await navigator.clipboard.writeText(content);+ setCopied(true);+ setTimeout(() => setCopied(false), 2000);+ } catch {+ // Clipboard API not available+ }+ };++ return (+ <Button+ variant="ghost"+ size="icon"+ className="h-7 w-7"+ onClick={handleCopy}+ >+ {copied ? (+ <Check className="h-4 w-4 text-success" />+ ) : (+ <Copy className="h-4 w-4" />+ )}+ </Button>+ );+}diff --git a/frontend/src/react/pages/settings/SubscriptionPage.tsx b/frontend/src/react/pages/settings/SubscriptionPage.tsxindex 8ce4290283..cc6b93c14a 100644--- a/frontend/src/react/pages/settings/SubscriptionPage.tsx+++ b/frontend/src/react/pages/settings/SubscriptionPage.tsx@@ -5,50 +5,104 @@ import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { Textarea } from "@/react/components/ui/textarea";-import type { SubscriptionData } from "@/react/types";+import { useVueState } from "@/react/hooks/useVueState";+import {+ getWorkspaceId,+ pushNotification,+ useActuatorV1Store,+ useSubscriptionV1Store,+} from "@/store";+import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";+import { hasWorkspacePermissionV2 } from "@/utils";interface SubscriptionPageProps {- data: SubscriptionData;- allowEdit: boolean;- allowManageInstanceLicenses: boolean;- onUploadLicense: (license: string) => Promise<boolean>;onRequireEnterprise: () => void;onManageInstanceLicenses: () => void;}export function SubscriptionPage({- data,- allowEdit,- allowManageInstanceLicenses,- onUploadLicense,onRequireEnterprise,onManageInstanceLicenses,}: SubscriptionPageProps) {const { t } = useTranslation();+ const subscriptionStore = useSubscriptionV1Store();+ const actuatorStore = useActuatorV1Store();++ const allowEdit = hasWorkspacePermissionV2("bb.settings.set");+ const allowManageInstanceLicenses =+ allowEdit && hasWorkspacePermissionV2("bb.instances.list");++ // Subscribe to Vue reactive state+ const currentPlan = useVueState(() => subscriptionStore.currentPlan);+ const isFreePlan = useVueState(() => subscriptionStore.isFreePlan);+ const isTrialing = useVueState(() => subscriptionStore.isTrialing);+ const isExpired = useVueState(() => subscriptionStore.isExpired);+ const isSelfHostLicense = useVueState(+ () => subscriptionStore.isSelfHostLicense+ );+ const showTrial = useVueState(() => subscriptionStore.showTrial);+ const trialingDays = useVueState(() => subscriptionStore.trialingDays);+ const expireAt = useVueState(() => subscriptionStore.expireAt);+ const instanceCountLimit = useVueState(+ () => subscriptionStore.instanceCountLimit+ );+ const instanceLicenseCount = useVueState(+ () => subscriptionStore.instanceLicenseCount+ );+ const userCountLimit = useVueState(() => subscriptionStore.userCountLimit);+ const activeUserCount = useVueState(() => actuatorStore.activeUserCount);+ const activatedInstanceCount = useVueState(+ () => actuatorStore.activatedInstanceCount+ );+ const workspaceId = useVueState(() =>+ getWorkspaceId(actuatorStore.workspaceResourceName)+ );+const [license, setLicense] = useState("");const [loading, setLoading] = useState(false);const [copied, setCopied] = useState(false);const disabled = loading || !license;+ let planType: "FREE" | "TEAM" | "ENTERPRISE" = "FREE";+ let planLabel = t("subscription.plan.free.title");+ if (currentPlan === PlanType.TEAM) {+ planType = "TEAM";+ planLabel = t("subscription.plan.team.title");+ } else if (currentPlan === PlanType.ENTERPRISE) {+ planType = "ENTERPRISE";+ planLabel = t("subscription.plan.enterprise.title");+ }+const userLimit =- data.userCountLimit === Number.MAX_VALUE+ userCountLimit === Number.MAX_VALUE? t("common.unlimited")- : `${data.userCountLimit}`;+ : `${userCountLimit}`;const totalLicenseCount =- data.instanceLicenseCount === Number.MAX_VALUE+ instanceLicenseCount === Number.MAX_VALUE? t("common.unlimited")- : `${data.instanceLicenseCount}`;+ : `${instanceLicenseCount}`;const handleUpload = async () => {if (disabled) return;setLoading(true);try {- const success = await onUploadLicense(license);- if (success) {- setLicense("");- }+ await subscriptionStore.patchSubscription(license);+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("subscription.update.success.title"),+ description: t("subscription.update.success.description"),+ });+ setLicense("");+ } catch {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("subscription.update.failure.title"),+ description: t("subscription.update.failure.description"),+ });} finally {setLoading(false);}@@ -56,7 +110,7 @@ export function SubscriptionPage({const handleCopy = async () => {try {- await navigator.clipboard.writeText(data.workspaceId);+ await navigator.clipboard.writeText(workspaceId);setCopied(true);setTimeout(() => setCopied(false), 2000);} catch {@@ -72,40 +126,38 @@ export function SubscriptionPage({<div className="flex flex-col text-left"><div className="flex items-center text-main">{t("subscription.current")}- {data.isExpired && (+ {isExpired && (<Badge variant="destructive" className="ml-2 h-6">{t("subscription.expired")}</Badge>)}- {!data.isExpired && data.isTrialing && (+ {!isExpired && isTrialing && (<Badge variant="secondary" className="ml-2 h-6">{t("subscription.trialing")}</Badge>)}</div><div className="text-accent mt-1 text-3xl lg:text-4xl">- {data.currentPlan}+ {planLabel}</div></div>{/* Expires at */}- {!data.isFreePlan && (+ {!isFreePlan && (<div className="flex flex-col text-left"><div className="text-main">{t("subscription.expires-at")}</div>- <dd className="mt-1 text-3xl lg:text-4xl">- {data.expireAt || "N/A"}- </dd>+ <dd className="mt-1 text-3xl lg:text-4xl">{expireAt || "N/A"}</dd></div>)}{/* Free trial */}- {data.showTrial && allowEdit && (+ {showTrial && allowEdit && (<div className="flex flex-col text-left"><div className="text-main">{t("subscription.try-for-free")}</div><div className="mt-1"><Button className="text-lg" onClick={onRequireEnterprise}>{t("subscription.enterprise-free-trial", {- days: data.trialingDays,+ days: trialingDays,})}</Button></div>@@ -113,7 +165,7 @@ export function SubscriptionPage({)}{/* Inquire enterprise */}- {data.isTrialing && data.planType === "ENTERPRISE" && (+ {isTrialing && planType === "ENTERPRISE" && (<div className="flex flex-col text-left"><div className="text-main">{t("subscription.inquire-enterprise-plan")}@@ -129,9 +181,9 @@ export function SubscriptionPage({{/* Instance license stats */}{allowManageInstanceLicenses && (<InstanceLicenseStats- planType={data.planType}- instanceCountLimit={data.instanceCountLimit}- activatedCount={data.activatedInstanceCount}+ planType={planType}+ instanceCountLimit={instanceCountLimit}+ activatedCount={activatedInstanceCount}totalLicenseCount={totalLicenseCount}onManageInstanceLicenses={onManageInstanceLicenses}/>@@ -143,7 +195,7 @@ export function SubscriptionPage({{t("subscription.instance-assignment.used-and-total-user")}</div><div className="mt-1 text-4xl flex items-center gap-2">- {data.activeUserCount}+ {activeUserCount}<span className="font-mono text-control-light">/</span>{userLimit}</div>@@ -166,7 +218,7 @@ export function SubscriptionPage({<div className="mb-4 flex items-center gap-x-2"><InputreadOnly- value={data.workspaceId}+ value={workspaceId}onClick={(e) => (e.target as HTMLInputElement).select()}/><Button@@ -184,7 +236,7 @@ export function SubscriptionPage({</div>{/* Upload license */}- {data.isSelfHostLicense && (+ {isSelfHostLicense && (<div className="w-full mt-4 flex flex-col"><label className="flex items-center gap-x-2"><span className="text-main">@@ -201,7 +253,7 @@ export function SubscriptionPage({>{t("common.learn-more")} ></a>- {data.showTrial && allowEdit && (+ {showTrial && allowEdit && (<Buttonvariant="link"size="sm"diff --git a/frontend/src/react/react-env.d.ts b/frontend/src/react/react-env.d.tsindex 11f02fe2a0..55c953fb23 100644--- a/frontend/src/react/react-env.d.ts+++ b/frontend/src/react/react-env.d.ts@@ -1 +1,20 @@/// <reference types="vite/client" />++// Allow tsconfig.react.json to resolve .vue imports transitively+// (React pages import from @/store, @/router which re-export .vue modules)+declare module "*.vue" {+ import type { DefineComponent } from "vue";+ const component: DefineComponent<+ Record<string, unknown>,+ Record<string, unknown>,+ // biome-ignore lint/suspicious/noExplicitAny: Vue module shim+ any // eslint-disable-line @typescript-eslint/no-explicit-any+ >;+ export default component;+}++// Allow .yaml imports used by @/types+declare module "*.yaml" {+ const content: unknown;+ export default content;+}diff --git a/frontend/src/react/shims-vue-router.d.ts b/frontend/src/react/shims-vue-router.d.tsnew file mode 100644index 0000000000..93b3d7d624--- /dev/null+++ b/frontend/src/react/shims-vue-router.d.ts@@ -0,0 +1,12 @@+// Augment vue-router RouteMeta for transitive imports from @/router.+// Simplified version of src/shims-vue-router.d.ts that avoids+// referencing RouteLocationNormalized (not available in plain tsc).+import "vue-router";+declare module "vue-router" {+ interface RouteMeta {+ // biome-ignore lint/suspicious/noExplicitAny: simplified shim for React tsc+ title?: (...args: any[]) => string; // eslint-disable-line @typescript-eslint/no-explicit-any+ requiredPermissionList?: () => string[];+ overrideDocumentTitle?: boolean;+ }+}diff --git a/frontend/src/react/types.ts b/frontend/src/react/types.tsdeleted file mode 100644index acaa32971d..0000000000--- a/frontend/src/react/types.ts+++ /dev/null@@ -1,17 +0,0 @@-export interface SubscriptionData {- currentPlan: string;- planType: "FREE" | "TEAM" | "ENTERPRISE";- isFreePlan: boolean;- isTrialing: boolean;- isExpired: boolean;- isSelfHostLicense: boolean;- showTrial: boolean;- trialingDays: number;- expireAt: string;- instanceCountLimit: number;- instanceLicenseCount: number;- userCountLimit: number;- activeUserCount: number;- activatedInstanceCount: number;- workspaceId: string;-}diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.tsindex 13d961919d..93f8febe50 100644--- a/frontend/src/router/dashboard/workspace.ts+++ b/frontend/src/router/dashboard/workspace.ts@@ -374,8 +374,8 @@ const workspaceRoutes: RouteRecordRaw[] = [title: () => t("settings.sidebar.im-integration"),requiredPermissionList: () => ["bb.settings.get"],},- component: () => import("@/views/SettingWorkspaceIM.vue"),- props: true,+ component: () => import("@/react/ReactPageMount.vue"),+ props: () => ({ page: "IMPage" }),},{path: "mcp",@@ -384,8 +384,8 @@ const workspaceRoutes: RouteRecordRaw[] = [title: () => t("settings.sidebar.mcp"),requiredPermissionList: () => ["bb.settings.get"],},- component: () => import("@/views/SettingWorkspaceMCP.vue"),- props: true,+ component: () => import("@/react/ReactPageMount.vue"),+ props: () => ({ page: "MCPPage" }),},],},diff --git a/frontend/src/router/dashboard/workspaceSetting.ts b/frontend/src/router/dashboard/workspaceSetting.tsindex 082041666a..0c57cd532b 100644--- a/frontend/src/router/dashboard/workspaceSetting.ts+++ b/frontend/src/router/dashboard/workspaceSetting.ts@@ -56,8 +56,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [title: () => t("settings.sidebar.subscription"),requiredPermissionList: () => ["bb.settings.get"],},- component: () => import("@/react/ReactBridge.vue"),- props: true,+ component: () => import("@/react/SubscriptionPageMount.vue"),},],},diff --git a/frontend/src/views/SettingWorkspaceIM.vue b/frontend/src/views/SettingWorkspaceIM.vuedeleted file mode 100644index 6b1f912e96..0000000000--- a/frontend/src/views/SettingWorkspaceIM.vue+++ /dev/null@@ -1,684 +0,0 @@-<template>- <div class="w-full px-4 flex flex-col gap-y-4 py-4">- <div class="textinfolabel">- {{ $t("settings.im-integration.description") }}- <LearnMoreLink- url="https://docs.bytebase.com/change-database/webhook?source=console"- />- </div>-- <NEmpty- v-if="state.setting.settings.length === 0"- class="py-12 border rounded-sm"- >- <template #extra>- <PermissionGuardWrapper- v-if="availableImSettings.length > 0"- v-slot="slotProps"- :permissions="['bb.settings.set']"- >- <NButton- type="primary"- :disabled="slotProps.disabled"- @click="() => onAddIM(availableImSettings[0].value)"- >- <template #icon>- <PlusIcon class="h-4 w-4" />- </template>- {{ $t("settings.im.add-im-integration") }}- </NButton>- </PermissionGuardWrapper>- </template>- </NEmpty>- <div v-else class="flex flex-col gap-y-4">- <div- v-for="(item, i) in state.setting.settings"- :key="item.type"- class="border rounded-sm p-4"- >- <template v-if="isConfigured(item.type)">- <component :is="renderOption({ value: item.type })" />- </template>- <NSelect- v-else- v-model:value="item.type"- :options="availableImSettings"- :render-label="renderOption"- />-- <div class="mt-4">- <div v-if="item.type === WebhookType.SLACK">- <div class="textlabel">Token</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Slack).token"- />- </div>- <div- v-else-if="item.type === WebhookType.FEISHU"- class="flex flex-col gap-y-4"- >- <div>- <div class="textlabel">App ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Feishu).appId"- />- </div>- <div>- <div class="textlabel">App Secret</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Feishu).appSecret"- />- </div>- </div>- <div- v-else-if="item.type === WebhookType.WECOM"- class="flex flex-col gap-y-4"- >- <div>- <div class="textlabel">Corp ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Wecom).corpId"- />- </div>- <div>- <div class="textlabel">Agent ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Wecom).agentId"- />- </div>- <div>- <div class="textlabel">Secret</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Wecom).secret"- />- </div>- </div>- <div- v-else-if="item.type === WebhookType.LARK"- class="flex flex-col gap-y-4"- >- <div>- <div class="textlabel">App ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Lark).appId"- />- </div>- <div>- <div class="textlabel">App Secret</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Lark).appSecret"- />- </div>- </div>- <div- v-else-if="item.type === WebhookType.DINGTALK"- class="flex flex-col gap-y-4"- >- <div>- <div class="textlabel">Client ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_DingTalk).clientId"- />- </div>- <div>- <div class="textlabel">Client Secret</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_DingTalk).clientSecret"- />- </div>- <div>- <div class="textlabel">Robot Code</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_DingTalk).robotCode"- />- </div>- </div>- <div- v-else-if="item.type === WebhookType.TEAMS"- class="flex flex-col gap-y-4"- >- <div>- <div class="textlabel">Tenant ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Teams).tenantId"- />- </div>- <div>- <div class="textlabel">Client ID</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Teams).clientId"- />- </div>- <div>- <div class="textlabel">Client Secret</div>- <BBTextField- class="mt-2"- :disabled="!allowEdit"- :placeholder="t('common.sensitive-placeholder')"- v-model:value="(item.payload.value as AppIMSetting_Teams).clientSecret"- />- </div>- </div>- </div>-- <div class="flex items-center justify-between mt-4 gap-x-2">- <div>- <NPopconfirm- v-if="isConfigured(item.type) && allowEdit"- :positive-button-props="{- type: 'error',- }"- @positive-click="() => onDeleteIM(i, item.type)"- >- <template #trigger>- <NButton quaternary circle @click.stop type="error">- <template #icon>- <Trash2Icon class="w-4 h-auto" />- </template>- </NButton>- </template>- <template #default>- {{ $t("bbkit.confirm-button.sure-to-delete") }}- </template>- </NPopconfirm>- </div>- <div- v-if="isDataChanged(item.type, item.payload.value)"- class="flex items-center gap-x-2"- >- <NButton- tertiary- :disabled="!!state.pendingSaveType"- @click="() => onDiscardIM(i, item.type)"- >- {{ $t("common.discard-changes") }}- </NButton>- <NButton- type="primary"- :disabled="!!state.pendingSaveType || !allowEdit"- :loading="state.pendingSaveType === item.type"- @click="() => onSaveIM(i, item.type)"- >- {{ $t("common.save") }}- </NButton>- </div>- </div>- </div>-- <div v-if="availableImSettings.length > 0" class="flex justify-end">- <PermissionGuardWrapper- v-slot="slotProps"- :permissions="['bb.settings.set']"- >- <NButton- type="primary"- secondary- :disabled="slotProps.disabled"- @click="() => onAddIM(availableImSettings[0].value)"- >- <template #icon>- <PlusIcon class="h-4 w-4" />- </template>- {{ $t("settings.im.add-another-im") }}- </NButton>- </PermissionGuardWrapper>- </div>- </div>- </div>-</template>--<script lang="tsx" setup>-import { clone, create } from "@bufbuild/protobuf";-import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";-import { isEqual } from "lodash-es";-import { PlusIcon, Trash2Icon } from "lucide-vue-next";-import { NButton, NEmpty, NPopconfirm, NSelect } from "naive-ui";-import { computed, onMounted, reactive, watch } from "vue";-import { useI18n } from "vue-i18n";-import BBTextField from "@/bbkit/BBTextField.vue";-import LearnMoreLink from "@/components/LearnMoreLink.vue";-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";-import WebhookTypeIcon from "@/components/Project/WebhookTypeIcon.vue";-import { pushNotification, useSettingV1Store } from "@/store";-import { WebhookType } from "@/types/proto-es/v1/common_pb";-import {- type AppIMSetting,- type AppIMSetting_DingTalk,- AppIMSetting_DingTalkSchema,- type AppIMSetting_Feishu,- AppIMSetting_FeishuSchema,- type AppIMSetting_IMSetting,- AppIMSetting_IMSettingSchema,- type AppIMSetting_Lark,- AppIMSetting_LarkSchema,- type AppIMSetting_Slack,- AppIMSetting_SlackSchema,- type AppIMSetting_Teams,- AppIMSetting_TeamsSchema,- type AppIMSetting_Wecom,- AppIMSetting_WecomSchema,- AppIMSettingSchema,- Setting_SettingName,- SettingValueSchema,-} from "@/types/proto-es/v1/setting_service_pb";--interface LocalState {- setting: AppIMSetting;- pendingSaveType?: WebhookType;-}--type IMSettingPayloadValue =- | AppIMSetting_Slack- | AppIMSetting_Feishu- | AppIMSetting_Wecom- | AppIMSetting_Lark- | AppIMSetting_DingTalk- | AppIMSetting_Teams- | undefined;--defineProps<{- allowEdit: boolean;-}>();--const { t } = useI18n();-const state = reactive<LocalState>({- setting: create(AppIMSettingSchema, {- settings: [],- }),-});--const settingStore = useSettingV1Store();--const onAddIM = (type: WebhookType) => {- let setting: AppIMSetting_IMSetting | undefined = undefined;- switch (type) {- case WebhookType.SLACK:- setting = create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "slack",- value: create(AppIMSetting_SlackSchema, {}),- },- });- break;- case WebhookType.FEISHU:- setting = create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "feishu",- value: create(AppIMSetting_FeishuSchema, {}),- },- });- break;- case WebhookType.LARK:- setting = create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "lark",- value: create(AppIMSetting_LarkSchema, {}),- },- });- break;- case WebhookType.WECOM:- setting = create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "wecom",- value: create(AppIMSetting_WecomSchema, {}),- },- });- break;- case WebhookType.DINGTALK:- setting = create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "dingtalk",- value: create(AppIMSetting_DingTalkSchema, {}),- },- });- break;- case WebhookType.TEAMS:- setting = create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "teams",- value: create(AppIMSetting_TeamsSchema, {}),- },- });- break;- }- if (!setting) {- return;- }- state.setting.settings.push(setting);-};--const onDeleteIM = async (index: number, type: WebhookType) => {- state.setting.settings.splice(index, 1);- if (isConfigured(type)) {- await settingStore.upsertSetting({- name: Setting_SettingName.APP_IM,- value: create(SettingValueSchema, {- value: {- case: "appIm",- value: create(AppIMSettingSchema, {- settings: imSetting.value.settings.filter(- (setting) => setting.type !== type- ),- }),- },- }),- });- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.deleted"),- });- }-};--const onDiscardIM = (index: number, type: WebhookType) => {- const oldSetting = imSetting.value.settings.find(- (setting) => setting.type === type- );- if (oldSetting) {- state.setting.settings[index] = clone(- AppIMSetting_IMSettingSchema,- oldSetting- );- } else {- state.setting.settings.splice(index, 1);- }-};--const onSaveIM = async (index: number, type: WebhookType) => {- state.pendingSaveType = type;-- const updateMask: string[] = [];- switch (type) {- case WebhookType.SLACK:- updateMask.push("value.app_im.slack");- break;- case WebhookType.FEISHU:- updateMask.push("value.app_im.feishu");- break;- case WebhookType.WECOM:- updateMask.push("value.app_im.wecom");- break;- case WebhookType.LARK:- updateMask.push("value.app_im.lark");- break;- case WebhookType.DINGTALK:- updateMask.push("value.app_im.dingtalk");- break;- case WebhookType.TEAMS:- updateMask.push("value.app_im_setting_value.teams");- break;- }-- const setting = state.setting.settings[index];- const oldIndex = imSetting.value.settings.findIndex(- (setting) => setting.type === type- );-- // Reconstruct the setting with proper oneof payload to avoid Vue reactivity issues- const reconstructSetting = (): AppIMSetting_IMSetting => {- const payloadValue = setting.payload.value;- switch (type) {- case WebhookType.SLACK:- return create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "slack",- value: create(- AppIMSetting_SlackSchema,- payloadValue as AppIMSetting_Slack- ),- },- });- case WebhookType.FEISHU:- return create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "feishu",- value: create(- AppIMSetting_FeishuSchema,- payloadValue as AppIMSetting_Feishu- ),- },- });- case WebhookType.WECOM:- return create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "wecom",- value: create(- AppIMSetting_WecomSchema,- payloadValue as AppIMSetting_Wecom- ),- },- });- case WebhookType.LARK:- return create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "lark",- value: create(- AppIMSetting_LarkSchema,- payloadValue as AppIMSetting_Lark- ),- },- });- case WebhookType.DINGTALK:- return create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "dingtalk",- value: create(- AppIMSetting_DingTalkSchema,- payloadValue as AppIMSetting_DingTalk- ),- },- });- case WebhookType.TEAMS:- return create(AppIMSetting_IMSettingSchema, {- type,- payload: {- case: "teams",- value: create(- AppIMSetting_TeamsSchema,- payloadValue as AppIMSetting_Teams- ),- },- });- default:- return setting;- }- };-- const reconstructedSetting = reconstructSetting();-- // Use protobuf clone to properly preserve oneof discriminators- const pendingUpdate = clone(AppIMSettingSchema, imSetting.value);- if (oldIndex < 0) {- pendingUpdate.settings.push(reconstructedSetting);- } else {- pendingUpdate.settings[oldIndex] = reconstructedSetting;- }- try {- await settingStore.upsertSetting({- name: Setting_SettingName.APP_IM,- value: create(SettingValueSchema, {- value: {- case: "appIm",- value: pendingUpdate,- },- }),- updateMask: create(FieldMaskSchema, { paths: updateMask }),- });- onDiscardIM(index, type);- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.updated"),- });- } finally {- state.pendingSaveType = undefined;- }-};--const fillMask = (data: IMSettingPayloadValue): IMSettingPayloadValue => {- if (!data) {- return data;- }- const result = { ...data };- for (const key of Object.keys(result)) {- if (key === "$typeName" || key === "$unknown") {- continue;- }- const k = key as keyof IMSettingPayloadValue;- if (typeof result[k] === "string" && result[k] === "") {- (result[k] as string) = "*********";- }- }- return result;-};--const imSetting = computed(() => {- const setting = settingStore.getSettingByName(Setting_SettingName.APP_IM);- if (setting?.value?.value?.case !== "appIm") {- return create(AppIMSettingSchema, {- settings: [],- });- }- return create(AppIMSettingSchema, {- settings: setting.value.value.value.settings.map((imSetting) => {- return {- ...imSetting,- payload: {- case: imSetting.payload.case,- value: imSetting.payload.value- ? fillMask(imSetting.payload.value)- : undefined,- },- } as AppIMSetting_IMSetting;- }),- });-});--const isConfigured = (type: WebhookType) => {- return (- imSetting.value.settings.findIndex((setting) => setting.type === type) >= 0- );-};--const isExisted = (type: WebhookType) => {- return (- state.setting.settings.findIndex((setting) => setting.type === type) >= 0- );-};--const getImLabel = (type: WebhookType): string => {- switch (type) {- case WebhookType.SLACK:- return t("common.slack");- case WebhookType.FEISHU:- return t("common.feishu");- case WebhookType.LARK:- return t("common.lark");- case WebhookType.WECOM:- return t("common.wecom");- case WebhookType.DINGTALK:- return t("common.dingtalk");- case WebhookType.TEAMS:- return t("common.teams");- default:- return "";- }-};--const availableImSettings = computed(() => {- return [- WebhookType.SLACK,- WebhookType.FEISHU,- WebhookType.LARK,- WebhookType.WECOM,- WebhookType.DINGTALK,- WebhookType.TEAMS,- ]- .filter((type) => !isConfigured(type) && !isExisted(type))- .map((type) => ({- value: type,- }));-});--const renderOption = ({ value }: { value: WebhookType }) => {- return (- <div class="flex items-center gap-x-2">- <WebhookTypeIcon type={value} class="h-5 w-5" />- {getImLabel(value)}- </div>- );-};--onMounted(async () => {- await settingStore.getOrFetchSettingByName(Setting_SettingName.APP_IM);-});--watch(- () => imSetting.value,- (setting) => {- state.setting = clone(AppIMSettingSchema, setting);- },- { immediate: true }-);--const isDataChanged = (- type: WebhookType,- value: IMSettingPayloadValue-): boolean => {- const oldSetting = imSetting.value.settings.find(- (setting) => setting.type === type- )?.payload.value;- return !isEqual(value, oldSetting);-};-</script>diff --git a/frontend/src/views/SettingWorkspaceMCP.vue b/frontend/src/views/SettingWorkspaceMCP.vuedeleted file mode 100644index 0948abc143..0000000000--- a/frontend/src/views/SettingWorkspaceMCP.vue+++ /dev/null@@ -1,175 +0,0 @@-<template>- <div class="w-full px-4 flex flex-col gap-y-6 py-4">- <!-- Header -->- <div>- <h2 class="text-lg font-medium">{{ $t("settings.mcp.title") }}</h2>- <p class="textinfolabel mt-1">- {{ $t("settings.mcp.description") }}- </p>- </div>-- <!-- Warning if external URL not configured -->- <MissingExternalURLAttention />-- <!-- Authentication Notice -->- <NAlert type="info" :show-icon="true">- <template #header>- {{ $t("settings.mcp.auth.title") }}- </template>- {{ $t("settings.mcp.auth.description") }}- </NAlert>-- <!-- Section 1: General Config -->- <div class="flex flex-col gap-y-3">- <div class="flex flex-col gap-y-1">- <div class="flex items-center gap-x-2">- <h3 class="text-base font-medium">- {{ $t("settings.mcp.general-config.title") }}- </h3>- <CopyButton :content="generalConfig" />- </div>- <p class="text-sm text-control-light">- {{ $t("settings.mcp.setup.add-to-config") }}- </p>- </div>- <NInput- type="textarea"- :value="generalConfig"- readonly- :autosize="{ minRows: 5, maxRows: 8 }"- class="font-mono text-sm"- />- </div>-- <!-- Section 2: Quick Start CLI Commands -->- <div class="flex flex-col gap-y-3">- <div class="flex flex-col gap-y-1">- <div class="flex items-center gap-x-2">- <h3 class="text-base font-medium">- {{ $t("settings.mcp.quick-start.title") }}- </h3>- <CopyButton :content="activeTabContent" />- </div>- <p class="text-sm text-control-light">- {{ $t("settings.mcp.quick-start.description") }}- </p>- </div>- <NTabs v-model:value="activeTab" type="line" animated>- <NTabPane- v-for="tab in tabs"- :key="tab.id"- :name="tab.id"- :tab="tab.title"- >- <NInput- :value="tab.content"- readonly- class="font-mono text-sm mt-3"- />- </NTabPane>- </NTabs>- </div>-- <!-- Section 3: Your First Prompt -->- <div class="flex flex-col gap-y-3">- <div class="flex flex-col gap-y-1">- <div class="flex items-center gap-x-2">- <h3 class="text-base font-medium">- {{ $t("settings.mcp.first-prompt.title") }}- </h3>- <CopyButton :content="$t('settings.mcp.first-prompt.example')" />- </div>- <p class="text-sm text-control-light">- {{ $t("settings.mcp.first-prompt.description") }}- </p>- </div>- <code class="text-sm bg-gray-100 px-3 py-2 rounded">- {{ $t("settings.mcp.first-prompt.example") }}- </code>- </div>- </div>-</template>--<script lang="ts" setup>-import { NAlert, NInput, NTabPane, NTabs } from "naive-ui";-import { computed, ref } from "vue";-import { CopyButton, MissingExternalURLAttention } from "@/components/v2";-import { useActuatorV1Store } from "@/store";--const actuatorStore = useActuatorV1Store();-const activeTab = ref("claude-code");--const hasExternalUrl = computed(() => {- return !actuatorStore.needConfigureExternalUrl;-});--const mcpEndpointUrl = computed(() => {- const url = actuatorStore.serverInfo?.externalUrl ?? "";- if (!hasExternalUrl.value || !url) {- return "{https://your-bytebase-url.com}/mcp";- }- const base = url.replace(/\/$/, "");- return `${base}/mcp`;-});--const generalConfig = computed(() => {- const config = {- mcpServers: {- bytebase: {- type: "http",- url: mcpEndpointUrl.value,- },- },- };- return JSON.stringify(config, null, 2);-});--const cliCommands = computed(() => ({- claudeCode: `claude mcp add bytebase --transport http ${mcpEndpointUrl.value}`,- codex: `codex mcp add --name bytebase --transport http --url ${mcpEndpointUrl.value}`,- copilotCli: `gh copilot mcp add bytebase --transport http --url ${mcpEndpointUrl.value}`,- geminiCli: `gemini mcp add --name bytebase --transport http --url ${mcpEndpointUrl.value}`,- vscode: `code --add-mcp '{"name":"bytebase","type":"http","url":"${mcpEndpointUrl.value}"}'`,-}));--const tabs = computed(- (): {- id: string;- title: string;- content: string;- }[] => {- return [- {- id: "claude-code",- title: "Claude Code",- content: cliCommands.value.claudeCode,- },- {- id: "codex",- title: "Codex",- content: cliCommands.value.codex,- },- {- id: "copilot-cli",- title: "Copilot CLI",- content: cliCommands.value.copilotCli,- },- {- id: "gemini-cli",- title: "Gemini CLI",- content: cliCommands.value.geminiCli,- },- {- id: "vscode",- title: "VS Code",- content: cliCommands.value.vscode,- },- ];- }-);--const activeTabContent = computed(() => {- const tab = tabs.value.find((t) => t.id === activeTab.value);- return tab?.content ?? "";-});-</script>diff --git a/frontend/tsconfig.react.json b/frontend/tsconfig.react.jsonindex 503b87a802..9d5f0af143 100644--- a/frontend/tsconfig.react.json+++ b/frontend/tsconfig.react.json@@ -9,6 +9,7 @@"types": ["react", "react-dom", "vite/client"],"strict": true,"noEmit": true,+ "skipLibCheck": true,"paths": {"@/*": ["./src/*"]}