Skip to content

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

Make instance panel use BBTableSearch to filter on instance name

Tianzhou Chenbc61ea2fc559
diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vue
index 38e1e34178..b82a1bf51a 100644
--- a/frontend/src/views/InstanceDashboard.vue
+++ b/frontend/src/views/InstanceDashboard.vue
@@ -1,14 +1,18 @@
<template>
<div class="flex flex-col">
- <div class="px-2 py-1">
+ <div class="px-2 py-2 flex justify-between items-center">
<EnvironmentTabFilter @select-environment="selectEnvironment" />
+ <BBTableSearch
+ ref="searchField"
+ @change-text="(text) => changeSearchText(text)"
+ />
</div>
<InstanceTable :instanceList="filteredList(state.instanceList)" />
</div>
</template>
<script lang="ts">
-import { watchEffect, reactive } from "vue";
+import { watchEffect, onMounted, reactive, ref } from "vue";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import InstanceTable from "../components/InstanceTable.vue";
import { useStore } from "vuex";
@@ -17,6 +21,7 @@ import { Environment, Instance } from "../types";
interface LocalState {
instanceList: Instance[];
selectedEnvironment?: Environment;
+ searchText: string;
}
export default {
@@ -26,11 +31,19 @@ export default {
InstanceTable,
},
setup(props, ctx) {
+ const searchField = ref();
+
const state = reactive<LocalState>({
instanceList: [],
+ searchText: "",
});
const store = useStore();
+ onMounted(() => {
+ // Focus on the internal search field when mounted
+ searchField.value.$el.querySelector("#search").focus();
+ });
+
const prepareInstanceList = () => {
store
.dispatch("instance/fetchInstanceList")
@@ -46,22 +59,35 @@ export default {
state.selectedEnvironment = environment;
};
+ const changeSearchText = (searchText: string) => {
+ state.searchText = searchText;
+ };
+
const filteredList = (list: Instance[]) => {
- if (!state.selectedEnvironment) {
+ if (!state.selectedEnvironment && !state.searchText) {
// Select "All"
return list;
}
return list.filter((instance) => {
- return instance.environmentId == state.selectedEnvironment!.id;
+ return (
+ (!state.selectedEnvironment ||
+ instance.environmentId == state.selectedEnvironment.id) &&
+ (!state.searchText ||
+ instance.name
+ .toLowerCase()
+ .includes(state.searchText.toLowerCase()))
+ );
});
};
watchEffect(prepareInstanceList);
return {
+ searchField,
state,
filteredList,
selectEnvironment,
+ changeSearchText,
};
},
};