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: remove dev guard and add feature guard for index advisor (#5894)
rebelice8a3578842d93
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex edf06b8ce4..f89b681f31 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -1402,6 +1402,9 @@ func isUpperCaseLetter(c rune) bool {// AdviseIndex advises the index of a table.func (s *DatabaseService) AdviseIndex(ctx context.Context, request *v1pb.AdviseIndexRequest) (*v1pb.AdviseIndexResponse, error) {+ if !s.licenseService.IsFeatureEnabled(api.FeaturePluginOpenAI) {+ return nil, status.Errorf(codes.PermissionDenied, api.FeaturePluginOpenAI.AccessErrorMessage())+ }environmentID, instanceID, databaseName, err := getEnvironmentInstanceDatabaseID(request.Parent)if err != nil {return nil, status.Errorf(codes.InvalidArgument, err.Error())diff --git a/frontend/src/components/SlowQuery/Panel/AdviseIndex.vue b/frontend/src/components/SlowQuery/Panel/AdviseIndex.vueindex 7e86080623..39eab11fa6 100644--- a/frontend/src/components/SlowQuery/Panel/AdviseIndex.vue+++ b/frontend/src/components/SlowQuery/Panel/AdviseIndex.vue@@ -16,6 +16,7 @@<button class="ml-2 normal-link underline" @click="handleCreateIndex">{{ $t("slow-query.advise-index.create-index") }}</button>+ <!--TODO(boojack): add a FeatureBadge for bb.feature.plugin.openai here--></div><span class="w-full font-mono">{{ state.suggestion }}</span></div>@@ -32,6 +33,7 @@ import { useRouter } from "vue-router";import { databaseServiceClient } from "@/grpcweb";import { getErrorCode } from "@/utils/grpcweb";import { Status } from "nice-grpc-common";+import { hasFeature } from "@/store";const props = defineProps<{slowQueryLog: ComposedSlowQueryLog;@@ -89,19 +91,25 @@ const generateIssueName = () => {watch(() => props.slowQueryLog,async () => {- try {- const response = await databaseServiceClient.adviseIndex({- parent: log.value.resource,- statement: sqlFingerprint.value,- });+ if (hasFeature("bb.feature.plugin.openai")) {+ try {+ const response = await databaseServiceClient.adviseIndex({+ parent: log.value.resource,+ statement: sqlFingerprint.value,+ });- state.currentIndex = response.currentIndex;- state.suggestion = response.suggestion;- state.createIndexStatement = response.createIndexStatement;- } catch (error) {- if (getErrorCode(error) !== Status.NOT_FOUND) {- throw error;+ state.currentIndex = response.currentIndex;+ state.suggestion = response.suggestion;+ state.createIndexStatement = response.createIndexStatement;+ } catch (error) {+ if (getErrorCode(error) !== Status.NOT_FOUND) {+ throw error;+ }}+ } else {+ state.currentIndex = "";+ state.suggestion = "";+ state.createIndexStatement = "";}},{diff --git a/frontend/src/components/SlowQuery/Panel/DetailPanel.vue b/frontend/src/components/SlowQuery/Panel/DetailPanel.vueindex b855c744a6..61208272b8 100644--- a/frontend/src/components/SlowQuery/Panel/DetailPanel.vue+++ b/frontend/src/components/SlowQuery/Panel/DetailPanel.vue@@ -61,11 +61,7 @@</div></div></div>- <!-- TODO(junyi): remove the isDev guard before releasing -->- <AdviseIndex- v-if="isDev() && slowQueryLog"- :slow-query-log="slowQueryLog"- />+ <AdviseIndex v-if="slowQueryLog" :slow-query-log="slowQueryLog" /><divv-if="instanceHasSlowQueryDetail(database.instance)"class="flex-1 overflow-auto border"@@ -132,7 +128,7 @@ import { NButton, NDrawer, NDrawerContent } from "naive-ui";import { type BBGridColumn, type BBGridRow, BBGrid } from "@/bbkit";import type { ComposedSlowQueryLog } from "@/types";import type { SlowQueryDetails } from "@/types/proto/v1/database_service";-import { instanceHasSlowQueryDetail, isDev } from "@/utils";+import { instanceHasSlowQueryDetail } from "@/utils";import {DatabaseName,InstanceName,diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex d3722699a8..04920e0706 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1930,7 +1930,7 @@},"bb-feature-plugin-openai": {"title": "AI Augmentation",- "desc": "AI augmented SQL Editor features powered by OpenAI."+ "desc": "AI augmented SQL Editor and index advisor features powered by OpenAI."},"bb-feature-shared-sql-script": {"title": "Shared SQL script",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 16f77f4453..d121189156 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1930,7 +1930,7 @@},"bb-feature-plugin-openai": {"title": "Aumento de AI",- "desc": "Características del editor de SQL mejoradas por AI proporcionado por OpenAI."+ "desc": "Editor de SQL aumentado con IA y características de asesoramiento de índice impulsadas por OpenAI."},"bb-feature-shared-sql-script": {"title": "Script SQL compartido",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex efe0b952f1..7a6ef5f8a5 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1927,7 +1927,7 @@},"bb-feature-plugin-openai": {"title": "AI 增强",- "desc": "AI 增强的 SQL 编辑器功能,基于 OpenAI 技术驱动。"+ "desc": "AI 增强的 SQL 编辑器和索引建议功能,基于 OpenAI 技术驱动。"},"bb-feature-shared-sql-script": {"title": "共享 SQL 脚本",