Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: support search by engine (#15490)
ecmadao24318891eb1e
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex 76fc8c366b..677041ad5b 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -209,6 +209,9 @@ func getListDatabaseFilter(filter string) (*store.ListResourceFilter, error) {if !ok {return "", status.Errorf(codes.InvalidArgument, "invalid engine value %q", value)}+ if len(rawEngineList) == 0 {+ return "", status.Errorf(codes.InvalidArgument, "empty engine filter")+ }engineList := []string{}for _, rawEngine := range rawEngineList {v1Engine, ok := v1pb.Engine_value[rawEngine.(string)]diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex c2b71a2aab..6494c9a377 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -209,6 +209,9 @@ func getListUserFilter(filter string) (*store.ListResourceFilter, error) {if !ok {return "", status.Errorf(codes.InvalidArgument, "invalid user_type value %q", value)}+ if len(rawTypeList) == 0 {+ return "", status.Errorf(codes.InvalidArgument, "empty user_type filter")+ }userTypeList := []string{}for _, rawType := range rawTypeList {v1UserType, ok := v1pb.UserType_value[rawType.(string)]diff --git a/backend/plugin/webhook/dingtalk/dingtalk.go b/backend/plugin/webhook/dingtalk/dingtalk.goindex cfc5e735c6..4b861d096b 100644--- a/backend/plugin/webhook/dingtalk/dingtalk.go+++ b/backend/plugin/webhook/dingtalk/dingtalk.go@@ -45,14 +45,14 @@ type Message struct {}func init() {- webhook.Register("bb.plugin.webhook.dingtalk", &DingTalkReceiver{})+ webhook.Register("bb.plugin.webhook.dingtalk", &Receiver{})}-// DingTalkReceiver is the receiver for DingTalk.-type DingTalkReceiver struct {+// Receiver is the receiver for DingTalk.+type Receiver struct {}-func (*DingTalkReceiver) Post(context webhook.Context) error {+func (*Receiver) Post(context webhook.Context) error {if context.DirectMessage && len(context.MentionEndUsers) > 0 {sendDirectMessage(context)return nil@@ -60,7 +60,7 @@ func (*DingTalkReceiver) Post(context webhook.Context) error {return sendMessage(context)}-// returns true if the message is sent successfully+// returns true if the message is sent successfully.func sendDirectMessage(webhookCtx webhook.Context) {dingtalk := webhookCtx.IMSetting.GetDingtalk()if dingtalk == nil {diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.tsindex e4198bf0cf..012074571c 100644--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts@@ -6,6 +6,7 @@ import {ProjectV1Name,RichDatabaseName,EnvironmentV1Name,+ RichEngineName,} from "@/components/v2";import { t } from "@/plugins/i18n";import {@@ -23,6 +24,7 @@ import {extractEnvironmentResourceName,extractInstanceResourceName,extractProjectResourceName,+ supportedEngineV1List,} from "@/utils";import type { ScopeOption, ValueOption } from "./types";@@ -160,11 +162,26 @@ export const useCommonSearchScopeOptions = (}),label: () => ({id: "label",- title: "Label",- description: "Input the {label key}:{label value} then press Enter.",+ title: t("issue.advanced-search.scope.database-label.title"),+ description: t(+ "issue.advanced-search.scope.database-label.description"+ ),options: [] as ValueOption[],allowMultiple: true,}),+ engine: () => ({+ id: "engine",+ title: t("issue.advanced-search.scope.engine.title"),+ description: t("issue.advanced-search.scope.engine.description"),+ options: supportedEngineV1List().map((engine) => {+ return {+ value: engine,+ keywords: [engineToJSON(engine).toLowerCase()],+ render: () => h(RichEngineName, { engine, tag: "p" }),+ };+ }),+ allowMultiple: true,+ }),} as Record<SearchScopeId, () => ScopeOption>;const scopes: ScopeOption[] = [];diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vueindex 19217251eb..46510b3f55 100644--- a/frontend/src/components/ProjectDatabasesPanel.vue+++ b/frontend/src/components/ProjectDatabasesPanel.vue@@ -63,6 +63,7 @@ import {} from "@/store/modules/v1/common";import type { ComposedDatabase, ComposedProject } from "@/types";import { isValidDatabaseName } from "@/types";+import { engineFromJSON } from "@/types/proto/v1/common";import type { SearchParams, SearchScope } from "@/utils";import {CommonFilterScopeIdList,@@ -108,7 +109,7 @@ const allowToCreateDB = computed(() => {const scopeOptions = useCommonSearchScopeOptions(computed(() => state.params),- [...CommonFilterScopeIdList, "label"]+ [...CommonFilterScopeIdList, "label", "engine"]);const selectedInstance = computed(() => {@@ -137,11 +138,18 @@ const selectedLabels = computed(() => {.map((scope) => scope.value);});+const selectedEngines = computed(() => {+ return state.params.scopes+ .filter((scope) => scope.id === "engine")+ .map((scope) => engineFromJSON(scope.value));+});+const filter = computed(() => ({instance: selectedInstance.value,environment: selectedEnvironment.value,query: state.params.query,labels: selectedLabels.value,+ engines: selectedEngines.value,}));const selectedDatabases = computed((): ComposedDatabase[] => {diff --git a/frontend/src/components/SQLReview/components/SQLReviewTabsByEngine.vue b/frontend/src/components/SQLReview/components/SQLReviewTabsByEngine.vueindex 1d4dc0ddbf..8164bff462 100644--- a/frontend/src/components/SQLReview/components/SQLReviewTabsByEngine.vue+++ b/frontend/src/components/SQLReview/components/SQLReviewTabsByEngine.vue@@ -7,7 +7,6 @@><template #tab><div class="flex items-center space-x-2">- <EngineIcon :engine="engine" custom-class="ml-1" /><RichEngineName:engine="engine"tag="p"@@ -30,7 +29,6 @@<script setup lang="ts">import { NTabs, NTabPane } from "naive-ui";import { ref, watch, computed } from "vue";-import { EngineIcon } from "@/components/Icon";import { RichEngineName } from "@/components/v2";import type { RuleTemplateV2 } from "@/types";import { Engine } from "@/types/proto/v1/common";diff --git a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vueindex 8c1d22b9c3..0b9d6937ca 100644--- a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue+++ b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue@@ -10,7 +10,6 @@{{ $t("common.name") }}</h3><div class="flex items-center space-x-2">- <EngineIcon :engine="rule.engine" custom-class="ml-1" /><RichEngineName:engine="rule.engine"tag="p"@@ -92,7 +91,6 @@import { NButton, NSwitch } from "naive-ui";import { nextTick, reactive, watch, ref } from "vue";import { BBModal, BBTextField } from "@/bbkit";-import { EngineIcon } from "@/components/Icon";import { payloadValueListToComponentList } from "@/components/SQLReview/components";import { RichEngineName } from "@/components/v2";import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue b/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vueindex c746d1e3bf..8de0770dbb 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue@@ -89,13 +89,16 @@ const filter = computed(() => {if (props.filter?.excludeUnassigned) {params.push(`exclude_unassigned == true`);}- if (props.filter?.engines) {+ if (props.filter?.engines && props.filter?.engines.length > 0) {// engine filter should be:// engine in ["MYSQL", "POSTGRES"]params.push(`engine in [${props.filter?.engines.map((e) => `"${e}"`).join(", ")}]`);- } else if (props.filter?.excludeEngines) {+ } else if (+ props.filter?.excludeEngines &&+ props.filter?.excludeEngines.length > 0+ ) {// engine filter should be:// !(engine in ["REDIS", "MONGODB"])params.push(diff --git a/frontend/src/components/v2/Model/Instance/InstanceEngineRadioGrid.vue b/frontend/src/components/v2/Model/Instance/InstanceEngineRadioGrid.vueindex ae9828697d..2d3bbf022e 100644--- a/frontend/src/components/v2/Model/Instance/InstanceEngineRadioGrid.vue+++ b/frontend/src/components/v2/Model/Instance/InstanceEngineRadioGrid.vue@@ -6,11 +6,6 @@><template #item="{ option }: RadioGridItem<Engine>"><div class="flex flex-row items-center gap-x-1">- <img- v-if="EngineIconPath[option.value]"- :src="EngineIconPath[option.value]"- class="w-5 h-auto max-h-[20px] object-contain"- /><RichEngineName:engine="option.value"tag="p"@@ -24,7 +19,6 @@<script setup lang="ts">import { computed } from "vue";-import { EngineIconPath } from "@/components/InstanceForm/constants";import type { Engine } from "@/types/proto/v1/common";import { engineNameV1 } from "@/utils";import {diff --git a/frontend/src/components/v2/Model/Instance/RichEngineName.vue b/frontend/src/components/v2/Model/Instance/RichEngineName.vueindex 422b1625aa..9f78f99aae 100644--- a/frontend/src/components/v2/Model/Instance/RichEngineName.vue+++ b/frontend/src/components/v2/Model/Instance/RichEngineName.vue@@ -1,5 +1,6 @@<template>- <component :is="tag">+ <component :is="tag" class="flex items-center gap-x-2">+ <EngineIcon :engine="engine" />{{ title }}<span v-if="subtitle" class="text-xs opacity-70">{{ subtitle }}@@ -9,6 +10,7 @@<script setup lang="ts">import { computed } from "vue";+import { EngineIcon } from "@/components/Icon";import type { Engine } from "@/types/proto/v1/common";import { engineNameV1 } from "@/utils";diff --git a/frontend/src/components/v2/Model/index.ts b/frontend/src/components/v2/Model/index.tsindex 853dfff25e..1d6221a0f5 100644--- a/frontend/src/components/v2/Model/index.ts+++ b/frontend/src/components/v2/Model/index.ts@@ -2,6 +2,7 @@ import DatabaseV1Name from "./DatabaseV1Name.vue";import DatabaseView from "./DatabaseView.vue";import EnvironmentV1Name from "./EnvironmentV1Name.vue";import EnvironmentV1Table from "./EnvironmentV1Table.vue";+import RichEngineName from "./Instance/RichEngineName.vue";import PagedProjectTable from "./PagedProjectTable.vue";import ProductionEnvironmentV1Icon from "./ProductionEnvironmentV1Icon.vue";import ProjectV1Name from "./ProjectV1Name.vue";@@ -21,4 +22,5 @@ export {ProjectV1Table,PagedProjectTable,DatabaseView,+ RichEngineName,};diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 7ed94068d9..f7d7cb4662 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -822,6 +822,14 @@"label": {"title": "Label","description": "Filter by issue label"+ },+ "database-label": {+ "title": "Label",+ "description": "Input the \"label key\":\"label value\" then press Enter"+ },+ "engine": {+ "title": "Engine",+ "description": "Filter by engines"}},"hide": "Hide advanced search"diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex cef92d7c06..f88bd6eeb8 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -822,6 +822,14 @@"label": {"title": "Etiqueta","description": "Filtrar por etiqueta de problema"+ },+ "database-label": {+ "title": "Etiqueta",+ "description": "Ingrese la \"key\":\"value\" y luego presione Enter"+ },+ "engine": {+ "title": "Motor",+ "description": "Filtrar por motores"}},"hide": "Ocultar búsqueda avanzada"diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 501c5a3d2e..ba1a859ded 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -822,6 +822,14 @@"label": {"title": "ラベル","description": "イシュータグで絞り込む"+ },+ "database-label": {+ "title": "ラベル",+ "description": "\"key\":\"value\"を入力し、Enterを押します。"+ },+ "engine": {+ "title": "エンジン",+ "description": "エンジンでフィルタリング"}},"hide": "詳細検索を非表示にする"diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 6c122dcd31..5fce5db45e 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -822,6 +822,14 @@"label": {"title": "Nhãn","description": "Lọc theo nhãn vấn đề"+ },+ "database-label": {+ "title": "Nhãn",+ "description": "Nhập \"key\":\"value\" rồi nhấn Enter"+ },+ "engine": {+ "title": "Động cơ",+ "description": "Lọc theo động cơ"}},"hide": "Ẩn tìm kiếm nâng cao"diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 45dd4bd0d7..83c78ea971 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -822,6 +822,14 @@"label": {"title": "标签","description": "按工单标签过滤"+ },+ "database-label": {+ "title": "标签",+ "description": "输入\"key\":\"value\"后按下回车"+ },+ "engine": {+ "title": "引擎",+ "description": "按引擎过滤"}},"hide": "隐藏高级搜索"diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.tsindex 60c9d3a73a..3751ebd623 100644--- a/frontend/src/utils/v1/advanced-search/common.ts+++ b/frontend/src/utils/v1/advanced-search/common.ts@@ -24,9 +24,11 @@ export const AllSearchScopeIdList = ["creator","created","status",+ // database related search scopes.+ "engine",// issue related search scopes."subscriber",- "label",+ "label", // label is also used by database search"taskType",// auditLog related search scopes."method",diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vueindex 4a56a76a99..d99bf3b74d 100644--- a/frontend/src/views/DatabaseDashboard.vue+++ b/frontend/src/views/DatabaseDashboard.vue@@ -71,6 +71,7 @@ import {} from "@/store/modules/v1/common";import type { ComposedDatabase } from "@/types";import { DEFAULT_PROJECT_NAME, isValidDatabaseName } from "@/types";+import { engineFromJSON } from "@/types/proto/v1/common";import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";import type { SearchParams } from "@/utils";import {@@ -126,7 +127,7 @@ const allowToCreateDB = computed(() => {const scopeOptions = useCommonSearchScopeOptions(computed(() => state.params),- [...CommonFilterScopeIdList, "project", "label"]+ [...CommonFilterScopeIdList, "project", "label", "engine"]);const selectedLabels = computed(() => {@@ -165,6 +166,12 @@ const selectedEnvironment = computed(() => {return `${environmentNamePrefix}${environmentId}`;});+const selectedEngines = computed(() => {+ return state.params.scopes+ .filter((scope) => scope.id === "engine")+ .map((scope) => engineFromJSON(scope.value));+});+const filter = computed(() => ({instance: selectedInstance.value,environment: selectedEnvironment.value,@@ -172,6 +179,7 @@ const filter = computed(() => ({query: state.params.query,labels: selectedLabels.value,excludeUnassigned: hideUnassignedDatabases.value,+ engines: selectedEngines.value,}));onMounted(() => {