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: optimize tab (#17029)
ecmadao134ba34de369
diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vueindex b7888335a7..28f91e2ea2 100644--- a/frontend/src/components/ProvideSQLEditorContext.vue+++ b/frontend/src/components/ProvideSQLEditorContext.vue@@ -156,7 +156,6 @@ const handleProjectSwitched = async () => {if (project) {await projectStore.getOrFetchProjectByName(project, true /* silent */);}- tabStore.maybeInitProject(project);};const connect = (connection: SQLEditorConnection) => {diff --git a/frontend/src/store/modules/sqlEditor/tab.ts b/frontend/src/store/modules/sqlEditor/tab.tsindex f3480281b8..d0b86c3ebe 100644--- a/frontend/src/store/modules/sqlEditor/tab.ts+++ b/frontend/src/store/modules/sqlEditor/tab.ts@@ -201,10 +201,15 @@ export const useSQLEditorTabStore = defineStore("sqlEditorTab", () => {return tabById(currId);});+ const supportBatchMode = computed(() => currentTab.value?.mode !== "ADMIN");+const isInBatchMode = computed(() => {if (!currentTab.value) {return false;}+ if (!supportBatchMode.value) {+ return false;+ }if (!hasFeature(PlanFeature.FEATURE_BATCH_QUERY)) {return false;}@@ -481,6 +486,7 @@ export const useSQLEditorTabStore = defineStore("sqlEditorTab", () => {isDisconnected,isSwitchingTab,isInBatchMode,+ supportBatchMode,};});diff --git a/frontend/src/types/dataSource.ts b/frontend/src/types/dataSource.tsindex 7c97041751..7f538d80ab 100644--- a/frontend/src/types/dataSource.ts+++ b/frontend/src/types/dataSource.ts@@ -1,6 +1,3 @@-// which from the ops perspective, having different meaning from the normal RW data source.-export type DataSourceType = "ADMIN" | "RW" | "RO";-// DataSourceOptions is the options for a data source.export interface DataSourceOptions {srv: boolean;diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vueindex f8b0df64fd..2d3fdcc16d 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue@@ -1,6 +1,6 @@<template><div class="sql-editor-tree gap-y-1 h-full flex flex-col relative">- <div class="w-full px-4 mt-4">+ <div class="w-full px-4 mt-4" v-if="tabStore.supportBatchMode"><divclass="textinfolabel mb-2 w-full leading-4 flex flex-col items-start gap-x-1">diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vueindex 9bbedcd9db..51cc8aa582 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue@@ -1,15 +1,17 @@<template><div class="flex items-center max-w-full overflow-hidden gap-x-1">- <LinkIcon- v-if="tabStore.currentTab?.connection.database === database.name"- class="w-4 textinfolabel"- />- <NCheckbox- v-else-if="canQuery"- :checked="checked"- @click.stop.prevent=""- @update:checked="$emit('update:checked', $event)"- />+ <template v-if="tabStore.supportBatchMode">+ <LinkIcon+ v-if="tabStore.currentTab?.connection.database === database.name"+ class="w-4 textinfolabel"+ />+ <NCheckbox+ v-else-if="canQuery"+ :checked="checked"+ @click.stop.prevent=""+ @update:checked="$emit('update:checked', $event)"+ />+ </template><RichDatabaseName:database="database"diff --git a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vueindex 1107afa25c..b4753e0f67 100644--- a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue+++ b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue@@ -187,7 +187,6 @@ defineOptions({const emit = defineEmits<{(e: "execute", params: SQLEditorQueryParams): void;- (e: "clear-screen"): void;}>();const state = reactive<LocalState>({});@@ -270,6 +269,9 @@ const allowSave = computed(() => {if (tab.status === "NEW" || tab.status === "CLEAN") {return false;}+ if (!tab.connection.database) {+ return false;+ }return true;});diff --git a/frontend/src/views/sql-editor/EditorCommon/SaveSheetModal.vue b/frontend/src/views/sql-editor/EditorCommon/SaveSheetModal.vueindex a8eaa93def..d2feba7f34 100644--- a/frontend/src/views/sql-editor/EditorCommon/SaveSheetModal.vue+++ b/frontend/src/views/sql-editor/EditorCommon/SaveSheetModal.vue@@ -63,7 +63,7 @@ const doSaveSheet = async (const sheetId = Number(extractWorksheetUID(worksheet ?? ""));if (sheetId !== UNKNOWN_ID) {- const currentSheet = await worksheetV1Store.getWorksheetByName(worksheet);+ const currentSheet = worksheetV1Store.getWorksheetByName(worksheet);if (!currentSheet) return;const updatedSheet = await worksheetV1Store.patchWorksheet(@@ -130,6 +130,9 @@ const trySaveSheet = (editTitle?: boolean,mask?: Array<keyof Worksheet>) => {+ if (!tab.connection.database) {+ return;+ }if (needSheetTitle(tab) || editTitle) {state.pendingEdit = {tab,diff --git a/frontend/src/views/sql-editor/EditorPanel/ResultPanel/BatchQuerySelect.vue b/frontend/src/views/sql-editor/EditorPanel/ResultPanel/BatchQuerySelect.vueindex 9e77a98b42..80cb909771 100644--- a/frontend/src/views/sql-editor/EditorPanel/ResultPanel/BatchQuerySelect.vue+++ b/frontend/src/views/sql-editor/EditorPanel/ResultPanel/BatchQuerySelect.vue@@ -102,7 +102,6 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";-import { useLocalStorage } from "@vueuse/core";import dayjs from "dayjs";import { head } from "lodash-es";import { EyeIcon, EyeOffIcon, CircleAlertIcon, XIcon } from "lucide-vue-next";@@ -148,10 +147,7 @@ const tabStore = useSQLEditorTabStore();const { currentTab: tab } = storeToRefs(tabStore);const databaseStore = useDatabaseV1Store();const sqlStore = useSQLStore();-const showEmpty = useLocalStorage(- "bb.sql-editor.batch-query.show-empty-result-sets",- true-);+const showEmpty = ref<boolean>(true);const selectedDatabaseNameList = ref<string[]>([]);diff --git a/frontend/src/views/sql-editor/EditorPanel/StandardPanel/StandardPanel.vue b/frontend/src/views/sql-editor/EditorPanel/StandardPanel/StandardPanel.vueindex 4625ac5d28..5b9df49549 100644--- a/frontend/src/views/sql-editor/EditorPanel/StandardPanel/StandardPanel.vue+++ b/frontend/src/views/sql-editor/EditorPanel/StandardPanel/StandardPanel.vue@@ -61,7 +61,8 @@<Panev-if="!isDisconnected && allowReadonlyMode"class="relative"- :size="40"+ :size="50"+ :min-size="20"><ResultPanel /></Pane>diff --git a/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue b/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vueindex 9e219189fb..bd16421e3d 100644--- a/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue+++ b/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue@@ -2,7 +2,7 @@<divclass="flex h-full w-full flex-col justify-start items-stretch overflow-hidden bg-dark-bg">- <EditorAction @execute="handleExecute" @clear-screen="handleClearScreen" />+ <EditorAction /><divv-if="!tabStore.isDisconnected"diff --git a/frontend/src/views/sql-editor/EditorPanel/Welcome/Welcome.vue b/frontend/src/views/sql-editor/EditorPanel/Welcome/Welcome.vueindex 84971e3c6f..d708d80c54 100644--- a/frontend/src/views/sql-editor/EditorPanel/Welcome/Welcome.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Welcome/Welcome.vue@@ -71,7 +71,7 @@<script setup lang="ts">import { LayersIcon, LinkIcon, SquarePenIcon } from "lucide-vue-next";import { NButton } from "naive-ui";-import { computed } from "vue";+import { computed, nextTick } from "vue";import { useRouter } from "vue-router";import BytebaseLogo from "@/components/BytebaseLogo.vue";import { SQL_EDITOR_SETTING_INSTANCE_MODULE } from "@/router/sqlEditor";@@ -99,6 +99,7 @@ const changeConnection = () => {const createNewWorksheet = () => {useSQLEditorTabStore().addTab();+ nextTick(() => changeConnection());};const gotoInstanceCreatePage = () => {diff --git a/frontend/src/views/sql-editor/TabList/TabList.vue b/frontend/src/views/sql-editor/TabList/TabList.vueindex 554942aed8..97cfa9988c 100644--- a/frontend/src/views/sql-editor/TabList/TabList.vue+++ b/frontend/src/views/sql-editor/TabList/TabList.vue@@ -66,7 +66,6 @@<script lang="ts" setup>import { useResizeObserver } from "@vueuse/core";-import { cloneDeep } from "lodash-es";import { PlusIcon } from "lucide-vue-next";import { NScrollbar, useDialog } from "naive-ui";import { storeToRefs } from "pinia";@@ -83,14 +82,10 @@ import {useTabViewStateStore,} from "@/store";import type { SQLEditorTab } from "@/types";-import {- defaultSQLEditorTab,- defer,- suggestedTabTitleForSQLEditorConnection,- usePreventBackAndForward,-} from "@/utils";+import { defer, usePreventBackAndForward } from "@/utils";import { SettingButton } from "../Setting";import { useSheetContext } from "../Sheet";+import { useSQLEditorContext } from "../context";import BrandingLogoWrapper from "./BrandingLogoWrapper.vue";import ContextMenu from "./ContextMenu.vue";import TabItem from "./TabItem";@@ -105,6 +100,7 @@ const tabStore = useSQLEditorTabStore();const { t } = useI18n();const dialog = useDialog();+const { showConnectionPanel } = useSQLEditorContext();const state = reactive<LocalState>({dragging: false,@@ -115,7 +111,7 @@ const { events: sheetEvents } = useSheetContext();const scrollbarRef = ref<InstanceType<typeof NScrollbar>>();const tabListRef = ref<InstanceType<typeof Draggable>>();const { strictProject } = storeToRefs(useSQLEditorStore());-const { cloneViewState, removeViewState } = useTabViewStateStore();+const { removeViewState } = useTabViewStateStore();const context = provideTabListContext();const contextMenuRef = ref<InstanceType<typeof ContextMenu>>();@@ -144,25 +140,10 @@ const handleSelectTab = async (tab: SQLEditorTab | undefined) => {};const handleAddTab = () => {- const fromTab = tabStore.currentTab;- const clonedTab = defaultSQLEditorTab();- if (fromTab) {- clonedTab.connection = cloneDeep(fromTab.connection);- clonedTab.treeState = cloneDeep(fromTab.treeState);- }- clonedTab.title = suggestedTabTitleForSQLEditorConnection(- clonedTab.connection- );- const newTab = tabStore.addTab(clonedTab);- if (fromTab) {- const vs = cloneViewState(fromTab.id, newTab.id);- if (vs) {- vs.view = "CODE";- vs.detail = {};- }- }+ tabStore.addTab();nextTick(() => {+ showConnectionPanel.value = true;requestAnimationFrame(() => {const elem = scrollElement.value;if (elem) {