Skip to content

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

fix: dbgroup selector (#14485)

p0ny4cc3cee7d1ed
diff --git a/frontend/src/components/v2/Select/DatabaseGroupSelect.vue b/frontend/src/components/v2/Select/DatabaseGroupSelect.vue
index 758f70afca..6491404be4 100644
--- a/frontend/src/components/v2/Select/DatabaseGroupSelect.vue
+++ b/frontend/src/components/v2/Select/DatabaseGroupSelect.vue
@@ -1,6 +1,6 @@
<template>
<NSelect
- :value="state.selectedDatabaseGroup"
+ :value="selected"
:options="dbGroupOptions"
:disabled="disabled"
:clearable="clearable"
@@ -10,37 +10,27 @@
</template>
<script lang="ts" setup>
-import { head } from "lodash-es";
import { NSelect, type SelectOption } from "naive-ui";
-import { computed, reactive, watch } from "vue";
+import { computed } from "vue";
import { useDBGroupListByProject } from "@/store";
-interface LocalState {
- selectedDatabaseGroup?: string;
-}
-
const props = withDefaults(
defineProps<{
project: string;
selected?: string;
disabled?: boolean;
clearable?: boolean;
- selectFirstAsDefault?: boolean;
}>(),
{
clearable: false,
selected: undefined,
- selectFirstAsDefault: true,
}
);
-const emit = defineEmits<{
+defineEmits<{
(event: "update:selected", name: string | undefined): void;
}>();
-const state = reactive<LocalState>({
- selectedDatabaseGroup: undefined,
-});
const { dbGroupList } = useDBGroupListByProject(props.project);
const dbGroupOptions = computed(() => {
@@ -49,18 +39,4 @@ const dbGroupOptions = computed(() => {
label: dbGroup.databaseGroupName,
}));
});
-
-watch(
- [() => props.project, () => props.selected],
- () => {
- state.selectedDatabaseGroup = dbGroupList.value.find(
- (item) => item.name === props.selected
- )?.name;
- if (!state.selectedDatabaseGroup && props.selectFirstAsDefault) {
- state.selectedDatabaseGroup = head(dbGroupList.value)?.name;
- }
- emit("update:selected", state.selectedDatabaseGroup);
- },
- { immediate: true, deep: true }
-);
</script>