Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(sql-editor): introducing new layout of SQL Editor (#7904)
Liu Ji9f1cfb4ed5c1
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex ad41754967..3f73c46fe6 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -260,7 +260,8 @@"condition": "Condition","search-user": "Search user","branches": "Branches",- "merge": "Merge"+ "merge": "Merge",+ "info": "Info"},"error-page": {"go-back-home": "Go back home"@@ -2309,7 +2310,8 @@"from-issue-warning": "The sheet comes from issue {issue} in read-only mode. {oversize}","content-oversize-warning": "SQL is oversized and inline-editing is disallowed. ","sheets": "Sheets",- "search-sheets": "Search Sheets"+ "search-sheets": "Search Sheets",+ "sheet": "Sheet"},"engine": {"mysql": "MySQL",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 6780c5bb76..15dcb08a24 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -260,7 +260,8 @@"condition": "Condición","search-user": "Buscar usuario","branches": "Ramas",- "merge": "Combinar"+ "merge": "Combinar",+ "info": "Información"},"error-page": {"go-back-home": "Volver al inicio"@@ -2305,7 +2306,8 @@"duplicate-success": "Duplicado con éxito en \"Mis hojas\""},"sheets": "Hojas",- "search-sheets": "Hojas de búsqueda"+ "search-sheets": "Hojas de búsqueda",+ "sheet": "Hoja"},"engine": {"mysql": "MySQL",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 0b7fc7c3ac..37edb6a679 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -258,7 +258,8 @@"condition": "条件","search-user": "搜索用户","branches": "分支",- "merge": "合并"+ "merge": "合并",+ "info": "信息"},"error-page": {"go-back-home": "回到主页"@@ -2305,7 +2306,8 @@"from-issue-warning": "这个工作表来自工单 {issue},处于只读模式。{oversize}","content-oversize-warning": "SQL 过大所以无法直接编辑。","sheets": "工作表",- "search-sheets": "搜索工作表"+ "search-sheets": "搜索工作表",+ "sheet": "工作表"},"engine": {"mysql": "MySQL",diff --git a/frontend/src/store/modules/tab.ts b/frontend/src/store/modules/tab.tsindex 99322179fa..f564540208 100644--- a/frontend/src/store/modules/tab.ts+++ b/frontend/src/store/modules/tab.ts@@ -1,7 +1,7 @@import { watchThrottled } from "@vueuse/core";import { pick } from "lodash-es";import { defineStore } from "pinia";-import { computed, nextTick, reactive, ref, toRef, watch } from "vue";+import { computed, reactive, ref, toRef, watch } from "vue";import { TabInfo, CoreTabInfo, AnyTabInfo, TabMode } from "@/types";import {getDefaultTab,@@ -45,7 +45,6 @@ export const useTabStore = defineStore("tab", () => {const tabs = ref(new Map<string, TabInfo>());const tabIdList = ref<string[]>([]);const currentTabId = ref<string>();- const asidePanelTab = ref<"databases" | "sheets">("databases");// gettersconst getTabById = (id: string) => {@@ -77,14 +76,6 @@ export const useTabStore = defineStore("tab", () => {currentTabId.value = id;tabs.value.set(id, newTab);- nextTick(() => {- if (!currentTab.value.sheetName && isDisconnectedTab(currentTab.value)) {- // Switch the tab to "database" after adding a new sheet- // because users need to select a database to continue editing- asidePanelTab.value = "databases";- }- });-watchTab(newTab, false);};const removeTab = (tab: TabInfo) => {@@ -261,7 +252,6 @@ export const useTabStore = defineStore("tab", () => {selectOrAddTempTab,selectOrAddSimilarTab,reset,- asidePanelTab,};});diff --git a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vueindex 11ba5a1438..de3e35366a 100644--- a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue@@ -1,82 +1,29 @@<template><div class="aside-panel h-full"><NTabs- v-model:value="tabStore.asidePanelTab"- class="h-full overflow-hidden"- pane-style="height: calc(100% - 33px); padding: 0 4px;"- :tabs-padding="8"+ v-model:value="databaseTab"+ type="segment"+ size="small"+ class="h-full"+ pane-style="height: calc(100% - 35px); padding: 0;">- <NTabPane name="databases" :tab="$t('common.databases')">- <NTabs- v-model:value="databaseTab"- type="segment"- size="small"- class="h-full"- pane-style="height: calc(100% - 35px); padding: 0;"- >- <NTabPane name="projects" :tab="$t('common.projects')">- <Splitpanes- horizontal- class="default-theme"- :dbl-click-splitter="false"- >- <Pane>- <DatabaseTree- key="sql-editor-database-tree"- v-model:search-pattern="searchPattern"- @alter-schema="$emit('alter-schema', $event)"- />- </Pane>- <Pane v-if="showSchemaPanel" :size="40">- <SchemaPanel @alter-schema="$emit('alter-schema', $event)" />- </Pane>- </Splitpanes>- </NTabPane>- <NTabPane- v-if="hasInstanceView"- name="instances"- :tab="$t('common.instances')"- >- <Splitpanes- horizontal- class="default-theme"- :dbl-click-splitter="false"- >- <Pane>- <DatabaseTree- key="sql-editor-database-tree"- v-model:search-pattern="searchPattern"- @alter-schema="$emit('alter-schema', $event)"- />- </Pane>- <Pane v-if="showSchemaPanel" :size="40">- <SchemaPanel @alter-schema="$emit('alter-schema', $event)" />- </Pane>- </Splitpanes>- </NTabPane>- <NTabPane name="history" :tab="$t('common.history')">- <QueryHistoryContainer />- </NTabPane>- </NTabs>+ <NTabPane name="projects" :tab="$t('common.projects')">+ <DatabaseTree+ key="sql-editor-database-tree"+ v-model:search-pattern="searchPattern"+ @alter-schema="$emit('alter-schema', $event)"+ /></NTabPane>- <NTabPane name="sheets" :tab="$t('sheet.sheets')">- <NTabs- v-model:value="sheetTab"- size="small"- type="segment"- class="h-full"- pane-style="height: calc(100% - 35px); padding: 0;"- >- <NTabPane name="my" :tab="$t('sheet.mine')">- <SheetList view="my" />- </NTabPane>- <NTabPane name="starred" :tab="$t('sheet.starred')">- <SheetList view="starred" />- </NTabPane>- <NTabPane name="shared" :tab="$t('sheet.shared-with-me')">- <SheetList view="shared" />- </NTabPane>- </NTabs>+ <NTabPane+ v-if="hasInstanceView"+ name="instances"+ :tab="$t('common.instances')"+ >+ <DatabaseTree+ key="sql-editor-database-tree"+ v-model:search-pattern="searchPattern"+ @alter-schema="$emit('alter-schema', $event)"+ /></NTabPane></NTabs></div>@@ -84,23 +31,11 @@<script lang="ts" setup>import { NTabs, NTabPane } from "naive-ui";-import { Splitpanes, Pane } from "splitpanes";import { computed, ref, watchEffect } from "vue";-import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";-import {- useConnectionTreeStore,- useCurrentUserV1,- useInstanceV1Store,- useTabStore,-} from "@/store";-import { ConnectionTreeMode, UNKNOWN_ID } from "@/types";-import { Engine } from "@/types/proto/v1/common";+import { useConnectionTreeStore, useCurrentUserV1 } from "@/store";+import { ConnectionTreeMode } from "@/types";import { hasWorkspacePermissionV1 } from "@/utils";-import { useSheetContext } from "../Sheet";import DatabaseTree from "./DatabaseTree.vue";-import QueryHistoryContainer from "./QueryHistoryContainer.vue";-import SchemaPanel from "./SchemaPanel/";-import SheetList from "./SheetList";defineEmits<{(@@ -110,17 +45,14 @@ defineEmits<{}>();const currentUserV1 = useCurrentUserV1();-const tabStore = useTabStore();const connectionTreeStore = useConnectionTreeStore();const searchPattern = ref("");-const { events: sheetEvents } = useSheetContext();-const databaseTab = ref<"projects" | "instances" | "history">(+const databaseTab = ref<"projects" | "instances">(connectionTreeStore.tree.mode === ConnectionTreeMode.INSTANCE? "instances": "projects");-const sheetTab = ref<"my" | "shared" | "starred">("my");const hasInstanceView = computed((): boolean => {return hasWorkspacePermissionV1(@@ -129,18 +61,6 @@ const hasInstanceView = computed((): boolean => {);});-const showSchemaPanel = computed(() => {- const conn = tabStore.currentTab.connection;- if (conn.databaseId === String(UNKNOWN_ID)) {- return false;- }- const instance = useInstanceV1Store().getInstanceByUID(conn.instanceId);- if (instance.engine === Engine.REDIS) {- return false;- }- return true;-});-watchEffect(() => {if (databaseTab.value === "projects") {connectionTreeStore.tree.mode = ConnectionTreeMode.PROJECT;@@ -149,8 +69,4 @@ watchEffect(() => {connectionTreeStore.tree.mode = ConnectionTreeMode.INSTANCE;}});--useEmitteryEventListener(sheetEvents, "add-sheet", () => {- sheetTab.value = "my";-});</script>diff --git a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vueindex 2951462712..f511fbf539 100644--- a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue+++ b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue@@ -1,7 +1,7 @@<template><divv-if="connectionTreeStore.tree.state === ConnectionTreeState.LOADED"- class="databases-tree pt-2 px-0.5 gap-y-2 h-full flex flex-col"+ class="databases-tree p-0.5 gap-y-2 h-full flex flex-col":class="connectionTreeStore.tree.mode"><div class="databases-tree--input">diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vueindex cb14c149e0..b6e8958df5 100644--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue@@ -1,11 +1,8 @@<template><div class="flex items-center justify-center w-full h-full">- <div- class="flex items-center text-blue-600 cursor-pointer"- @click="tabStore.asidePanelTab = 'databases'"- >- <heroicons-outline:lightning-bolt class="mr-1" />- <div>+ <div class="flex items-start text-info">+ <heroicons-outline:lightning-bolt class="mr-1 w-5 h-5" />+ <div class="leading-5"><p>{{ $t("sql-editor.connection-holder") }}</p>@@ -13,9 +10,3 @@</div></div></template>--<script lang="ts" setup>-import { useTabStore } from "@/store";--const tabStore = useTabStore();-</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vueindex 69670f89c3..36d9a1fdff 100644--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue@@ -1,5 +1,7 @@<template>- <div class="w-full block lg:flex justify-between items-start bg-white">+ <div+ class="w-full flex flex-col sm:flex-row sm:flex-wrap xl:flex-nowrap lg:justify-between items-start bg-white"+ ><divv-if="!tabStore.isDisconnected"class="flex justify-start items-center h-8 px-4 whitespace-nowrap overflow-x-auto"@@ -61,7 +63,7 @@<divv-if="isProductionEnvironment"- class="flex justify-start items-center py-1 sm:py-0 sm:h-8 px-4 text-white bg-error"+ class="w-full xl:w-auto flex justify-start items-center py-1 sm:py-0 sm:h-8 px-4 text-white bg-error truncate">{{ $t("sql-editor.sql-execute-in-production-environment") }}</div>diff --git a/frontend/src/views/sql-editor/SQLEditorPage.vue b/frontend/src/views/sql-editor/SQLEditorPage.vueindex a22d312d9a..0ca388bfd7 100644--- a/frontend/src/views/sql-editor/SQLEditorPage.vue+++ b/frontend/src/views/sql-editor/SQLEditorPage.vue@@ -1,7 +1,10 @@<template><div class="sqleditor--wrapper"><TabList />- <Splitpanes class="default-theme flex flex-col flex-1 overflow-hidden">+ <Splitpanes+ class="default-theme flex flex-col flex-1 overflow-hidden"+ :dbl-click-splitter="false"+ ><Pane v-if="windowWidth >= 800" size="20"><AsidePanel @alter-schema="handleAlterSchema" /></Pane>@@ -42,9 +45,24 @@v-if="allowReadOnlyMode"horizontalclass="default-theme"+ :dbl-click-splitter="false"><Pane>- <EditorPanel />+ <Splitpanes+ vertical+ class="default-theme"+ :dbl-click-splitter="false"+ >+ <Pane>+ <EditorPanel />+ </Pane>+ <Pane+ v-if="showSecondarySidebar && windowWidth >= 1024"+ :size="25"+ >+ <SecondarySidebar @alter-schema="handleAlterSchema" />+ </Pane>+ </Splitpanes></Pane><Pane v-if="!isDisconnected" :size="40"><ResultPanel />@@ -136,6 +154,10 @@ import AsidePanel from "./AsidePanel/AsidePanel.vue";import AdminModeButton from "./EditorCommon/AdminModeButton.vue";import EditorPanel from "./EditorPanel/EditorPanel.vue";import ResultPanel from "./ResultPanel";+import {+ provideSecondarySidebarContext,+ default as SecondarySidebar,+} from "./SecondarySidebar";import { provideSheetContext } from "./Sheet";import SheetPanel from "./SheetPanel";import TabList from "./TabList";@@ -160,6 +182,7 @@ const sqlEditorStore = useSQLEditorStore();const currentUserV1 = useCurrentUserV1();// provide context for sheetsconst { showPanel: showSheetPanel } = provideSheetContext();+const { show: showSecondarySidebar } = provideSecondarySidebarContext();const isDisconnected = computed(() => tabStore.isDisconnected);const isFetchingSheet = computed(() => sqlEditorStore.isFetchingSheet);diff --git a/frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vue b/frontend/src/views/sql-editor/SecondarySidebar/HistoryTabPane/HistoryTabPane.vuesimilarity index 98%rename from frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vuerename to frontend/src/views/sql-editor/SecondarySidebar/HistoryTabPane/HistoryTabPane.vueindex 519ab74fdf..a9626e6c1e 100644--- a/frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vue+++ b/frontend/src/views/sql-editor/SecondarySidebar/HistoryTabPane/HistoryTabPane.vue@@ -1,7 +1,7 @@<!-- eslint-disable vue/no-v-html --><template><div- class="relative py-2 px-0.5 w-full h-full flex flex-col justify-start items-start"+ class="relative p-0.5 w-full h-full flex flex-col justify-start items-start"><div class="w-full"><NInputdiff --git a/frontend/src/views/sql-editor/SecondarySidebar/HistoryTabPane/index.ts b/frontend/src/views/sql-editor/SecondarySidebar/HistoryTabPane/index.tsnew file mode 100644index 0000000000..af1dd2a122--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/HistoryTabPane/index.ts@@ -0,0 +1,3 @@+import HistoryTabPane from "./HistoryTabPane.vue";++export default HistoryTabPane;diff --git a/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/InfoTabPane.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/InfoTabPane.vuenew file mode 100644index 0000000000..4879f01cb8--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/InfoTabPane.vue@@ -0,0 +1,14 @@+<template>+ <SchemaPanel @alter-schema="$emit('alter-schema', $event)" />+</template>++<script setup lang="ts">+import SchemaPanel from "./SchemaPanel";++defineEmits<{+ (+ event: "alter-schema",+ params: { databaseId: string; schema: string; table: string }+ ): void;+}>();+</script>diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/AlterSchemaButton.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/AlterSchemaButton.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/AlterSchemaButton.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/AlterSchemaButton.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/ColumnList.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/ColumnList.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/ColumnList.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/ColumnList.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/DatabaseSchema.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/DatabaseSchema.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/DatabaseSchema.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/DatabaseSchema.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/ExternalLinkButton.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/ExternalLinkButton.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/ExternalLinkButton.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/ExternalLinkButton.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/SchemaDiagramButton.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/SchemaDiagramButton.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/SchemaDiagramButton.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/SchemaDiagramButton.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/SchemaPanel.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/SchemaPanel.vuesimilarity index 95%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/SchemaPanel.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/SchemaPanel.vueindex 0a0f3b26e1..8698ed7faa 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/SchemaPanel.vue+++ b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/SchemaPanel.vue@@ -36,7 +36,6 @@import { storeToRefs } from "pinia";import { computed, reactive, ref, watch } from "vue";import { useDatabaseV1ByUID, useDBSchemaV1Store, useTabStore } from "@/store";-import { DatabaseId } from "@/types";import {DatabaseMetadata,SchemaMetadata,@@ -52,7 +51,7 @@ type LocalState = {const emit = defineEmits<{(event: "alter-schema",- params: { databaseId: DatabaseId; schema: string; table: string }+ params: { databaseId: string; schema: string; table: string }): void;}>();diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableList.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/TableList.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableList.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/TableList.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableSchema.vue b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/TableSchema.vuesimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableSchema.vuerename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/TableSchema.vuediff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/index.ts b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/index.tssimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SchemaPanel/index.tsrename to frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/SchemaPanel/index.tsdiff --git a/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/index.ts b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/index.tsnew file mode 100644index 0000000000..7ad7e5e4d9--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/InfoTabPane/index.ts@@ -0,0 +1,3 @@+import InfoTabPane from "./InfoTabPane.vue";++export default InfoTabPane;diff --git a/frontend/src/views/sql-editor/SecondarySidebar/SecondarySidebar.vue b/frontend/src/views/sql-editor/SecondarySidebar/SecondarySidebar.vuenew file mode 100644index 0000000000..960b161dc2--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/SecondarySidebar.vue@@ -0,0 +1,84 @@+<template>+ <NTabs+ v-model:value="tab"+ type="segment"+ size="small"+ class="h-full"+ pane-style="height: calc(100% - 35px); padding: 0;"+ >+ <NTabPane v-if="showInfoPane" name="INFO" :tab="$t('common.info')">+ <InfoTabPane @alter-schema="$emit('alter-schema', $event)" />+ </NTabPane>+ <NTabPane name="SHEET" :tab="$t('sheet.sheet')">+ <SheetTabPane />+ </NTabPane>+ <NTabPane name="HISTORY" :tab="$t('common.history')">+ <HistoryTabPane />+ </NTabPane>+ </NTabs>+</template>++<script setup lang="ts">+import { NTabs, NTabPane } from "naive-ui";+import { computed, watch } from "vue";+import { useInstanceV1Store, useTabStore } from "@/store";+import { UNKNOWN_ID } from "@/types";+import { instanceV1HasAlterSchema, isDisconnectedTab } from "@/utils";+import HistoryTabPane from "./HistoryTabPane";+import InfoTabPane from "./InfoTabPane";+import SheetTabPane from "./SheetTabPane";+import { useSecondarySidebarContext } from "./context";++defineEmits<{+ (+ event: "alter-schema",+ params: { databaseId: string; schema: string; table: string }+ ): void;+}>();++const { tab } = useSecondarySidebarContext();++const tabStore = useTabStore();++const isDisconnected = computed(() => {+ return isDisconnectedTab(tabStore.currentTab);+});++const isSchemalessInstance = computed(() => {+ if (isDisconnected.value) {+ return false;+ }+ const { instanceId } = tabStore.currentTab.connection;++ if (instanceId === String(UNKNOWN_ID)) {+ return false;+ }++ const instance = useInstanceV1Store().getInstanceByUID(instanceId);++ return !instanceV1HasAlterSchema(instance);+});++const showInfoPane = computed(() => {+ if (isDisconnected.value) {+ return false;+ }++ const conn = tabStore.currentTab.connection;+ if (conn.databaseId === String(UNKNOWN_ID)) {+ return false;+ }++ return !isSchemalessInstance.value;+});++watch(+ showInfoPane,+ (show) => {+ if (!show && tab.value === "INFO") {+ tab.value = "SHEET";+ }+ },+ { immediate: true }+);+</script>diff --git a/frontend/src/views/sql-editor/AsidePanel/SheetList/SheetItem.vue b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/SheetItem.vuesimilarity index 95%rename from frontend/src/views/sql-editor/AsidePanel/SheetList/SheetItem.vuerename to frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/SheetItem.vueindex 236edcfb3e..004af892a8 100644--- a/frontend/src/views/sql-editor/AsidePanel/SheetList/SheetItem.vue+++ b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/SheetItem.vue@@ -1,7 +1,7 @@<template><div:id="domIDForItem(item)"- class="flex items-start justify-between hover:bg-gray-100 px-2 gap-x-1"+ class="flex items-start justify-between hover:bg-gray-100 px-1 gap-x-1":class="[isCurrentItem && 'bg-indigo-600/10']"@click="$emit('click', item, $event)"@contextmenu="$emit('contextmenu', item, $event)"@@ -38,9 +38,9 @@<script setup lang="ts">import { computed } from "vue";import { useTabStore } from "@/store";+import { SheetConnectionIcon } from "@/views/sql-editor/EditorCommon";import { Dropdown } from "@/views/sql-editor/Sheet";import { SheetViewMode } from "@/views/sql-editor/Sheet";-import { SheetConnectionIcon } from "../../EditorCommon";import { MergedItem, SheetItem, domIDForItem, titleHTML } from "./common";const props = defineProps<{diff --git a/frontend/src/views/sql-editor/AsidePanel/SheetList/SheetList.vue b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/SheetList.vuesimilarity index 95%rename from frontend/src/views/sql-editor/AsidePanel/SheetList/SheetList.vuerename to frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/SheetList.vueindex 2db53a5c55..e7cd89cefe 100644--- a/frontend/src/views/sql-editor/AsidePanel/SheetList/SheetList.vue+++ b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/SheetList.vue@@ -1,5 +1,5 @@<template>- <div class="flex flex-col h-full px-0.5 pt-2 gap-y-2">+ <div class="flex flex-col h-full py-1 gap-y-2"><div class="flex items-center gap-x-1"><NInputv-model:value="keyword"@@ -15,10 +15,10 @@<NButtonquaternarystyle="--n-padding: 0 5px; --n-height: 28px"- @click="handleAddSheet"+ @click="showPanel = true"><template #icon>- <heroicons:plus />+ <heroicons:arrow-left-on-rectangle /></template></NButton></div>@@ -86,7 +86,6 @@ import {openSheet,useSheetContextByView,Dropdown,- addNewSheet,useSheetContext,} from "@/views/sql-editor/Sheet";import SheetItem from "./SheetItem.vue";@@ -104,7 +103,7 @@ const props = defineProps<{}>();const tabStore = useTabStore();-const { events } = useSheetContext();+const { showPanel } = useSheetContext();const { isInitialized, isLoading, sheetList, fetchSheetList } =useSheetContextByView(props.view);const keyword = ref("");@@ -182,11 +181,6 @@ const handleItemClick = (item: MergedItem, e: MouseEvent) => {}};-const handleAddSheet = () => {- addNewSheet();- events.emit("add-sheet");-};-const handleRightClick = (item: MergedItem, e: MouseEvent) => {if (!isSheetItem(item)) return;e.preventDefault();diff --git a/frontend/src/views/sql-editor/AsidePanel/SheetList/TabItem.vue b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/TabItem.vuesimilarity index 93%rename from frontend/src/views/sql-editor/AsidePanel/SheetList/TabItem.vuerename to frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/TabItem.vueindex ec44597d61..0ea6bab668 100644--- a/frontend/src/views/sql-editor/AsidePanel/SheetList/TabItem.vue+++ b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/TabItem.vue@@ -1,7 +1,7 @@<template><div:id="domIDForItem(item)"- class="flex items-start justify-between hover:bg-gray-100 px-2 gap-x-1"+ class="flex items-start justify-between hover:bg-gray-100 px-1 gap-x-1":class="[isCurrentItem && 'bg-indigo-600/10']"@click="$emit('click', item, $event)">@@ -27,7 +27,7 @@<script setup lang="ts">import { NTooltip } from "naive-ui";-import { SheetConnectionIcon } from "../../EditorCommon";+import { SheetConnectionIcon } from "@/views/sql-editor/EditorCommon";import { MergedItem, TabItem, domIDForItem, titleHTML } from "./common";defineProps<{diff --git a/frontend/src/views/sql-editor/AsidePanel/SheetList/common.ts b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/common.tssimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SheetList/common.tsrename to frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/common.tsdiff --git a/frontend/src/views/sql-editor/AsidePanel/SheetList/index.ts b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/index.tssimilarity index 100%rename from frontend/src/views/sql-editor/AsidePanel/SheetList/index.tsrename to frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetList/index.tsdiff --git a/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetTabPane.vue b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetTabPane.vuenew file mode 100644index 0000000000..f7edd0638c--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/SheetTabPane.vue@@ -0,0 +1,35 @@+<template>+ <NTabs+ v-model:value="sheetTab"+ size="small"+ class="h-full pt-1 px-1"+ pane-style="height: calc(100% - 29px); padding: 0;"+ :tabs-padding="4"+ >+ <NTabPane name="my" :tab="$t('sheet.mine')">+ <SheetList view="my" />+ </NTabPane>+ <NTabPane name="starred" :tab="$t('sheet.starred')">+ <SheetList view="starred" />+ </NTabPane>+ <NTabPane name="shared" :tab="$t('sheet.shared-with-me')">+ <SheetList view="shared" />+ </NTabPane>+ </NTabs>+</template>++<script setup lang="ts">+import { NTabs, NTabPane } from "naive-ui";+import { ref } from "vue";+import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";+import { useSheetContext } from "../../Sheet";+import SheetList from "./SheetList";++const { events: sheetEvents } = useSheetContext();++const sheetTab = ref<"my" | "shared" | "starred">("my");++useEmitteryEventListener(sheetEvents, "add-sheet", () => {+ sheetTab.value = "my";+});+</script>diff --git a/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/index.ts b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/index.tsnew file mode 100644index 0000000000..55a7037ee0--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/SheetTabPane/index.ts@@ -0,0 +1,3 @@+import SheetTabPane from "./SheetTabPane.vue";++export default SheetTabPane;diff --git a/frontend/src/views/sql-editor/SecondarySidebar/ToggleSecondarySidebarButton.vue b/frontend/src/views/sql-editor/SecondarySidebar/ToggleSecondarySidebarButton.vuenew file mode 100644index 0000000000..575e2a2be0--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/ToggleSecondarySidebarButton.vue@@ -0,0 +1,20 @@+<template>+ <NButton+ size="small"+ style="--n-padding: 0 6px"+ :type="showSecondarySidebar ? 'info' : 'default'"+ ghost+ @click="showSecondarySidebar = !showSecondarySidebar"+ >+ <template #icon>+ <heroicons:view-columns />+ </template>+ </NButton>+</template>++<script setup lang="ts">+import { NButton } from "naive-ui";+import { useSecondarySidebarContext } from "./context";++const { show: showSecondarySidebar } = useSecondarySidebarContext();+</script>diff --git a/frontend/src/views/sql-editor/SecondarySidebar/context.ts b/frontend/src/views/sql-editor/SecondarySidebar/context.tsnew file mode 100644index 0000000000..21f9f560ff--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/context.ts@@ -0,0 +1,35 @@+import Emittery from "emittery";+import { InjectionKey, inject, provide, Ref, ref } from "vue";++type SecondarySidebarEvents = Emittery<{+ // nothing by now+}>;++export type TabView = "INFO" | "SHEET" | "HISTORY";++export type SecondarySidebarContext = {+ show: Ref<boolean>; // Whether to show the panel+ tab: Ref<TabView>;++ events: SecondarySidebarEvents;+};++export const KEY = Symbol(+ "bb.sql-editor.secondary-sidebar"+) as InjectionKey<SecondarySidebarContext>;++export const useSecondarySidebarContext = () => {+ return inject(KEY)!;+};++export const provideSecondarySidebarContext = () => {+ const context: SecondarySidebarContext = {+ show: ref(true),+ tab: ref("INFO"),+ events: new Emittery(),+ };++ provide(KEY, context);++ return context;+};diff --git a/frontend/src/views/sql-editor/SecondarySidebar/index.ts b/frontend/src/views/sql-editor/SecondarySidebar/index.tsnew file mode 100644index 0000000000..a569c0d9b8--- /dev/null+++ b/frontend/src/views/sql-editor/SecondarySidebar/index.ts@@ -0,0 +1,6 @@+import SecondarySidebar from "./SecondarySidebar.vue";+import ToggleSecondarySidebarButton from "./ToggleSecondarySidebarButton.vue";++export * from "./context";+export { ToggleSecondarySidebarButton };+export default SecondarySidebar;diff --git a/frontend/src/views/sql-editor/TabList/TabList.vue b/frontend/src/views/sql-editor/TabList/TabList.vueindex 73696d1667..1f2010063e 100644--- a/frontend/src/views/sql-editor/TabList/TabList.vue+++ b/frontend/src/views/sql-editor/TabList/TabList.vue@@ -42,10 +42,8 @@</button></div>- <div class="pb-1">- <NButton size="small" @click="showSheetPanel = true">- {{ $t("sql-editor.sheet.choose-sheet") }}- </NButton>+ <div class="pb-1 hidden lg:block">+ <ToggleSecondarySidebarButton /></div><ContextMenu ref="contextMenuRef" />@@ -54,7 +52,7 @@<script lang="ts" setup>import { useResizeObserver } from "@vueuse/core";-import { useDialog, NButton } from "naive-ui";+import { useDialog } from "naive-ui";import scrollIntoView from "scroll-into-view-if-needed";import { ref, reactive, nextTick, computed, onMounted, watch } from "vue";import { useI18n } from "vue-i18n";@@ -64,6 +62,7 @@ import { useTabStore } from "@/store";import type { TabInfo } from "@/types";import { TabMode } from "@/types";import { defer, getSuggestedTabNameFromConnection } from "@/utils";+import { ToggleSecondarySidebarButton } from "../SecondarySidebar";import { useSheetContext } from "../Sheet";import ContextMenu from "./ContextMenu.vue";import TabItem from "./TabItem";@@ -83,7 +82,7 @@ const state = reactive<LocalState>({dragging: false,hoverTabId: "",});-const { showPanel: showSheetPanel, events: sheetEvents } = useSheetContext();+const { events: sheetEvents } = useSheetContext();const tabListRef = ref<InstanceType<typeof Draggable>>();const context = provideTabListContext();const contextMenuRef = ref<InstanceType<typeof ContextMenu>>();