Skip to content

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

chore: deprecate BBSelect (#10040)

ecmadaoec911733564a
diff --git a/frontend/src/bbkit/BBSelect.vue b/frontend/src/bbkit/BBSelect.vue
deleted file mode 100644
index ec9667717b..0000000000
--- a/frontend/src/bbkit/BBSelect.vue
+++ /dev/null
@@ -1,266 +0,0 @@
-<template>
- <VBinder>
- <VTarget>
- <button
- ref="button"
- type="button"
- aria-haspopup="listbox"
- aria-expanded="true"
- aria-labelledby="listbox-label"
- class="btn-select relative w-full pl-3 pr-10 py-2"
- :disabled="disabled"
- v-bind="$attrs"
- @click="toggle"
- >
- <div
- class="whitespace-nowrap hide-scrollbar overflow-x-auto"
- :class="
- error
- ? 'text-error'
- : isSelected
- ? 'text-control'
- : 'text-control-placeholder'
- "
- >
- <template v-if="isSelected">
- <slot
- v-if="!multiple"
- name="menuItem"
- :item="state.selectedItem"
- :index="itemList.indexOf(state.selectedItem)"
- />
- <template v-else>
- <slot name="menuItemGroup" :item-list="state.selectedItemList" />
- </template>
- </template>
- <template v-else>
- <slot name="placeholder" :placeholder="placeholder">
- {{ placeholder }}
- </slot>
- </template>
- </div>
- <span
- class="ml-3 absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none"
- >
- <heroicons-solid:selector class="h-5 w-5 text-control-light" />
- </span>
- </button>
- </VTarget>
- <VFollower :show="state.showMenu" placement="bottom-start">
- <transition :appear="true" name="fade-fast">
- <div
- v-if="state.showMenu"
- ref="popup"
- class="z-50 rounded bg-white shadow-lg mt-0.5"
- :style="popupStyle"
- >
- <ul
- tabindex="-1"
- role="listbox"
- aria-labelledby="listbox-label"
- aria-activedescendant="listbox-item-3"
- class="max-h-56 rounded py-1 ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
- >
- <!--
- Select option, manage highlight styles based on mouseenter/mouseleave and keyboard navigation.
- Highlighted: "text-white bg-indigo-600", Not Highlighted: "text-gray-900"
- -->
- <slot v-if="showPrefixItem" name="prefixItem">
- <li
- class="cursor-default select-none py-2 px-3 text-control-light"
- >
- {{ placeholder }}
- </li>
- </slot>
- <li
- v-for="(item, index) in itemList"
- :key="index"
- role="option"
- class="group text-main cursor-default select-none relative py-2 pl-3 pr-9 hover:bg-gray-200"
- @click="handleSelect(item)"
- >
- <div class="whitespace-nowrap hide-scrollbar overflow-x-auto">
- <slot name="menuItem" :item="item" :index="index" />
- </div>
- <span
- v-if="
- (!multiple && isEqual(item, state.selectedItem)) ||
- (multiple && state.selectedItemList.includes(item))
- "
- class="absolute inset-y-0 right-0 flex items-center pr-4"
- >
- <!-- Heroicon name: solid/check -->
- <heroicons-solid:check class="h-5 w-5" />
- </span>
- </li>
- <div @click="close()">
- <slot name="suffixItem"></slot>
- </div>
- </ul>
- </div>
- </transition>
- </VFollower>
- </VBinder>
-</template>
-
-<script lang="ts">
-import { onClickOutside, useElementBounding } from "@vueuse/core";
-import { isEqual } from "lodash-es";
-import {
- reactive,
- PropType,
- watch,
- defineComponent,
- ref,
- CSSProperties,
- computed,
-} from "vue";
-import { VBinder, VTarget, VFollower } from "vueuc";
-
-interface LocalState {
- showMenu: boolean;
- selectedItem: any;
- selectedItemList: any[];
-}
-
-type ItemType = number | string | any;
-
-type FitWidthMode = "fit" | "min";
-
-export default defineComponent({
- name: "BBSelect",
- components: {
- VBinder,
- VTarget,
- VFollower,
- },
- inheritAttrs: false,
- props: {
- selectedItem: {
- type: [Object, Number, String] as PropType<ItemType>,
- default: undefined,
- },
- selectedItemList: {
- type: Array as PropType<ItemType[]>,
- default: () => [],
- required: false,
- },
- itemList: {
- required: true,
- type: Array as PropType<ItemType[]>,
- },
- placeholder: {
- default: "",
- type: String,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
- multiple: {
- default: false,
- type: Boolean,
- },
- showPrefixItem: {
- default: false,
- type: Boolean,
- },
- fitWidth: {
- type: String as PropType<FitWidthMode>,
- default: "fit",
- },
- error: {
- type: Boolean,
- default: false,
- },
- },
- emits: ["select-item", "update-item-list"],
- setup(props, { emit }) {
- const state = reactive<LocalState>({
- showMenu: false,
- selectedItem: props.selectedItem,
- selectedItemList: props.selectedItemList,
- });
-
- const button = ref<HTMLButtonElement>();
- const popup = ref<HTMLElement>();
-
- const { width } = useElementBounding(button);
-
- const popupStyle = computed(() => {
- const style = {} as CSSProperties;
-
- const key = props.fitWidth === "fit" ? "width" : "min-width";
- style[key] = `${width.value}px`;
-
- return style;
- });
-
- const isSelected = computed(() => {
- if (props.multiple) {
- return (
- state.selectedItemList !== null &&
- state.selectedItemList !== undefined &&
- state.selectedItemList.length > 0
- );
- } else {
- return (
- state.selectedItem !== null &&
- state.selectedItem !== undefined &&
- state.selectedItem !== ""
- );
- }
- });
-
- watch(
- () => props.selectedItem,
- (cur) => {
- state.selectedItem = cur;
- }
- );
-
- const handleSelect = (item: any) => {
- if (!props.multiple) {
- if (item !== state.selectedItem) {
- emit("select-item", item, () => {
- state.selectedItem = item;
- });
- }
- close();
- } else {
- if (!state.selectedItemList.includes(item)) {
- state.selectedItemList.push(item);
- } else {
- state.selectedItemList.splice(
- state.selectedItemList.indexOf(item),
- 1
- );
- }
- emit("update-item-list", state.selectedItemList);
- }
- };
-
- const toggle = () => {
- state.showMenu = !state.showMenu;
- };
-
- const close = () => {
- state.showMenu = false;
- };
-
- onClickOutside(popup, close);
-
- return {
- state,
- isSelected,
- handleSelect,
- toggle,
- close,
- button,
- popup,
- popupStyle,
- isEqual,
- };
- },
-});
-</script>
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index 033c8973e3..92644b6ffe 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -6,7 +6,6 @@ import BBButtonConfirm from "./BBButtonConfirm.vue";
import BBDialog from "./BBDialog.vue";
import { BBGrid } from "./BBGrid";
import BBModal from "./BBModal.vue";
-import BBSelect from "./BBSelect.vue";
import BBSpin from "./BBSpin.vue";
import BBTab from "./BBTab.vue";
import {
@@ -26,7 +25,6 @@ export {
BBButtonConfirm,
BBModal,
BBDialog,
- BBSelect,
BBSpin,
BBTab,
BBTable,
diff --git a/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue b/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
index 46037b5877..464f79cff2 100644
--- a/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
+++ b/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
@@ -62,20 +62,19 @@
<label class="textlabel">
{{ $t("database.backup-setting.form.day-of-week") }}
</label>
- <div class="w-[16rem]">
- <BBSelect
- :selected-item="
- localFromUTC(state.setting.hour, state.setting.dayOfWeek)
- .dayOfWeek
- "
- :item-list="AVAILABLE_DAYS_OF_WEEK"
- @select-item="setDayOfWeek"
- >
- <template #menuItem="{ item: day }">
- {{ nameOfDay(day) }}
- </template>
- </BBSelect>
- </div>
+ <NSelect
+ :value="
+ localFromUTC(state.setting.hour, state.setting.dayOfWeek)
+ .dayOfWeek
+ "
+ :options="
+ AVAILABLE_DAYS_OF_WEEK.map((item) => ({
+ value: item,
+ label: nameOfDay(item),
+ }))
+ "
+ @update:value="setDayOfWeek"
+ />
</div>
<div
@@ -93,19 +92,18 @@
({{ Intl.DateTimeFormat().resolvedOptions().timeZone }})
</span>
</label>
- <div class="w-[16rem]">
- <BBSelect
- :selected-item="
- localFromUTC(state.setting.hour, state.setting.dayOfWeek).hour
- "
- :item-list="AVAILABLE_HOURS_OF_DAY"
- @select-item="setHour"
- >
- <template #menuItem="{ item: hour }">
- {{ nameOfHour(hour) }}
- </template>
- </BBSelect>
- </div>
+ <NSelect
+ :value="
+ localFromUTC(state.setting.hour, state.setting.dayOfWeek).hour
+ "
+ :options="
+ AVAILABLE_HOURS_OF_DAY.map((item) => ({
+ value: item,
+ label: nameOfHour(item),
+ }))
+ "
+ @update:value="setHour"
+ />
</div>
<div
@@ -118,15 +116,11 @@
<label class="textlabel">
{{ $t("database.backup-setting.form.retention-period") }}
</label>
- <div class="w-[16rem]">
- <input
- type="number"
- class="textfield w-full hide-ticker"
- :placeholder="String(DEFAULT_BACKUP_RETENTION_PERIOD_DAYS)"
- :value="retentionPeriodDaysInputValue"
- @input="(e: any) => setRetentionPeriodDays(e.target.value)"
- />
- </div>
+ <NInputNumber
+ :placeholder="String(DEFAULT_BACKUP_RETENTION_PERIOD_DAYS)"
+ :value="retentionPeriodDaysInputValue"
+ @update:value="setRetentionPeriodDays"
+ />
</div>
</div>
@@ -156,7 +150,7 @@
</template>
<script lang="ts" setup>
-import { NPopover } from "naive-ui";
+import { NPopover, NSelect, NInputNumber } from "naive-ui";
import { computed, PropType, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { DrawerContent } from "@/components/v2";
@@ -260,10 +254,10 @@ const checkedSchedule = computed((): BackupPlanSchedule => {
);
});
-const retentionPeriodDaysInputValue = computed((): string => {
+const retentionPeriodDaysInputValue = computed(() => {
const seconds = state.setting.retentionPeriodTs;
- if (!seconds || seconds <= 0) return "";
- return String(Math.floor(seconds / 3600 / 24));
+ if (!seconds || seconds <= 0) return null;
+ return Math.floor(seconds / 3600 / 24);
});
const isValid = computed((): boolean => {
@@ -394,12 +388,13 @@ function setHour(hour: number) {
state.setting.dayOfWeek = utc.dayOfWeek;
}
-function setRetentionPeriodDays(input: string) {
- const days = parseInt(input, 10);
- if (days <= 0 || Number.isNaN(days)) {
+function setRetentionPeriodDays(input: number | null) {
+ if (!input) {
+ state.setting.retentionPeriodTs = -1;
+ } else if (input <= 0 || Number.isNaN(input)) {
state.setting.retentionPeriodTs = -1;
} else {
- state.setting.retentionPeriodTs = days * 3600 * 24;
+ state.setting.retentionPeriodTs = input * 3600 * 24;
}
}
diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vue
index a50f2b1e7a..180a3b5a70 100644
--- a/frontend/src/components/DatabaseBackupPanel.vue
+++ b/frontend/src/components/DatabaseBackupPanel.vue
@@ -60,12 +60,11 @@
<heroicons-outline:external-link class="w-4 h-4" />
</a>
</div>
- <input
+ <BBTextField
id="hookUrl"
- v-model="state.autoBackupUpdatedHookUrl"
+ v-model:value="state.autoBackupUpdatedHookUrl"
name="hookUrl"
- type="text"
- class="textfield mt-1 w-full"
+ class="mt-1 w-full"
placeholder="https://betteruptime.com/api/v1/heartbeat/..."
:disabled="!allowEdit"
/>
diff --git a/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue b/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
index 9082eccff2..c32d1a1877 100644
--- a/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
@@ -5,12 +5,10 @@
{{ $t("common.environment") }}
</p>
<EnvironmentSelect
- id="environment"
class="mt-1 max-w-md"
- name="environment"
+ :environment="environment?.uid"
:disabled="!allowEdit"
- :selected-id="environment?.uid"
- :default-environment="database.instanceEntity.environment"
+ :default-environment-name="database.instanceEntity.environment"
@select-environment-id="handleSelectEnvironmentUID"
/>
</div>
@@ -22,6 +20,7 @@
<script setup lang="ts">
import { cloneDeep } from "lodash-es";
import { computed } from "vue";
+import { EnvironmentSelect } from "@/components/v2";
import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
import { type ComposedDatabase } from "@/types";
import Labels from "./components/Labels.vue";
diff --git a/frontend/src/components/DatabaseOverviewPanel.vue b/frontend/src/components/DatabaseOverviewPanel.vue
index 822300a099..172f8db2fe 100644
--- a/frontend/src/components/DatabaseOverviewPanel.vue
+++ b/frontend/src/components/DatabaseOverviewPanel.vue
@@ -83,18 +83,12 @@
class="flex flex-row justify-start items-center mb-4"
>
<span class="text-lg leading-6 font-medium text-main mr-2">Schema</span>
- <BBSelect
- class="!w-auto min-w-[12rem]"
- :selected-item="state.selectedSchemaName"
- :item-list="schemaNameList"
+ <NSelect
+ v-model:value="state.selectedSchemaName"
+ :options="schemaNameOptions"
:placeholder="$t('database.schema.select')"
- :show-prefix-item="true"
- @select-item="(schema: string) => state.selectedSchemaName = schema"
- >
- <template #menuItem="{ item: schema }">
- {{ schema }}
- </template>
- </BBSelect>
+ class="!w-auto min-w-[12rem]"
+ />
</div>
<template v-if="databaseEngine !== Engine.REDIS">
@@ -193,6 +187,7 @@
<script lang="ts" setup>
import { head } from "lodash-es";
+import { NSelect } from "naive-ui";
import { computed, reactive, watch, PropType } from "vue";
import { useRoute } from "vue-router";
import DBExtensionDataTable from "@/components/DBExtensionDataTable.vue";
@@ -297,8 +292,11 @@ const schemaList = computed(() => {
return dbSchemaStore.getSchemaList(props.database.name);
});
-const schemaNameList = computed(() => {
- return schemaList.value.map((schema) => schema.name);
+const schemaNameOptions = computed(() => {
+ return schemaList.value.map((schema) => ({
+ value: schema.name,
+ label: schema.name,
+ }));
});
const databaseSchemaMetadata = computed(() => {
diff --git a/frontend/src/components/EnvironmentSelect.vue b/frontend/src/components/EnvironmentSelect.vue
deleted file mode 100644
index 270e601388..0000000000
--- a/frontend/src/components/EnvironmentSelect.vue
+++ /dev/null
@@ -1,133 +0,0 @@
-<template>
- <BBSelect
- :selected-item="state.selectedEnvironment"
- :item-list="environmentList"
- :disabled="disabled"
- :placeholder="$t('environment.select')"
- :show-prefix-item="true"
- @select-item="(env: Environment) => $emit('select-environment-id', env.uid)"
- >
- <template #menuItem="{ item: environment }">
- <EnvironmentV1Name
- :environment="environment"
- :link="false"
- :suffix="
- defaultEnvironment == environment.name
- ? `(${$t('common.default')})`
- : ''
- "
- />
- </template>
- </BBSelect>
-</template>
-
-<script lang="ts">
-import { computed, defineComponent, onMounted, reactive, watch } from "vue";
-import { EnvironmentV1Name } from "@/components/v2";
-import { useEnvironmentV1List } from "@/store";
-import { State } from "@/types/proto/v1/common";
-import { Environment } from "@/types/proto/v1/environment_service";
-
-interface LocalState {
- selectedEnvironment?: Environment;
-}
-
-export default defineComponent({
- name: "EnvironmentSelect",
- components: { EnvironmentV1Name },
- props: {
- selectedId: {
- type: String,
- default: undefined,
- },
- selectDefault: {
- default: true,
- type: Boolean,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
- defaultEnvironment: {
- default: "",
- type: String,
- },
- },
- emits: ["select-environment-id"],
- setup(props, { emit }) {
- const state = reactive<LocalState>({
- selectedEnvironment: undefined,
- });
-
- const rawEnvironmentList = useEnvironmentV1List(true /* showDeleted */);
- const environmentList = computed(() => {
- const list = [...rawEnvironmentList.value].reverse();
-
- return list.filter((env) => {
- if (env.state === State.ACTIVE) {
- return true;
- }
-
- // env.rowStatus === "ARCHIVED"
- if (env.uid === state.selectedEnvironment?.uid) {
- return true;
- }
- return false;
- });
- });
-
- const autoSelectDefaultIfNeeded = () => {
- if (!props.selectDefault) {
- return;
- }
-
- const list = environmentList.value;
- if (list.length > 0) {
- if (
- !props.selectedId ||
- !list.find((item: Environment) => item.uid === props.selectedId)
- ) {
- // auto select the first NORMAL environment
- const defaultEnvironment = list.find(
- (env) => env.state === State.ACTIVE
- );
- state.selectedEnvironment = defaultEnvironment;
- emit("select-environment-id", defaultEnvironment?.uid);
- }
- }
- };
-
- onMounted(() => {
- autoSelectDefaultIfNeeded();
- });
-
- const invalidateSelectionIfNeeded = () => {
- if (
- state.selectedEnvironment &&
- !environmentList.value.find(
- (item: Environment) => item.uid == state.selectedEnvironment?.uid
- )
- ) {
- state.selectedEnvironment = undefined;
- emit("select-environment-id", undefined);
- }
- };
-
- watch(
- () => props.selectedId,
- (selectedId) => {
- invalidateSelectionIfNeeded();
- state.selectedEnvironment = environmentList.value.find(
- (env) => env.uid === String(selectedId)
- );
- },
- { immediate: true }
- );
-
- return {
- state,
- environmentList,
- };
- },
-});
-</script>
diff --git a/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue b/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
index 16cbb349a0..dba567383f 100644
--- a/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
+++ b/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
@@ -13,10 +13,7 @@
</div>
<div class="flex-1 lg:px-4">
<div class="mb-7 mt-4 lg:mt-0">
- <label
- class="flex items-center gap-x-2"
- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"
- >
+ <label class="flex items-center gap-x-2">
<span class="font-medium">{{
$t("settings.general.workspace.plugin.openai.openai-key.self")
}}</span>
@@ -57,10 +54,7 @@
</span>
</NTooltip>
- <label
- class="flex items-center gap-x-2"
- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"
- >
+ <label class="flex items-center gap-x-2">
<span class="font-medium">{{
$t("settings.general.workspace.plugin.openai.openai-endpoint.self")
}}</span>
diff --git a/frontend/src/components/GeneralSetting/AnnouncementSetting.vue b/frontend/src/components/GeneralSetting/AnnouncementSetting.vue
index b769dfef57..3c3f51e482 100644
--- a/frontend/src/components/GeneralSetting/AnnouncementSetting.vue
+++ b/frontend/src/components/GeneralSetting/AnnouncementSetting.vue
@@ -16,10 +16,7 @@
</div>
<div class="flex-1 lg:px-5">
<div class="mb-7 mt-5 lg:mt-0">
- <label
- class="flex items-center gap-x-2"
- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"
- >
+ <label class="flex items-center gap-x-2">
<span class="font-medium">{{
$t(
"settings.general.workspace.announcement-alert-level.description"
@@ -44,10 +41,7 @@
</span>
</NTooltip>
- <label
- class="flex items-center mt-2 gap-x-2"
- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"
- >
+ <label class="flex items-center mt-2 gap-x-2">
<span class="font-medium"
>{{ $t("settings.general.workspace.announcement-text.self") }}
</span>
@@ -75,10 +69,7 @@
</span>
</NTooltip>
- <label
- class="flex items-center py-2 gap-x-2"
- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"
- >
+ <label class="flex items-center py-2 gap-x-2">
<span class="font-medium">{{
$t("settings.general.workspace.extra-link.self")
}}</span>
diff --git a/frontend/src/components/InstanceSelect.vue b/frontend/src/components/InstanceSelect.vue
deleted file mode 100644
index 657dd35e90..0000000000
--- a/frontend/src/components/InstanceSelect.vue
+++ /dev/null
@@ -1,128 +0,0 @@
-<template>
- <BBSelect
- :selected-item="state.selectedInstance"
- :item-list="instanceList"
- :disabled="disabled"
- :placeholder="$t('instance.select')"
- :show-prefix-item="true"
- :error="!validate()"
- @select-item="(instance: ComposedInstance) => $emit('select-instance-id', instance.uid)"
- >
- <template #menuItem="{ item: instance }: { item: ComposedInstance }">
- <div class="flex items-center gap-x-2">
- <InstanceV1EngineIcon :instance="instance" />
- <span>{{ instanceV1Name(instance) }}</span>
- </div>
- </template>
- </BBSelect>
-</template>
-
-<script lang="ts" setup>
-import { computed, PropType, reactive, watch } from "vue";
-import { useInstanceV1List } from "@/store";
-import { State } from "@/types/proto/v1/common";
-import { instanceV1Name } from "@/utils";
-import { ComposedInstance, UNKNOWN_ID } from "../types";
-import { InstanceV1EngineIcon } from "./v2";
-
-interface LocalState {
- selectedInstance?: ComposedInstance;
-}
-
-const props = defineProps({
- selectedId: {
- type: String,
- default: undefined,
- },
- environmentId: {
- type: String,
- default: undefined,
- },
- filter: {
- type: Function as PropType<(instance: ComposedInstance) => boolean>,
- default: undefined,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
- required: {
- type: Boolean,
- default: false,
- },
-});
-
-const emit = defineEmits<{
- (event: "select-instance-id", uid: string | undefined): void;
-}>();
-
-const state = reactive<LocalState>({
- selectedInstance: undefined,
-});
-const { instanceList: allInstanceList, ready } = useInstanceV1List(
- true /* showDeleted */
-);
-
-const rawInstanceList = computed(() => {
- const list = [...allInstanceList.value];
- if (props.environmentId && props.environmentId !== String(UNKNOWN_ID)) {
- return list.filter(
- (instance) => instance.environmentEntity.uid === props.environmentId
- );
- }
- return list;
-});
-
-const instanceList = computed(() => {
- const list = rawInstanceList.value.filter((instance) => {
- if (instance.state === State.ACTIVE) {
- return true;
- }
- // instance.rowStatus === "ARCHIVED"
- if (instance.uid === state.selectedInstance?.uid) {
- return true;
- }
- return false;
- });
-
- if (!props.filter) {
- return list;
- }
- return list.filter(props.filter);
-});
-
-const validate = (): boolean => {
- if (!props.required) {
- return true;
- }
- return (
- !!state.selectedInstance &&
- state.selectedInstance.uid !== String(UNKNOWN_ID)
- );
-};
-
-// The instance list might change if environmentId changes, and the previous selected id
-// might not exist in the new list. In such case, we need to invalidate the selection
-// and emit the event.
-const invalidateSelectionIfNeeded = () => {
- if (
- ready.value &&
- state.selectedInstance &&
- !instanceList.value.find((item) => item.uid == state.selectedInstance?.uid)
- ) {
- state.selectedInstance = undefined;
- emit("select-instance-id", undefined);
- }
-};
-
-watch(
- [() => props.selectedId, instanceList],
- ([selectedId, list]) => {
- invalidateSelectionIfNeeded();
- state.selectedInstance = list.find(
- (instance) => instance.uid === selectedId
- );
- },
- { immediate: true }
-);
-</script>
diff --git a/frontend/src/components/IssueStatusSelect.vue b/frontend/src/components/IssueStatusSelect.vue
deleted file mode 100644
index c8d6592c12..0000000000
--- a/frontend/src/components/IssueStatusSelect.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-<template>
- <BBSelect
- :selected-item="selectedStatus"
- :item-list="['OPEN', 'DONE', 'CANCELED']"
- :placeholder="'Unknown Status'"
- :disabled="disabled"
- @select-item="(status, didSelect) => changeStatus(status, didSelect)"
- >
- <template #menuItem="{ item }">
- <span class="flex items-center space-x-2">
- <IssueStatusIcon :issue-status="item" :size="'small'" />
- <span>
- {{ item }}
- </span>
- </span>
- </template>
- </BBSelect>
-</template>
-
-<script lang="ts">
-import { defineComponent, PropType } from "vue";
-import { IssueStatus, IssueStatusTransitionType } from "../types";
-import IssueStatusIcon from "./Issue/IssueStatusIcon.vue";
-
-export default defineComponent({
- name: "IssueStatusSelect",
- components: { IssueStatusIcon },
- props: {
- selectedStatus: {
- type: String as PropType<IssueStatus>,
- default: undefined,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
- },
- emits: ["start-transition"],
- setup(_, { emit }) {
- const changeStatus = (newStatus: IssueStatus, didChange: () => any) => {
- let transition: IssueStatusTransitionType;
- switch (newStatus) {
- case "OPEN":
- transition = "REOPEN";
- break;
- case "DONE":
- transition = "RESOLVE";
- break;
- case "CANCELED":
- transition = "CANCEL";
- break;
- }
- emit("start-transition", transition, didChange);
- };
-
- return { changeStatus };
- },
-});
-</script>
diff --git a/frontend/src/components/ProjectRoleSelect.vue b/frontend/src/components/ProjectRoleSelect.vue
deleted file mode 100644
index 5483e6d4dc..0000000000
--- a/frontend/src/components/ProjectRoleSelect.vue
+++ /dev/null
@@ -1,33 +0,0 @@
-<template>
- <BBSelect
- :selected-item="selectedRole"
- :item-list="['OWNER', 'DEVELOPER']"
- :placeholder="$t('settings.members.select-role')"
- :disabled="disabled"
- @select-item="(role) => $emit('change-role', role)"
- >
- <template #menuItem="{ item }">
- {{ $t(`common.role.${item.toLowerCase()}`) }}
- </template>
- </BBSelect>
-</template>
-
-<script lang="ts">
-import { defineComponent, PropType } from "vue";
-import { ProjectRoleType } from "../types";
-
-export default defineComponent({
- name: "ProjectRoleSelect",
- props: {
- selectedRole: {
- type: String as PropType<ProjectRoleType>,
- default: undefined,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
- },
- emits: ["change-role"],
-});
-</script>
diff --git a/frontend/src/components/ProjectSelect.vue b/frontend/src/components/ProjectSelect.vue
deleted file mode 100644
index fa029ab5b2..0000000000
--- a/frontend/src/components/ProjectSelect.vue
+++ /dev/null
@@ -1,205 +0,0 @@
-<template>
- <BBSelect
- :selected-item="state.selectedProject"
- :item-list="projectList"
- :disabled="disabled"
- :placeholder="$t('project.select')"
- :show-prefix-item="true"
- :error="!validate()"
- @select-item="(project: Project) => $emit('select-project-id', project.uid)"
- >
- <template #menuItem="{ item: project }">
- {{ projectV1Name(project) }}
- </template>
- </BBSelect>
-</template>
-
-<script lang="ts">
-import { computed, defineComponent, PropType, reactive, watch } from "vue";
-import { useCurrentUserV1, useProjectV1Store } from "@/store";
-import { State } from "@/types/proto/v1/common";
-import { Project, TenantMode } from "@/types/proto/v1/project_service";
-import {
- hasWorkspacePermissionV1,
- isMemberOfProjectV1,
- projectV1Name,
-} from "@/utils";
-import { UNKNOWN_ID, DEFAULT_PROJECT_ID, unknownProject } from "../types";
-
-interface LocalState {
- selectedProject?: Project;
-}
-
-export enum Mode {
- Standard = 1,
- Tenant = 2,
-}
-
-export default defineComponent({
- name: "ProjectSelect",
- props: {
- selectedId: {
- default: String(UNKNOWN_ID),
- type: String,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
- allowedRoleList: {
- default: () => ["OWNER", "DEVELOPER"],
- type: Array as PropType<string[]>,
- },
- includeDefaultProject: {
- default: false,
- type: Boolean,
- },
- mode: {
- type: Number as PropType<Mode>,
- default: Mode.Standard | Mode.Tenant,
- },
- onlyUserself: {
- type: Boolean,
- default: true,
- },
- required: {
- type: Boolean,
- default: false,
- },
- },
- emits: ["select-project-id"],
- setup(props) {
- const state = reactive<LocalState>({
- selectedProject: undefined,
- });
-
- const currentUserV1 = useCurrentUserV1();
- const projectV1Store = useProjectV1Store();
- const canManageProject = hasWorkspacePermissionV1(
- "bb.permission.workspace.manage-project",
- currentUserV1.value.userRole
- );
-
- const rawProjectList = computed((): Project[] => {
- let list = projectV1Store.getProjectList(true /* showDeleted */);
-
- if (props.onlyUserself) {
- list = list.filter((project) => {
- return (
- canManageProject ||
- isMemberOfProjectV1(project.iamPolicy, currentUserV1.value)
- );
- });
- }
-
- list = list.filter((project) => {
- if (
- project.tenantMode === TenantMode.TENANT_MODE_DISABLED &&
- props.mode & Mode.Standard
- ) {
- return true;
- }
- if (
- project.tenantMode === TenantMode.TENANT_MODE_ENABLED &&
- props.mode & Mode.Tenant
- ) {
- return true;
- }
- return false;
- });
-
- return list.filter((project: Project) => {
- // Do not show Default project in selector.
- return project.uid !== String(DEFAULT_PROJECT_ID);
- });
- });
-
- const selectedIdNotInList = computed((): boolean => {
- if (props.selectedId === String(UNKNOWN_ID)) {
- return false;
- }
-
- return (
- rawProjectList.value.find((item) => {
- return item.uid === props.selectedId;
- }) == null
- );
- });
-
- const projectList = computed((): Project[] => {
- const list = rawProjectList.value.filter((project) => {
- if (project.state === State.ACTIVE) {
- return true;
- }
- // project.state === State.DELETED
- if (project.uid === props.selectedId) {
- return true;
- }
- return false;
- });
-
- const defaultProject = projectV1Store.getProjectByUID(
- String(DEFAULT_PROJECT_ID)
- );
- if (
- props.includeDefaultProject ||
- props.selectedId === String(DEFAULT_PROJECT_ID)
- ) {
- // If includeDefaultProject is false but the selected project is the default
- // project, we will show it. If includeDefaultProject is true, then it's
- // already in the list, so no need to show it twice
- list.unshift(defaultProject);
- }
-
- if (
- props.selectedId !== String(DEFAULT_PROJECT_ID) &&
- selectedIdNotInList.value
- ) {
- // It may happen the selected id might not be in the project list.
- // e.g. the selected project is deleted after the selection and we
- // are unable to cleanup properly. In such case, the selected project id
- // is orphaned and we just display the id
- const dummyProject = {
- ...unknownProject(),
- name: `projects/${props.selectedId}`,
- uid: props.selectedId,
- title: props.selectedId,
- };
- list.unshift(dummyProject);
- }
-
- return list;
- });
-
- const validate = () => {
- if (!props.required) {
- return true;
- }
- return (
- !!state.selectedProject &&
- state.selectedProject.uid !== String(UNKNOWN_ID)
- );
- };
-
- watch(
- [() => props.selectedId, projectList],
- ([selectedId, list]) => {
- state.selectedProject = list.find(
- (project) => project.uid === selectedId
- );
- },
- { immediate: true }
- );
-
- return {
- UNKNOWN_ID,
- DEFAULT_PROJECT_ID,
- projectV1Name,
- state,
- projectList,
- validate,
- selectedIdNotInList,
- };
- },
-});
-</script>
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vue
index 2fe8598fed..1ffaeb839a 100644
--- a/frontend/src/components/RepositoryForm.vue
+++ b/frontend/src/components/RepositoryForm.vue
@@ -91,31 +91,13 @@
class="ml-1"
/>
</div>
- <BBSelect
- id="schemamigrationtype"
- :disabled="!allowEdit"
- :selected-item="schemaChangeType"
- :item-list="[SchemaChange.DDL, SchemaChange.SDL]"
+ <NSelect
+ :options="schemaChangeTypeOptions"
+ :value="schemaChangeType"
+ :render-label="renderLabel"
class="mt-1"
- @select-item="
- (type: SchemaChange) => {
- $emit('change-schema-change-type', type);
- }
- "
- >
- <template #menuItem="{ item }">
- <div class="flex items-center gap-x-2">
- {{
- $t(
- `project.settings.select-schema-change-type-${schemaChangeToJSON(
- item
- ).toLowerCase()}`
- )
- }}
- <BBBetaBadge v-if="item === SchemaChange.SDL" class="!leading-3" />
- </div>
- </template>
- </BBSelect>
+ @update:value="$emit('change-schema-change-type', $event)"
+ />
</div>
<div>
<div class="textlabel">
@@ -329,10 +311,11 @@
</template>
<script lang="ts" setup>
-import { NCheckbox } from "naive-ui";
+import { NCheckbox, NSelect, SelectOption } from "naive-ui";
import { storeToRefs } from "pinia";
-import { reactive, PropType, computed } from "vue";
+import { reactive, PropType, computed, h } from "vue";
import { useI18n } from "vue-i18n";
+import { BBBetaBadge } from "@/bbkit";
import {
hasFeature,
useSubscriptionV1Store,
@@ -584,4 +567,31 @@ const onSQLReviewCIToggle = (on: boolean) => {
const actuatorStore = useActuatorV1Store();
const isDebug = storeToRefs(actuatorStore).isDebug;
+
+const renderLabel = (option: SelectOption) => {
+ const value = option.value as SchemaChange;
+ const child = [
+ h(
+ "span",
+ {},
+ t(
+ `project.settings.select-schema-change-type-${schemaChangeToJSON(
+ value
+ ).toLowerCase()}`
+ )
+ ),
+ ];
+ if (value === SchemaChange.SDL) {
+ child.push(h(BBBetaBadge, { class: "!leading-3" }));
+ }
+
+ return h("div", { class: "flex items-center gap-x-2" }, child);
+};
+
+const schemaChangeTypeOptions = computed(() => {
+ return [SchemaChange.DDL, SchemaChange.SDL].map((val) => ({
+ value: val,
+ label: schemaChangeToJSON(val),
+ }));
+});
</script>
diff --git a/frontend/src/components/RoleSelect.vue b/frontend/src/components/RoleSelect.vue
deleted file mode 100644
index 8e3713735f..0000000000
--- a/frontend/src/components/RoleSelect.vue
+++ /dev/null
@@ -1,34 +0,0 @@
-<template>
- <BBSelect
- :selected-item="role"
- :item-list="[UserRole.OWNER, UserRole.DBA, UserRole.DEVELOPER]"
- :placeholder="$t('settings.members.select-role')"
- :disabled="disabled"
- @select-item="$emit('update:role', $event as UserRole)"
- >
- <template #menuItem="{ item }">
- {{ roleNameV1(item) }}
- </template>
- </BBSelect>
-</template>
-
-<script lang="ts" setup>
-import { PropType } from "vue";
-import { UserRole } from "@/types/proto/v1/auth_service";
-import { roleNameV1 } from "@/utils";
-
-defineProps({
- role: {
- type: Number as PropType<UserRole>,
- default: undefined,
- },
- disabled: {
- default: false,
- type: Boolean,
- },
-});
-
-defineEmits<{
- (event: "update:role", role: UserRole): void;
-}>();
-</script>
diff --git a/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue b/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue
index 8802c0928b..0d18dffa94 100644
--- a/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue
+++ b/frontend/src/components/SchemaEditorV1/Modals/EditColumnForeignKeyModal.vue
@@ -6,45 +6,31 @@
>
<div v-if="shouldShowSchemaSelector" class="w-72">
<p class="mb-2">{{ $t("schema-editor.select-reference-schema") }}</p>
- <BBSelect
- :selected-item="selectedSchema"
- :item-list="schemas"
+ <NSelect
+ v-model:value="state.referencedSchemaId"
:placeholder="$t('schema-editor.schema.select')"
- :show-prefix-item="true"
- @select-item="(schema) => (state.referencedSchemaId = schema.id)"
- >
- <template #menuItem="{ item }">
- {{ item.name }}
- </template>
- </BBSelect>
+ :options="schemas.map((item) => ({ value: item.id, label: item.name }))"
+ />
</div>
<div class="w-72">
<p class="mt-4 mb-2">{{ $t("schema-editor.select-reference-table") }}</p>
- <BBSelect
- :selected-item="selectedTable"
- :item-list="tableList"
+ <NSelect
+ v-model:value="state.referencedTableId"
:placeholder="$t('schema-editor.table.select')"
- :show-prefix-item="true"
- @select-item="(table) => (state.referencedTableId = table.id)"
- >
- <template #menuItem="{ item }">
- {{ item.name }}
- </template>
- </BBSelect>
+ :options="
+ tableList.map((item) => ({ value: item.id, label: item.name }))
+ "
+ />
</div>
<div class="w-72">
<p class="mt-4 mb-2">{{ $t("schema-editor.select-reference-column") }}</p>
- <BBSelect
- :selected-item="selectedColumn"
- :item-list="columnList"
+ <NSelect
+ v-model:value="state.referencedColumnId"
:placeholder="$t('schema-editor.column.select')"
- :show-prefix-item="true"
- @select-item="(column) => (state.referencedColumnId = column.id)"
- >
- <template #menuItem="{ item }">
- {{ item.name }}
- </template>
- </BBSelect>
+ :options="
+ columnList.map((item) => ({ value: item.id, label: item.name }))
+ "
+ />
</div>
<div
class="w-full flex items-center justify-between mt-6 space-x-2 pr-1 pb-1"
@@ -73,8 +59,9 @@
<script lang="ts" setup>
import { isUndefined } from "lodash-es";
+import { NSelect } from "naive-ui";
import { computed, onMounted, reactive, watch } from "vue";
-import { BBModal, BBSelect } from "@/bbkit";
+import { BBModal } from "@/bbkit";
import { useSchemaEditorV1Store } from "@/store";
import { Engine } from "@/types/proto/v1/common";
import { Column, ForeignKey } from "@/types/v1/schemaEditor";
@@ -161,12 +148,6 @@ const columnList = computed(() => {
);
});
-const selectedColumn = computed(() => {
- return columnList.value.find(
- (column) => column.id === state.referencedColumnId
- );
-});
-
const foreignKey = computed(() => {
for (const fk of foreignKeyList.value) {
const foundIndex = fk.columnIdList.findIndex((id) => id === props.columnId);
diff --git a/frontend/src/components/TwoFactorSecretModal.vue b/frontend/src/components/TwoFactorSecretModal.vue
index 352ab260b6..71cf416f4c 100644
--- a/frontend/src/components/TwoFactorSecretModal.vue
+++ b/frontend/src/components/TwoFactorSecretModal.vue
@@ -9,12 +9,12 @@
<code class="pr-4">{{ props.secret }}</code>
</div>
<div class="w-full flex items-center justify-end space-x-3 pr-1 pb-1">
- <button type="button" class="btn-cancel" @click="dismissModal">
+ <NButton @click="dismissModal">
{{ $t("common.close") }}
- </button>
- <button class="btn-primary" @click="copySecret">
+ </NButton>
+ <NButton type="primary" @click="copySecret">
{{ $t("common.copy") }}
- </button>
+ </NButton>
</div>
</BBModal>
</template>
diff --git a/frontend/src/components/v2/Select/EnvironmentSelect.vue b/frontend/src/components/v2/Select/EnvironmentSelect.vue
index 68f7672186..7ddf64bf64 100644
--- a/frontend/src/components/v2/Select/EnvironmentSelect.vue
+++ b/frontend/src/components/v2/Select/EnvironmentSelect.vue
@@ -15,6 +15,7 @@
<script lang="ts" setup>
import { NSelect, SelectOption } from "naive-ui";
import { computed, h, watchEffect } from "vue";
+import { useI18n } from "vue-i18n";
import { useEnvironmentV1Store, useProjectV1Store } from "@/store";
import { State } from "@/types/proto/v1/common";
import { Environment } from "@/types/proto/v1/environment_service";
@@ -28,12 +29,14 @@ interface EnvironmentSelectOption extends SelectOption {
const props = withDefaults(
defineProps<{
environment?: string | undefined;
+ defaultEnvironmentName?: string | undefined;
includeArchived?: boolean;
showProductionIcon?: boolean;
filter?: (environment: Environment, index: number) => boolean;
}>(),
{
environment: undefined,
+ defaultEnvironmentName: undefined,
includeArchived: false,
showProductionIcon: true,
filter: () => true,
@@ -44,6 +47,7 @@ defineEmits<{
(event: "update:environment", id: string | undefined): void;
}>();
+const { t } = useI18n();
const projectV1Store = useProjectV1Store();
const environmentV1Store = useEnvironmentV1Store();
@@ -90,6 +94,10 @@ const renderLabel = (option: SelectOption) => {
environment,
showIcon: props.showProductionIcon,
link: false,
+ suffix:
+ props.defaultEnvironmentName === environment.name
+ ? `(${t("common.default")})`
+ : "",
});
};
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index 321ba497fe..d9776716ef 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -46,9 +46,9 @@
<dd
class="mt-1 text-4xl flex items-center gap-x-2 cursor-pointer group"
>
- <span class="group-hover:underline">{{
- subscriptionStore.instanceCountLimit
- }}</span>
+ <span class="group-hover:underline">
+ {{ subscriptionStore.instanceCountLimit }}
+ </span>
</dd>
</div>
<div v-else class="my-3">
@@ -112,13 +112,10 @@
v-if="canManageSubscription && subscriptionStore.isSelfHostLicense"
class="w-full mt-4 flex flex-col"
>
- <textarea
- id="license"
- v-model="state.license"
- type="text"
- name="license"
+ <NInput
+ v-model:value="state.license"
+ type="textarea"
:placeholder="$t('subscription.sensitive-placeholder')"
- class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md"
/>
<div class="ml-auto mt-3">
<NButton type="primary" :disabled="disabled" @click="uploadLicense">