Skip to content

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

chore: highlight the matched keyword (#14752)

ecmadao23a8a3230dcb
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 61b50a058f..c97fe4d26f 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -34,6 +34,7 @@
mode="ALL_SHORT"
:show-sql-editor-button="false"
:database-list="selectableDatabaseList"
+ :keyword="state.params.query.trim().toLowerCase()"
@update:selected-databases="handleDatabasesSelectionChanged"
/>
<SchemalessDatabaseTable
diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
index 6c6c8940b2..5f7aa1e5ac 100644
--- a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
+++ b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
@@ -28,6 +28,7 @@
mode="ALL_SHORT"
:database-list="filteredDatabaseList"
:single-selection="true"
+ :keyword="state.params.query.trim().toLowerCase()"
@update:selected-databases="handleDatabasesSelectionChanged"
/>
</div>
diff --git a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
index ab3061e048..54c9560afb 100644
--- a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
+++ b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
@@ -13,6 +13,7 @@
:database-list="filteredDatabaseList"
:show-selection="true"
:selected-database-names="databaseSelectState.selectedDatabaseNameList"
+ :keyword="searchParams.query.trim().toLowerCase()"
@update:selected-databases="
databaseSelectState.selectedDatabaseNameList = Array.from($event)
"
diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vue
index 129e6ec40b..a4231de59e 100644
--- a/frontend/src/components/ProjectDatabasesPanel.vue
+++ b/frontend/src/components/ProjectDatabasesPanel.vue
@@ -47,6 +47,7 @@
mode="PROJECT"
:database-list="filteredDatabaseList"
:custom-click="true"
+ :keyword="state.params.query.trim().toLowerCase()"
@row-click="handleDatabaseClick"
@update:selected-databases="handleDatabasesSelectionChanged"
/>
diff --git a/frontend/src/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue b/frontend/src/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue
index 79fec1dbde..c2040bc890 100644
--- a/frontend/src/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue
+++ b/frontend/src/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue
@@ -24,6 +24,7 @@
:database-list="filteredDatabaseList"
:show-selection="true"
:selected-database-names="state.selectedDatabaseNameList"
+ :keyword="state.params.query.trim().toLowerCase()"
@update:selected-databases="
state.selectedDatabaseNameList = Array.from($event)
"
diff --git a/frontend/src/components/v2/Model/DatabaseV1Name.vue b/frontend/src/components/v2/Model/DatabaseV1Name.vue
index a852065325..052f3da653 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Name.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Name.vue
@@ -9,7 +9,8 @@
]"
>
<span v-if="prefix" class="mr-1 text-gray-400">{{ prefix }}</span>
- <span>{{ database.databaseName }}</span>
+ <!-- eslint-disable-next-line vue/no-v-html -->
+ <span v-html="renderedDatabaseName" />
<span
v-if="showNotFound && database.syncState === State.DELETED"
class="text-control-placeholder"
@@ -25,7 +26,7 @@ import { computed } from "vue";
import { useRouter } from "vue-router";
import type { ComposedDatabase } from "@/types";
import { Engine, State } from "@/types/proto/v1/common";
-import { autoDatabaseRoute } from "@/utils";
+import { autoDatabaseRoute, getHighlightHTMLByRegExp } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -33,11 +34,13 @@ const props = withDefaults(
link?: boolean;
plain?: boolean;
showNotFound?: boolean;
+ keyword?: string;
}>(),
{
link: true,
plain: false,
showNotFound: false,
+ keyword: "",
}
);
@@ -67,4 +70,8 @@ const prefix = computed(() => {
}
return "";
});
+
+const renderedDatabaseName = computed(() => {
+ return getHighlightHTMLByRegExp(props.database.databaseName, props.keyword);
+});
</script>
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
index 553387e300..aaa8ac7386 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
@@ -10,7 +10,7 @@
:row-key="(data: ComposedDatabase) => data.name"
:checked-row-keys="Array.from(state.selectedDatabaseNameList)"
:row-props="rowProps"
- :pagination="{ pageSize: 20 }"
+ :pagination="{ pageSize: 60 }"
:paginate-single-page="false"
@update:checked-row-keys="
(val) => (state.selectedDatabaseNameList = new Set(val as string[]))
@@ -57,12 +57,14 @@ const props = withDefaults(
customClick?: boolean;
rowClickable?: boolean;
selectedDatabaseNames?: string[];
+ keyword?: string;
}>(),
{
mode: "ALL",
bordered: true,
showSelection: true,
rowClickable: true,
+ keyword: undefined,
selectedDatabaseNames: () => [],
}
);
@@ -95,7 +97,7 @@ const columnList = computed((): DatabaseDataTableColumn[] => {
title: t("common.name"),
resizable: true,
render: (data) => {
- return <DatabaseNameCell database={data} />;
+ return <DatabaseNameCell database={data} keyword={props.keyword} />;
},
};
const ENVIRONMENT: DatabaseDataTableColumn = {
@@ -108,6 +110,7 @@ const columnList = computed((): DatabaseDataTableColumn[] => {
environment={data.effectiveEnvironmentEntity}
link={false}
tag="div"
+ keyword={props.keyword}
/>
),
};
@@ -123,7 +126,11 @@ const columnList = computed((): DatabaseDataTableColumn[] => {
title: t("common.project"),
resizable: true,
render: (data) => (
- <ProjectNameCell project={data.projectEntity} mode={props.mode} />
+ <ProjectNameCell
+ project={data.projectEntity}
+ mode={props.mode}
+ keyword={props.keyword}
+ />
),
};
const INSTANCE: DatabaseDataTableColumn = {
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue b/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue
index 6d05bf423a..3bbb1d7a54 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue
@@ -1,6 +1,11 @@
<template>
<div class="flex items-center space-x-2">
- <DatabaseV1Name :database="database" :link="false" tag="span" />
+ <DatabaseV1Name
+ :database="database"
+ :link="false"
+ tag="span"
+ :keyword="keyword"
+ />
</div>
</template>
@@ -8,7 +13,13 @@
import { DatabaseV1Name } from "@/components/v2";
import type { ComposedDatabase } from "@/types";
-defineProps<{
- database: ComposedDatabase;
-}>();
+withDefaults(
+ defineProps<{
+ database: ComposedDatabase;
+ keyword?: string;
+ }>(),
+ {
+ keyword: undefined,
+ }
+);
</script>
diff --git a/frontend/src/components/v2/Model/EnvironmentV1Name.vue b/frontend/src/components/v2/Model/EnvironmentV1Name.vue
index a8f91d5d99..f55de58d8d 100644
--- a/frontend/src/components/v2/Model/EnvironmentV1Name.vue
+++ b/frontend/src/components/v2/Model/EnvironmentV1Name.vue
@@ -7,6 +7,8 @@
>
<span class="line-clamp-1 select-none" :class="textClass">
{{ prefix }}
+ <!-- eslint-disable-next-line vue/no-v-html -->
+ <span v-html="renderedEnvironmentName" />
{{ environmentV1Name(environment) }}
<slot name="suffix">
{{ suffix }}
@@ -26,7 +28,11 @@ import { computed } from "vue";
import { useRouter } from "vue-router";
import type { Environment } from "@/types/proto/v1/environment_service";
import type { VueClass } from "@/utils";
-import { autoEnvironmentRoute, environmentV1Name } from "@/utils";
+import {
+ autoEnvironmentRoute,
+ environmentV1Name,
+ getHighlightHTMLByRegExp,
+} from "@/utils";
import ProductionEnvironmentV1Icon from "./ProductionEnvironmentV1Icon.vue";
const props = withDefaults(
@@ -41,6 +47,7 @@ const props = withDefaults(
prefix?: string;
showIcon?: boolean;
textClass?: string;
+ keyword?: string;
}>(),
{
tag: "span",
@@ -52,6 +59,7 @@ const props = withDefaults(
prefix: "",
showIcon: true,
textClass: "",
+ keyword: "",
}
);
@@ -72,4 +80,11 @@ const bindings = computed(() => {
}
return {};
});
+
+const renderedEnvironmentName = computed(() => {
+ return getHighlightHTMLByRegExp(
+ environmentV1Name(props.environment),
+ props.keyword
+ );
+});
</script>
diff --git a/frontend/src/components/v2/Model/ProjectV1Name.vue b/frontend/src/components/v2/Model/ProjectV1Name.vue
index d158a17562..bde929ce8b 100644
--- a/frontend/src/components/v2/Model/ProjectV1Name.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Name.vue
@@ -37,7 +37,7 @@ const props = withDefaults(
link: true,
plain: false,
hash: "",
- keyword: undefined,
+ keyword: "",
}
);
const router = useRouter();
@@ -57,9 +57,6 @@ const bindings = computed(() => {
});
const renderedProjectName = computed(() => {
- return getHighlightHTMLByRegExp(
- projectV1Name(props.project),
- props.keyword || ""
- );
+ return getHighlightHTMLByRegExp(projectV1Name(props.project), props.keyword);
});
</script>
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index 8af771d703..7dd7a63328 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -37,6 +37,7 @@
:bordered="false"
:database-list="filteredDatabaseList"
:custom-click="true"
+ :keyword="state.params.query.trim().toLowerCase()"
@row-click="handleDatabaseClick"
@update:selected-databases="handleDatabasesSelectionChanged"
/>
diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
index 6df05ae521..cabce0ffed 100644
--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
@@ -205,8 +205,7 @@ import dayjs from "dayjs";
import { ArrowRightLeftIcon } from "lucide-vue-next";
import { NButton, NTabPane, NTabs } from "naive-ui";
import { computed, reactive, watch, ref, onMounted } from "vue";
-import { useRouter } from "vue-router";
-import { useRoute } from "vue-router";
+import { useRouter, useRoute } from "vue-router";
import { BBModal } from "@/bbkit";
import SchemaEditorModal from "@/components/AlterSchemaPrepForm/SchemaEditorModal.vue";
import DatabaseChangeHistoryPanel from "@/components/Database/DatabaseChangeHistoryPanel.vue";
@@ -330,7 +329,8 @@ watch(
hash: `#${tab}`,
query: route.query,
});
- }
+ },
+ { immediate: true }
);
const database = computed(() => {
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 52f5418a6f..39e434752c 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -9,7 +9,7 @@
</div>
</div>
- <NTabs>
+ <NTabs v-model:value="state.selectedTab">
<template #suffix>
<div class="flex items-center space-x-2">
<InstanceSyncButton
@@ -28,13 +28,13 @@
</NButton>
</div>
</template>
- <NTabPane name="OVERVIEW" :tab="$t('common.overview')">
+ <NTabPane name="overview" :tab="$t('common.overview')">
<InstanceForm class="-mt-2" :instance="instance">
<InstanceFormBody :hide-archive-restore="hideArchiveRestore" />
<InstanceFormButtons class="sticky bottom-0 z-10" />
</InstanceForm>
</NTabPane>
- <NTabPane name="DATABASES" :tab="$t('common.databases')">
+ <NTabPane name="databases" :tab="$t('common.databases')">
<div class="space-y-2">
<div
class="w-full flex flex-col sm:flex-row items-start sm:items-end justify-between gap-2"
@@ -60,12 +60,13 @@
:show-selection="true"
:database-list="filteredDatabaseList"
:custom-click="true"
+ :keyword="state.params.query.trim().toLowerCase()"
@row-click="handleDatabaseClick"
@update:selected-databases="handleDatabasesSelectionChanged"
/>
</div>
</NTabPane>
- <NTabPane name="USERS" :tab="$t('instance.users')">
+ <NTabPane name="users" :tab="$t('instance.users')">
<InstanceRoleTable :instance-role-list="instanceRoleList" />
</NTabPane>
</NTabs>
@@ -87,9 +88,9 @@
import { useTitle } from "@vueuse/core";
import { PlusIcon } from "lucide-vue-next";
import { NButton, NTabPane, NTabs } from "naive-ui";
-import { computed, reactive } from "vue";
+import { computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
+import { useRouter, useRoute } from "vue-router";
import AdvancedSearch from "@/components/AdvancedSearch";
import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
@@ -128,15 +129,22 @@ import {
CommonFilterScopeIdList,
filterDatabaseV1ByKeyword,
extractEnvironmentResourceName,
+ extractProjectResourceName,
} from "@/utils";
import type { SearchParams, SearchScope } from "@/utils";
+const instanceHashList = ["overview", "databases", "users"] as const;
+export type InstanceHash = (typeof instanceHashList)[number];
+const isInstanceHash = (x: any): x is InstanceHash =>
+ instanceHashList.includes(x);
+
interface LocalState {
showCreateDatabaseModal: boolean;
syncingSchema: boolean;
selectedDatabaseNameList: Set<string>;
selectedLabels: { key: string; value: string }[];
params: SearchParams;
+ selectedTab: InstanceHash;
}
const props = defineProps<{
@@ -172,11 +180,36 @@ const state = reactive<LocalState>({
query: "",
scopes: [...readonlyScopes.value],
},
+ selectedTab: "overview",
});
+const route = useRoute();
+
const scopeOptions = useCommonSearchScopeOptions(
computed(() => state.params),
- [...CommonFilterScopeIdList]
+ [...CommonFilterScopeIdList, "project"]
+);
+
+watch(
+ () => route.hash,
+ (hash) => {
+ const targetHash = hash.replace(/^#?/g, "") as InstanceHash;
+ if (isInstanceHash(targetHash)) {
+ state.selectedTab = targetHash;
+ }
+ },
+ { immediate: true }
+);
+
+watch(
+ () => state.selectedTab,
+ (tab) => {
+ router.replace({
+ hash: `#${tab}`,
+ query: route.query,
+ });
+ },
+ { immediate: true }
);
const instance = computed(() => {
@@ -202,6 +235,10 @@ const selectedEnvironment = computed(() => {
);
});
+const selectedProject = computed(() => {
+ return state.params.scopes.find((scope) => scope.id === "project")?.value;
+});
+
const filteredDatabaseList = computed(() => {
let list = databaseList.value;
if (selectedEnvironment.value !== `${UNKNOWN_ID}`) {
@@ -211,6 +248,11 @@ const filteredDatabaseList = computed(() => {
selectedEnvironment.value
);
}
+ if (selectedProject.value) {
+ list = list.filter(
+ (db) => extractProjectResourceName(db.project) === selectedProject.value
+ );
+ }
const keyword = state.params.query.trim().toLowerCase();
if (keyword) {
list = list.filter((db) =>
@@ -218,6 +260,7 @@ const filteredDatabaseList = computed(() => {
"name",
"environment",
"instance",
+ "project",
])
);
}