Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: some sql editor ux fix (#19432)
ecmadaofd57562b75d9
diff --git a/frontend/src/store/modules/sqlEditor/editor.ts b/frontend/src/store/modules/sqlEditor/editor.tsindex c2211f2a15..fa11f2d43f 100644--- a/frontend/src/store/modules/sqlEditor/editor.ts+++ b/frontend/src/store/modules/sqlEditor/editor.ts@@ -2,9 +2,11 @@ import { useLocalStorage } from "@vueuse/core";import { includes } from "lodash-es";import { defineStore } from "pinia";import { computed, ref } from "vue";+import { useProjectV1Store } from "@/store";import type { Database } from "@/types/proto-es/v1/database_service_pb";import { QueryOption_RedisRunCommandsOn } from "@/types/proto-es/v1/sql_service_pb";import {+ hasProjectPermissionV2,hasWorkspacePermissionV2,STORAGE_KEY_SQL_EDITOR_LAST_PROJECT,STORAGE_KEY_SQL_EDITOR_REDIS_NODE,@@ -12,6 +14,8 @@ import {} from "@/utils";export const useSQLEditorStore = defineStore("sqlEditor", () => {+ const projectStore = useProjectV1Store();+const resultRowsLimit = useLocalStorage(STORAGE_KEY_SQL_EDITOR_RESULT_LIMIT,1000@@ -61,6 +65,13 @@ export const useSQLEditorStore = defineStore("sqlEditor", () => {const isShowExecutingHint = ref(false);const executingHintDatabase = ref<Database | undefined>();+ const allowAdmin = computed(() => {+ const project = projectStore.getProjectByName(+ storedLastViewedProject.value+ );+ return hasProjectPermissionV2(project, "bb.sql.admin");+ });+return {resultRowsLimit,project: computed(() => storedLastViewedProject.value),@@ -71,5 +82,6 @@ export const useSQLEditorStore = defineStore("sqlEditor", () => {isShowExecutingHint,executingHintDatabase,redisCommandOption,+ allowAdmin,};});diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsxindex 4e57bd6095..330c8c1c2d 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx@@ -9,7 +9,7 @@ import { computed, ref } from "vue";import { useRouter } from "vue-router";import { t } from "@/plugins/i18n";import { PROJECT_V1_ROUTE_DATABASE_DETAIL } from "@/router/dashboard/projectV1";-import { useSQLEditorTabStore } from "@/store";+import { useSQLEditorStore, useSQLEditorTabStore } from "@/store";import {type BatchQueryContext,DEFAULT_SQL_EDITOR_TAB_MODE,@@ -26,7 +26,6 @@ import {extractInstanceResourceName,extractProjectResourceName,getInstanceResource,- hasWorkspacePermissionV2,instanceV1HasAlterSchema,instanceV1HasReadonlyMode,setDefaultDataSourceForConn,@@ -40,6 +39,7 @@ type DropdownOptionWithTreeNode = DropdownOption & {export const useDropdown = () => {const router = useRouter();const editorContext = useSQLEditorContext();+const { events: editorEvents, showConnectionPanel } = editorContext;const show = ref(false);@@ -49,9 +49,8 @@ export const useDropdown = () => {});const context = ref<TreeNode>();- const allowAdmin = computed(() => hasWorkspacePermissionV2("bb.sql.admin"));-const options = computed((): DropdownOptionWithTreeNode[] => {+ const { allowAdmin } = useSQLEditorStore();const node = context.value;if (!node) {return [];@@ -96,7 +95,7 @@ export const useDropdown = () => {},});}- if (allowAdmin.value) {+ if (allowAdmin) {items.push({key: "connect-in-admin-mode",label: t("sql-editor.connect-in-admin-mode"),diff --git a/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue b/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vueindex 1ad7b741bd..26357f8c1d 100644--- a/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue+++ b/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue@@ -20,8 +20,7 @@ import { type ButtonProps, NButton } from "naive-ui";import { storeToRefs } from "pinia";import type { PropType } from "vue";import { computed } from "vue";-import { useSQLEditorTabStore } from "@/store";-import { hasWorkspacePermissionV2 } from "@/utils";+import { useSQLEditorStore, useSQLEditorTabStore } from "@/store";const emit = defineEmits<{(e: "enter"): void;@@ -38,13 +37,13 @@ const props = defineProps({},});-const allowAdmin = computed(() => hasWorkspacePermissionV2("bb.sql.admin"));-const tabStore = useSQLEditorTabStore();+const editorStore = useSQLEditorStore();+const { currentTab, isDisconnected } = storeToRefs(tabStore);const showButton = computed(() => {- if (!allowAdmin.value) return false;+ if (!editorStore.allowAdmin) return false;const mode = currentTab.value?.mode;return mode === "WORKSHEET";});diff --git a/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue b/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vueindex 305c83322d..b9cad6dc62 100644--- a/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue@@ -50,6 +50,7 @@ import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/proimport {pushNotification,useDatabaseV1Store,+ useSQLEditorStore,useSQLEditorTabStore,useStorageStore,} from "@/store";@@ -58,7 +59,6 @@ import {extractDatabaseResourceName,extractProjectResourceName,getDatabaseEnvironment,- hasWorkspacePermissionV2,} from "@/utils";import AdminModeButton from "./AdminModeButton.vue";@@ -76,6 +76,7 @@ const emit = defineEmits<{const router = useRouter();const { t } = useI18n();const tabStore = useSQLEditorTabStore();+const editorStore = useSQLEditorStore();const statement = computed(() => {const tab = tabStore.currentTab;@@ -91,7 +92,7 @@ const actions = computed(() => {admin: false,issue: true,};- if (hasWorkspacePermissionV2("bb.sql.admin")) {+ if (editorStore.allowAdmin) {actions.admin = true;}diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.tsindex 80ee60cf7b..1ff28bce4e 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.ts@@ -13,7 +13,7 @@ import {import { useI18n } from "vue-i18n";import { pushNotification } from "@/store";import type { RowValue } from "@/types/proto-es/v1/sql_service_pb";-import { extractSQLRowValuePlain } from "@/utils";+import { extractSQLRowValuePlain, isDescendantOf } from "@/utils";import {type BinaryFormatContext,detectBinaryFormat,@@ -307,6 +307,14 @@ export const provideSelectionContext = ({copy(state.value);};+ useEventListener("click", (e) => {+ if (copying.value) return;+ if (isDescendantOf(e.target as Element, ".result-scroll-buttons")) {+ return;+ }+ deselect();+ });+useEventListener("keydown", (e) => {if (disabled.value) return;if (state.value.columns.length === 0 && state.value.rows.length === 0)diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex 9e3b8c16d5..71a06916a3 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -167,7 +167,7 @@</NButton></div>- <div class="flex flex-col gap-y-2">+ <div class="flex flex-col gap-y-2 result-scroll-buttons"><NTooltip><template #trigger><div class="rounded-full shadow bg-white dark:bg-gray-800">