Skip to content

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

chore(sql-editor): several UI improvements (#11517)

Liu Jiceb304b2cc2b
diff --git a/frontend/src/components/Icon/ColumnIcon.vue b/frontend/src/components/Icon/ColumnIcon.vue
new file mode 100644
index 0000000000..3199732ea8
--- /dev/null
+++ b/frontend/src/components/Icon/ColumnIcon.vue
@@ -0,0 +1,7 @@
+<template>
+ <Columns2Icon v-bind="$attrs" />
+</template>
+
+<script setup lang="ts">
+import { Columns2Icon } from "lucide-vue-next";
+</script>
diff --git a/frontend/src/components/Icon/IndexIcon.vue b/frontend/src/components/Icon/IndexIcon.vue
index d02eae4d3d..0c1f11b246 100644
--- a/frontend/src/components/Icon/IndexIcon.vue
+++ b/frontend/src/components/Icon/IndexIcon.vue
@@ -1,3 +1,7 @@
<template>
- <tabler:diamonds class="w-3 h-3" />
+ <DiamondIcon class="w-3 h-3" />
</template>
+
+<script setup lang="ts">
+import DiamondIcon from "~icons/tabler/diamonds";
+</script>
diff --git a/frontend/src/components/Icon/PrimaryKeyIcon.vue b/frontend/src/components/Icon/PrimaryKeyIcon.vue
new file mode 100644
index 0000000000..ed10dd8dea
--- /dev/null
+++ b/frontend/src/components/Icon/PrimaryKeyIcon.vue
@@ -0,0 +1,9 @@
+<template>
+ <div class="relative overflow-hidden">
+ <KeyIcon class="w-full h-full mx-auto text-amber-500" />
+ </div>
+</template>
+
+<script setup lang="ts">
+import KeyIcon from "~icons/heroicons-outline/key";
+</script>
diff --git a/frontend/src/components/Icon/index.ts b/frontend/src/components/Icon/index.ts
index 33cb42487d..1b7612a4f8 100644
--- a/frontend/src/components/Icon/index.ts
+++ b/frontend/src/components/Icon/index.ts
@@ -1,6 +1,8 @@
+import ColumnIcon from "./ColumnIcon.vue";
import DatabaseIcon from "./DatabaseIcon.vue";
import EngineIcon from "./EngineIcon.vue";
import IndexIcon from "./IndexIcon.vue";
+import PrimaryKeyIcon from "./PrimaryKeyIcon.vue";
import SchemaIcon from "./SchemaIcon.vue";
import SkipIcon from "./SkipIcon.vue";
import TableIcon from "./TableIcon.vue";
@@ -14,4 +16,6 @@ export {
TableIcon,
ViewIcon,
IndexIcon,
+ PrimaryKeyIcon,
+ ColumnIcon,
};
diff --git a/frontend/src/utils/v1/sql.ts b/frontend/src/utils/v1/sql.ts
index 2fb2768bfc..2d2aaf907e 100644
--- a/frontend/src/utils/v1/sql.ts
+++ b/frontend/src/utils/v1/sql.ts
@@ -79,7 +79,7 @@ export const generateSimpleSelectAllStatement = (
limit: number
) => {
if (engine === Engine.MONGODB) {
- return `db["${table}"].find().limit(${limit});`;
+ return `db.${table}.find().limit(${limit});`;
}
const schemaAndTable = generateSchemaAndTableNameInSQL(engine, schema, table);
diff --git a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
index bab63eea36..ba7d391f37 100644
--- a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
@@ -1,12 +1,15 @@
<template>
- <div class="h-full flex flex-col overflow-hidden">
+ <div
+ ref="containerRef"
+ class="h-full flex flex-col overflow-hidden"
+ :data-width="containerWidth"
+ >
<div
v-if="!strictProject"
class="flex flex-row items-center gap-x-1 px-1 py-1 border-b"
>
<ProjectSelect
style="width: 100%"
- size="small"
class="project-select"
:project="projectUID"
:include-all="false"
@@ -17,7 +20,15 @@
<div class="flex-1 flex flex-row overflow-hidden">
<div class="h-full border-r shrink-0">
- <GutterBar />
+ <GutterBar
+ :size="
+ containerWidth >= 320
+ ? 'large'
+ : containerWidth < 240
+ ? 'small'
+ : 'medium'
+ "
+ />
</div>
<div class="h-full flex-1 flex flex-col pt-1 overflow-hidden">
<WorksheetPane v-if="asidePanelTab === 'WORKSHEET'" />
@@ -29,8 +40,9 @@
</template>
<script lang="ts" setup>
+import { useElementSize } from "@vueuse/core";
import { storeToRefs } from "pinia";
-import { computed, watch } from "vue";
+import { computed, ref, watch } from "vue";
import { ProjectSelect } from "@/components/v2";
import {
useProjectV1Store,
@@ -49,6 +61,8 @@ const treeStore = useSQLEditorTreeStore();
const { events, asidePanelTab } = useSQLEditorContext();
const { project, projectContextReady, strictProject } =
storeToRefs(editorStore);
+const containerRef = ref<HTMLDivElement>();
+const { width: containerWidth } = useElementSize(containerRef);
const projectUID = computed(() => {
return editorStore.currentProject?.uid ?? null;
@@ -76,6 +90,6 @@ const handleSwitchProject = (uid: string | undefined) => {
<style lang="postcss" scoped>
.project-select :deep(.n-base-selection) {
- --n-height: 25px !important;
+ --n-height: 30px !important;
}
</style>
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
index 6ff35e79da..c4913d0ee4 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
@@ -1,16 +1,24 @@
<template>
- <div class="h-full flex flex-col items-stretch justify-between text-sm pb-1">
- <div class="divide-y border-b">
- <TabItem tab="WORKSHEET" @click="handleClickTab('WORKSHEET')" />
+ <div
+ ref="containerRef"
+ class="h-full flex flex-col items-stretch justify-between overflow-hidden text-sm p-1"
+ >
+ <div class="flex flex-col gap-y-1">
+ <TabItem
+ tab="WORKSHEET"
+ :size="size"
+ @click="handleClickTab('WORKSHEET')"
+ />
<TabItem
tab="SCHEMA"
+ :size="size"
:disabled="!showSchemaPane"
@click="handleClickTab('SCHEMA')"
/>
- <TabItem tab="HISTORY" @click="handleClickTab('HISTORY')" />
+ <TabItem tab="HISTORY" :size="size" @click="handleClickTab('HISTORY')" />
</div>
- <OpenAIButton class="self-center" />
+ <OpenAIButton :size="size" />
</div>
</template>
@@ -25,8 +33,18 @@ import {
import { UNKNOWN_ID } from "@/types";
import { hasProjectPermissionV2, instanceV1HasAlterSchema } from "@/utils";
import { useSQLEditorContext, type AsidePanelTab } from "../../context";
-import OpenAIButton from "../OpenAIButton.vue";
+import OpenAIButton from "./OpenAIButton.vue";
import TabItem from "./TabItem.vue";
+import type { Size } from "./common";
+
+withDefaults(
+ defineProps<{
+ size?: Size;
+ }>(),
+ {
+ size: "medium",
+ }
+);
const me = useCurrentUserV1();
const { currentTab, isDisconnected } = storeToRefs(useSQLEditorTabStore());
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/OpenAIButton.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/OpenAIButton.vue
new file mode 100644
index 0000000000..423889529f
--- /dev/null
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/OpenAIButton.vue
@@ -0,0 +1,66 @@
+<template>
+ <NTooltip v-if="showButton" placement="right">
+ <template #trigger>
+ <NButton
+ :style="buttonStyle"
+ v-bind="buttonProps"
+ @click="showAIChatBox = !showAIChatBox"
+ >
+ <template #icon>
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 320 320"
+ fill="currentColor"
+ stroke="none"
+ >
+ <path
+ xmlns="http://www.w3.org/2000/svg"
+ d="m297.06 130.97c7.26-21.79 4.76-45.66-6.85-65.48-17.46-30.4-52.56-46.04-86.84-38.68-15.25-17.18-37.16-26.95-60.13-26.81-35.04-.08-66.13 22.48-76.91 55.82-22.51 4.61-41.94 18.7-53.31 38.67-17.59 30.32-13.58 68.54 9.92 94.54-7.26 21.79-4.76 45.66 6.85 65.48 17.46 30.4 52.56 46.04 86.84 38.68 15.24 17.18 37.16 26.95 60.13 26.8 35.06.09 66.16-22.49 76.94-55.86 22.51-4.61 41.94-18.7 53.31-38.67 17.57-30.32 13.55-68.51-9.94-94.51zm-120.28 168.11c-14.03.02-27.62-4.89-38.39-13.88.49-.26 1.34-.73 1.89-1.07l63.72-36.8c3.26-1.85 5.26-5.32 5.24-9.07v-89.83l26.93 15.55c.29.14.48.42.52.74v74.39c-.04 33.08-26.83 59.9-59.91 59.97zm-128.84-55.03c-7.03-12.14-9.56-26.37-7.15-40.18.47.28 1.3.79 1.89 1.13l63.72 36.8c3.23 1.89 7.23 1.89 10.47 0l77.79-44.92v31.1c.02.32-.13.63-.38.83l-64.41 37.19c-28.69 16.52-65.33 6.7-81.92-21.95zm-16.77-139.09c7-12.16 18.05-21.46 31.21-26.29 0 .55-.03 1.52-.03 2.2v73.61c-.02 3.74 1.98 7.21 5.23 9.06l77.79 44.91-26.93 15.55c-.27.18-.61.21-.91.08l-64.42-37.22c-28.63-16.58-38.45-53.21-21.95-81.89zm221.26 51.49-77.79-44.92 26.93-15.54c.27-.18.61-.21.91-.08l64.42 37.19c28.68 16.57 38.51 53.26 21.94 81.94-7.01 12.14-18.05 21.44-31.2 26.28v-75.81c.03-3.74-1.96-7.2-5.2-9.06zm26.8-40.34c-.47-.29-1.3-.79-1.89-1.13l-63.72-36.8c-3.23-1.89-7.23-1.89-10.47 0l-77.79 44.92v-31.1c-.02-.32.13-.63.38-.83l64.41-37.16c28.69-16.55 65.37-6.7 81.91 22 6.99 12.12 9.52 26.31 7.15 40.1zm-168.51 55.43-26.94-15.55c-.29-.14-.48-.42-.52-.74v-74.39c.02-33.12 26.89-59.96 60.01-59.94 14.01 0 27.57 4.92 38.34 13.88-.49.26-1.33.73-1.89 1.07l-63.72 36.8c-3.26 1.85-5.26 5.31-5.24 9.06l-.04 89.79zm14.63-31.54 34.65-20.01 34.65 20v40.01l-34.65 20-34.65-20z"
+ />
+ </svg>
+ </template>
+ </NButton>
+ </template>
+ <template #default>
+ {{
+ showAIChatBox
+ ? $t("plugin.ai.disable-chat-sql")
+ : $t("plugin.ai.enable-chat-sql")
+ }}
+ </template>
+ </NTooltip>
+</template>
+
+<script setup lang="ts">
+import { NButton, NTooltip } 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";
+
+const props = defineProps<{
+ size: Size;
+}>();
+
+const tabStore = useSQLEditorTabStore();
+const settingV1Store = useSettingV1Store();
+const openAIKeySetting = computed(() =>
+ settingV1Store.getSettingByName("bb.plugin.openai.key")
+);
+const openAIKey = computed(
+ () => openAIKeySetting.value?.value?.stringValue ?? ""
+);
+
+const { showAIChatBox } = useSQLEditorContext();
+
+const showButton = computed(() => {
+ return openAIKey.value && !tabStore.isDisconnected;
+});
+
+const { props: buttonProps, style: buttonStyle } = useButton({
+ size: toRef(props, "size"),
+ active: showAIChatBox,
+ disabled: false,
+});
+</script>
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
index e697e3ac7d..efc8b09b09 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
@@ -1,12 +1,13 @@
<template>
<NTooltip placement="right" :delay="300" :disabled="disabled">
<template #trigger>
- <div class="px-2 py-3 select-none" :class="classes" v-bind="$attrs">
- <FileCodeIcon v-if="tab === 'WORKSHEET'" class="w-4 h-4" />
- <DatabaseIcon v-else-if="tab === 'SCHEMA'" class="w-4 h-4" />
- <HistoryIcon v-else-if="tab === 'HISTORY'" class="w-4 h-4" />
- <span v-else></span>
- </div>
+ <NButton :style="buttonStyle" v-bind="{ ...buttonProps, ...$attrs }">
+ <template #icon>
+ <FileCodeIcon v-if="tab === 'WORKSHEET'" />
+ <DatabaseIcon v-else-if="tab === 'SCHEMA'" />
+ <HistoryIcon v-else-if="tab === 'HISTORY'" />
+ </template>
+ </NButton>
</template>
<template #default>
{{ text }}
@@ -17,32 +18,25 @@
<script setup lang="ts">
import { FileCodeIcon, HistoryIcon } from "lucide-vue-next";
import { NTooltip } from "naive-ui";
-import { computed } from "vue";
+import { computed, toRef } from "vue";
import { useI18n } from "vue-i18n";
import DatabaseIcon from "@/components/Icon/DatabaseIcon.vue";
import { useSQLEditorContext, type AsidePanelTab } from "../../context";
+import { type Size, useButton } from "./common";
const props = defineProps<{
tab: AsidePanelTab;
+ size: Size;
disabled?: boolean;
}>();
const { t } = useI18n();
const { asidePanelTab } = useSQLEditorContext();
-const classes = computed(() => {
- const classes: string[] = [];
- if (props.disabled) {
- classes.push("text-main/30 bg-gray-100/30 cursor-not-allowed");
- } else {
- classes.push("cursor-pointer");
- if (props.tab === asidePanelTab.value) {
- classes.push("bg-accent/10");
- } else {
- classes.push("bg-white");
- }
- }
- return classes;
+const { props: buttonProps, style: buttonStyle } = useButton({
+ size: toRef(props, "size"),
+ active: computed(() => props.tab === asidePanelTab.value),
+ disabled: toRef(props, "disabled"),
});
const text = computed(() => {
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts b/frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts
new file mode 100644
index 0000000000..749b65ad96
--- /dev/null
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts
@@ -0,0 +1,48 @@
+import type { ButtonProps } from "naive-ui";
+import { computed, unref, type MaybeRef } from "vue";
+
+export type Size = "small" | "medium" | "large";
+
+export const useButton = (options: {
+ size: MaybeRef<Size>;
+ active: MaybeRef<boolean>;
+ disabled: MaybeRef<boolean>;
+}) => {
+ const props = computed(() => {
+ const props: ButtonProps = {
+ tag: "div",
+ disabled: unref(options.disabled),
+ size: unref(options.size),
+ };
+ if (unref(options.active)) {
+ props.secondary = true;
+ props.type = "primary";
+ } else {
+ props.quaternary = true;
+ props.type = "default";
+ }
+ props.disabled = unref(options.disabled);
+
+ return props;
+ });
+ const style = computed(() => {
+ const parts: string[] = [];
+ const size = unref(options.size);
+
+ if (size === "small") {
+ parts.push("--n-height: 32px");
+ parts.push("--n-padding: 4px 8px");
+ parts.push("--n-icon-size: 16px");
+ } else if (size === "medium") {
+ parts.push("--n-height: 40px");
+ parts.push("--n-padding: 6px 10px");
+ parts.push("--n-icon-size: 20px");
+ } else if (size === "large") {
+ parts.push("--n-height: 48px");
+ parts.push("--n-padding: 12px 12px");
+ parts.push("--n-icon-size: 24px");
+ }
+ return parts.join("; ");
+ });
+ return { props, style };
+};
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts b/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts
index 840d765ac2..0873d44b9a 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts
@@ -1,3 +1,4 @@
import GutterBar from "./GutterBar.vue";
+export * from "./common";
export default GutterBar;
diff --git a/frontend/src/views/sql-editor/AsidePanel/OpenAIButton.vue b/frontend/src/views/sql-editor/AsidePanel/OpenAIButton.vue
deleted file mode 100644
index fb81674d81..0000000000
--- a/frontend/src/views/sql-editor/AsidePanel/OpenAIButton.vue
+++ /dev/null
@@ -1,69 +0,0 @@
-<template>
- <NTooltip v-if="showButton">
- <template #trigger>
- <NButton
- tag="div"
- size="small"
- style="--n-height: 24px; --n-padding: 0 4px"
- class="self-center"
- v-bind="buttonProps"
- @click="showAIChatBox = !showAIChatBox"
- >
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 320 320"
- fill="currentColor"
- stroke="none"
- class="w-4 h-4"
- >
- <path
- xmlns="http://www.w3.org/2000/svg"
- d="m297.06 130.97c7.26-21.79 4.76-45.66-6.85-65.48-17.46-30.4-52.56-46.04-86.84-38.68-15.25-17.18-37.16-26.95-60.13-26.81-35.04-.08-66.13 22.48-76.91 55.82-22.51 4.61-41.94 18.7-53.31 38.67-17.59 30.32-13.58 68.54 9.92 94.54-7.26 21.79-4.76 45.66 6.85 65.48 17.46 30.4 52.56 46.04 86.84 38.68 15.24 17.18 37.16 26.95 60.13 26.8 35.06.09 66.16-22.49 76.94-55.86 22.51-4.61 41.94-18.7 53.31-38.67 17.57-30.32 13.55-68.51-9.94-94.51zm-120.28 168.11c-14.03.02-27.62-4.89-38.39-13.88.49-.26 1.34-.73 1.89-1.07l63.72-36.8c3.26-1.85 5.26-5.32 5.24-9.07v-89.83l26.93 15.55c.29.14.48.42.52.74v74.39c-.04 33.08-26.83 59.9-59.91 59.97zm-128.84-55.03c-7.03-12.14-9.56-26.37-7.15-40.18.47.28 1.3.79 1.89 1.13l63.72 36.8c3.23 1.89 7.23 1.89 10.47 0l77.79-44.92v31.1c.02.32-.13.63-.38.83l-64.41 37.19c-28.69 16.52-65.33 6.7-81.92-21.95zm-16.77-139.09c7-12.16 18.05-21.46 31.21-26.29 0 .55-.03 1.52-.03 2.2v73.61c-.02 3.74 1.98 7.21 5.23 9.06l77.79 44.91-26.93 15.55c-.27.18-.61.21-.91.08l-64.42-37.22c-28.63-16.58-38.45-53.21-21.95-81.89zm221.26 51.49-77.79-44.92 26.93-15.54c.27-.18.61-.21.91-.08l64.42 37.19c28.68 16.57 38.51 53.26 21.94 81.94-7.01 12.14-18.05 21.44-31.2 26.28v-75.81c.03-3.74-1.96-7.2-5.2-9.06zm26.8-40.34c-.47-.29-1.3-.79-1.89-1.13l-63.72-36.8c-3.23-1.89-7.23-1.89-10.47 0l-77.79 44.92v-31.1c-.02-.32.13-.63.38-.83l64.41-37.16c28.69-16.55 65.37-6.7 81.91 22 6.99 12.12 9.52 26.31 7.15 40.1zm-168.51 55.43-26.94-15.55c-.29-.14-.48-.42-.52-.74v-74.39c.02-33.12 26.89-59.96 60.01-59.94 14.01 0 27.57 4.92 38.34 13.88-.49.26-1.33.73-1.89 1.07l-63.72 36.8c-3.26 1.85-5.26 5.31-5.24 9.06l-.04 89.79zm14.63-31.54 34.65-20.01 34.65 20v40.01l-34.65 20-34.65-20z"
- />
- </svg>
- </NButton>
- </template>
- <template #default>
- {{
- showAIChatBox
- ? $t("plugin.ai.disable-chat-sql")
- : $t("plugin.ai.enable-chat-sql")
- }}
- </template>
- </NTooltip>
-</template>
-
-<script setup lang="ts">
-import type { ButtonProps } from "naive-ui";
-import { NButton, NTooltip } from "naive-ui";
-import { computed } from "vue";
-import { useSettingV1Store, useSQLEditorTabStore } from "@/store";
-import { useSQLEditorContext } from "../context";
-
-const tabStore = useSQLEditorTabStore();
-const settingV1Store = useSettingV1Store();
-const openAIKeySetting = computed(() =>
- settingV1Store.getSettingByName("bb.plugin.openai.key")
-);
-const openAIKey = computed(
- () => openAIKeySetting.value?.value?.stringValue ?? ""
-);
-
-const { showAIChatBox } = useSQLEditorContext();
-
-const showButton = computed(() => {
- return openAIKey.value && !tabStore.isDisconnected;
-});
-
-const buttonProps = computed(() => {
- const props: ButtonProps = {};
- if (showAIChatBox.value) {
- props.secondary = true;
- props.type = "primary";
- } else {
- props.quaternary = true;
- props.type = "default";
- }
- return props;
-});
-</script>
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue
index 444c5be5f6..be958bf7c0 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue
@@ -265,7 +265,10 @@ watch(tree, () => {
padding: 0;
}
.schema-tree :deep(.n-tree-node-indent) {
- width: 0.5rem;
+ width: 1rem;
+}
+.schema-tree :deep(.n-tree-node-switcher--hide) {
+ width: 0.5rem !important;
}
.schema-tree :deep(.n-tree-node-content__prefix) {
@apply shrink-0 !mr-1;
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/ColumnNode.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/ColumnNode.vue
index e048705507..211908bd5a 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/ColumnNode.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/ColumnNode.vue
@@ -1,5 +1,8 @@
<template>
<div class="flex items-center max-w-full overflow-hidden gap-x-1">
+ <PrimaryKeyIcon v-if="isPrimaryKey" class="w-4 h-4" />
+ <IndexIcon v-else-if="isIndex" class="!w-4 !h-4 text-gray-500" />
+ <div v-else class="w-4 h-4" />
<HighlightLabelText
:text="target.column.name"
:keyword="keyword"
@@ -10,6 +13,7 @@
<script setup lang="ts">
import { computed } from "vue";
+import { IndexIcon, PrimaryKeyIcon } from "@/components/Icon";
import type { TreeNode } from "../common";
import HighlightLabelText from "./HighlightLabelText.vue";
@@ -19,4 +23,25 @@ const props = defineProps<{
}>();
const target = computed(() => (props.node as TreeNode<"column">).meta.target);
+
+const isPrimaryKey = computed(() => {
+ if ("table" in target.value) {
+ const { table, column } = target.value;
+ const pk = table.indexes.find((idx) => idx.primary);
+ if (!pk) return false;
+ return pk.expressions.includes(column.name);
+ }
+
+ return false;
+});
+const isIndex = computed(() => {
+ if (isPrimaryKey.value) return false;
+
+ if ("table" in target.value) {
+ const { table, column } = target.value;
+ return table.indexes.some((idx) => idx.expressions.includes(column.name));
+ }
+
+ return false;
+});
</script>
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts
index 90e8a90e36..c8ed1f8a1b 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts
@@ -38,8 +38,8 @@ export type RichExternalTableMetadata = RichSchemaMetadata & {
externalTable: ExternalTableMetadata;
};
export type RichColumnMetadata = (
- | RichSchemaMetadata
- | RichPartitionTableMetadata
+ | RichTableMetadata
+ | RichExternalTableMetadata
) & {
column: ColumnMetadata;
};
@@ -230,6 +230,9 @@ export const mapTreeNodeByType = <T extends NodeType>(
isLeaf: isLeafNodeType(type),
...overrides,
};
+ if (type === "column") {
+ console.log(node.isLeaf);
+ }
return node;
};
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
index d958d0e0da..f1cb46faa1 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
@@ -364,7 +364,10 @@ onMounted(() => calcDefaultExpandKeys(false));
padding: 0;
}
.sql-editor-tree :deep(.n-tree-node-indent) {
- width: 0.25rem;
+ width: 1rem;
+}
+.sql-editor-tree :deep(.n-tree-node-switcher--hide) {
+ width: 0.5rem !important;
}
.sql-editor-tree :deep(.n-tree-node-content__prefix) {
@apply shrink-0 !mr-1;
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
index 7140bd12a0..9c82352062 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
@@ -25,15 +25,17 @@
<div class="flex flex-row gap-x-2 text-main">
<NPopover :disabled="!isProductionEnvironment">
<template #trigger>
- <div
- class="inline-flex items-center px-2 border text-sm rounded-sm"
- :class="[
- isProductionEnvironment
- ? 'border-error text-error'
- : 'border-main text-main',
- ]"
- >
- {{ environment.title }}
+ <div class="inline-flex items-center text-sm rounded-sm bg-white">
+ <span
+ class="px-2 rounded-sm"
+ :class="[
+ isProductionEnvironment
+ ? 'text-error bg-error/15'
+ : 'text-main bg-control-bg',
+ ]"
+ >
+ {{ environment.title }}
+ </span>
</div>
</template>
<template #default>
diff --git a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
index d927bc158d..3e6a150469 100644
--- a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
@@ -37,12 +37,6 @@
({{ keyboardShortcutStr("cmd_or_ctrl+E") }})
</span>
</NButton>
- <NButton size="small" :disabled="!allowQuery" @click="handleFormatSQL">
- <span>{{ $t("sql-editor.format") }}</span>
- <span v-show="showShortcutText" class="ml-1">
- ({{ keyboardShortcutStr("shift+opt_or_alt+F") }})
- </span>
- </NButton>
<NButton
v-if="showClearScreen"
size="small"
@@ -273,10 +267,6 @@ const handleExplainQuery = () => {
});
};
-const handleFormatSQL = () => {
- events.emit("format-content");
-};
-
const handleClearScreen = () => {
emit("clear-screen");
};
diff --git a/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue b/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue
index 3dc8cbc31f..2ba53879eb 100644
--- a/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue
+++ b/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue
@@ -80,10 +80,10 @@ const isCurrentTab = computed(() => props.tab.id === tabStore.currentTabId);
}
.body {
- @apply flex items-center justify-between gap-x-1 pl-2 pr-1 pb-1 border-t pt-[4px];
+ @apply flex items-center justify-between gap-x-1 pl-2 pr-1 border-t pt-[4px] h-[36px];
}
.current .body {
- @apply relative bg-white text-accent border-t-accent border-t-2 pt-[3px];
+ @apply relative bg-white text-accent border-t-accent border-t-[3px] pt-[2px];
}
.tab-item.admin .body {
diff --git a/frontend/src/views/sql-editor/TabList/TabList.vue b/frontend/src/views/sql-editor/TabList/TabList.vue
index c5e699adc0..980f38a022 100644
--- a/frontend/src/views/sql-editor/TabList/TabList.vue
+++ b/frontend/src/views/sql-editor/TabList/TabList.vue
@@ -1,8 +1,8 @@
<template>
<div
- class="flex justify-between items-center box-border text-gray-500 text-sm border-b pr-2 pt-1"
+ class="flex justify-between items-center box-border text-gray-500 text-sm border-b pr-2 pt-0.5"
>
- <div class="relative flex flex-1 flex-nowrap overflow-hidden h-[29px]">
+ <div class="relative flex flex-1 flex-nowrap overflow-hidden h-[36px]">
<Draggable
id="tab-list"
ref="tabListRef"