Skip to content

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

chore: remove BBDialog (#16269)

boojack439a560eaf7f
diff --git a/frontend/src/bbkit/BBDialog.vue b/frontend/src/bbkit/BBDialog.vue
deleted file mode 100644
index 9ab701129f..0000000000
--- a/frontend/src/bbkit/BBDialog.vue
+++ /dev/null
@@ -1,94 +0,0 @@
-<template>
- <BBModal
- :show="state.visible"
- :title="title"
- :subtitle="subtitle"
- :show-close="closable"
- :close-on-esc="closable"
- @close="onNegativeClick"
- >
- <slot name="default"></slot>
-
- <div class="pt-4 border-t border-block-border flex justify-end space-x-3">
- <NButton
- v-if="showNegativeBtn"
- size="small"
- @click.prevent="onNegativeClick"
- >
- {{ negativeText || $t("common.cancel") }}
- </NButton>
- <NButton
- v-if="showPositiveBtn"
- :type="type"
- size="small"
- data-label="bb-modal-confirm-button"
- @click.prevent="onPositiveClick"
- >
- {{ positiveText || $t("common.confirm") }}
- </NButton>
- </div>
- </BBModal>
-</template>
-
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
-import { reactive } from "vue";
-import type { Defer } from "@/utils";
-import { defer } from "@/utils";
-import BBModal from "./BBModal.vue";
-
-withDefaults(
- defineProps<{
- title: string;
- subtitle?: string;
- closable?: boolean;
- showNegativeBtn?: boolean;
- showPositiveBtn?: boolean;
- negativeText?: string;
- positiveText?: string;
- type: "info" | "warning";
- }>(),
- {
- showNegativeBtn: true,
- showPositiveBtn: true,
- type: "info",
- }
-);
-
-const emit = defineEmits<{
- (event: "on-positive-click"): void;
- (event: "on-negative-click"): void;
-}>();
-
-const state = reactive({
- visible: false,
- defer: undefined as Defer<boolean> | undefined,
-});
-
-const open = () => {
- if (state.defer) {
- state.defer.reject(new Error("duplicated call"));
- }
-
- state.defer = defer<boolean>();
- state.visible = true;
-
- return state.defer.promise;
-};
-
-const onPositiveClick = () => {
- state.visible = false;
- state.defer?.resolve(true);
-
- emit("on-positive-click");
-};
-
-const onNegativeClick = () => {
- state.visible = false;
- state.defer?.resolve(false);
-
- emit("on-negative-click");
-};
-
-defineExpose({ open });
-</script>
diff --git a/frontend/src/bbkit/directives/click-inside-outside.js b/frontend/src/bbkit/directives/click-inside-outside.js
deleted file mode 100644
index a10e1b7245..0000000000
--- a/frontend/src/bbkit/directives/click-inside-outside.js
+++ /dev/null
@@ -1,116 +0,0 @@
-// Based on v-click-outside f9fa3a0
-const HANDLERS_PROPERTY = "__v-click-inside-outside";
-const HAS_WINDOWS = typeof window !== "undefined";
-const HAS_NAVIGATOR = typeof navigator !== "undefined";
-const IS_TOUCH =
- HAS_WINDOWS &&
- ("ontouchstart" in window ||
- (HAS_NAVIGATOR && navigator.msMaxTouchPoints > 0));
-const EVENTS = IS_TOUCH ? ["touchstart"] : ["click"];
-
-function processDirectiveArguments(bindingValue) {
- const isFunction = typeof bindingValue === "function";
- if (!isFunction && typeof bindingValue !== "object") {
- throw new Error(
- "v-click-inside-outside: Binding value must be a function or an object"
- );
- }
-
- return {
- handler: isFunction ? bindingValue : bindingValue.handler,
- middleware: bindingValue.middleware || ((item) => item),
- events: bindingValue.events || EVENTS,
- isActive: !(bindingValue.isActive === false),
- detectIframe: !(bindingValue.detectIframe === false),
- };
-}
-
-function execHandler({ event, handler, middleware }, isClickInside) {
- if (middleware(event, isClickInside)) {
- handler(event, isClickInside);
- }
-}
-
-function onFauxIframeClick({ el, event, handler, middleware }) {
- // Note: on firefox clicking on iframe triggers blur, but only on
- // next event loop it becomes document.activeElement
- // https://stackoverflow.com/q/2381336#comment61192398_23231136
- setTimeout(() => {
- const { activeElement } = document;
- if (activeElement && activeElement.tagName === "IFRAME") {
- execHandler({ event, handler, middleware }, el.contains(activeElement));
- }
- }, 0);
-}
-
-function onEvent({ el, event, handler, middleware }) {
- // Note: composedPath is not supported on IE and Edge, more information here:
- // https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath
- // In the meanwhile, we are using el.contains for those browsers, not
- // the ideal solution, but using IE or EDGE is not ideal either.
- const path = event.path || (event.composedPath && event.composedPath());
- const isClickInside = path
- ? path.indexOf(el) >= 0
- : el.contains(event.target);
-
- execHandler({ event, handler, middleware }, isClickInside);
-}
-
-function beforeMount(el, { value }) {
- const { events, handler, middleware, isActive, detectIframe } =
- processDirectiveArguments(value);
- if (!isActive) {
- return;
- }
-
- el[HANDLERS_PROPERTY] = events.map((eventName) => ({
- event: eventName,
- srcTarget: document.documentElement,
- handler: (event) => onEvent({ el, event, handler, middleware }),
- }));
-
- if (detectIframe) {
- const detectIframeEvent = {
- event: "blur",
- srcTarget: window,
- handler: (event) => onFauxIframeClick({ el, event, handler, middleware }),
- };
-
- el[HANDLERS_PROPERTY] = [...el[HANDLERS_PROPERTY], detectIframeEvent];
- }
-
- el[HANDLERS_PROPERTY].forEach(({ event, srcTarget, handler }) =>
- setTimeout(() => {
- // Note: More info about this implementation can be found here:
- // https://github.com/ndelvalle/v-click-outside/issues/137
- if (!el[HANDLERS_PROPERTY]) {
- return;
- }
- srcTarget.addEventListener(event, handler, false);
- }, 0)
- );
-}
-
-function unmounted(el) {
- const handlers = el[HANDLERS_PROPERTY] || [];
- handlers.forEach(({ event, srcTarget, handler }) =>
- srcTarget.removeEventListener(event, handler, false)
- );
- delete el[HANDLERS_PROPERTY];
-}
-
-function updated(el, { value, oldValue }) {
- if (JSON.stringify(value) === JSON.stringify(oldValue)) {
- return;
- }
- unmounted(el);
- beforeMount(el, { value });
-}
-
-const directive = {
- beforeMount,
- updated,
- unmounted,
-};
-
-export default HAS_WINDOWS ? directive : {};
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index 7727f92242..309de6d04c 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -4,7 +4,6 @@ import BBAvatar from "./BBAvatar.vue";
import BBBadge from "./BBBadge.vue";
import BBBetaBadge from "./BBBetaBadge.vue";
import BBButtonConfirm from "./BBButtonConfirm.vue";
-import BBDialog from "./BBDialog.vue";
import { BBGrid } from "./BBGrid";
import BBModal from "./BBModal.vue";
import BBSpin from "./BBSpin.vue";
@@ -19,7 +18,6 @@ export {
BBAvatar,
BBButtonConfirm,
BBModal,
- BBDialog,
BBSpin,
BBTable,
BBTableCell,
diff --git a/frontend/src/components/v2/Model/ProjectV1Table.vue b/frontend/src/components/v2/Model/ProjectV1Table.vue
index a98a5266f3..5578ffb4d5 100644
--- a/frontend/src/components/v2/Model/ProjectV1Table.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Table.vue
@@ -20,7 +20,6 @@ import { NDataTable, type DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import type { BBGridRow } from "@/bbkit";
import { useCurrentProject } from "@/components/Project/useCurrentProject";
import { useProjectSidebar } from "@/components/Project/useProjectSidebar";
import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
@@ -28,7 +27,6 @@ import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
import { PROJECT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
import { getProjectName } from "@/store/modules/v1/common";
import type { ComposedProject } from "@/types";
-import type { Project } from "@/types/proto/v1/project_service";
import { extractProjectResourceName } from "@/utils";
import HighlightLabelText from "./HighlightLabelText.vue";
@@ -36,8 +34,6 @@ type ProjectDataTableColumn = DataTableColumn<ComposedProject> & {
hide?: boolean;
};
-export type ProjectGridRow = BBGridRow<Project>;
-
const props = withDefaults(
defineProps<{
projectList: ComposedProject[];
diff --git a/frontend/src/components/v2/ResourceOccupiedModal/ResourceOccupiedModal.vue b/frontend/src/components/v2/ResourceOccupiedModal/ResourceOccupiedModal.vue
index a7b58e8335..6377f1e907 100644
--- a/frontend/src/components/v2/ResourceOccupiedModal/ResourceOccupiedModal.vue
+++ b/frontend/src/components/v2/ResourceOccupiedModal/ResourceOccupiedModal.vue
@@ -1,49 +1,60 @@
<template>
- <BBDialog
- ref="resourceOccupiedModalRef"
+ <BBModal
+ v-model:show="modalVisible"
:title="$t('common.warning')"
- :closable="true"
- :show-positive-btn="showPositiveButton"
- :positive-text="$t('common.continue-anyway')"
- :type="'warning'"
- @on-positive-click="() => $emit('on-submit')"
- @on-negative-click="() => $emit('on-close')"
+ :show-close="true"
+ :close-on-esc="true"
+ @close="handleClose"
>
- <template #default>
- <div
- class="w-[30rem] max-w-full pt-2 pb-4 text-control break-words text-sm"
- >
- <div v-if="resources.length === 0">
- {{ $t("resource.delete-warning", { name: target }) }}
- </div>
- <div v-else class="space-y-2">
- <p>
- {{
- description ||
- $t("resource.delete-warning-with-resources", {
- name: target,
- })
- }}
- </p>
- <ul class="list-disc">
- <Resource
- v-for="(resource, i) in resources"
- :key="i"
- :show-prefix="true"
- :link="true"
- :resource="resource"
- />
- </ul>
- <p v-if="!description">{{ $t("resource.delete-warning-retry") }}</p>
- </div>
+ <div
+ class="w-[30rem] max-w-full pt-2 pb-4 text-control break-words text-sm"
+ >
+ <div v-if="resources.length === 0">
+ {{ $t("resource.delete-warning", { name: target }) }}
+ </div>
+ <div v-else class="space-y-2">
+ <p>
+ {{
+ description ||
+ $t("resource.delete-warning-with-resources", {
+ name: target,
+ })
+ }}
+ </p>
+ <ul class="list-disc">
+ <Resource
+ v-for="(resource, i) in resources"
+ :key="i"
+ :show-prefix="true"
+ :link="true"
+ :resource="resource"
+ />
+ </ul>
+ <p v-if="!description">{{ $t("resource.delete-warning-retry") }}</p>
</div>
- </template>
- </BBDialog>
+ </div>
+
+ <div class="pt-4 border-t border-block-border flex justify-end space-x-3">
+ <NButton size="small" @click.prevent="handleClose">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ v-if="showPositiveButton"
+ type="warning"
+ size="small"
+ data-label="bb-modal-confirm-button"
+ @click.prevent="handleSubmit"
+ >
+ {{ $t("common.continue-anyway") }}
+ </NButton>
+ </div>
+ </BBModal>
</template>
<script lang="tsx" setup>
+import { NButton } from "naive-ui";
import { ref } from "vue";
-import { BBDialog } from "@/bbkit";
+import { BBModal } from "@/bbkit";
import Resource from "./Resource.vue";
defineProps<{
@@ -53,12 +64,26 @@ defineProps<{
showPositiveButton: boolean;
}>();
-defineEmits<{
+const emit = defineEmits<{
(event: "on-submit"): void;
(event: "on-close"): void;
}>();
-const resourceOccupiedModalRef = ref<InstanceType<typeof BBDialog>>();
+const modalVisible = ref(false);
+
+const open = () => {
+ modalVisible.value = true;
+};
+
+const handleClose = () => {
+ modalVisible.value = false;
+ emit("on-close");
+};
+
+const handleSubmit = () => {
+ modalVisible.value = false;
+ emit("on-submit");
+};
-defineExpose({ open: () => resourceOccupiedModalRef.value?.open() });
+defineExpose({ open });
</script>
diff --git a/frontend/src/composables/useVModel.ts b/frontend/src/composables/useVModel.ts
deleted file mode 100644
index c860623012..0000000000
--- a/frontend/src/composables/useVModel.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { watch } from "vue";
-
-export const useVModel = <
- PS extends { [key in K]: PS[K] },
- K extends string,
- E extends (name: `update:${K}`, value: PS[K]) => void,
->(
- props: PS,
- state: PS,
- emit: E,
- key: K,
- immediate = false
-) => {
- watch(
- () => props[key],
- (v) => {
- state[key] = v;
- },
- { immediate }
- );
-
- watch(
- () => state[key],
- (v) => emit(`update:${key}`, v)
- );
-};