From af16ac219cff8f03ff4ed4029286cccb7b61b9e4 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Mon, 18 May 2026 17:53:02 +0800 Subject: [PATCH] Revert "fix(objects): guard system source edits" This reverts commit 17bc2e66d476218beb52e7700bb326df0cda0c14. --- apps/desktop/src/App.vue | 35 ++--------- .../src/components/layout/ContentArea.vue | 9 +-- .../src/components/layout/EditorToolbar.vue | 19 ++---- .../src/components/objects/ObjectBrowser.vue | 62 +++---------------- .../src/components/sidebar/TreeItem.vue | 45 ++------------ apps/desktop/src/i18n/locales/en.ts | 1 - apps/desktop/src/i18n/locales/es.ts | 1 - apps/desktop/src/i18n/locales/zh-CN.ts | 1 - apps/desktop/src/lib/contentAreaLayout.ts | 13 ---- apps/desktop/src/lib/objectSourceEditor.ts | 42 ------------- apps/desktop/src/types/database.ts | 1 - packages/app-tests/contentAreaLayout.test.ts | 54 ---------------- packages/app-tests/objectSourceEditor.test.ts | 35 ----------- 13 files changed, 27 insertions(+), 291 deletions(-) delete mode 100644 apps/desktop/src/lib/contentAreaLayout.ts delete mode 100644 packages/app-tests/contentAreaLayout.test.ts diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index 54fc0bf19..c795639ba 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -218,26 +218,6 @@ function openAiPanel() { } } -function isActiveObjectSourceReadOnly() { - return !!activeTab.value?.objectSource?.readOnlyReason; -} - -function guardWritableObjectSource() { - if (!isActiveObjectSourceReadOnly()) return true; - toast(t("objects.sourceReadOnlySystemObject"), 5000); - return false; -} - -function tryExecuteActiveTab() { - if (!guardWritableObjectSource()) return; - tryExecute(); -} - -function tryExplainActiveTab() { - if (!guardWritableObjectSource()) return; - tryExplain(); -} - function analyzeHistoryWithAi(entry: HistoryEntry) { const connectionId = entry.connection_id || activeTab.value?.connectionId; if (!connectionId) { @@ -274,7 +254,6 @@ async function openSaveSqlDialog() { const tab = activeTab.value; if (!tab || !tab.sql.trim()) return; if (tab.objectSource) { - if (!guardWritableObjectSource()) return; await saveActiveObjectSource(tab); return; } @@ -304,10 +283,6 @@ async function saveActiveObjectSource(tab: NonNullable) const connection = connectionStore.getConfig(tab.connectionId); const source = tab.objectSource; if (!connection || !source) return; - if (source.readOnlyReason) { - toast(t("objects.sourceReadOnlySystemObject"), 5000); - return; - } try { const statements = buildExecutableObjectSourceStatements({ @@ -595,7 +570,7 @@ function handleKeydown(e: KeyboardEvent) { ) { e.preventDefault(); e.stopPropagation(); - tryExecuteActiveTab(); + tryExecute(); } } @@ -789,9 +764,9 @@ onUnmounted(() => { :active-tab="activeTab" :active-connection="activeConnection" :executable-sql="executableSql" - @execute="tryExecuteActiveTab" + @execute="tryExecute()" @cancel="cancelActiveExecution()" - @explain="tryExplainActiveTab" + @explain="tryExplain()" @format-sql="formatActiveSql" @save-sql="void openSaveSqlDialog()" @open-sql="openSqlFile" @@ -812,9 +787,9 @@ onUnmounted(() => { :cursor-pos="cursorPos" @update:active-output-view="activeOutputView = $event" @fix-with-ai="fixWithAi" - @execute="tryExecuteActiveTab" + @execute="tryExecute()" @cancel="cancelActiveExecution()" - @explain="tryExplainActiveTab" + @explain="tryExplain()" @editor-update=" (v: string) => { if (queryStore.activeTabId) queryStore.updateSql(queryStore.activeTabId, v); diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue index 0f3498a4b..ee906b006 100644 --- a/apps/desktop/src/components/layout/ContentArea.vue +++ b/apps/desktop/src/components/layout/ContentArea.vue @@ -28,7 +28,6 @@ const ExplainPlanViewer = defineAsyncComponent(() => import("@/components/explai const QueryChart = defineAsyncComponent(() => import("@/components/chart/QueryChart.vue")); import { useQueryStore } from "@/stores/queryStore"; import { canCancelQueryExecution, queryExecutionLabelKey } from "@/lib/queryExecutionState"; -import { shouldShowQueryOutputPane } from "@/lib/contentAreaLayout"; import { databaseDisplayNameForTab } from "@/lib/tabPresentation"; import { isTableDataEditable } from "@/lib/tableEditing"; import type { QueryTab, ConnectionConfig } from "@/types/database"; @@ -115,9 +114,6 @@ const activeQueryError = computed(() => { return String(result.rows[0]?.[0] ?? ""); }); -const showQueryOutputPane = computed(() => shouldShowQueryOutputPane(props.activeTab)); -const objectSourceReadOnly = computed(() => !!props.activeTab.objectSource?.readOnlyReason); - // Column info panel handlers async function onHandleClickColumn( matchedCols: Array<{ name: string; table: string; schema?: string }>, @@ -212,7 +208,7 @@ defineExpose({ focusSearch, refreshData }); @@ -743,8 +701,7 @@ watch( variant="ghost" size="icon" class="h-5 w-5" - :disabled="!sourceContent || !!sourceRowReadOnlyReason" - :title="sourceRowReadOnlyReason ? t('objects.sourceReadOnlySystemObject') : undefined" + :disabled="!sourceContent" @click="editSource" > @@ -767,7 +724,6 @@ watch( :database="props.database" :dialect="sourceDialect" :format-dialect="sourceFormatDialect" - :read-only="!!sourceRowReadOnlyReason" force-word-wrap @save="saveSource" /> diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue index de7f817d3..11640588d 100644 --- a/apps/desktop/src/components/sidebar/TreeItem.vue +++ b/apps/desktop/src/components/sidebar/TreeItem.vue @@ -92,7 +92,6 @@ import { treeNodeRowAction, treeNodeRowDoubleClickAction, } from "@/lib/treeNodeClick"; -import { objectSourceReadOnlyReason } from "@/lib/objectSourceEditor"; import { formatCsv, formatJson, formatSqlInsert } from "@/lib/exportFormats"; import { fetchTableDataForExport } from "@/lib/tableDataExport"; import { @@ -666,18 +665,6 @@ function viewObjectSource() { schema, name: node.label, objectType, - readOnlyReason: (() => { - const databaseType = currentDatabaseType(); - if (!databaseType) return undefined; - return ( - objectSourceReadOnlyReason({ - databaseType, - schema, - name: node.label, - objectType, - }) ?? undefined - ); - })(), }); }) .catch((e: any) => { @@ -686,10 +673,6 @@ function viewObjectSource() { } function requestDropObject() { - if (currentObjectSourceReadOnlyReason.value) { - toast(t("objects.sourceReadOnlySystemObject"), 5000); - return; - } showDropObjectConfirm.value = true; } @@ -703,21 +686,7 @@ function nodeRenameObjectType(): RenameableObjectType | null { const canRenameObject = computed(() => { const objectType = nodeRenameObjectType(); - return ( - !!objectType && !currentObjectSourceReadOnlyReason.value && supportsObjectRename(currentDatabaseType(), objectType) - ); -}); - -const currentObjectSourceReadOnlyReason = computed(() => { - const objectType = objectSourceKindForTreeNode(props.node.type); - const databaseType = currentDatabaseType(); - if (!objectType || !databaseType) return null; - return objectSourceReadOnlyReason({ - databaseType, - schema: props.node.schema, - name: props.node.label, - objectType, - }); + return !!objectType && supportsObjectRename(currentDatabaseType(), objectType); }); function openRenameObjectDialog() { @@ -2005,13 +1974,11 @@ const isDragging = computed(() => dragState.active && dragState.draggedId === pr {{ t("contextMenu.renameObject") }} - + + + + {{ node.type === "procedure" ? t("contextMenu.dropProcedure") : t("contextMenu.dropFunction") }} +