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 page update (#7673)
ecmadao6712d0a5825b
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex c78490a8fa..5539309252 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1798,7 +1798,9 @@"no-rows-found": "No rows found","download-as-file": "Download as {file}","only-select-allowed": "Only {select} statements are allowed to execute.",- "want-to-action": "If you want to {want}, click the {action} button and submit an issue.",+ "want-to-action": "If you want to {want}, click the {action} button {reaction}.",+ "and-submit-an-issue": "and submit an issue",+ "to-enable-admin-mode": "to enable the admin mode","table-schema-placeholder": "Select a table to see its schema","notify-empty-statement": "Please input your SQL statements in the editor","notify-multiple-statements": "Multiple SQL statements detected. SQL Editor only executes the first statement. You can select another statement and execute it individually.",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex d8f9ea6e68..7d03d4f3e5 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1795,7 +1795,9 @@"no-rows-found": "No se encontraron filas","download-as-file": "Descargar como {file}","only-select-allowed": "Solo se permiten declaraciones {select} para ejecutar.",- "want-to-action": "Si desea {want}, haga clic en el botón {action} y envíe una incidencia.",+ "want-to-action": "Si desea {want}, haga clic en el botón {action} {reaction}.",+ "and-submit-an-issue": "y enviar un problema",+ "to-enable-admin-mode": "para habilitar el modo administrador","table-schema-placeholder": "Seleccione una tabla para ver su esquema","notify-empty-statement": "Ingrese sus declaraciones SQL en el editor","notify-multiple-statements": "Se detectaron múltiples declaraciones SQL. El Editor de SQL solo ejecuta la primera declaración. Puede seleccionar otra declaración y ejecutarla individualmente.",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 897a18a6e0..69088f76ee 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1792,7 +1792,9 @@"no-rows-found": "暂无数据","download-as-file": "下载为 {file} 格式","only-select-allowed": "只允许执行 {select} 语句",- "want-to-action": "如果您想要{action},点击“{action}”按钮并提交一个工单。",+ "want-to-action": "如果您想要{want},点击“{action}”按钮{reaction}。",+ "and-submit-an-issue": "并提交一个工单",+ "to-enable-admin-mode": "来开启管理员模式","table-schema-placeholder": "选择一个表进行查看 Schema","notify-empty-statement": "请在编辑器中输入 SQL 语句","notify-multiple-statements": "检测到您输入了多条 SQL 语句。SQL 编辑器只支持执行第一条语句。您可以选择其他语句单独执行。",diff --git a/frontend/src/store/modules/sqlEditor.ts b/frontend/src/store/modules/sqlEditor.tsindex d143aec4e1..9eff927b59 100644--- a/frontend/src/store/modules/sqlEditor.ts+++ b/frontend/src/store/modules/sqlEditor.ts@@ -24,6 +24,7 @@ export const useSQLEditorStore = defineStore("sqlEditor", {queryHistoryList: [],isFetchingQueryHistory: false,isFetchingSheet: false,+ mode: "BUNDLED",}),actions: {diff --git a/frontend/src/types/sqlEditor.ts b/frontend/src/types/sqlEditor.tsindex 984fb4c290..0475d5a0e7 100644--- a/frontend/src/types/sqlEditor.ts+++ b/frontend/src/types/sqlEditor.ts@@ -8,6 +8,12 @@ export type CompletionItems = monaco.languages.CompletionItem[];export type Language = "sql" | "javascript" | "redis";+export type SQLEditorMode =+ // SQL Editor is bundled with main console.+ | "BUNDLED"+ // SQL Editor is by its own.+ | "STANDALONE";+export const EngineTypesUsingSQL = ["MYSQL","CLICKHOUSE",diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.tsindex f0d227e5d4..2db12afb9c 100644--- a/frontend/src/types/store.ts+++ b/frontend/src/types/store.ts@@ -21,6 +21,7 @@ import { Notification } from "./notification";import { Principal } from "./principal";import { Project } from "./project";import { DatabaseMetadata } from "./proto/store/database";+import { SQLEditorMode } from "./sqlEditor";import { VCS } from "./vcs";export interface PrincipalState {@@ -103,6 +104,7 @@ export interface SQLEditorState {isFetchingQueryHistory: boolean;isFetchingSheet: boolean;isShowExecutingHint: boolean;+ mode: SQLEditorMode;}export interface DebugState {diff --git a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vueindex 682681fdf9..5b4c7bb082 100644--- a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue+++ b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue@@ -63,6 +63,7 @@ import {useCurrentUserV1,useDatabaseV1Store,useInstanceV1Store,+ useSQLEditorStore,useIsLoggedIn,useTabStore,} from "@/store";@@ -115,6 +116,7 @@ const connectionTreeStore = useConnectionTreeStore();const tabStore = useTabStore();const isLoggedIn = useIsLoggedIn();const currentUserV1 = useCurrentUserV1();+const sqlEditorStore = useSQLEditorStore();const mounted = useMounted();const treeRef = ref<InstanceType<typeof NTree>>();@@ -125,6 +127,7 @@ const dropdownPosition = ref<Position>({y: 0,});const dropdownContext = ref<ConnectionAtom>();+const dropdownOptions = computed((): DropdownOptionWithConnectionAtom[] => {const atom = dropdownContext.value;if (!atom) {@@ -157,7 +160,7 @@ const dropdownOptions = computed((): DropdownOptionWithConnectionAtom[] => {});}}- if (atom.type === "database") {+ if (atom.type === "database" && sqlEditorStore.mode === "BUNDLED") {const database = databaseStore.getDatabaseByUID(atom.id);if (instanceV1HasAlterSchema(database.instanceEntity)) {items.push({diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/DatabaseSchema.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/DatabaseSchema.vueindex 07472a388f..f7db6365e6 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/DatabaseSchema.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/DatabaseSchema.vue@@ -16,11 +16,15 @@:database-metadata="databaseMetadata"/><ExternalLinkButton+ v-if="sqlEditorStore.mode === 'BUNDLED'":link="`/db/${databaseV1Slug(database)}`":tooltip="$t('common.detail')"/><AlterSchemaButton- v-if="instanceV1HasAlterSchema(database.instanceEntity)"+ v-if="+ sqlEditorStore.mode === 'BUNDLED' &&+ instanceV1HasAlterSchema(database.instanceEntity)+ ":database="database"@click="emit('alter-schema', {@@ -45,6 +49,7 @@<script lang="ts" setup>import { computed } from "vue";import { useCurrentUserV1 } from "@/store";+import { useSQLEditorStore } from "@/store";import type { ComposedDatabase } from "@/types";import { Engine } from "@/types/proto/v1/common";import {@@ -78,6 +83,7 @@ const emit = defineEmits<{}>();const currentUser = useCurrentUserV1();+const sqlEditorStore = useSQLEditorStore();const engine = computed(() => props.database.instanceEntity.engine);diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableSchema.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableSchema.vueindex b5d10f2eec..7196cedfeb 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableSchema.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPanel/TableSchema.vue@@ -10,7 +10,10 @@<span class="font-semibold">{{ table.name }}</span></div>- <div class="flex justify-end gap-x-0.5">+ <div+ v-if="sqlEditorStore.mode === 'BUNDLED'"+ class="flex justify-end gap-x-0.5"+ ><ExternalLinkButton:link="tableDetailLink":tooltip="$t('common.detail')"@@ -36,6 +39,7 @@<script lang="ts" setup>import { computed } from "vue";+import { useSQLEditorStore } from "@/store";import type { ComposedDatabase } from "@/types";import type {DatabaseMetadata,@@ -62,6 +66,8 @@ const emit = defineEmits<{): void;}>();+const sqlEditorStore = useSQLEditorStore();+const tableDetailLink = computed((): string => {const { database, schema, table } = props;let url = `/db/${databaseV1Slug(database)}/table/${encodeURIComponent(diff --git a/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue b/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vueindex 769887c208..8552b05447 100644--- a/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue@@ -21,26 +21,43 @@<template #action><strong>{{- isDDL- ? $t("database.alter-schema")- : $t("database.change-data")+ sqlEditorStore.mode === "BUNDLED"+ ? isDDL+ ? $t("database.alter-schema")+ : $t("database.change-data")+ : $t("sql-editor.admin-mode.self")}}</strong></template>+ <template #reaction>+ {{+ sqlEditorStore.mode === "BUNDLED"+ ? $t("sql-editor.and-submit-an-issue")+ : $t("sql-editor.to-enable-admin-mode")+ }}+ </template></i18n-t></p></section></NAlert><div class="execute-hint-content mt-4 flex justify-between">- <div class="flex justify-start items-center space-x-2">+ <div+ v-if="sqlEditorStore.mode === 'BUNDLED'"+ class="flex justify-start items-center space-x-2"+ ><AdminModeButton @enter="$emit('close')" /></div>- <div class="flex justify-end items-center space-x-2">+ <div class="flex flex-1 justify-end items-center space-x-2"><NButton @click="handleClose">{{ $t("common.close") }}</NButton>- <NButton type="primary" @click="gotoAlterSchema">+ <NButton+ v-if="sqlEditorStore.mode === 'BUNDLED'"+ type="primary"+ @click="gotoAlterSchema"+ >{{ isDDL ? $t("database.alter-schema") : $t("database.change-data") }}</NButton>+ <AdminModeButton v-else @enter="$emit('close')" /></div></div></div>@@ -51,7 +68,12 @@ import { computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { parseSQL, isDDLStatement } from "@/components/MonacoEditor/sqlParser";-import { pushNotification, useDatabaseV1Store, useTabStore } from "@/store";+import {+ pushNotification,+ useDatabaseV1Store,+ useTabStore,+ useSQLEditorStore,+} from "@/store";import { UNKNOWN_ID } from "@/types";import AdminModeButton from "./AdminModeButton.vue";@@ -65,6 +87,7 @@ const DMLIssueTemplate = "bb.issue.database.data.update";const router = useRouter();const { t } = useI18n();const tabStore = useTabStore();+const sqlEditorStore = useSQLEditorStore();const sqlStatement = computed(() => tabStore.currentTab.selectedStatement || tabStore.currentTab.statementdiff --git a/frontend/src/views/sql-editor/SQLEditorPage.vue b/frontend/src/views/sql-editor/SQLEditorPage.vueindex a22d312d9a..623bbd1da7 100644--- a/frontend/src/views/sql-editor/SQLEditorPage.vue+++ b/frontend/src/views/sql-editor/SQLEditorPage.vue@@ -116,7 +116,8 @@ import { useWindowSize } from "@vueuse/core";import { NDrawer } from "naive-ui";import { stringify } from "qs";import { Splitpanes, Pane } from "splitpanes";-import { computed, reactive } from "vue";+import { computed, reactive, onMounted } from "vue";+import { useRoute } from "vue-router";import SchemaEditorModal from "@/components/AlterSchemaPrepForm/SchemaEditorModal.vue";import { Drawer, DrawerContent, InstanceV1Name } from "@/components/v2";import {@@ -126,7 +127,7 @@ import {useSQLEditorStore,useTabStore,} from "@/store";-import { DatabaseId, TabMode, UNKNOWN_ID } from "@/types";+import { DatabaseId, TabMode, UNKNOWN_ID, SQLEditorMode } from "@/types";import {allowUsingSchemaEditorV1,instanceV1HasReadonlyMode,@@ -154,6 +155,7 @@ const state = reactive<LocalState>({sidebarExpanded: false,});+const route = useRoute();const tabStore = useTabStore();const databaseStore = useDatabaseV1Store();const sqlEditorStore = useSQLEditorStore();@@ -164,6 +166,13 @@ const { showPanel: showSheetPanel } = provideSheetContext();const isDisconnected = computed(() => tabStore.isDisconnected);const isFetchingSheet = computed(() => sqlEditorStore.isFetchingSheet);+onMounted(() => {+ const mode = (route.query.mode || "BUNDLED") as SQLEditorMode;+ sqlEditorStore.setSQLEditorState({+ mode,+ });+});+const { width: windowWidth } = useWindowSize();const allowAccess = computed(() => {