Skip to content

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

feat(sql-editor): add "Add a new instance" to SQL Editor welcome page (#12551)

Liu Ji8f99c7112100
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 3b16af43bb..113bd9fc1f 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2371,7 +2371,8 @@
"standard-mode": {
"self": "Standard mode"
},
- "to-enable-standard-mode": "to enable the standard mode"
+ "to-enable-standard-mode": "to enable the standard mode",
+ "add-a-new-instance": "Add a new instance"
},
"schema-editor": {
"self": "Schema Editor",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index fc4e425f08..b61078969d 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2371,7 +2371,8 @@
"standard-mode": {
"self": "Modo estandar"
},
- "to-enable-standard-mode": "para habilitar el modo estándar"
+ "to-enable-standard-mode": "para habilitar el modo estándar",
+ "add-a-new-instance": "Agregar una nueva instancia"
},
"schema-editor": {
"self": "Editor de esquema",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 4f49407338..d78742ec0b 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2371,7 +2371,8 @@
"standard-mode": {
"self": "標準モード"
},
- "to-enable-standard-mode": "標準モードを有効にするには"
+ "to-enable-standard-mode": "標準モードを有効にするには",
+ "add-a-new-instance": "新しいインスタンスを追加する"
},
"schema-editor": {
"self": "スキーマエディタ",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 901d0c8c33..c9859e791c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2371,7 +2371,8 @@
"standard-mode": {
"self": "标准模式"
},
- "to-enable-standard-mode": "来开启标准模式"
+ "to-enable-standard-mode": "来开启标准模式",
+ "add-a-new-instance": "添加实例"
},
"schema-editor": {
"self": "Schema 编辑器",
@@ -3588,4 +3589,4 @@
"self": "最后更新"
}
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue b/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue
index 7e4632804d..3992891b14 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ExecuteHint.vue
@@ -45,9 +45,7 @@
@click="handleClickActionButton"
>
<template v-if="actions.action === 'CREATE_ISSUE'">
- {{
- isDDL ? $t("database.edit-schema") : $t("database.change-data")
- }}
+ {{ descriptions.action }}
</template>
<template v-if="actions.action === 'STANDARD_MODE'">
{{ $t("sql-editor.standard-mode.self") }}
@@ -133,7 +131,7 @@ const descriptions = computed(() => {
};
const { admin, action } = actions.value;
if (action === "CREATE_ISSUE") {
- descriptions.action = isDDL
+ descriptions.action = isDDL.value
? t("database.edit-schema")
: t("database.change-data");
descriptions.reaction = t("sql-editor.and-submit-an-issue");
diff --git a/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue b/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue
index 3bab44a4f6..454357f318 100644
--- a/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue
@@ -16,7 +16,9 @@
</template>
</Suspense>
</template>
- <Welcome v-else />
+ <template v-else>
+ <Welcome />
+ </template>
</template>
<Suspense>
@@ -85,12 +87,12 @@ const handleApplyStatement = async (
};
watch(
- [() => tab.value, standardModeEnabled],
- ([tab, standardModeEnabled]) => {
- if (!tab) return;
- // Fallback to READONLY mode if standard mode is not allowed.
- if (!standardModeEnabled && tab.mode === "STANDARD") {
- tab.mode = "READONLY";
+ [() => tab.value?.id, standardModeEnabled],
+ () => {
+ if (!tab.value) return;
+ // Fallback to READONLY mode if standard.value mode is not allowed.
+ if (!standardModeEnabled.value && tab.value.mode === "STANDARD") {
+ tab.value.mode = "READONLY";
}
},
{
diff --git a/frontend/src/views/sql-editor/EditorPanel/Welcome.vue b/frontend/src/views/sql-editor/EditorPanel/Welcome.vue
index 1d4d699bfa..2e553e5805 100644
--- a/frontend/src/views/sql-editor/EditorPanel/Welcome.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/Welcome.vue
@@ -3,16 +3,35 @@
class="w-full h-auto flex-grow flex flex-col items-center justify-center"
>
<HideInStandaloneMode>
- <BytebaseLogo component="span" class="mb-4 -mt-[20%]" />
+ <BytebaseLogo component="span" class="mb-4 -mt-[10vh]" />
</HideInStandaloneMode>
- <div class="flex flex-col items-start gap-y-1 w-max">
- <NButton type="primary" class="!w-full !justify-start" @click="changeConnection">
+ <div class="flex flex-col items-start gap-y-2 w-max">
+ <NButton
+ type="primary"
+ class="!w-full !justify-start"
+ @click="changeConnection"
+ >
<template #icon>
<LinkIcon class="w-4 h-4" />
</template>
{{ $t("sql-editor.connect-to-a-database") }}
</NButton>
- <NButton quaternary class="!w-full !justify-start" @click="createNewWorksheet">
+ <NButton
+ v-if="showCreateInstanceButton"
+ type="default"
+ class="!w-full !justify-start"
+ @click="gotoInstanceCreatePage"
+ >
+ <template #icon>
+ <LayersIcon class="w-4 h-4" />
+ </template>
+ {{ $t("sql-editor.add-a-new-instance") }}
+ </NButton>
+ <NButton
+ type="default"
+ class="!w-full !justify-start"
+ @click="createNewWorksheet"
+ >
<template #icon>
<SquarePenIcon class="w-4 h-4" />
</template>
@@ -23,13 +42,27 @@
</template>
<script setup lang="ts">
-import { LinkIcon, SquarePenIcon } from "lucide-vue-next";
+import { LayersIcon, LinkIcon, SquarePenIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
+import { computed } from "vue";
+import { useRouter } from "vue-router";
import BytebaseLogo from "@/components/BytebaseLogo.vue";
+import { SQL_EDITOR_SETTING_INSTANCE_MODULE } from "@/router/sqlEditor";
import { useSQLEditorTabStore } from "@/store";
+import { useSidebarItems as useSettingItems } from "../Setting/Sidebar";
import { useSQLEditorContext } from "../context";
const { showConnectionPanel } = useSQLEditorContext();
+const { itemList: settingItemList } = useSettingItems();
+const router = useRouter();
+
+const showCreateInstanceButton = computed(() => {
+ return (
+ settingItemList.value.findIndex(
+ (item) => item.name === SQL_EDITOR_SETTING_INSTANCE_MODULE
+ ) >= 0
+ );
+});
const changeConnection = () => {
showConnectionPanel.value = true;
@@ -38,4 +71,18 @@ const changeConnection = () => {
const createNewWorksheet = () => {
useSQLEditorTabStore().addTab();
};
+
+const gotoInstanceCreatePage = () => {
+ if (
+ settingItemList.value.findIndex(
+ (item) => item.name === SQL_EDITOR_SETTING_INSTANCE_MODULE
+ ) < 0
+ ) {
+ return;
+ }
+ router.push({
+ name: SQL_EDITOR_SETTING_INSTANCE_MODULE,
+ hash: `#add`,
+ });
+};
</script>
diff --git a/frontend/src/views/sql-editor/context.ts b/frontend/src/views/sql-editor/context.ts
index 02e3277cb5..9bdf0bdda6 100644
--- a/frontend/src/views/sql-editor/context.ts
+++ b/frontend/src/views/sql-editor/context.ts
@@ -1,10 +1,7 @@
import Emittery from "emittery";
import type { InjectionKey, Ref } from "vue";
import { computed, inject, provide, ref } from "vue";
-import {
- useSQLEditorStore,
- useSettingV1Store,
-} from "@/store";
+import { useSQLEditorStore, useSettingV1Store } from "@/store";
import type { ComposedDatabase, SQLEditorTab } from "@/types";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
import type { Worksheet } from "@/types/proto/v1/worksheet_service";
@@ -67,7 +64,7 @@ export const provideSQLEditorContext = () => {
standardModeEnabled: computed(() => {
return (
useSettingV1Store().workspaceProfileSetting?.databaseChangeMode ===
- DatabaseChangeMode.EDITOR
+ DatabaseChangeMode.EDITOR
);
}),