Skip to content

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

chore: move the Text2SQL button (#13622)

Liu Jifc54abe3212a
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
index d2a9e70c80..6882201fc4 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
@@ -13,15 +13,12 @@
<TabItem tab="HISTORY" :size="size" @click="handleClickTab('HISTORY')" />
</div>
- <div class="flex flex-col justify-end items-center">
- <OpenAIButton :size="size" />
- </div>
+ <div class="flex flex-col justify-end items-center"></div>
</div>
</template>
<script setup lang="ts">
import { useSQLEditorContext, type AsidePanelTab } from "../../context";
-import OpenAIButton from "./OpenAIButton.vue";
import TabItem from "./TabItem.vue";
import { type Size } from "./common";
diff --git a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
index 2f2076ecf7..f4f536222d 100644
--- a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
@@ -44,6 +44,8 @@
/>
</NButtonGroup>
+ <OpenAIButton size="small" />
+
<NPopover placement="bottom">
<template #trigger>
<AdminModeButton
@@ -160,6 +162,7 @@ import { useSQLEditorContext } from "../context";
import AdminModeButton from "./AdminModeButton.vue";
import BatchQueryDatabasesSelector from "./BatchQueryDatabasesSelector.vue";
import DatabaseChooser from "./DatabaseChooser.vue";
+import OpenAIButton from "./OpenAIButton.vue";
import QueryContextSettingPopover from "./QueryContextSettingPopover.vue";
import SharePopover from "./SharePopover.vue";
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/OpenAIButton.vue b/frontend/src/views/sql-editor/EditorCommon/OpenAIButton.vue
similarity index 81%
rename from frontend/src/views/sql-editor/AsidePanel/GutterBar/OpenAIButton.vue
rename to frontend/src/views/sql-editor/EditorCommon/OpenAIButton.vue
index bffb459fbf..f19daa7ec4 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/OpenAIButton.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/OpenAIButton.vue
@@ -1,9 +1,13 @@
<template>
- <NTooltip v-if="showButton" placement="right">
+ <NPopover v-if="showButton" placement="bottom">
<template #trigger>
<NButton
- :style="buttonStyle"
- v-bind="buttonProps"
+ :active="showAIChatBox"
+ v-bind="{
+ ...buttonProps,
+ ...$attrs,
+ }"
+ style="--n-icon-size: 16px; --n-padding: 0 6px"
@click="showAIChatBox = !showAIChatBox"
>
<template #icon>
@@ -28,20 +32,18 @@
: $t("plugin.ai.enable-text2sql")
}}
</template>
- </NTooltip>
+ </NPopover>
</template>
<script setup lang="ts">
-import { NButton, NTooltip } from "naive-ui";
+import { NButton, NPopover, type ButtonProps } from "naive-ui";
import { computed } from "vue";
-import { toRef } from "vue";
import { useSettingV1Store, useSQLEditorTabStore } from "@/store";
-import { useSQLEditorContext } from "../../context";
-import { useButton, type Size } from "./common";
+import { useSQLEditorContext } from "../context";
-const props = defineProps<{
- size: Size;
-}>();
+defineOptions({
+ inheritAttrs: false,
+});
const tabStore = useSQLEditorTabStore();
const settingV1Store = useSettingV1Store();
@@ -58,9 +60,16 @@ const showButton = computed(() => {
return openAIKey.value && !tabStore.isDisconnected;
});
-const { props: buttonProps, style: buttonStyle } = useButton({
- size: toRef(props, "size"),
- active: showAIChatBox,
- disabled: false,
+const buttonProps = computed(() => {
+ const buttonProps: ButtonProps = {
+ tag: "div",
+ };
+ if (showAIChatBox.value) {
+ buttonProps.ghost = true;
+ buttonProps.type = "primary";
+ } else {
+ buttonProps.type = "default";
+ }
+ return buttonProps;
});
</script>