Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: get menu actions by connection (#15795)

ecmadaod64d23839bf0
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
index 4a2e9a91c7..c33f16260d 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
@@ -2,7 +2,6 @@ import { head, cloneDeep } from "lodash-es";
import {
CodeIcon,
CopyIcon,
- InfoIcon,
ExternalLinkIcon,
FileCodeIcon,
FileDiffIcon,
@@ -13,18 +12,10 @@ import {
SquarePenIcon,
} from "lucide-vue-next";
import {
- FunctionIcon,
TableIcon,
- ViewIcon,
- ProcedureIcon,
- ExternalTableIcon,
- PackageIcon,
- SequenceIcon,
} from "@/components/Icon";
-import { SchemaDiagramIcon } from "@/components/SchemaDiagram";
import { NButton, useDialog, type DropdownOption } from "naive-ui";
import { computed, h, nextTick, ref } from "vue";
-import type { VNodeChild } from "vue";
import { useRouter } from "vue-router";
import formatSQL from "@/components/MonacoEditor/sqlFormatter";
import { useExecuteSQL } from "@/composables/useExecuteSQL";
@@ -189,7 +180,7 @@ export const useActions = () => {
continue;
}
const viewState = tabViewStateStore.getViewState(tab.id);
- if (viewState.view !== view || viewState.schema !== schema) {
+ if (viewState.view !== view || (schema && viewState.schema !== schema)) {
continue;
}
tabStore.setCurrentTabId(tab.id);
@@ -262,6 +253,7 @@ export const useActions = () => {
export const useDropdown = () => {
const router = useRouter();
+ const { availableActions } = useCurrentTabViewStateContext();
const { events: editorEvents, schemaViewer } = useSQLEditorContext();
const { selectAllFromTableOrView, viewDetail, openNewTab } = useActions();
const disallowEditSchema = useAppFeature(
@@ -293,54 +285,7 @@ export const useDropdown = () => {
const items: DropdownOptionWithTreeNode[] = [];
if (type === "database" || type === "schema") {
- const actions: { view: EditorPanelView; title: string; icon: () => VNodeChild }[] = [
- {
- view: "INFO",
- title: t("common.info"),
- icon: () => <InfoIcon class="w-4 h-4" />
- },
- {
- view: "TABLES",
- title: t("db.tables"),
- icon: () => <TableIcon class="w-4 h-4" />
- },
- {
- view: "VIEWS",
- title: t("db.views"),
- icon: () => <ViewIcon class="w-4 h-4" />
- },
- {
- view: "FUNCTIONS",
- title: t("db.functions"),
- icon: () => <FunctionIcon class="w-4 h-4" />
- },
- {
- view: "PROCEDURES",
- title: t("db.procedures"),
- icon: () => <ProcedureIcon class="w-4 h-4" />
- },
- {
- view: "SEQUENCES",
- title: t("db.sequences"),
- icon: () => <SequenceIcon class="w-4 h-4" />
- },
- {
- view: "PACKAGES",
- title: t("db.packages"),
- icon: () => <PackageIcon class="w-4 h-4" />
- },
- {
- view: "EXTERNAL_TABLES",
- title: t("db.external-tables"),
- icon: () => <ExternalTableIcon class="w-4 h-4" />
- },
- {
- view: "DIAGRAM",
- title: t("schema-diagram.self"),
- icon: () => <SchemaDiagramIcon class="w-4 h-4" />
- },
- ]
- for (const action of actions) {
+ for (const action of availableActions.value) {
items.push({
key: action.view,
label: action.title,
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue
index 2fddca2259..d6a18045d6 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue
@@ -32,7 +32,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesPanel.vue
index 5110af64f1..623ecf8697 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesPanel.vue
@@ -70,7 +70,7 @@ import {
SchemaMetadata,
ExternalTableMetadata,
} from "@/types/proto/v1/database_service";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import ExternalTableColumnsTable from "./ExternalTableColumnsTable.vue";
import ExternalTablesTable from "./ExternalTablesTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue
index ed62669c3d..220ffde405 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue
@@ -29,7 +29,7 @@ import type {
ExternalTableMetadata,
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsPanel.vue
index f3a443aa76..65cc931c89 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsPanel.vue
@@ -52,7 +52,7 @@ import {
extractKeyWithPosition,
keyWithPosition,
} from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import { CodeViewer } from "../common";
import FunctionsTable from "./FunctionsTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue
index 4226578ca7..ffdff6be56 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue
@@ -30,7 +30,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { keyWithPosition } from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
type FunctionWithPosition = { func: FunctionMetadata; position: number };
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/InfoPanel/InfoPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/InfoPanel/InfoPanel.vue
index 35f4d50495..5da89a9f36 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/InfoPanel/InfoPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/InfoPanel/InfoPanel.vue
@@ -220,7 +220,7 @@ import {
instanceV1SupportsSequence,
} from "@/utils";
import { keyWithPosition } from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import ExternalTablesTable from "../ExternalTablesPanel/ExternalTablesTable.vue";
import FunctionsTable from "../FunctionsPanel/FunctionsTable.vue";
import PackagesTable from "../PackagesPanel/PackagesTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesPanel.vue
index a22683ac4b..aa7fbd13f0 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesPanel.vue
@@ -52,7 +52,7 @@ import {
extractKeyWithPosition,
keyWithPosition,
} from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import { CodeViewer } from "../common";
import PackagesTable from "./PackagesTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesTable.vue
index eebd3f8925..9932bb093e 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/PackagesPanel/PackagesTable.vue
@@ -32,7 +32,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { keyWithPosition } from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
type PackageWithPosition = {
package: PackageMetadata;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/Panels.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/Panels.vue
index 00492d6b92..a4b4f34387 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/Panels.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/Panels.vue
@@ -66,7 +66,7 @@ import {
type VueClass,
} from "@/utils";
import DatabaseChooser from "@/views/sql-editor/EditorCommon/DatabaseChooser.vue";
-import { useCurrentTabViewStateContext } from "../context";
+import { useCurrentTabViewStateContext } from "../context/viewState.tsx";
import DiagramPanel from "./DiagramPanel";
import ExternalTablesPanel from "./ExternalTablesPanel";
import FunctionsPanel from "./FunctionsPanel";
@@ -79,7 +79,6 @@ import ViewsPanel from "./ViewsPanel";
import { SchemaSelectToolbar } from "./common";
defineProps<{
- gutterBarClass?: VueClass;
contentClass?: VueClass;
}>();
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresPanel.vue
index ba16b6ea27..a3d393da7d 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresPanel.vue
@@ -52,7 +52,7 @@ import {
extractKeyWithPosition,
keyWithPosition,
} from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import { CodeViewer } from "../common";
import ProceduresTable from "./ProceduresTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue
index 73cd03a3e8..83e3102fd1 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue
@@ -32,7 +32,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { keyWithPosition } from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
type ProcedureWithPosition = {
procedure: ProcedureMetadata;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesPanel.vue
index 3c58a69cf1..b639b28d02 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesPanel.vue
@@ -37,7 +37,7 @@ import {
extractKeyWithPosition,
keyWithPosition,
} from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import SequencesTable from "./SequencesTable.vue";
const { database } = useConnectionOfCurrentSQLEditorTab();
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesTable.vue
index dba6bd9205..2dc64730a4 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/SequencesPanel/SequencesTable.vue
@@ -33,7 +33,7 @@ import type {
import { useAutoHeightDataTable } from "@/utils";
import { keyWithPosition } from "@/views/sql-editor/EditorCommon";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
type SequenceWithPosition = { sequence: SequenceMetadata; position: number };
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue
index 45bf8d51da..00ea5c6f6c 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue
@@ -36,7 +36,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue
index 25b7b6bac6..971a8216bf 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue
@@ -31,7 +31,7 @@ import type {
TableMetadata,
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue
index 91de0ccec6..b29c641958 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue
@@ -31,7 +31,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue
index 112fd04cf5..a476e93825 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue
@@ -30,7 +30,7 @@ import {
type TableMetadata,
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
type FlattenTablePartitionMetadata = {
partition: TablePartitionMetadata;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TableDetail.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TableDetail.vue
index f5ef40bfc8..cee0622e53 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TableDetail.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TableDetail.vue
@@ -105,7 +105,7 @@ import type {
TableMetadata,
} from "@/types/proto/v1/database_service";
import { keyWithPosition } from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import ColumnsTable from "./ColumnsTable.vue";
import ForeignKeysTable from "./ForeignKeysTable.vue";
import IndexesTable from "./IndexesTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesPanel.vue
index 6676560490..655b8b8592 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesPanel.vue
@@ -46,7 +46,7 @@ import {
TableMetadata,
TablePartitionMetadata,
} from "@/types/proto/v1/database_service";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import TableDetail from "./TableDetail.vue";
import TablesTable from "./TablesTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue
index f00c01a73d..d064804101 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue
@@ -37,7 +37,7 @@ import {
useAutoHeightDataTable,
} from "@/utils";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TriggersTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TriggersTable.vue
index da94f2caac..e0cb4dd1a2 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TriggersTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TriggersTable.vue
@@ -69,7 +69,7 @@ import {
keyWithPosition,
} from "@/views/sql-editor/EditorCommon";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import { CodeViewer } from "../common";
type TriggerWithPosition = {
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue
index af0c1b597f..acaa8b3b7f 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue
@@ -32,7 +32,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependencyColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependencyColumnsTable.vue
index dd5a97dc7e..2d1e14f7f0 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependencyColumnsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependencyColumnsTable.vue
@@ -36,7 +36,7 @@ import {
keyForDependencyColumn,
useAutoHeightDataTable,
} from "@/utils";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewDetail.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewDetail.vue
index 3c233d6be5..b24787374b 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewDetail.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewDetail.vue
@@ -88,7 +88,7 @@ import type {
ViewMetadata,
} from "@/types/proto/v1/database_service";
import { OpenAIButton } from "@/views/sql-editor/EditorCommon";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import ColumnsTable from "./ColumnsTable.vue";
import DefinitionViewer from "./DefinitionViewer.vue";
import DependencyColumnsTable from "./DependencyColumnsTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsPanel.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsPanel.vue
index 41cd5ae40d..2a10cd2543 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsPanel.vue
@@ -43,7 +43,7 @@ import {
ViewMetadata,
SchemaMetadata,
} from "@/types/proto/v1/database_service";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
import ViewDetail from "./ViewDetail.vue";
import ViewsTable from "./ViewsTable.vue";
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue
index f15ed6f3bb..a9186ffade 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue
@@ -30,7 +30,7 @@ import type {
} from "@/types/proto/v1/database_service";
import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";
import { EllipsisCell } from "../../common";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
const props = defineProps<{
db: ComposedDatabase;
diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/common/SchemaSelectToolbar.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/common/SchemaSelectToolbar.vue
index 56537e68f8..b7d741bd91 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Panels/common/SchemaSelectToolbar.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/common/SchemaSelectToolbar.vue
@@ -38,7 +38,7 @@ import {
useDBSchemaV1Store,
} from "@/store";
import { hasSchemaProperty } from "@/utils";
-import { useCurrentTabViewStateContext } from "../../context";
+import { useCurrentTabViewStateContext } from "../../context/viewState";
defineOptions({
inheritAttrs: false,
diff --git a/frontend/src/views/sql-editor/EditorPanel/common/common.ts b/frontend/src/views/sql-editor/EditorPanel/common/common.ts
index c65893bac3..7b85ee8534 100644
--- a/frontend/src/views/sql-editor/EditorPanel/common/common.ts
+++ b/frontend/src/views/sql-editor/EditorPanel/common/common.ts
@@ -6,7 +6,7 @@ import {
useDBSchemaV1Store,
} from "@/store";
import { hasSchemaProperty } from "@/utils";
-import { useCurrentTabViewStateContext } from "../context";
+import { useCurrentTabViewStateContext } from "../context/viewState";
export const useSelectSchema = () => {
const { database, instance } = useConnectionOfCurrentSQLEditorTab();
diff --git a/frontend/src/views/sql-editor/EditorPanel/context/index.ts b/frontend/src/views/sql-editor/EditorPanel/context/viewState.tsx
similarity index 58%
rename from frontend/src/views/sql-editor/EditorPanel/context/index.ts
rename to frontend/src/views/sql-editor/EditorPanel/context/viewState.tsx
index 14ef09f92e..52331fd759 100644
--- a/frontend/src/views/sql-editor/EditorPanel/context/index.ts
+++ b/frontend/src/views/sql-editor/EditorPanel/context/viewState.tsx
@@ -1,4 +1,3 @@
-import { head } from "lodash-es";
import { storeToRefs } from "pinia";
import { computed, inject, provide, watch, type InjectionKey } from "vue";
import {
@@ -15,6 +14,19 @@ import {
instanceV1SupportsPackage,
instanceV1SupportsSequence,
} from "@/utils";
+import type { VNodeChild } from "vue";
+import { t } from "@/plugins/i18n";
+import {
+ FunctionIcon,
+ TableIcon,
+ ViewIcon,
+ ProcedureIcon,
+ ExternalTableIcon,
+ PackageIcon,
+ SequenceIcon,
+} from "@/components/Icon";
+import { InfoIcon } from "lucide-vue-next"
+import { SchemaDiagramIcon } from "@/components/SchemaDiagram";
const KEY = Symbol(
"bb.sql-editor.editor-panel"
@@ -32,26 +44,61 @@ export const provideCurrentTabViewStateContext = () => {
return tabViewStateStore.getViewState(tab.value.id);
});
- const availableViews = computed(() => {
- const views: EditorPanelView[] = [
- "CODE",
- "INFO",
- "TABLES",
- "VIEWS",
- "FUNCTIONS",
- "PROCEDURES",
+ const availableActions = computed(() => {
+ const actions: { view: EditorPanelView; title: string; icon: () => VNodeChild }[] = [
+ {
+ view: "INFO",
+ title: t("common.info"),
+ icon: () => <InfoIcon class="w-4 h-4" />
+ },
+ {
+ view: "TABLES",
+ title: t("db.tables"),
+ icon: () => <TableIcon class="w-4 h-4" />
+ },
+ {
+ view: "VIEWS",
+ title: t("db.views"),
+ icon: () => <ViewIcon class="w-4 h-4" />
+ },
+ {
+ view: "FUNCTIONS",
+ title: t("db.functions"),
+ icon: () => <FunctionIcon class="w-4 h-4" />
+ },
+ {
+ view: "PROCEDURES",
+ title: t("db.procedures"),
+ icon: () => <ProcedureIcon class="w-4 h-4" />
+ },
];
if (instanceV1SupportsSequence(instance.value)) {
- views.push("SEQUENCES");
+ actions.push({
+ view: "SEQUENCES",
+ title: t("db.sequences"),
+ icon: () => <SequenceIcon class="w-4 h-4" />
+ });
}
if (instanceV1SupportsExternalTable(instance.value)) {
- views.push("EXTERNAL_TABLES");
+ actions.push({
+ view: "EXTERNAL_TABLES",
+ title: t("db.external-tables"),
+ icon: () => <ExternalTableIcon class="w-4 h-4" />
+ });
}
if (instanceV1SupportsPackage(instance.value)) {
- views.push("PACKAGES");
+ actions.push({
+ view: "PACKAGES",
+ title: t("db.packages"),
+ icon: () => <PackageIcon class="w-4 h-4" />
+ });
}
- views.push("DIAGRAM");
- return views;
+ actions.push({
+ view: "DIAGRAM",
+ title: t("schema-diagram.self"),
+ icon: () => <SchemaDiagramIcon class="w-4 h-4" />
+ });
+ return actions;
});
const selectedSchemaName = computed({
@@ -71,18 +118,6 @@ export const provideCurrentTabViewStateContext = () => {
tabViewStateStore.updateViewState(tab.value.id, patch);
};
- watch(
- [() => viewState.value?.view, availableViews],
- ([view, availableViews]) => {
- if (view && !availableViews.includes(view)) {
- updateViewState({
- view: head(availableViews),
- });
- }
- },
- { immediate: true }
- );
-
watch(
() => tab.value?.connection.schema,
(schema) => {
@@ -109,7 +144,7 @@ export const provideCurrentTabViewStateContext = () => {
const context = {
viewState,
selectedSchemaName,
- availableViews,
+ availableActions,
updateViewState,
};
diff --git a/frontend/src/views/sql-editor/EditorPanel/index.ts b/frontend/src/views/sql-editor/EditorPanel/index.ts
index 3d5e5a29aa..aadd6e3525 100644
--- a/frontend/src/views/sql-editor/EditorPanel/index.ts
+++ b/frontend/src/views/sql-editor/EditorPanel/index.ts
@@ -1,5 +1,5 @@
import EditorPanel from "./EditorPanel.vue";
-export * from "./context";
+export * from "./context/viewState.tsx";
export default EditorPanel;
diff --git a/frontend/src/views/sql-editor/SQLEditorHomePage.vue b/frontend/src/views/sql-editor/SQLEditorHomePage.vue
index 3301c0476d..92c6bd45c1 100644
--- a/frontend/src/views/sql-editor/SQLEditorHomePage.vue
+++ b/frontend/src/views/sql-editor/SQLEditorHomePage.vue
@@ -89,7 +89,7 @@ import { extractProjectResourceName } from "@/utils";
import AsidePanel from "./AsidePanel";
import ConnectionPanel from "./ConnectionPanel";
import EditorPanel from "./EditorPanel";
-import { provideCurrentTabViewStateContext } from "./EditorPanel/context";
+import { provideCurrentTabViewStateContext } from "./EditorPanel/context/viewState";
import { useSheetContext } from "./Sheet";
import SheetPanel from "./SheetPanel";
import TabList from "./TabList";