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(sql-editor): hide projects and environments when workspaceMode=EDITOR (#13073)
Liu Jicb39a1d88927
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vueindex 4c913f6758..9c40ceb04d 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue@@ -170,7 +170,7 @@"class="mt-4 sm:col-span-3 sm:col-start-1">- <div class="mb-4">+ <div v-if="!hideAdvancedFeatures" class="mb-4"><NRadioGroupclass="textlabel":value="state.passwordType"@@ -221,7 +221,7 @@<label class="textlabel block">{{ $t("common.password") }}</label>- <div class="flex space-x-2 text-sm">+ <div v-if="!hideAdvancedFeatures" class="flex space-x-2 text-sm"><div class="text-gray-400">{{ $t("instance.password-type.password-tip") }}</div>@@ -814,6 +814,7 @@ MIIEvQ...<divv-if="+ !hideAdvancedFeatures &&showSSH &&dataSource.authenticationType === DataSource_AuthenticationType.PASSWORD"@@ -916,6 +917,7 @@ const {adminDataSource,hasReadonlyReplicaFeature,missingFeature,+ hideAdvancedFeatures,} = useInstanceFormContext();const {diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vueindex 9c90e9703c..c893de5243 100644--- a/frontend/src/components/InstanceForm/InstanceForm.vue+++ b/frontend/src/components/InstanceForm/InstanceForm.vue@@ -23,6 +23,7 @@ import { provideInstanceFormContext } from "./context";const props = defineProps<{instance?: Instance;+ hideAdvancedFeatures?: boolean;}>();const emit = defineEmits<{@@ -32,7 +33,8 @@ const emit = defineEmits<{const settingV1Store = useSettingV1Store();const instance = toRef(props, "instance");-const context = provideInstanceFormContext({ instance });+const hideAdvancedFeatures = toRef(props, "hideAdvancedFeatures");+const context = provideInstanceFormContext({ instance, hideAdvancedFeatures });const { events, isCreating, basicInfo, adminDataSource, missingFeature } =context;onMounted(async () => {diff --git a/frontend/src/components/InstanceForm/MaximumConnectionsInput.vue b/frontend/src/components/InstanceForm/MaximumConnectionsInput.vueindex 8081b07540..0e67221d33 100644--- a/frontend/src/components/InstanceForm/MaximumConnectionsInput.vue+++ b/frontend/src/components/InstanceForm/MaximumConnectionsInput.vue@@ -1,5 +1,8 @@<template>- <div class="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2">+ <div+ v-if="!hideAdvancedFeatures"+ class="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2"+ ><label class="textlabel">{{ $t("instance.maximum-connections.self") }}</label>@@ -81,7 +84,7 @@ const emit = defineEmits<{}>();const subscriptionStore = useSubscriptionV1Store();-const { instance } = useInstanceFormContext();+const { instance, hideAdvancedFeatures } = useInstanceFormContext();const hasSecretFeature = computed(() => {return subscriptionStore.hasInstanceFeature(diff --git a/frontend/src/components/InstanceForm/ScanIntervalInput.vue b/frontend/src/components/InstanceForm/ScanIntervalInput.vueindex 425266f9b7..9843b904fd 100644--- a/frontend/src/components/InstanceForm/ScanIntervalInput.vue+++ b/frontend/src/components/InstanceForm/ScanIntervalInput.vue@@ -1,5 +1,8 @@<template>- <div class="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2">+ <div+ v-if="!hideAdvancedFeatures"+ class="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2"+ ><label class="textlabel">{{ $t("instance.scan-interval.self") }}</label>@@ -84,7 +87,7 @@ const emit = defineEmits<{}>();const subscriptionStore = useSubscriptionV1Store();-const { instance } = useInstanceFormContext();+const { instance, hideAdvancedFeatures } = useInstanceFormContext();const hasSecretFeature = computed(() => {return subscriptionStore.hasInstanceFeature(diff --git a/frontend/src/components/InstanceForm/context.ts b/frontend/src/components/InstanceForm/context.tsindex 2cca3d0e14..857fb9527c 100644--- a/frontend/src/components/InstanceForm/context.ts+++ b/frontend/src/components/InstanceForm/context.ts@@ -52,6 +52,7 @@ const KEY = Symbol(export const provideInstanceFormContext = (baseContext: {instance: Ref<Instance | undefined>;+ hideAdvancedFeatures: Ref<boolean | undefined>;}) => {const $d = useDialog();const { t } = useI18n();diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vueindex 8a603e38aa..5192229203 100644--- a/frontend/src/components/ProfileDropdown.vue+++ b/frontend/src/components/ProfileDropdown.vue@@ -24,6 +24,8 @@ import { useLanguage } from "@/composables/useLanguage";import { AUTH_SIGNIN_MODULE } from "@/router/auth";import {useActuatorV1Store,+ useAppFeature,+ useWorkspaceMode,useAuthStore,useCurrentUserV1,useSubscriptionV1Store,@@ -44,6 +46,9 @@ const router = useRouter();const { setLocale, locale } = useLanguage();const currentUserV1 = useCurrentUserV1();const showDropdown = ref(false);+const workspaceMode = useWorkspaceMode();+const hideQuickstart = useAppFeature("bb.feature.hide-quick-start");+const hideHelp = useAppFeature("bb.feature.hide-help");// For now, debug mode is a global setting and will affect all users.// So we only allow DBA and Owner to toggle it.@@ -212,6 +217,7 @@ const options = computed((): DropdownOption[] => [type: "render",render() {return h(ProfilePreview, {+ link: workspaceMode.value === "CONSOLE",onClick: () => (showDropdown.value = false),});},@@ -268,6 +274,7 @@ const options = computed((): DropdownOption[] => [{key: "quick-start",type: "render",+ show: !hideQuickstart.value,render() {return h("div",@@ -282,6 +289,7 @@ const options = computed((): DropdownOption[] => [{key: "help",type: "render",+ show: !hideHelp.value,render() {return h("a",diff --git a/frontend/src/components/ProfilePreview.vue b/frontend/src/components/ProfilePreview.vueindex 52cace7238..123c24863e 100644--- a/frontend/src/components/ProfilePreview.vue+++ b/frontend/src/components/ProfilePreview.vue@@ -1,5 +1,6 @@<template>- <router-link+ <component+ :is="link ? 'router-link' : 'div'"class="px-4 py-3 menu-item w-48":to="{ name: SETTING_ROUTE_PROFILE }"role="menuitem"@@ -12,12 +13,21 @@<p class="text-sm text-control truncate text-ellipsis">{{ currentUserV1.email }}</p>- </router-link>+ </component></template><script setup lang="ts">import { SETTING_ROUTE_PROFILE } from "@/router/dashboard/workspaceSetting";import { useCurrentUserV1 } from "@/store";+withDefaults(+ defineProps<{+ link?: boolean;+ }>(),+ {+ link: true,+ }+);+const currentUserV1 = useCurrentUserV1();</script>diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vueindex 3addafcc66..dcf9764c15 100644--- a/frontend/src/components/ProvideSQLEditorContext.vue+++ b/frontend/src/components/ProvideSQLEditorContext.vue@@ -44,6 +44,7 @@ import {useUserGroupStore,pushNotification,useFilterStore,+ useAppFeature,} from "@/store";import type { SQLEditorConnection } from "@/types";import {@@ -95,6 +96,7 @@ const {events: editorEvents,maybeSwitchProject,} = useSQLEditorContext();+const hideProjects = useAppFeature("bb.feature.sql-editor.hide-projects");const initializeProjects = async () => {const initProject = async (project: string) => {@@ -122,23 +124,31 @@ const initializeProjects = async () => {await initProject(project);} else {// plain "/sql-editor"- const projectList = await projectStore.fetchProjectList(false);- const lastView = editorStore.storedLastViewedProject;- if (- lastView &&- projectList.findIndex((proj) => proj.name === lastView) >= 0- ) {- editorStore.project = lastView;++ if (hideProjects.value) {+ // Direct to Default Project+ editorStore.project = DEFAULT_PROJECT_NAME;+ editorStore.strictProject = false;+ await initProject(DEFAULT_PROJECT_NAME);} else {- const projectListWithoutDefaultProject = projectList.filter(- (proj) => proj.name !== DEFAULT_PROJECT_NAME- );- editorStore.project =- head(projectListWithoutDefaultProject)?.name ??- head(projectList)?.name ??- "";+ const projectList = await projectStore.fetchProjectList(false);+ const lastView = editorStore.storedLastViewedProject;+ if (+ lastView &&+ projectList.findIndex((proj) => proj.name === lastView) >= 0+ ) {+ editorStore.project = lastView;+ } else {+ const projectListWithoutDefaultProject = projectList.filter(+ (proj) => proj.name !== DEFAULT_PROJECT_NAME+ );+ editorStore.project =+ head(projectListWithoutDefaultProject)?.name ??+ head(projectList)?.name ??+ "";+ }+ editorStore.strictProject = false;}- editorStore.strictProject = false;}tabStore.maybeInitProject(editorStore.project);diff --git a/frontend/src/customAppProfile.ts b/frontend/src/customAppProfile.tsindex a819e674ce..20039e34c5 100644--- a/frontend/src/customAppProfile.ts+++ b/frontend/src/customAppProfile.ts@@ -1,5 +1,6 @@import { computed, watch } from "vue";import { useActuatorV1Store, useAppFeature, useSettingByName } from "./store";+import { defaultAppProfile, type WorkspaceMode } from "./types";import { DatabaseChangeMode } from "./types/proto/v1/setting_service";import { useCustomTheme } from "./utils/customTheme";@@ -18,6 +19,23 @@ export const overrideAppProfile = () => {});const query = new URLSearchParams(window.location.search);+ overrideAppFeatures(workspaceMode.value, query);+ useCustomTheme(useAppFeature("bb.feature.custom-color-scheme"));++ watch(workspaceMode, (mode) => {+ overrideAppFeatures(mode, query);+ });+};++const overrideAppFeatures = (+ workspaceMode: WorkspaceMode,+ query: URLSearchParams+) => {+ const actuatorStore = useActuatorV1Store();++ actuatorStore.appProfile = defaultAppProfile();+ actuatorStore.appProfile.mode = workspaceMode;+const modeInQuery = query.get("mode");if (modeInQuery === "STANDALONE") {// The webapp is embedded within iframe@@ -72,5 +90,16 @@ export const overrideAppProfile = () => {}}- useCustomTheme(useAppFeature("bb.feature.custom-color-scheme"));+ if (workspaceMode === "EDITOR") {+ actuatorStore.overrideAppFeatures({+ "bb.feature.hide-quick-start": true,+ "bb.feature.hide-help": true,++ "bb.feature.sql-editor.hide-projects": true,+ "bb.feature.sql-editor.hide-environments": true,+ "bb.feature.sql-editor.disallow-batch-query": true,+ "bb.feature.sql-editor.disallow-share-worksheet": true,+ "bb.feature.sql-editor.hide-advance-instance-features": true,+ });+ }};diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex eed1263285..814481da2e 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2425,7 +2425,8 @@"query-context": {"admin-data-source-is-disallowed-to-query": "Admin data source is disallowed to query.","admin-data-source-is-disallowed-to-query-when-read-only-data-source-is-available": "Admin data source is disallowed to query when read-only data source is available."- }+ },+ "manage-connections": "Manage connections"},"schema-editor": {"self": "Schema Editor",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 5d8fb9912b..47ece4ff5c 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2425,7 +2425,8 @@"query-context": {"admin-data-source-is-disallowed-to-query": "No se permite realizar consultas a la fuente de datos del administrador.","admin-data-source-is-disallowed-to-query-when-read-only-data-source-is-available": "No se permite realizar consultas a la fuente de datos del administrador cuando la fuente de datos de solo lectura está disponible."- }+ },+ "manage-connections": "Gestionar las conexiones"},"schema-editor": {"self": "Editor de esquema",@@ -3631,4 +3632,4 @@"self": "Última actualización"}}-}\ No newline at end of file+}diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 034e87e23f..529d07b575 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2425,7 +2425,8 @@"query-context": {"admin-data-source-is-disallowed-to-query": "管理者データ ソースはクエリできません。","admin-data-source-is-disallowed-to-query-when-read-only-data-source-is-available": "読み取り専用データ ソースが使用可能な場合、管理データ ソースはクエリを実行できません。"- }+ },+ "manage-connections": "接続を管理する"},"schema-editor": {"self": "スキーマエディタ",@@ -3631,4 +3632,4 @@"self": "最後の更新"}}-}\ No newline at end of file+}diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 67cebbce14..58b90cbe79 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2425,7 +2425,8 @@"query-context": {"admin-data-source-is-disallowed-to-query": "禁止查询管理员数据源。","admin-data-source-is-disallowed-to-query-when-read-only-data-source-is-available": "当只读数据源可用时,不允许查询管理员数据源。"- }+ },+ "manage-connections": "管理连接"},"schema-editor": {"self": "Schema 编辑器",diff --git a/frontend/src/store/modules/sqlEditor/tree.ts b/frontend/src/store/modules/sqlEditor/tree.tsindex c37dd6925c..28f6768321 100644--- a/frontend/src/store/modules/sqlEditor/tree.ts+++ b/frontend/src/store/modules/sqlEditor/tree.ts@@ -1,5 +1,5 @@import { useLocalStorage } from "@vueuse/core";-import { cloneDeep, orderBy, uniq } from "lodash-es";+import { cloneDeep, orderBy, pullAt, uniq } from "lodash-es";import { defineStore, storeToRefs } from "pinia";import { computed, reactive, ref, watch } from "vue";import { useCurrentUserV1 } from "@/store";@@ -23,7 +23,11 @@ import type { Environment } from "@/types/proto/v1/environment_service";import type { InstanceResource } from "@/types/proto/v1/instance_service";import { getSemanticLabelValue, groupBy, isDatabaseV1Queryable } from "@/utils";import { useFilterStore } from "../filter";-import { useEnvironmentV1Store, useInstanceResourceByName } from "../v1";+import {+ useAppFeature,+ useEnvironmentV1Store,+ useInstanceResourceByName,+} from "../v1";import { useSQLEditorStore } from "./editor";export const ROOT_NODE_ID = "ROOT";@@ -32,12 +36,22 @@ const defaultEnvironmentFactor: StatefulFactor = {factor: "environment",disabled: false,};+const defaultInstanceFactor: StatefulFactor = {+ factor: "instance",+ disabled: false,+};export const useSQLEditorTreeStore = defineStore("sqlEditorTree", () => {const { filter } = useFilterStore();const me = useCurrentUserV1();+ const hideEnvironments = useAppFeature(+ "bb.feature.sql-editor.hide-environments"+ );const defaultFactorList = (): StatefulFactor[] => {+ if (hideEnvironments.value) {+ return [defaultInstanceFactor];+ }return [defaultEnvironmentFactor];};@@ -82,6 +96,11 @@ export const useSQLEditorTreeStore = defineStore("sqlEditorTree", () => {cloneDeep(factorListInLocalStorage.value));+ const hasMissingQueryDatabases = computed(() => {+ return databaseList.value.some(+ (db) => !isDatabaseV1Queryable(db, me.value)+ );+ });const sortedDatabaseList = computed(() => {if (!showMissingQueryDatabases.value) {return databaseList.value.filter((db) =>@@ -115,7 +134,9 @@ export const useSQLEditorTreeStore = defineStore("sqlEditorTree", () => {return factorList.value.filter((sf) => !sf.disabled).map((sf) => sf.factor);});const availableFactorList = computed(() => {- const PRESET_FACTORS: Factor[] = ["instance", "environment"];+ const PRESET_FACTORS: Factor[] = hideEnvironments.value+ ? ["instance"]+ : ["instance", "environment"];const labelFactors = orderBy(uniq(databaseList.value.flatMap((db) => Object.keys(db.labels))@@ -131,6 +152,26 @@ export const useSQLEditorTreeStore = defineStore("sqlEditorTree", () => {};});+ watch(+ [hideEnvironments, factorList],+ () => {+ if (hideEnvironments.value) {+ const index = factorList.value.findIndex(+ (factor) => factor.factor === "environment"+ );+ if (index >= 0) {+ pullAt(factorList.value, index);+ }+ if (factorList.value.length === 0) {+ factorList.value = [defaultInstanceFactor];+ }+ }+ },+ {+ immediate: true,+ }+ );+const state = ref<TreeState>("UNSET");const tree = ref<TreeNode[]>([]);const expandedKeys = ref<string[]>([]);@@ -216,6 +257,7 @@ export const useSQLEditorTreeStore = defineStore("sqlEditorTree", () => {nodesByTarget,buildTree,expandedKeys,+ hasMissingQueryDatabases,showMissingQueryDatabases,cleanup,};diff --git a/frontend/src/store/modules/v1/actuator.ts b/frontend/src/store/modules/v1/actuator.tsindex aecbf4ab9e..f76ad49163 100644--- a/frontend/src/store/modules/v1/actuator.ts+++ b/frontend/src/store/modules/v1/actuator.ts@@ -173,3 +173,7 @@ export const useActuatorV1Store = defineStore("actuator_v1", {export const useAppFeature = <T extends keyof AppFeatures>(feature: T) => {return computed(() => useActuatorV1Store().appProfile.features[feature]);};++export const useWorkspaceMode = () => {+ return computed(() => useActuatorV1Store().appProfile.mode);+};diff --git a/frontend/src/types/appProfile.ts b/frontend/src/types/appProfile.tsindex 7321860669..5b87f90b97 100644--- a/frontend/src/types/appProfile.ts+++ b/frontend/src/types/appProfile.ts@@ -29,12 +29,16 @@ export type AppFeatures = {"bb.feature.databases.hide-inalterable": boolean;"bb.feature.sql-editor.disable-setting": boolean;"bb.feature.sql-editor.disallow-share-worksheet": boolean;+ "bb.feature.sql-editor.disallow-batch-query": boolean;"bb.feature.sql-editor.disallow-export-query-data": boolean;"bb.feature.sql-editor.disallow-request-query": boolean;"bb.feature.sql-editor.disallow-sync-schema": boolean;"bb.feature.sql-editor.hide-bytebase-logo": boolean;"bb.feature.sql-editor.hide-profile": boolean;"bb.feature.sql-editor.hide-readonly-datasource-hint": boolean;+ "bb.feature.sql-editor.hide-projects": boolean;+ "bb.feature.sql-editor.hide-environments": boolean;+ "bb.feature.sql-editor.hide-advance-instance-features": boolean;};export type AppProfile = {@@ -74,11 +78,15 @@ export const defaultAppProfile = (): AppProfile => ({"bb.feature.databases.hide-inalterable": false,"bb.feature.sql-editor.disable-setting": false,"bb.feature.sql-editor.disallow-share-worksheet": false,+ "bb.feature.sql-editor.disallow-batch-query": false,"bb.feature.sql-editor.disallow-export-query-data": false,"bb.feature.sql-editor.disallow-request-query": false,"bb.feature.sql-editor.disallow-sync-schema": false,"bb.feature.sql-editor.hide-bytebase-logo": false,"bb.feature.sql-editor.hide-profile": false,"bb.feature.sql-editor.hide-readonly-datasource-hint": false,+ "bb.feature.sql-editor.hide-projects": false,+ "bb.feature.sql-editor.hide-environments": false,+ "bb.feature.sql-editor.hide-advance-instance-features": false,},});diff --git a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vueindex 9d2908c8a1..29d7db5dec 100644--- a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue@@ -5,7 +5,7 @@:data-width="containerWidth"><div- v-if="!strictProject"+ v-if="!strictProject && !hideProjects"class="flex flex-row items-center gap-x-1 px-1 py-1 border-b"><ProjectSelect@@ -45,7 +45,11 @@ import { useElementSize } from "@vueuse/core";import { storeToRefs } from "pinia";import { computed, ref, watch } from "vue";import { ProjectSelect } from "@/components/v2";-import { useSQLEditorTreeStore, useSQLEditorStore } from "@/store";+import {+ useSQLEditorTreeStore,+ useSQLEditorStore,+ useAppFeature,+} from "@/store";import { isValidProjectName } from "@/types";import { useSQLEditorContext } from "../context";import GutterBar from "./GutterBar";@@ -60,6 +64,7 @@ const { project, projectContextReady, strictProject } =storeToRefs(editorStore);const containerRef = ref<HTMLDivElement>();const { width: containerWidth } = useElementSize(containerRef);+const hideProjects = useAppFeature("bb.feature.sql-editor.hide-projects");const projectName = computed(() => {return editorStore.currentProject?.name ?? null;diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vueindex 77b300f0c0..b96d9e427d 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue@@ -4,7 +4,10 @@<SearchBox v-model:searchPattern="searchPattern" class="flex-1" /><GroupingBar class="shrink-0" /></div>- <div class="flex items-center space-x-2 px-2 py-2">+ <div+ v-if="hasMissingQueryDatabases"+ class="flex items-center space-x-2 px-2 py-2"+ ><NCheckbox v-model:checked="showMissingQueryDatabases"><span class="textinfolabel text-sm">{{ $t("sql-editor.show-databases-without-query-permission") }}@@ -105,7 +108,8 @@ const databaseStore = useDatabaseV1Store();const isLoggedIn = useIsLoggedIn();const me = useCurrentUserV1();-const { events: editorEvents, showConnectionPanel } = useSQLEditorContext();+const editorContext = useSQLEditorContext();+const { events: editorEvents, showConnectionPanel } = editorContext;const searchHistory = useSearchHistory();const {state: hoverState,@@ -152,7 +156,8 @@ const selectedKeys = computed(() => {}return [];});-const { expandedKeys, showMissingQueryDatabases } = storeToRefs(treeStore);+const { expandedKeys, hasMissingQueryDatabases, showMissingQueryDatabases } =+ storeToRefs(treeStore);const upsertExpandedKeys = (key: string) => {if (expandedKeys.value.includes(key)) {return;@@ -227,8 +232,11 @@ const nodeProps = ({ option }: { option: TreeOption }) => {if (type === "database") {if (canQueryDatabase(node.meta.target as ComposedDatabase)) {setConnection(node, {- worksheet: tabStore.currentTab?.worksheet ?? "",- mode: DEFAULT_SQL_EDITOR_TAB_MODE,+ extra: {+ worksheet: tabStore.currentTab?.worksheet ?? "",+ mode: DEFAULT_SQL_EDITOR_TAB_MODE,+ },+ context: editorContext,});showConnectionPanel.value = false;}diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/GroupingBar.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/GroupingBar.vueindex cf76ad924f..9b477ad508 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/GroupingBar.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/GroupingBar.vue@@ -1,5 +1,6 @@<template><NPopover+ v-if="show"raw:show-arrow="false"to="body"@@ -40,7 +41,10 @@ defineOptions({});const treeStore = useSQLEditorTreeStore();-const { factorList } = storeToRefs(treeStore);+const { factorList, availableFactorList } = storeToRefs(treeStore);+const show = computed(() => {+ return availableFactorList.value.all.length > 1;+});const viewMode = computed((): "PRESET" | "CUSTOM" => {if (factorList.value.length === 0) {diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vueindex 435a4f74c3..185fea11ef 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue@@ -31,7 +31,7 @@ import { useI18n } from "vue-i18n";import { EnvironmentV1Name, InstanceV1EngineIcon } from "@/components/v2";import { useDatabaseV1Store } from "@/store";import type { CoreSQLEditorTab } from "@/types";-import { DEFAULT_SQL_EDITOR_TAB_MODE } from "@/types";+import { DEFAULT_SQL_EDITOR_TAB_MODE, isValidDatabaseName } from "@/types";import {emptySQLEditorConnection,tryConnectToCoreSQLEditorTab,@@ -75,6 +75,7 @@ const autoCompleteOptions = computed(() => {const database = databaseStore.getDatabaseByName(databaseName);return (database &&+ isValidDatabaseName(database.name) &&database.name.toLowerCase().includes((props.searchPattern || "").toLowerCase())@@ -147,12 +148,13 @@ const handleEscapeKey = (e: KeyboardEvent) => {watchEffect(async () => {for (const databaseName of searchHistory.value) {- const database = await databaseStore.getOrFetchDatabaseByName(- databaseName,- true /* silent */- );- if (!database) {- continue;+ try {+ await databaseStore.getOrFetchDatabaseByName(+ databaseName,+ true /* silent */+ );+ } catch {+ // nothing}}});diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsxindex 7e4d77a7a0..efc943fc4e 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx@@ -29,7 +29,7 @@ import {instanceV1HasReadonlyMode,tryConnectToCoreSQLEditorTab,} from "@/utils";-import { useSQLEditorContext } from "../../context";+import { useSQLEditorContext, type SQLEditorContext } from "../../context";type DropdownOptionWithTreeNode = DropdownOption & {onSelect: () => void;@@ -37,7 +37,8 @@ type DropdownOptionWithTreeNode = DropdownOption & {export const useDropdown = () => {const router = useRouter();- const { events: editorEvents, showConnectionPanel } = useSQLEditorContext();+ const editorContext = useSQLEditorContext();+ const { events: editorEvents, showConnectionPanel } = editorContext;const disallowNavigateAwaySQLEditor = useAppFeature("bb.feature.disallow-navigate-to-console");@@ -79,7 +80,9 @@ export const useDropdown = () => {label: t("sql-editor.connect"),icon: () => <LinkIcon class="w-4 h-4" />,onSelect: () => {- setConnection(node);+ setConnection(node, {+ context: editorContext,+ });showConnectionPanel.value = false;},});@@ -88,11 +91,11 @@ export const useDropdown = () => {label: t("sql-editor.connect-in-new-tab"),icon: () => <LinkIcon class="w-4 h-4" />,onSelect: () => {- setConnection(- node,- { worksheet: "", mode: DEFAULT_SQL_EDITOR_TAB_MODE },- /* newTab */ true- );+ setConnection(node, {+ extra: { worksheet: "", mode: DEFAULT_SQL_EDITOR_TAB_MODE },+ newTab: true,+ context: editorContext,+ });showConnectionPanel.value = false;},});@@ -103,7 +106,10 @@ export const useDropdown = () => {label: t("sql-editor.connect-in-admin-mode"),icon: () => <WrenchIcon class="w-4 h-4" />,onSelect: () => {- setConnection(node, { worksheet: "", mode: "ADMIN" });+ setConnection(node, {+ extra: { worksheet: "", mode: "ADMIN" },+ context: editorContext,+ });showConnectionPanel.value = false;},});@@ -169,11 +175,11 @@ export const useDropdown = () => {export const setConnection = (node: TreeNode<"database">,- extra: { worksheet: string; mode: TabMode } = {- worksheet: "",- mode: DEFAULT_SQL_EDITOR_TAB_MODE,- },- newTab = false+ options: {+ extra?: { worksheet: string; mode: TabMode };+ newTab?: boolean;+ context?: SQLEditorContext;+ } = {}) => {if (!node) {return;@@ -182,6 +188,14 @@ export const setConnection = (// one more guardreturn;}+ const {+ extra = {+ worksheet: "",+ mode: DEFAULT_SQL_EDITOR_TAB_MODE,+ },+ newTab = false,+ context,+ } = options;const coreTab: CoreSQLEditorTab = {connection: emptySQLEditorConnection(),...extra,@@ -191,4 +205,8 @@ export const setConnection = (conn.instance = database.instance;conn.database = database.name;tryConnectToCoreSQLEditorTab(coreTab, /* overrideTitle */ true, newTab);++ if (context) {+ context.asidePanelTab.value = "SCHEMA";+ }};diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vueindex 497d772733..03d17be218 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue@@ -7,11 +7,33 @@@update:show="$emit('update:show', $event)"><DrawerContent- :title="$t('common.connection')":style="{width: contentWidth,}"+ class="connection-panel-content">+ <template #header>+ <span>{{ $t("common.connection") }}</span>+ <NTooltip v-if="allowManageInstance" placement="bottom">+ <template #trigger>+ <NButton+ quaternary+ size="tiny"+ style="--n-padding: 0 4px"+ @click="+ $router.push({ name: SQL_EDITOR_SETTING_INSTANCE_MODULE })+ "+ >+ <template #icon>+ <SettingsIcon class="w-4 h-4" />+ </template>+ </NButton>+ </template>+ <template #default>+ {{ $t("sql-editor.manage-connections") }}+ </template>+ </NTooltip>+ </template><ConnectionPane /></DrawerContent></Drawer>@@ -19,8 +41,12 @@<script setup lang="ts">import { useWindowSize } from "@vueuse/core";+import { SettingsIcon } from "lucide-vue-next";+import { NButton, NTooltip } from "naive-ui";import { computed } from "vue";import { Drawer, DrawerContent } from "@/components/v2";+import { SQL_EDITOR_SETTING_INSTANCE_MODULE } from "@/router/sqlEditor";+import { useSidebarItems as useSettingItems } from "../Setting/Sidebar";import ConnectionPane from "./ConnectionPane";defineProps<{@@ -32,10 +58,25 @@ defineEmits<{}>();const { width: winWidth } = useWindowSize();+const { itemList: settingItemList } = useSettingItems();const contentWidth = computed(() => {if (winWidth.value >= 640) {return "480px";}return "calc(100vw - 2rem)";});++const allowManageInstance = computed(() => {+ return (+ settingItemList.value.findIndex(+ (item) => item.name === SQL_EDITOR_SETTING_INSTANCE_MODULE+ ) >= 0+ );+});</script>++<style scoped lang="postcss">+.connection-panel-content :deep(.n-drawer-header__main) {+ @apply flex-1 flex items-center justify-between;+}+</style>diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vueindex d9c63fc0f2..13e5da2c66 100644--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue@@ -23,7 +23,10 @@@click="changeConnection"><div class="flex flex-row gap-x-2 text-main">- <NPopover :disabled="!isProductionEnvironment">+ <NPopover+ v-if="!hideEnvironments"+ :disabled="!isProductionEnvironment"+ ><template #trigger><div class="inline-flex items-center text-sm rounded-sm bg-white"><span@@ -117,6 +120,12 @@ const { projectContextReady } = storeToRefs(useSQLEditorStore());const hideReadonlyDatasourceHint = useAppFeature("bb.feature.sql-editor.hide-readonly-datasource-hint");+const hideEnvironments = useAppFeature(+ "bb.feature.sql-editor.hide-environments"+);+const disallowBatchQuery = useAppFeature(+ "bb.feature.sql-editor.disallow-batch-query"+);const { instance, database, environment } =useConnectionOfCurrentSQLEditorTab();@@ -133,6 +142,10 @@ const isProductionEnvironment = computed(() => {});const showBatchQuerySelector = computed(() => {+ if (disallowBatchQuery.value) {+ return false;+ }+const tab = currentTab.value;return (tab &&diff --git a/frontend/src/views/sql-editor/Setting/Instance/Instance.vue b/frontend/src/views/sql-editor/Setting/Instance/Instance.vueindex 3c68a9a0cf..da0d3666c0 100644--- a/frontend/src/views/sql-editor/Setting/Instance/Instance.vue+++ b/frontend/src/views/sql-editor/Setting/Instance/Instance.vue@@ -37,6 +37,7 @@><InstanceForm:instance="state.detail.instance"+ :hide-advanced-features="hideAdvancedFeatures"@dismiss="state.detail.show = false"><DrawerContent@@ -78,6 +79,7 @@ import {useEnvironmentV1List,useInstanceV1List,useInstanceV1Store,+ useAppFeature,} from "@/store";import { UNKNOWN_ID } from "@/types";import type { Instance } from "@/types/proto/v1/instance_service";@@ -108,6 +110,9 @@ const { instanceList: rawInstanceV1List, ready } = useInstanceV1List(/* showDeleted */ false,/* forceUpdate */ true);+const hideAdvancedFeatures = useAppFeature(+ "bb.feature.sql-editor.hide-advance-instance-features"+);const state = reactive<LocalState>({params: {diff --git a/frontend/src/views/sql-editor/Setting/Sidebar/Sidebar.vue b/frontend/src/views/sql-editor/Setting/Sidebar/Sidebar.vueindex 03828c4252..82c0814224 100644--- a/frontend/src/views/sql-editor/Setting/Sidebar/Sidebar.vue+++ b/frontend/src/views/sql-editor/Setting/Sidebar/Sidebar.vue@@ -17,7 +17,7 @@</nav><router-link- class="flex-shrink-0 flex gap-x-2 justify-start items-center border-t border-block-border px-3 py-1.5 hover:bg-control-bg-hover cursor-pointer"+ class="flex-shrink-0 flex gap-x-2 justify-start items-center border-t border-block-border px-3 py-2 hover:bg-control-bg-hover cursor-pointer text-sm":to="{ name: SQL_EDITOR_HOME_MODULE }"><ChevronLeftIcon class="w-5 h-5" />diff --git a/frontend/src/views/sql-editor/Setting/Sidebar/common.ts b/frontend/src/views/sql-editor/Setting/Sidebar/common.tsindex 05f535c41d..22e264e19a 100644--- a/frontend/src/views/sql-editor/Setting/Sidebar/common.ts+++ b/frontend/src/views/sql-editor/Setting/Sidebar/common.ts@@ -1,18 +1,11 @@-import {- BuildingIcon,- GalleryHorizontalEndIcon,- LayersIcon,- SquareStackIcon,-} from "lucide-vue-next";+import { BuildingIcon, LayersIcon } from "lucide-vue-next";import { computed, h } from "vue";import { useI18n } from "vue-i18n";import { useRoute, type RouteRecordRaw } from "vue-router";import type { SidebarItem } from "@/components/CommonSidebar.vue";import sqlEditorRoutes, {SQL_EDITOR_SETTING_GENERAL_MODULE,- SQL_EDITOR_SETTING_ENVIRONMENT_MODULE,SQL_EDITOR_SETTING_INSTANCE_MODULE,- SQL_EDITOR_SETTING_PROJECT_MODULE,} from "@/router/sqlEditor";import { useCurrentUserV1, useAppFeature } from "@/store";import type { WorkspacePermission } from "@/types";@@ -113,18 +106,6 @@ export const useSidebarItems = () => {name: SQL_EDITOR_SETTING_INSTANCE_MODULE,type: "route",},- {- title: t("common.projects"),- icon: () => h(GalleryHorizontalEndIcon),- name: SQL_EDITOR_SETTING_PROJECT_MODULE,- type: "route",- },- {- title: t("common.environments"),- icon: () => h(SquareStackIcon),- name: SQL_EDITOR_SETTING_ENVIRONMENT_MODULE,- type: "route",- },];return filterSidebarByPermissions(sidebarList);