Skip to content

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

chore: deprecate BBSwitch and BBNotification (#10017)

ecmadao422ec1d49c26
diff --git a/docs/fe-style-guide.md b/docs/fe-style-guide.md
index 6d6df8dd01..b151898c4d 100644
--- a/docs/fe-style-guide.md
+++ b/docs/fe-style-guide.md
@@ -25,7 +25,7 @@ We prefer templates rather than JSX. Since templates are better optimized in com
We recommend using a "local state" pattern when components mutate their properties or provide a `v-model` property. This also helps us to avoid complaints from [vue/no-mutating-props](https://eslint.vuejs.org/rules/no-mutating-props.html).
-See [BBSwitch](https://github.com/bytebase/bytebase/blob/main/frontend/src/bbkit/BBSwitch.vue) as an example of this pattern.
+See [BBAlert](https://github.com/bytebase/bytebase/blob/main/frontend/src/bbkit/BBAlert.vue) as an example of this pattern.
# Linting and formatting
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index a3b0568c02..1b64773765 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -2,32 +2,32 @@
<CustomThemeProvider>
<Watermark />
- <NDialogProvider>
- <OverlayStackManager>
- <KBarWrapper>
- <router-view />
- <template v-if="state.notificationList.length > 0">
- <BBNotification
- :placement="'BOTTOM_RIGHT'"
- :notification-list="state.notificationList"
- @close="removeNotification"
- />
- </template>
- </KBarWrapper>
- </OverlayStackManager>
- </NDialogProvider>
+ <NNotificationProvider
+ :max="MAX_NOTIFICATION_DISPLAY_COUNT"
+ placement="bottom-right"
+ >
+ <NDialogProvider>
+ <OverlayStackManager>
+ <KBarWrapper>
+ <NotificationContext>
+ <router-view />
+ </NotificationContext>
+ </KBarWrapper>
+ </OverlayStackManager>
+ </NDialogProvider>
+ </NNotificationProvider>
</CustomThemeProvider>
</template>
<script lang="ts" setup>
-import { NDialogProvider } from "naive-ui";
+import { NDialogProvider, NNotificationProvider } from "naive-ui";
import { ServerError } from "nice-grpc-common";
import { ClientError, Status } from "nice-grpc-web";
-import { reactive, watchEffect, onErrorCaptured } from "vue";
+import { reactive, onErrorCaptured } from "vue";
import { useRouter } from "vue-router";
import Watermark from "@/components/misc/Watermark.vue";
import CustomThemeProvider from "./CustomThemeProvider.vue";
-import { BBNotificationItem } from "./bbkit/types";
+import NotificationContext from "./NotificationContext.vue";
import KBarWrapper from "./components/KBar/KBarWrapper.vue";
import OverlayStackManager from "./components/misc/OverlayStackManager.vue";
import { t } from "./plugins/i18n";
@@ -40,11 +40,7 @@ const MAX_NOTIFICATION_DISPLAY_COUNT = 3;
// Check expiration every 30 sec and logout if expired
const CHECK_LOGGEDIN_STATE_DURATION = 30 * 1000;
-const NOTIFICATION_DURATION = 6000;
-const CRITICAL_NOTIFICATION_DURATION = 10000;
-
interface LocalState {
- notificationList: BBNotificationItem[];
prevLoggedIn: boolean;
}
@@ -53,7 +49,6 @@ const notificationStore = useNotificationStore();
const router = useRouter();
const state = reactive<LocalState>({
- notificationList: [],
prevLoggedIn: authStore.isLoggedIn(),
});
@@ -69,48 +64,6 @@ setInterval(() => {
}
}, CHECK_LOGGEDIN_STATE_DURATION);
-const removeNotification = (item: BBNotificationItem | undefined) => {
- if (!item) return;
- item.onClose();
- const index = state.notificationList.indexOf(item);
- if (index >= 0) {
- state.notificationList.splice(index, 1);
- }
-};
-
-const watchNotification = () => {
- const notification = notificationStore.tryPopNotification({
- module: "bytebase",
- });
- if (notification) {
- if (state.notificationList.length >= MAX_NOTIFICATION_DISPLAY_COUNT) {
- state.notificationList.pop();
- }
-
- const item: BBNotificationItem = {
- style: notification.style,
- title: notification.title,
- description: notification.description || "",
- link: notification.link || "",
- linkTitle: notification.linkTitle || "",
- onClose: notification.onClose || (() => {}),
- };
- state.notificationList.unshift(item);
- if (!notification.manualHide) {
- setTimeout(
- () => {
- removeNotification(item);
- },
- notification.style == "CRITICAL"
- ? CRITICAL_NOTIFICATION_DURATION
- : NOTIFICATION_DURATION
- );
- }
- }
-};
-
-watchEffect(watchNotification);
-
onErrorCaptured((error: any /* , _, info */) => {
// Handle grpc request error.
// It looks like: `{"path":"/bytebase.v1.AuthService/Login","code":2,"details":"Response closed without headers"}`
diff --git a/frontend/src/NotificationContext.vue b/frontend/src/NotificationContext.vue
new file mode 100644
index 0000000000..b4d9b02055
--- /dev/null
+++ b/frontend/src/NotificationContext.vue
@@ -0,0 +1,64 @@
+<template>
+ <slot></slot>
+</template>
+
+<script setup lang="ts">
+import { useNotification } from "naive-ui";
+import { watchEffect, h } from "vue";
+import { useNotificationStore } from "@/store";
+import { BBNotificationStyle } from "@/types";
+
+const NOTIFICATION_DURATION = 6000;
+const CRITICAL_NOTIFICATION_DURATION = 10000;
+
+const notificationStore = useNotificationStore();
+const notification = useNotification();
+
+const getNotificationType = (style: BBNotificationStyle) => {
+ switch (style) {
+ case "CRITICAL":
+ return "error";
+ case "INFO":
+ return "info";
+ case "WARN":
+ return "warning";
+ default:
+ return "success";
+ }
+};
+
+const watchNotification = () => {
+ const item = notificationStore.tryPopNotification({
+ module: "bytebase",
+ });
+ if (!item) {
+ return;
+ }
+
+ const duration = item.manualHide
+ ? undefined
+ : item.style === "CRITICAL"
+ ? CRITICAL_NOTIFICATION_DURATION
+ : NOTIFICATION_DURATION;
+
+ notification.create({
+ type: getNotificationType(item.style),
+ keepAliveOnHover: true,
+ duration,
+ title: item.title,
+ content: item.description,
+ meta: () => {
+ if (!item.link || !item.linkTitle) {
+ return undefined;
+ }
+ return h(
+ "a",
+ { href: item.link, class: "normal-link", target: "_blank" },
+ item.linkTitle
+ );
+ },
+ });
+};
+
+watchEffect(watchNotification);
+</script>
diff --git a/frontend/src/bbkit/BBNotification.vue b/frontend/src/bbkit/BBNotification.vue
deleted file mode 100644
index 9484c3cb9f..0000000000
--- a/frontend/src/bbkit/BBNotification.vue
+++ /dev/null
@@ -1,147 +0,0 @@
-<template>
- <div
- class="fixed inset-0 px-4 py-6 pointer-events-none sm:p-6 z-[9999]"
- :class="placementClass"
- >
- <template
- v-for="(notification, index) of notificationList.slice().reverse()"
- :key="index"
- >
- <!--
- Notification panel, show/hide based on alert state.
-
- Entering: "transform ease-out duration-300 transition"
- From: "translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
- To: "translate-y-0 opacity-100 sm:translate-x-0"
- Leaving: "transition ease-in duration-100"
- From: "opacity-100"
- To: "opacity-0"
- -->
- <transition
- enter-active-class="transform ease-out duration-300 transition"
- enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
- enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
- leave-active-class="transition ease-in duration-100"
- leave-from-class="opacity-100"
- leave-to-class="opacity-0"
- >
- <div
- v-if="true"
- class="max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"
- >
- <div class="p-4">
- <div class="flex items-start">
- <div class="flex-shrink-0">
- <template v-if="notification.style == 'SUCCESS'">
- <heroicons-outline:check-circle
- class="h-6 w-6 text-success"
- />
- </template>
- <template v-else-if="notification.style == 'WARN'">
- <heroicons-outline:exclamation
- class="h-6 w-6 text-yellow-600"
- />
- </template>
- <template v-else-if="notification.style == 'CRITICAL'">
- <heroicons-outline:exclamation-circle
- class="h-6 w-6 text-red-600"
- />
- </template>
- <template v-else>
- <heroicons-outline:information-circle
- class="w-6 h-6 text-blue-600"
- />
- </template>
- </div>
- <div class="ml-3 w-0 flex-1 pt-0.5">
- <p
- class="text-sm font-medium text-gray-900 whitespace-pre-wrap"
- >
- {{ notification.title }}
- </p>
- <p class="mt-1 text-sm text-gray-500 whitespace-pre-wrap">
- {{ notification.description }}
- </p>
- <div
- v-if="notification.link && notification.linkTitle"
- class="mt-2"
- >
- <button
- class="bg-white rounded-md text-sm font-medium text-accent hover:text-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
- @click.prevent="viewLink(notification)"
- >
- {{ notification.linkTitle }}
- </button>
- <button
- class="ml-6 bg-white rounded-md text-sm font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"
- @click.prevent="$emit('close', notification)"
- >
- Dismiss
- </button>
- </div>
- </div>
- <div class="ml-4 flex-shrink-0 flex">
- <button
- class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none"
- @click.prevent="$emit('close', notification)"
- >
- <span class="sr-only">Close</span>
- <!-- Heroicon name: solid/x -->
- <heroicons-solid:x class="h-5 w-5" />
- </button>
- </div>
- </div>
- </div>
- </div>
- </transition>
- </template>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { withDefaults, computed } from "vue";
-import { useRouter } from "vue-router";
-import { BBNotificationPlacement, BBNotificationItem } from "./types";
-
-// For <sm breakpoint, we always position it at the center.
-const placementClassMap: Map<BBNotificationPlacement, string> = new Map([
- [
- "TOP_LEFT",
- "flex flex-col-reverse items-start justify-center sm:justify-end",
- ],
- [
- "TOP_RIGHT",
- "flex flex-col-reverse items-end justify-center sm:justify-end",
- ],
- [
- "BOTTOM_LEFT",
- "flex flex-col space-y-2 items-start justify-center sm:justify-end",
- ],
- [
- "BOTTOM_RIGHT",
- "flex flex-col space-y-2 items-end justify-center sm:justify-end",
- ],
-]);
-
-const props = withDefaults(
- defineProps<{
- notificationList: BBNotificationItem[];
- placement?: BBNotificationPlacement;
- }>(),
- {
- placement: "TOP_RIGHT",
- }
-);
-
-const emit = defineEmits<{
- (event: "close", notification?: BBNotificationItem): void;
-}>();
-
-const router = useRouter();
-
-const viewLink = (notification: BBNotificationItem) => {
- router.push(notification.link);
- emit("close", notification);
-};
-const placementClass = computed(() => placementClassMap.get(props.placement));
-</script>
diff --git a/frontend/src/bbkit/BBSwitch.vue b/frontend/src/bbkit/BBSwitch.vue
deleted file mode 100644
index b94e43ff96..0000000000
--- a/frontend/src/bbkit/BBSwitch.vue
+++ /dev/null
@@ -1,111 +0,0 @@
-<template>
- <div class="flex items-center">
- <button
- type="button"
- class="relative inline-flex flex-shrink-0 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent disabled:cursor-not-allowed select-none"
- :class="[
- `w-${sizes.cw}`,
- `h-${sizes.ch}`,
- state.dirtyOn ? 'bg-accent disabled:bg-accent-disabled' : 'bg-gray-200',
- ]"
- :disabled="disabled"
- aria-pressed="false"
- @click.prevent="
- () => {
- state.dirtyOn = !state.dirtyOn;
- $emit('toggle', state.dirtyOn);
-
- state.dirtyOn = props.value;
- }
- "
- >
- <span class="sr-only">{{ label }}</span>
- <span
- aria-hidden="true"
- class="pointer-events-none inline-block rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"
- :class="[`w-${sizes.base}`, `h-${sizes.base}`]"
- :style="{
- transform: state.dirtyOn ? `translateX(${sizes.base * 0.25}rem)` : '',
- }"
- ></span>
- <span
- v-if="text"
- aria-hidden="true"
- class="pointer-events-none absolute right-0 top-0 flex items-center justify-center transition ease-in-out duration-200 overflow-hidden whitespace-nowrap"
- :class="[
- `w-${sizes.base}`,
- `h-${sizes.base}`,
- state.dirtyOn ? `text-white` : 'text-control',
- ]"
- :style="{
- fontSize: `${sizes.text}px`,
- transform: state.dirtyOn
- ? `translateX(-${sizes.base * 0.25}rem)`
- : '',
- }"
- >
- <slot v-if="state.dirtyOn" name="on">{{ $t("common.on") }}</slot>
- <slot v-else name="off">{{ $t("common.off") }}</slot>
- </span>
- </button>
- <span
- v-if="label"
- class="ml-2 text-sm font-medium items-center whitespace-nowrap"
- :class="disabled ? 'text-gray-400' : 'text-main'"
- >
- {{ label }}
- </span>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { watch, withDefaults, reactive, computed } from "vue";
-
-export type BBSwitchSize = "small" | "normal";
-
-const props = withDefaults(
- defineProps<{
- size?: BBSwitchSize;
- text?: boolean;
- label?: string;
- value?: boolean;
- disabled?: boolean;
- }>(),
- {
- size: "normal",
- text: false,
- label: "",
- value: true,
- disabled: false,
- }
-);
-
-defineEmits<{
- (event: "toggle", dirtyOn: boolean): void;
-}>();
-
-const state = reactive({
- dirtyOn: props.value,
-});
-
-const sizes = computed(() => {
- type Sizes = {
- base: number;
- cw: number; // container width
- ch: number; // container height
- text: number; // unit px
- };
- const sizeMap: Record<BBSwitchSize, Sizes> = {
- normal: { base: 5, cw: 11, ch: 6, text: 10 },
- small: { base: 4, cw: 9, ch: 5, text: 7.5 },
- };
- return sizeMap[props.size] ?? sizeMap["normal"];
-});
-
-watch(
- () => props.value,
- (cur) => {
- state.dirtyOn = cur;
- }
-);
-</script>
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index 6e3690f7b0..4c7cae7d3d 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -8,10 +8,8 @@ import BBContextMenu from "./BBContextMenu.vue";
import BBDialog from "./BBDialog.vue";
import { BBGrid } from "./BBGrid";
import BBModal from "./BBModal.vue";
-import BBNotification from "./BBNotification.vue";
import BBSelect from "./BBSelect.vue";
import BBSpin from "./BBSpin.vue";
-import BBSwitch from "./BBSwitch.vue";
import BBTab from "./BBTab.vue";
import {
BBTable,
@@ -32,10 +30,8 @@ export {
BBContextMenu,
BBModal,
BBDialog,
- BBNotification,
BBSelect,
BBSpin,
- BBSwitch,
BBTab,
BBTable,
BBTableCell,
diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.ts
index 71938c72c3..6b49abb573 100644
--- a/frontend/src/bbkit/types.ts
+++ b/frontend/src/bbkit/types.ts
@@ -47,19 +47,4 @@ export type BBTabItem<T = any> = {
data?: T;
};
-export type BBNotificationStyle = "INFO" | "SUCCESS" | "WARN" | "CRITICAL";
-export type BBNotificationPlacement =
- | "TOP_LEFT"
- | "TOP_RIGHT"
- | "BOTTOM_LEFT"
- | "BOTTOM_RIGHT";
-export type BBNotificationItem = {
- style: BBNotificationStyle;
- title: string;
- description: string;
- link: string;
- linkTitle: string;
- onClose: () => void;
-};
-
export type BBAvatarSizeType = "TINY" | "SMALL" | "NORMAL" | "LARGE" | "HUGE";
diff --git a/frontend/src/components/MonacoEditor/dev.ts b/frontend/src/components/MonacoEditor/dev.ts
index aec4b691d2..3a998bf12b 100644
--- a/frontend/src/components/MonacoEditor/dev.ts
+++ b/frontend/src/components/MonacoEditor/dev.ts
@@ -1,6 +1,6 @@
import { useLocalStorage } from "@vueuse/core";
+import { NSwitch } from "naive-ui";
import { defineComponent, h } from "vue";
-import { BBSwitch } from "@/bbkit";
import { useActuatorV1Store } from "@/store";
import { isDev } from "@/utils";
@@ -38,18 +38,18 @@ export const LSPTypeSwitch = defineComponent({
render() {
const label = h("span", {}, "[DEV] LSP Type");
const switcher = h(
- BBSwitch,
+ NSwitch,
{
text: true,
value: StoredLSPType.value === "NEW",
- onToggle(on: boolean) {
+ onUpdateValue(on: boolean) {
StoredLSPType.value = on ? "NEW" : "OLD";
location.reload();
},
},
{
- on: () => h("span", { class: "font-medium scale-x-75" }, "NEW"),
- off: () => h("span", { class: "font-medium scale-x-75" }, "OLD"),
+ checked: () => h("span", { class: "font-medium scale-x-75" }, "NEW"),
+ unchecked: () => h("span", { class: "font-medium scale-x-75" }, "OLD"),
}
);
return h(
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vue
index 44964f01f2..21a29cdc67 100644
--- a/frontend/src/components/ProfileDropdown.vue
+++ b/frontend/src/components/ProfileDropdown.vue
@@ -154,7 +154,7 @@
<div v-if="allowToggleDebug" class="py-1 menu-item">
<div class="flex flex-row items-center space-x-2 justify-between">
<span>Debug</span>
- <BBSwitch :value="isDebug" @toggle="switchDebug" />
+ <NSwitch size="small" :value="isDebug" @update-value="switchDebug" />
</div>
</div>
<div class="border-t border-gray-100"></div>
@@ -168,6 +168,7 @@
</template>
<script lang="ts" setup>
+import { NSwitch } from "naive-ui";
import { storeToRefs } from "pinia";
import { computed, ref } from "vue";
import { useRouter } from "vue-router";
diff --git a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue
index 6b0ec29ac0..78884e281b 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue
@@ -29,11 +29,10 @@
{{ $t("sql-review.rule.active") }}
</h3>
<div class="flex items-center gap-x-2 text-sm">
- <BBSwitch
+ <NSwitch
:disabled="disabled"
:value="state.level !== SQLReviewRuleLevel.DISABLED"
- size="small"
- @toggle="toggleActivity(rule, $event)"
+ @update-value="(val) => toggleActivity(rule, val)"
/>
</div>
</div>
@@ -163,6 +162,7 @@
</template>
<script lang="ts" setup>
+import { NSwitch } from "naive-ui";
import { computed, nextTick, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import AutoHeightTextarea from "@/components/misc/AutoHeightTextarea.vue";
diff --git a/frontend/src/components/SQLReview/components/SQLRuleTable.vue b/frontend/src/components/SQLReview/components/SQLRuleTable.vue
index 912f6828b5..35af408b58 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleTable.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleTable.vue
@@ -17,12 +17,11 @@
>
<template #item="{ item: rule }: { item: RuleTemplate }">
<div class="bb-grid-cell justify-center">
- <BBSwitch
- :class="[!editable && 'pointer-events-none']"
- :disabled="!isRuleAvailable(rule)"
- :value="rule.level !== SQLReviewRuleLevel.DISABLED"
+ <NSwitch
size="small"
- @toggle="toggleActivity(rule, $event)"
+ :disabled="!editable || !isRuleAvailable(rule)"
+ :value="rule.level !== SQLReviewRuleLevel.DISABLED"
+ @update-value="(val) => toggleActivity(rule, val)"
/>
</div>
<div class="bb-grid-cell gap-x-1">
@@ -140,12 +139,11 @@
class="w-4 h-4"
@click="setActiveRule(rule)"
/>
- <BBSwitch
- :class="[!editable && 'pointer-events-none']"
- :disabled="!isRuleAvailable(rule)"
- :value="rule.level !== SQLReviewRuleLevel.DISABLED"
+ <NSwitch
size="small"
- @toggle="toggleActivity(rule, $event)"
+ :disabled="!editable || !isRuleAvailable(rule)"
+ :value="rule.level !== SQLReviewRuleLevel.DISABLED"
+ @update-value="(val) => toggleActivity(rule, val)"
/>
</div>
</div>
@@ -181,9 +179,10 @@
<script lang="ts" setup>
import { ExternalLinkIcon, PencilIcon } from "lucide-vue-next";
+import { NSwitch } from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
-import { BBSwitch, BBGrid, type BBGridColumn } from "@/bbkit";
+import { BBGrid, type BBGridColumn } from "@/bbkit";
import { useCurrentPlan } from "@/store";
import {
convertToCategoryList,
diff --git a/frontend/src/composables/useExecuteSQL.ts b/frontend/src/composables/useExecuteSQL.ts
index a36ba39326..86697a7e2a 100644
--- a/frontend/src/composables/useExecuteSQL.ts
+++ b/frontend/src/composables/useExecuteSQL.ts
@@ -2,7 +2,6 @@ import { cloneDeep, isEmpty } from "lodash-es";
import { Status } from "nice-grpc-common";
import { markRaw } from "vue";
import { useI18n } from "vue-i18n";
-import { BBNotificationStyle } from "@/bbkit/types";
import { parseSQL } from "@/components/MonacoEditor/sqlParser";
import {
pushNotification,
@@ -17,6 +16,7 @@ import {
ExecuteOption,
SQLResultSetV1,
UNKNOWN_ID,
+ BBNotificationStyle,
} from "@/types";
import {
Advice_Status,
diff --git a/frontend/src/types/notification.ts b/frontend/src/types/notification.ts
index baf06c79e7..e94ff086f2 100644
--- a/frontend/src/types/notification.ts
+++ b/frontend/src/types/notification.ts
@@ -1,4 +1,4 @@
-import { BBNotificationStyle } from "../bbkit/types";
+export type BBNotificationStyle = "INFO" | "SUCCESS" | "WARN" | "CRITICAL";
export type Notification = {
id: string;
@@ -10,7 +10,6 @@ export type Notification = {
link?: string;
linkTitle?: string;
manualHide?: boolean;
- onClose?: () => void;
};
// "id" and "createdTs" is auto generated upon the notification store
diff --git a/frontend/src/views/ChangeHistoryDetail.vue b/frontend/src/views/ChangeHistoryDetail.vue
index cf04cd8b13..086a655c07 100644
--- a/frontend/src/views/ChangeHistoryDetail.vue
+++ b/frontend/src/views/ChangeHistoryDetail.vue
@@ -175,13 +175,16 @@
</div>
<div class="flex flex-row items-center gap-x-2">
- <BBSwitch
- v-if="allowShowDiff"
- :label="$t('change-history.show-diff')"
- :value="state.showDiff"
- data-label="bb-change-history-diff-switch"
- @toggle="state.showDiff = $event"
- />
+ <div v-if="allowShowDiff" class="flex space-x-1 items-center">
+ <NSwitch
+ v-model:value="state.showDiff"
+ size="small"
+ data-label="bb-change-history-diff-switch"
+ />
+ <span class="text-sm font-semibold">
+ {{ $t("change-history.show-diff") }}
+ </span>
+ </div>
<div class="textinfolabel">
<i18n-t
v-if="state.showDiff"
@@ -279,6 +282,7 @@
</template>
<script lang="ts" setup>
+import { NSwitch } from "naive-ui";
import { computed, reactive, watch, ref } from "vue";
import ChangeHistoryStatusIcon from "@/components/ChangeHistory/ChangeHistoryStatusIcon.vue";
import TableDetailDrawer from "@/components/TableDetailDrawer.vue";
diff --git a/frontend/src/views/sql-editor/ProfileDropdown/ProfileDropdown.vue b/frontend/src/views/sql-editor/ProfileDropdown/ProfileDropdown.vue
index 88bfff0138..2aa530dbff 100644
--- a/frontend/src/views/sql-editor/ProfileDropdown/ProfileDropdown.vue
+++ b/frontend/src/views/sql-editor/ProfileDropdown/ProfileDropdown.vue
@@ -104,7 +104,7 @@
<div v-if="allowToggleDebug" class="py-1 menu-item">
<div class="flex flex-row items-center space-x-2 justify-between">
<span>Debug</span>
- <BBSwitch :value="isDebug" @toggle="switchDebug" />
+ <NSwitch size="small" :value="isDebug" @update-value="switchDebug" />
</div>
</div>
<div class="border-t border-gray-100"></div>
@@ -118,10 +118,11 @@
</template>
<script lang="ts" setup>
+import { NSwitch } from "naive-ui";
import { storeToRefs } from "pinia";
import { computed, ref } from "vue";
import { useRouter } from "vue-router";
-import { BBContextMenu, BBSwitch } from "@/bbkit";
+import { BBContextMenu } from "@/bbkit";
import { LSPTypeSwitch } from "@/components/MonacoEditor/dev";
import UserAvatar from "@/components/User/UserAvatar.vue";
import { useLanguage } from "@/composables/useLanguage";