Skip to content

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

feat(sql-editor): simple mobile layout for sql editor (#4813)

Liu Ji29c82976936b
diff --git a/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue b/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue
index e1698c8a42..5bdf67f369 100644
--- a/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/AdminModeButton.vue
@@ -5,7 +5,7 @@
:disabled="tabStore.isDisconnected"
@click="enterAdminMode"
>
- <heroicons-outline:wrench />
+ <heroicons-outline:wrench class="-ml-1" />
<span class="ml-1"> {{ $t("sql-editor.admin-mode.self") }} </span>
</NButton>
</template>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
index 2ace55012e..d451e813bb 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
@@ -1,9 +1,11 @@
<template>
<div
v-if="!tabStore.isDisconnected"
- class="w-full flex justify-between items-start bg-white"
+ class="w-full block lg:flex justify-between items-start bg-white"
>
- <div class="flex justify-start items-center h-8 px-4">
+ <div
+ class="flex justify-start items-center h-8 px-4 whitespace-nowrap overflow-x-auto"
+ >
<NPopover v-if="showReadonlyDatasourceWarning" trigger="hover">
<template #trigger>
<heroicons-outline:exclamation
@@ -65,7 +67,7 @@
<div
v-if="isProductionEnvironment"
- class="flex justify-start items-center h-8 px-4 rounded-bl text-white bg-error"
+ class="flex justify-start items-center py-1 sm:py-0 sm:h-8 px-4 sm:rounded-bl text-white bg-error"
>
{{ $t("sql-editor.sql-execute-in-production-environment") }}
</div>
diff --git a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
index 8068bdfeff..c9aa51af7b 100644
--- a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
@@ -1,36 +1,51 @@
<template>
- <div class="w-full flex justify-between items-center p-4 border-b bg-white">
- <div class="action-left space-x-2 flex items-center">
+ <div
+ class="w-full flex flex-wrap gap-y-2 justify-between sm:items-center p-4 border-b bg-white"
+ >
+ <div
+ class="action-left gap-x-2 flex overflow-x-auto sm:overflow-x-hidden items-center"
+ >
<NButton
type="primary"
:disabled="isEmptyStatement || isExecutingSQL"
@click="handleRunQuery"
>
- <mdi:play class="h-5 w-5" />
- {{ showRunSelected ? $t("sql-editor.run-selected") : $t("common.run") }}
- (⌘+⏎)
+ <mdi:play class="h-5 w-5 -ml-1.5" />
+ <span>
+ {{
+ showRunSelected ? $t("sql-editor.run-selected") : $t("common.run")
+ }}
+ </span>
+
+ <span class="hidden sm:inline">(⌘+⏎)</span>
</NButton>
<NButton
:disabled="isEmptyStatement || isExecutingSQL"
@click="handleExplainQuery"
>
- <mdi:play class="h-5 w-5" /> Explain (⌘+E)
+ <mdi:play class="h-5 w-5 -ml-1.5" />
+ <span>Explain</span>
+ <span class="hidden sm:inline">(⌘+E)</span>
</NButton>
<NButton
:disabled="isEmptyStatement || isExecutingSQL"
@click="handleFormatSQL"
>
- {{ $t("sql-editor.format") }} (⇧+⌥+F)
+ <span>{{ $t("sql-editor.format") }}</span>
+ <span class="hidden sm:inline">(⇧+⌥+F)</span>
</NButton>
<NButton
v-if="showClearScreen"
:disabled="queryList.length <= 1 || isExecutingSQL"
@click="handleClearScreen"
>
- {{ $t("sql-editor.clear-screen") }} (⇧+⌥+C)
+ <span>{{ $t("sql-editor.clear-screen") }}</span>
+ <span class="hidden sm:inline">(⇧+⌥+C)</span>
</NButton>
</div>
- <div class="action-right space-x-2 flex justify-end items-center">
+ <div
+ class="action-right gap-x-2 flex overflow-x-auto sm:overflow-x-hidden sm:justify-end items-center"
+ >
<AdminModeButton />
<template v-if="showSheetsFeature">
@@ -41,7 +56,9 @@
:disabled="!allowSave"
@click="() => emit('save-sheet')"
>
- <carbon:save class="h-5 w-5" /> &nbsp; {{ $t("common.save") }} (⌘+S)
+ <carbon:save class="h-5 w-5 -ml-1" />
+ <span class="ml-1">{{ $t("common.save") }}</span>
+ <span class="hidden sm:inline ml-1">(⌘+S)</span>
</NButton>
<NPopover trigger="click" placement="bottom-end" :show-arrow="false">
<template #trigger>
diff --git a/frontend/src/views/sql-editor/EditorCommon/TableView.vue b/frontend/src/views/sql-editor/EditorCommon/TableView.vue
index 4c0069ecab..e782855c1d 100644
--- a/frontend/src/views/sql-editor/EditorCommon/TableView.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/TableView.vue
@@ -6,13 +6,13 @@
>
<div
v-show="queryResult !== null"
- class="w-full flex flex-row justify-between items-center mb-2"
+ class="w-full flex flex-row justify-between items-center mb-2 overflow-x-auto"
>
- <div class="flex flex-row justify-start items-center mr-2">
+ <div class="flex flex-row justify-start items-center mr-2 shrink-0">
<NInput
v-if="showSearchFeature"
v-model:value="state.search"
- class="max-w-xs"
+ class="!max-w-[8rem] sm:!max-w-xs"
type="text"
:placeholder="t('sql-editor.search-results')"
>
diff --git a/frontend/src/views/sql-editor/SQLEditorPage.vue b/frontend/src/views/sql-editor/SQLEditorPage.vue
index 4c00d3c6d4..8ef33e53ad 100644
--- a/frontend/src/views/sql-editor/SQLEditorPage.vue
+++ b/frontend/src/views/sql-editor/SQLEditorPage.vue
@@ -2,10 +2,40 @@
<div class="sqleditor--wrapper">
<TabList />
<Splitpanes class="default-theme flex flex-col flex-1 overflow-hidden">
- <Pane size="20">
+ <Pane v-if="windowWidth >= 800" size="20">
<AsidePanel @alter-schema="handleAlterSchema" />
</Pane>
- <Pane size="80" class="relative">
+ <template v-else>
+ <teleport to="body">
+ <div
+ id="fff"
+ class="fixed rounded-full border border-control-border shadow-lg w-10 h-10 bottom-[4rem] flex items-center justify-center bg-white hover:bg-control-bg cursor-pointer z-[99999999] transition-all"
+ :class="[
+ state.sidebarExpanded
+ ? 'left-[80%] -translate-x-5'
+ : 'left-[1rem]',
+ ]"
+ style="
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
+ transition-duration: 300ms;
+ "
+ @click="state.sidebarExpanded = !state.sidebarExpanded"
+ >
+ <heroicons-outline:chevron-left
+ class="w-6 h-6 transition-transform"
+ :class="[state.sidebarExpanded ? '' : '-scale-100']"
+ />
+ </div>
+ <NDrawer
+ v-model:show="state.sidebarExpanded"
+ width="80vw"
+ placement="left"
+ >
+ <AsidePanel @alter-schema="handleAlterSchema" />
+ </NDrawer>
+ </teleport>
+ </template>
+ <Pane class="relative">
<template v-if="allowAccess">
<template v-if="tabStore.currentTab.mode === TabMode.ReadOnly">
<Splitpanes
@@ -80,6 +110,7 @@
import { computed, reactive } from "vue";
import { Splitpanes, Pane } from "splitpanes";
import { stringify } from "qs";
+import { NDrawer } from "naive-ui";
import { DatabaseId, TabMode, UNKNOWN_ID } from "@/types";
import {
@@ -99,12 +130,21 @@ import TablePanel from "./TablePanel/TablePanel.vue";
import { allowUsingSchemaEditor, isDatabaseAccessible } from "@/utils";
import AdminModeButton from "./EditorCommon/AdminModeButton.vue";
import SchemaEditorModal from "@/components/AlterSchemaPrepForm/SchemaEditorModal.vue";
+import { useWindowSize } from "@vueuse/core";
+
+type LocalState = {
+ sidebarExpanded: boolean;
+};
type AlterSchemaState = {
showModal: boolean;
databaseIdList: DatabaseId[];
};
+const state = reactive<LocalState>({
+ sidebarExpanded: false,
+});
+
const tabStore = useTabStore();
const databaseStore = useDatabaseStore();
const connectionTreeStore = useConnectionTreeStore();
@@ -114,6 +154,8 @@ const currentUser = useCurrentUser();
const isDisconnected = computed(() => tabStore.isDisconnected);
const isFetchingSheet = computed(() => sqlEditorStore.isFetchingSheet);
+const { width: windowWidth } = useWindowSize();
+
const allowAccess = computed(() => {
const { databaseId } = tabStore.currentTab.connection;
const database = databaseStore.getDatabaseById(databaseId);