Skip to content

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

feat(instance): redesign create instance as full-page layout (#19528)

Vincent Huangdacd7c22b92b
diff --git a/frontend/src/components/InstanceForm/Buttons.vue b/frontend/src/components/InstanceForm/Buttons.vue
index 4b1cd010ea..975a3e1532 100644
--- a/frontend/src/components/InstanceForm/Buttons.vue
+++ b/frontend/src/components/InstanceForm/Buttons.vue
@@ -1,14 +1,25 @@
<template>
<template v-if="isCreating">
- <div class="w-full flex justify-between items-center" v-bind="$attrs">
- <div class="w-full flex justify-end items-center gap-x-2">
+ <div
+ class="w-full py-4 border-t border-block-border flex justify-between bg-white"
+ v-bind="$attrs"
+ >
+ <NButton
+ v-if="allowCancel"
+ :disabled="state.isRequesting || state.isTestingConnection"
+ @click.prevent="cancel"
+ >
+ {{ $t("common.cancel") }}
+ </NButton>
+ <div class="flex items-center gap-x-2">
<NButton
- v-if="allowCancel"
- quaternary
- :disabled="state.isRequesting || state.isTestingConnection"
- @click.prevent="cancel"
+ tertiary
+ type="primary"
+ :loading="state.isTestingConnection"
+ :disabled="!allowCreate || state.isRequesting || !allowEdit"
+ @click.prevent="testConnectionForCurrentEditingDS"
>
- {{ $t("common.cancel") }}
+ {{ $t("instance.test-connection") }}
</NButton>
<NButton
:disabled="
@@ -35,16 +46,27 @@
>
<span> {{ $t("common.cancel") }}</span>
</NButton>
- <NButton
- :disabled="
- !allowUpdate || state.isRequesting || state.isTestingConnection
- "
- :loading="state.isRequesting"
- type="primary"
- @click.prevent="doUpdate"
- >
- {{ $t("common.confirm-and-update") }}
- </NButton>
+ <div class="flex items-center gap-x-2">
+ <NButton
+ tertiary
+ type="primary"
+ :loading="state.isTestingConnection"
+ :disabled="!allowUpdate || state.isRequesting || !allowEdit"
+ @click.prevent="testConnectionForCurrentEditingDS"
+ >
+ {{ $t("instance.test-connection") }}
+ </NButton>
+ <NButton
+ :disabled="
+ !allowUpdate || state.isRequesting || state.isTestingConnection
+ "
+ :loading="state.isRequesting"
+ type="primary"
+ @click.prevent="doUpdate"
+ >
+ {{ $t("common.confirm-and-update") }}
+ </NButton>
+ </div>
</div>
</template>
</template>
@@ -107,6 +129,7 @@ const {
basicInfo,
labelKVList,
adminDataSource,
+ editingDataSource,
readonlyDataSourceList,
dataSourceEditState,
hasReadonlyReplicaFeature,
@@ -525,6 +548,12 @@ const doUpdate = async () => {
}
};
+const testConnectionForCurrentEditingDS = () => {
+ const editingDS = editingDataSource.value;
+ if (!editingDS) return;
+ testConnection(editingDS, /* !silent */ false);
+};
+
const cancel = () => {
events.emit("dismiss");
};
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
index e453b6c067..af90afa59f 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
@@ -1,6 +1,7 @@
<template>
<!-- eslint-disable vue/no-mutating-props -->
<div class="grid grid-cols-1 gap-y-4 gap-x-4 border-none sm:grid-cols-3">
+ <template v-if="!optionsOnly">
<template
v-if="
basicInfo.engine !== Engine.SPANNER &&
@@ -19,19 +20,21 @@
"
class="sm:col-span-3 sm:col-start-1"
>
- <NRadioGroup
- v-model:value="dataSource.authenticationType"
- class="textlabel"
- :disabled="!allowEdit"
- >
- <NRadio
- v-for="item in supportedAuthenticationTypes"
- :key="item.value"
- :value="item.value"
+ <div class="flex items-center gap-x-2">
+ <NRadioGroup
+ v-model:value="dataSource.authenticationType"
+ class="textlabel"
+ :disabled="!allowEdit"
>
- {{ item.label }}
- </NRadio>
- </NRadioGroup>
+ <NRadio
+ v-for="item in supportedAuthenticationTypes"
+ :key="item.value"
+ :value="item.value"
+ >
+ {{ item.label }}
+ </NRadio>
+ </NRadioGroup>
+ </div>
</div>
<div
v-else-if="basicInfo.engine === Engine.HIVE"
@@ -48,8 +51,9 @@
</NRadioGroup>
</div>
<CreateDataSourceExample
+ v-if="!isCreating"
class-name="sm:col-span-3 border-none"
- :create-instance-flag="isCreating"
+ :create-instance-flag="false"
:engine="basicInfo.engine"
:data-source-type="dataSource.type"
:authentication-type="dataSource.authenticationType"
@@ -934,7 +938,9 @@ MIIEvQ...
:placeholder="$t('common.database')"
/>
</div>
+ </template>
+ <template v-if="!hideOptions">
<div v-if="hasExtraParameters" class="sm:col-span-3 sm:col-start-1">
<div class="flex flex-row items-center justify-between">
<label class="textlabel block">
@@ -1030,6 +1036,10 @@ MIIEvQ...
:value="dataSource.useSsl"
@update:value="handleUseSslChanged"
/>
+ <InfoTrigger
+ v-if="isCreating && infoPanel"
+ @click="openInfoPanel('ssl')"
+ />
</div>
<template v-if="dataSource.useSsl">
<SslCertificateFormV1
@@ -1065,6 +1075,10 @@ MIIEvQ...
<label for="ssh" class="textlabel block">
{{ $t("data-source.ssh-connection") }}
</label>
+ <InfoTrigger
+ v-if="isCreating && infoPanel"
+ @click="openInfoPanel('ssh')"
+ />
</div>
<SshConnectionForm
:value="dataSource"
@@ -1073,6 +1087,7 @@ MIIEvQ...
@change="handleSSHChange"
/>
</div>
+ </template>
</div>
</template>
@@ -1088,7 +1103,7 @@ import {
NUploadDragger,
type UploadFileInfo,
} from "naive-ui";
-import { computed, reactive, watch } from "vue";
+import { computed, inject, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBTextField } from "@/bbkit";
import { FeatureBadge } from "@/components/FeatureGuard";
@@ -1114,6 +1129,8 @@ import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { onlyAllowNumber } from "@/utils";
import type { EditDataSource } from "../common";
import { useInstanceFormContext } from "../context";
+import InfoTrigger from "../InfoTrigger.vue";
+import type { InfoSection } from "../info-content";
import CreateDataSourceExample from "./CreateDataSourceExample.vue";
import CredentialSourceForm from "./CredentialSourceForm.vue";
import OracleSIDAndServiceNameInput from "./OracleSIDAndServiceNameInput.vue";
@@ -1129,9 +1146,17 @@ interface ExtraConnectionParam {
value: string;
}
-const props = defineProps<{
- dataSource: EditDataSource;
-}>();
+const props = withDefaults(
+ defineProps<{
+ dataSource: EditDataSource;
+ hideOptions?: boolean;
+ optionsOnly?: boolean;
+ }>(),
+ {
+ hideOptions: false,
+ optionsOnly: false,
+ }
+);
const {
instance,
@@ -1145,6 +1170,19 @@ const {
hideAdvancedFeatures,
} = useInstanceFormContext();
+const infoPanel = inject<
+ | {
+ open: (section: InfoSection) => void;
+ close: () => void;
+ setEngine: (engine: Engine) => void;
+ }
+ | undefined
+>("infoPanel", undefined);
+
+const openInfoPanel = (section: InfoSection) => {
+ infoPanel?.open(section);
+};
+
const {
showDatabase,
showSSL,
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue
index 41f150e4db..6a9bb6227d 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue
@@ -9,11 +9,24 @@
@add-readonly-datasource="handleCreateRODataSource"
/>
- <DataSourceForm v-if="editingDataSource" :data-source="editingDataSource" />
+ <DataSourceForm
+ v-if="editingDataSource"
+ :data-source="editingDataSource"
+ :hide-options="hideOptions"
+ />
</div>
</template>
<script setup lang="ts">
+withDefaults(
+ defineProps<{
+ hideOptions?: boolean;
+ }>(),
+ {
+ hideOptions: false,
+ }
+);
+
import { DATASOURCE_READONLY_USER_NAME } from "@/types";
import { Engine } from "@/types/proto-es/v1/common_pb";
import { DataSourceType } from "@/types/proto-es/v1/instance_service_pb";
diff --git a/frontend/src/components/InstanceForm/Form.vue b/frontend/src/components/InstanceForm/Form.vue
index 74acd4e72b..6856591121 100644
--- a/frontend/src/components/InstanceForm/Form.vue
+++ b/frontend/src/components/InstanceForm/Form.vue
@@ -1,488 +1,500 @@
<template>
<div class="flex flex-col gap-y-6 pb-2">
- <div class="max-w-212.5">
- <InstanceEngineRadioGrid
- v-if="isCreating"
- :engine="basicInfo.engine"
- :engine-list="supportedEngineV1List()"
- class="w-full grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2"
- @update:engine="(newEngine: Engine) => changeInstanceEngine(newEngine)"
- >
- <template #suffix="{ engine }">
- <NTag
- v-if="isEngineBeta(engine as Engine)"
- round
- size="small"
- type="info"
+ <InstanceEngineRadioGrid
+ v-if="isCreating"
+ :engine="basicInfo.engine"
+ :engine-list="supportedEngineV1List()"
+ class="w-full grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2"
+ @update:engine="(newEngine: Engine) => changeInstanceEngine(newEngine)"
+ >
+ <template #suffix="{ engine }">
+ <NTag
+ v-if="isEngineBeta(engine as Engine)"
+ round
+ size="small"
+ type="info"
+ >
+ Beta
+ </NTag>
+ </template>
+ </InstanceEngineRadioGrid>
+
+ <div class="max-w-212.5 flex flex-col gap-y-6">
+ <!-- Basic Info Card -->
+ <div class="border border-block-border rounded-lg p-5">
+ <h3 class="text-base font-medium text-main">
+ {{ $t("instance.section.basic-info") }}
+ </h3>
+
+ <div class="grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">
+ <div class="sm:col-span-2 sm:col-start-1">
+ <label for="name" class="textlabel flex flex-row items-center">
+ {{ $t("instance.instance-name") }}
+ <RequiredStar class="ml-0.5" />
+ <div v-if="instance" class="ml-2 flex items-center">
+ <InstanceV1EngineIcon :instance="instance" :tooltip="false" />
+ <span class="ml-1">{{ instance.engineVersion }}</span>
+ </div>
+ </label>
+ <NInput
+ v-model:value="basicInfo.title"
+ required
+ class="mt-1 w-full"
+ :disabled="!allowEdit"
+ :maxlength="200"
+ />
+ </div>
+
+ <div
+ v-if="subscriptionStore.currentPlan !== PlanType.FREE && allowEdit"
+ class="sm:col-span-2 ml-0 sm:ml-3"
>
- Beta
- </NTag>
- </template>
- </InstanceEngineRadioGrid>
-
- <NDivider />
-
- <!-- Instance Name -->
- <div class="grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">
- <div class="sm:col-span-2 sm:col-start-1">
- <label for="name" class="textlabel flex flex-row items-center">
- {{ $t("instance.instance-name") }}
- <RequiredStar class="ml-0.5" />
- <div v-if="instance" class="ml-2 flex items-center">
- <InstanceV1EngineIcon :instance="instance" :tooltip="false" />
- <span class="ml-1">{{ instance.engineVersion }}</span>
+ <label for="activation" class="textlabel block">
+ {{ $t("subscription.instance-assignment.assign-license") }}
+ (<router-link
+ :to="autoSubscriptionRoute()"
+ class="accent-link"
+ >
+ {{
+ $t("subscription.instance-assignment.n-license-remain", {
+ n: availableLicenseCountText,
+ })
+ }}</router-link
+ >)
+ </label>
+ <div class="h-8.5 flex flex-row items-center mt-1">
+ <NSwitch
+ :value="basicInfo.activation"
+ :disabled="!basicInfo.activation && availableLicenseCount === 0"
+ @update:value="changeInstanceActivation"
+ />
</div>
- </label>
- <NInput
- v-model:value="basicInfo.title"
- required
- class="mt-1 w-full"
- :disabled="!allowEdit"
- :maxlength="200"
- />
- </div>
+ </div>
- <div
- v-if="subscriptionStore.currentPlan !== PlanType.FREE && allowEdit"
- class="sm:col-span-2 ml-0 sm:ml-3"
- >
- <label for="activation" class="textlabel block">
- {{ $t("subscription.instance-assignment.assign-license") }}
- (<router-link
- :to="autoSubscriptionRoute()"
- class="accent-link"
- >
- {{
- $t("subscription.instance-assignment.n-license-remain", {
- n: availableLicenseCountText,
- })
- }}</router-link
- >)
- </label>
- <div class="h-8.5 flex flex-row items-center mt-1">
- <NSwitch
- :value="basicInfo.activation"
- :disabled="!basicInfo.activation && availableLicenseCount === 0"
- @update:value="changeInstanceActivation"
+ <div
+ :key="basicInfo.environment"
+ class="sm:col-span-3 sm:col-start-1 -mt-4"
+ >
+ <ResourceIdField
+ ref="resourceIdField"
+ v-model:value="resourceId"
+ class="max-w-full flex-nowrap"
+ editing-class="mt-4"
+ resource-type="instance"
+ :readonly="!isCreating"
+ :resource-title="basicInfo.title"
+ :fetch-resource="
+ (id) =>
+ instanceV1Store.getOrFetchInstanceByName(
+ `${instanceNamePrefix}${id}`,
+ true /* silent */
+ )
+ "
/>
</div>
- </div>
- <div
- :key="basicInfo.environment"
- class="sm:col-span-3 sm:col-start-1 -mt-4"
- >
- <ResourceIdField
- ref="resourceIdField"
- v-model:value="resourceId"
- class="max-w-full flex-nowrap"
- editing-class="mt-4"
- resource-type="instance"
- :readonly="!isCreating"
- :resource-title="basicInfo.title"
- :fetch-resource="
- (id) =>
- instanceV1Store.getOrFetchInstanceByName(
- `${instanceNamePrefix}${id}`,
- true /* silent */
+ <div class="sm:col-span-2 sm:col-start-1">
+ <label for="environment" class="textlabel">
+ {{ $t("common.environment") }}
+ </label>
+ <EnvironmentSelect
+ class="mt-1 w-full"
+ required="true"
+ :value="
+ isValidEnvironmentName(
+ `${environmentNamePrefix}${environment.id}`
)
- "
+ ? `${environmentNamePrefix}${environment.id}`
+ : undefined
+ "
+ :disabled="!allowEdit"
+ @update:value="handleSelectEnvironment($event as (string | undefined))"
+ />
+ </div>
+
+ <!-- Labels -->
+ <div class="sm:col-span-3 sm:col-start-1">
+ <label for="labels" class="textlabel">
+ {{ $t("common.labels") }}
+ </label>
+ <div class="mt-1">
+ <LabelListEditor
+ ref="labelListEditorRef"
+ v-model:kv-list="labelKVList"
+ :readonly="!allowEdit"
+ :show-errors="true"
+ />
+ </div>
+ </div>
+
+ <!--Do not show external link on create to reduce cognitive load-->
+ <div v-if="!isCreating" class="sm:col-span-3 sm:col-start-1">
+ <label for="external-link" class="textlabel inline-flex">
+ <span>
+ {{
+ basicInfo.engine === Engine.SNOWFLAKE
+ ? $t("instance.snowflake-web-console")
+ : $t("instance.external-link")
+ }}
+ </span>
+ <button
+ v-if="instanceLink.trim().length > 0"
+ class="ml-1 btn-icon"
+ @click.prevent="window.open(urlfy(instanceLink), '_blank')"
+ >
+ <heroicons-outline:external-link class="w-4 h-4" />
+ </button>
+ </label>
+ <template v-if="basicInfo.engine === Engine.SNOWFLAKE">
+ <NInput
+ required
+ class="mt-1 w-full"
+ :disabled="true"
+ :value="instanceLink"
+ />
+ </template>
+ <template v-else>
+ <div class="mt-1 textinfolabel">
+ {{ $t("instance.sentence.console.snowflake") }}
+ </div>
+ <NInput
+ v-model:value="basicInfo.externalLink"
+ required
+ class="textfield mt-1 w-full"
+ :disabled="!allowEdit"
+ :placeholder="SnowflakeExtraLinkPlaceHolder"
+ />
+ </template>
+ </div>
+
+ <ScanIntervalInput
+ v-if="!isCreating && instance"
+ ref="scanIntervalInputRef"
+ :scan-interval="basicInfo.syncInterval"
+ :allow-edit="allowEdit"
+ :instance="instance"
+ @update:scan-interval="changeScanInterval"
/>
- </div>
- <div class="sm:col-span-2 sm:col-start-1">
- <label for="environment" class="textlabel">
- {{ $t("common.environment") }}
- </label>
- <EnvironmentSelect
- class="mt-1 w-full"
- required="true"
- :value="
- isValidEnvironmentName(
- `${environmentNamePrefix}${environment.id}`
- )
- ? `${environmentNamePrefix}${environment.id}`
- : undefined
- "
- :disabled="!allowEdit"
- @update:value="handleSelectEnvironment($event as (string | undefined))"
+ <SyncDatabases
+ v-if="!isCreating"
+ :is-creating="false"
+ :show-label="true"
+ :allow-edit="allowEdit"
+ :sync-databases="basicInfo.syncDatabases"
+ @update:sync-databases="handleChangeSyncDatabases"
/>
</div>
+ </div>
- <div class="sm:col-span-3 sm:col-start-1">
- <template v-if="basicInfo.engine === Engine.SPANNER">
- <SpannerHostInput
- v-model:host="adminDataSource.host"
- :allow-edit="allowEdit"
- />
- </template>
- <template v-else-if="basicInfo.engine === Engine.BIGQUERY">
- <BigQueryHostInput
- v-model:host="adminDataSource.host"
- :allow-edit="allowEdit"
- />
- </template>
- <template v-else>
- <label for="host" class="textlabel block">
- <template v-if="basicInfo.engine === Engine.SNOWFLAKE">
- {{ $t("instance.account-locator") }}
- <RequiredStar class="mr-2" />
- <LearnMoreLink
- url="https://docs.snowflake.com/en/user-guide/admin-account-identifier#using-an-account-locator-as-an-identifier"
- class="text-sm"
- />
- </template>
- <template v-else-if="basicInfo.engine === Engine.COSMOSDB">
- {{ $t("instance.endpoint") }}
- <RequiredStar />
- </template>
- <div
- v-else-if="
- adminDataSource.authenticationType ===
- DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
- "
- >
- <span>
- {{ $t("instance.sentence.google-cloud-sql.instance-name") }}
+ <!-- Connection Card -->
+ <div class="border border-block-border rounded-lg p-5">
+ <h3 class="text-base font-medium text-main flex items-center gap-x-1">
+ {{ $t("instance.section.connection") }}
+ <InfoTrigger
+ v-if="isCreating && infoPanel"
+ @click="openInfoPanel('authentication')"
+ />
+ </h3>
+
+ <div class="grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">
+ <div class="sm:col-span-3 sm:col-start-1">
+ <template v-if="basicInfo.engine === Engine.SPANNER">
+ <SpannerHostInput
+ v-model:host="adminDataSource.host"
+ :allow-edit="allowEdit"
+ />
+ </template>
+ <template v-else-if="basicInfo.engine === Engine.BIGQUERY">
+ <BigQueryHostInput
+ v-model:host="adminDataSource.host"
+ :allow-edit="allowEdit"
+ />
+ </template>
+ <template v-else>
+ <label for="host" class="textlabel block">
+ <template v-if="basicInfo.engine === Engine.SNOWFLAKE">
+ {{ $t("instance.account-locator") }}
+ <RequiredStar class="mr-2" />
+ <LearnMoreLink
+ url="https://docs.snowflake.com/en/user-guide/admin-account-identifier#using-an-account-locator-as-an-identifier"
+ class="text-sm"
+ />
+ </template>
+ <template v-else-if="basicInfo.engine === Engine.COSMOSDB">
+ {{ $t("instance.endpoint") }}
<RequiredStar />
- </span>
- <i18n-t
- tag="div"
- class="textinfolabel mb-1"
- keypath="instance.sentence.google-cloud-sql.instance-name-tips"
+ </template>
+ <div
+ v-else-if="
+ adminDataSource.authenticationType ===
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
+ "
>
- <template #instance>
- <span class="font-bold">
- {project-id}:{region}:{instance-name}
- </span>
- </template>
- </i18n-t>
+ <span>
+ {{ $t("instance.sentence.google-cloud-sql.instance-name") }}
+ <RequiredStar />
+ </span>
+ <i18n-t
+ tag="div"
+ class="textinfolabel mb-1"
+ keypath="instance.sentence.google-cloud-sql.instance-name-tips"
+ >
+ <template #instance>
+ <span class="font-bold">
+ {project-id}:{region}:{instance-name}
+ </span>
+ </template>
+ </i18n-t>
+ </div>
+ <template v-else>
+ {{ $t("instance.host-or-socket") }}
+ <RequiredStar v-if="basicInfo.engine !== Engine.DYNAMODB" />
+ <InfoTrigger
+ v-if="isCreating && infoPanel"
+ @click="openInfoPanel('host')"
+ />
+ </template>
+ </label>
+ <NInput
+ v-model:value="adminDataSource.host"
+ required
+ :placeholder="
+ basicInfo.engine === Engine.SNOWFLAKE
+ ? $t('instance.your-snowflake-account-locator')
+ : $t('instance.sentence.host.none-snowflake')
+ "
+ class="mt-1 w-full"
+ :disabled="!allowEdit"
+ />
+ <div
+ v-if="basicInfo.engine === Engine.SNOWFLAKE"
+ class="mt-2 textinfolabel"
+ >
+ {{ $t("instance.sentence.proxy.snowflake") }}
</div>
- <template v-else>
- {{ $t("instance.host-or-socket") }}
- <RequiredStar v-if="basicInfo.engine !== Engine.DYNAMODB" />
- </template>
- </label>
- <NInput
- v-model:value="adminDataSource.host"
- required
- :placeholder="
- basicInfo.engine === Engine.SNOWFLAKE
- ? $t('instance.your-snowflake-account-locator')
- : $t('instance.sentence.host.none-snowflake')
- "
- class="mt-1 w-full"
- :disabled="!allowEdit"
- />
- <div
- v-if="basicInfo.engine === Engine.SNOWFLAKE"
- class="mt-2 textinfolabel"
- >
- {{ $t("instance.sentence.proxy.snowflake") }}
+ </template>
+ </div>
+
+ <template
+ v-if="
+ basicInfo.engine !== Engine.SPANNER &&
+ basicInfo.engine !== Engine.BIGQUERY &&
+ basicInfo.engine !== Engine.DATABRICKS &&
+ basicInfo.engine !== Engine.COSMOSDB &&
+ adminDataSource.authenticationType !==
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
+ "
+ >
+ <div class="sm:col-span-1">
+ <label for="port" class="textlabel block">
+ {{ $t("instance.port") }}
+ </label>
+ <NInput
+ v-model:value="adminDataSource.port"
+ class="mt-1 w-full"
+ :placeholder="defaultPort"
+ :disabled="!allowEdit || !allowEditPort"
+ :allow-input="onlyAllowNumber"
+ />
</div>
</template>
- </div>
- <template
- v-if="
- basicInfo.engine !== Engine.SPANNER &&
- basicInfo.engine !== Engine.BIGQUERY &&
- basicInfo.engine !== Engine.DATABRICKS &&
- basicInfo.engine !== Engine.COSMOSDB &&
- adminDataSource.authenticationType !==
- DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
- "
- >
- <div class="sm:col-span-1">
- <label for="port" class="textlabel block">
- {{ $t("instance.port") }}
+ <div
+ v-if="basicInfo.engine === Engine.MONGODB"
+ class="sm:col-span-4 sm:col-start-1"
+ >
+ <label
+ for="connectionStringSchema"
+ class="textlabel flex flex-row items-center"
+ >
+ {{ $t("data-source.connection-string-schema") }}
</label>
- <NInput
- v-model:value="adminDataSource.port"
- class="mt-1 w-full"
- :placeholder="defaultPort"
- :disabled="!allowEdit || !allowEditPort"
- :allow-input="onlyAllowNumber"
- />
+ <NRadioGroup
+ :value="currentMongoDBConnectionSchema"
+ @update:value="handleMongodbConnectionStringSchemaChange"
+ >
+ <NRadio
+ v-for="type in MongoDBConnectionStringSchemaList"
+ :key="type"
+ :value="type"
+ >
+ {{ type }}
+ </NRadio>
+ </NRadioGroup>
</div>
- </template>
- <div
- v-if="basicInfo.engine === Engine.MONGODB"
- class="sm:col-span-4 sm:col-start-1"
- >
- <label
- for="connectionStringSchema"
- class="textlabel flex flex-row items-center"
- >
- {{ $t("data-source.connection-string-schema") }}
- </label>
- <NRadioGroup
- :value="currentMongoDBConnectionSchema"
- @update:value="handleMongodbConnectionStringSchemaChange"
+ <div
+ v-if="basicInfo.engine === Engine.REDIS"
+ class="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2"
>
- <NRadio
- v-for="type in MongoDBConnectionStringSchemaList"
- :key="type"
- :value="type"
+ <label
+ for="connectionStringSchema"
+ class="textlabel flex flex-row items-center"
>
- {{ type }}
- </NRadio>
- </NRadioGroup>
- </div>
-
- <div
- v-if="basicInfo.engine === Engine.REDIS"
- class="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2"
- >
- <label
- for="connectionStringSchema"
- class="textlabel flex flex-row items-center"
- >
- {{ $t("data-source.connection-type") }}
- </label>
- <NRadioGroup
- :value="currentRedisConnectionType"
- @update:value="handleRedisConnectionTypeChange"
- >
- <NRadio
- v-for="type in RedisConnectionType"
- :key="type"
- :value="type"
+ {{ $t("data-source.connection-type") }}
+ </label>
+ <NRadioGroup
+ :value="currentRedisConnectionType"
+ @update:value="handleRedisConnectionTypeChange"
>
- {{ type }}
- </NRadio>
- </NRadioGroup>
- </div>
+ <NRadio
+ v-for="type in RedisConnectionType"
+ :key="type"
+ :value="type"
+ >
+ {{ type }}
+ </NRadio>
+ </NRadioGroup>
+ </div>
- <div
- v-if="showAdditionalAddresses"
- class="sm:col-span-4 sm:col-start-1"
- >
- <label
- for="additionalAddresses"
- class="textlabel flex flex-row items-center"
+ <div
+ v-if="showAdditionalAddresses"
+ class="sm:col-span-4 sm:col-start-1"
>
- {{ $t("data-source.additional-node-addresses") }}
- </label>
- <div class="mt-1 grid grid-cols-1 gap-y-1 gap-x-4 sm:grid-cols-12">
- <template
- v-for="(_, index) in adminDataSource.additionalAddresses"
- :key="index"
+ <label
+ for="additionalAddresses"
+ class="textlabel flex flex-row items-center"
>
- <div class="sm:col-span-8 sm:col-start-1">
- <label
- v-if="index === 0"
- for="additionalAddressesHost"
- class="textlabel font-normal! flex flex-row items-center"
- >
- {{ $t("instance.host-or-socket") }}
- </label>
- <NInput
- v-model:value="
- adminDataSource.additionalAddresses[index].host
- "
- required
- class="mt-1 w-full"
- :disabled="!allowEdit"
- />
- </div>
- <div class="sm:col-span-3">
- <label
- v-if="index === 0"
- for="additionalAddressesPort"
- class="textlabel font-normal! flex flex-row items-center"
- >
- {{ $t("instance.port") }}
- </label>
- <NInput
- v-model:value="
- adminDataSource.additionalAddresses[index].port
- "
- class="mt-1 w-full"
- :placeholder="defaultPort"
- :disabled="!allowEdit || !allowEditPort"
- :allow-input="onlyAllowNumber"
- />
- </div>
- <div class="h-8.5 flex flex-row items-center self-end">
- <MiniActionButton
- :disabled="!allowEdit"
- @click.stop="removeDSAdditionalAddress(index)"
+ {{ $t("data-source.additional-node-addresses") }}
+ </label>
+ <div
+ class="mt-1 grid grid-cols-1 gap-y-1 gap-x-4 sm:grid-cols-12"
+ >
+ <template
+ v-for="(_, index) in adminDataSource.additionalAddresses"
+ :key="index"
+ >
+ <div class="sm:col-span-8 sm:col-start-1">
+ <label
+ v-if="index === 0"
+ for="additionalAddressesHost"
+ class="textlabel font-normal! flex flex-row items-center"
+ >
+ {{ $t("instance.host-or-socket") }}
+ </label>
+ <NInput
+ v-model:value="
+ adminDataSource.additionalAddresses[index].host
+ "
+ required
+ class="mt-1 w-full"
+ :disabled="!allowEdit"
+ />
+ </div>
+ <div class="sm:col-span-3">
+ <label
+ v-if="index === 0"
+ for="additionalAddressesPort"
+ class="textlabel font-normal! flex flex-row items-center"
+ >
+ {{ $t("instance.port") }}
+ </label>
+ <NInput
+ v-model:value="
+ adminDataSource.additionalAddresses[index].port
+ "
+ class="mt-1 w-full"
+ :placeholder="defaultPort"
+ :disabled="!allowEdit || !allowEditPort"
+ :allow-input="onlyAllowNumber"
+ />
+ </div>
+ <div class="h-8.5 flex flex-row items-center self-end">
+ <MiniActionButton
+ :disabled="!allowEdit"
+ @click.stop="removeDSAdditionalAddress(index)"
+ >
+ <TrashIcon class="w-4 h-4" />
+ </MiniActionButton>
+ </div>
+ </template>
+ <div class="mt-1 sm:col-span-12 sm:col-start-1">
+ <NButton
+ class="ml-auto w-12!"
+ size="small"
+ @click.prevent="addDSAdditionalAddress"
>
- <TrashIcon class="w-4 h-4" />
- </MiniActionButton>
+ {{ $t("common.add") }}
+ </NButton>
</div>
- </template>
- <div class="mt-1 sm:col-span-12 sm:col-start-1">
- <NButton
- class="ml-auto w-12!"
- size="small"
- @click.prevent="addDSAdditionalAddress"
- >
- {{ $t("common.add") }}
- </NButton>
</div>
</div>
- </div>
- <div
- v-if="basicInfo.engine === Engine.MONGODB && !adminDataSource.srv"
- class="sm:col-span-2 sm:col-start-1"
- >
- <label for="replicaSet" class="textlabel">
- {{ $t("data-source.replica-set") }}
- </label>
- <NInput
- v-model:value="adminDataSource.replicaSet"
- required
- class="mt-1 w-full"
- :disabled="!allowEdit"
- />
- </div>
-
- <div
- v-if="
- basicInfo.engine === Engine.MONGODB &&
- !adminDataSource.srv &&
- adminDataSource.additionalAddresses.length === 0
- "
- class="sm:col-span-4 sm:col-start-1"
- >
- <NCheckbox
- :checked="adminDataSource.directConnection"
- :disabled="!allowEdit"
- style="--n-label-padding: 0 0 0 1rem"
- @update:checked="
- (on: boolean) => {
- adminDataSource.directConnection = on;
- }
- "
+ <div
+ v-if="basicInfo.engine === Engine.MONGODB && !adminDataSource.srv"
+ class="sm:col-span-2 sm:col-start-1"
>
- {{ $t("data-source.direct-connection") }}
- </NCheckbox>
- </div>
-
- <ScanIntervalInput
- v-if="!isCreating && instance"
- ref="scanIntervalInputRef"
- :scan-interval="basicInfo.syncInterval"
- :allow-edit="allowEdit"
- :instance="instance"
- @update:scan-interval="changeScanInterval"
- />
-
- <SyncDatabases
- v-if="!isCreating"
- :is-creating="false"
- :show-label="true"
- :allow-edit="allowEdit"
- :sync-databases="basicInfo.syncDatabases"
- @update:sync-databases="handleChangeSyncDatabases"
- />
-
- <!--Do not show external link on create to reduce cognitive load-->
- <div v-if="!isCreating" class="sm:col-span-3 sm:col-start-1">
- <label for="external-link" class="textlabel inline-flex">
- <span>
- {{
- basicInfo.engine === Engine.SNOWFLAKE
- ? $t("instance.snowflake-web-console")
- : $t("instance.external-link")
- }}
- </span>
- <button
- v-if="instanceLink.trim().length > 0"
- class="ml-1 btn-icon"
- @click.prevent="window.open(urlfy(instanceLink), '_blank')"
- >
- <heroicons-outline:external-link class="w-4 h-4" />
- </button>
- </label>
- <template v-if="basicInfo.engine === Engine.SNOWFLAKE">
+ <label for="replicaSet" class="textlabel">
+ {{ $t("data-source.replica-set") }}
+ </label>
<NInput
+ v-model:value="adminDataSource.replicaSet"
required
class="mt-1 w-full"
- :disabled="true"
- :value="instanceLink"
- />
- </template>
- <template v-else>
- <div class="mt-1 textinfolabel">
- {{ $t("instance.sentence.console.snowflake") }}
- </div>
- <NInput
- v-model:value="basicInfo.externalLink"
- required
- class="textfield mt-1 w-full"
:disabled="!allowEdit"
- :placeholder="SnowflakeExtraLinkPlaceHolder"
/>
- </template>
- </div>
+ </div>
- <!-- Labels -->
- <div class="sm:col-span-3 sm:col-start-1">
- <label for="labels" class="textlabel">
- {{ $t("common.labels") }}
- </label>
- <div class="mt-1">
- <LabelListEditor
- ref="labelListEditorRef"
- v-model:kv-list="labelKVList"
- :readonly="!allowEdit"
- :show-errors="true"
- />
+ <div
+ v-if="
+ basicInfo.engine === Engine.MONGODB &&
+ !adminDataSource.srv &&
+ adminDataSource.additionalAddresses.length === 0
+ "
+ class="sm:col-span-4 sm:col-start-1"
+ >
+ <NCheckbox
+ :checked="adminDataSource.directConnection"
+ :disabled="!allowEdit"
+ style="--n-label-padding: 0 0 0 1rem"
+ @update:checked="
+ (on: boolean) => {
+ adminDataSource.directConnection = on;
+ }
+ "
+ >
+ {{ $t("data-source.direct-connection") }}
+ </NCheckbox>
</div>
</div>
- </div>
-
- <NDivider />
- <!-- Connection Info -->
- <template v-if="basicInfo.engine !== Engine.DYNAMODB">
- <p class="w-full text-lg leading-6 font-medium text-gray-900">
- {{ $t("instance.connection-info") }}
- </p>
-
- <DataSourceSection />
- </template>
+ <!-- Credentials (auth method, username, password) -->
+ <template v-if="basicInfo.engine !== Engine.DYNAMODB">
+ <DataSourceSection hide-options />
- <BBAttention
- v-if="actuatorStore.isSaaSMode"
- class="my-4 border-none"
- type="info"
- >
- <a
- href="https://docs.bytebase.com/get-started/cloud#prerequisites"
- target="_blank"
- rel="noopener noreferrer"
- class="normal-link"
- >
- {{ $t("instance.sentence.firewall-info") }}
- </a>
- </BBAttention>
-
- <div class="mt-6 pt-0 border-none">
- <div class="flex flex-row gap-x-2">
- <NButton
- tertiary
- type="primary"
- class="whitespace-nowrap flex items-center"
- :loading="state.isTestingConnection"
- :disabled="!allowCreate || state.isRequesting || !allowEdit"
- @click.prevent="testConnectionForCurrentEditingDS"
+ <BBAttention
+ v-if="actuatorStore.isSaaSMode"
+ class="mt-4 border-none"
+ type="info"
>
- <span>{{ $t("instance.test-connection") }}</span>
- </NButton>
- </div>
+ <a
+ href="https://docs.bytebase.com/get-started/cloud#prerequisites"
+ target="_blank"
+ rel="noopener noreferrer"
+ class="normal-link"
+ >
+ {{ $t("instance.sentence.firewall-info") }}
+ </a>
+ </BBAttention>
+ </template>
</div>
- <NDivider />
+ <!-- Connection Options Card (Extra Params, SSL, SSH) -->
+ <div
+ v-if="basicInfo.engine !== Engine.DYNAMODB && editingDataSource"
+ class="border border-block-border rounded-lg p-5"
+ >
+ <h3 class="text-base font-medium text-main">
+ {{ $t("instance.connection-options") }}
+ </h3>
+ <DataSourceForm :data-source="editingDataSource" options-only />
+ </div>
+ <!-- Sync Databases Card (create only) -->
<div
v-if="basicInfo.engine !== Engine.DYNAMODB && isCreating"
- class="flex flex-col gap-y-1"
+ class="border border-block-border rounded-lg p-5 flex flex-col gap-y-1"
>
<p class="w-full text-lg leading-6 font-medium text-gray-900">
{{ $t("instance.sync-databases.self") }}
@@ -507,14 +519,13 @@ import { TrashIcon } from "lucide-vue-next";
import {
NButton,
NCheckbox,
- NDivider,
NInput,
NRadio,
NRadioGroup,
NSwitch,
NTag,
} from "naive-ui";
-import { computed, ref } from "vue";
+import { computed, inject, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBAttention } from "@/bbkit";
import { LabelListEditor } from "@/components/Label";
@@ -561,14 +572,16 @@ import {
SnowflakeExtraLinkPlaceHolder,
} from "./constants";
import { useInstanceFormContext } from "./context";
+import DataSourceForm from "./DataSourceSection/DataSourceForm.vue";
import DataSourceSection from "./DataSourceSection/DataSourceSection.vue";
+import InfoTrigger from "./InfoTrigger.vue";
+import type { InfoSection } from "./info-content";
import ScanIntervalInput from "./ScanIntervalInput.vue";
import SpannerHostInput from "./SpannerHostInput.vue";
import SyncDatabases from "./SyncDatabases.vue";
const context = useInstanceFormContext();
const {
- state,
specs,
instance,
environment,
@@ -581,10 +594,30 @@ const {
labelKVList,
adminDataSource,
editingDataSource,
- testConnection,
} = context;
const { isEngineBeta, defaultPort, instanceLink, allowEditPort } = specs;
+const infoPanel = inject<
+ | {
+ open: (section: InfoSection) => void;
+ close: () => void;
+ setEngine: (engine: Engine) => void;
+ }
+ | undefined
+>("infoPanel", undefined);
+
+watch(
+ () => basicInfo.value.engine,
+ (engine) => {
+ infoPanel?.setEngine(engine);
+ },
+ { immediate: true }
+);
+
+const openInfoPanel = (section: InfoSection) => {
+ infoPanel?.open(section);
+};
+
const { t } = useI18n();
const instanceV1Store = useInstanceV1Store();
const actuatorStore = useActuatorV1Store();
@@ -789,12 +822,6 @@ const changeInstanceActivation = async (on: boolean) => {
const handleSelectEnvironment = (name: string | undefined) => {
basicInfo.value.environment = name;
};
-
-const testConnectionForCurrentEditingDS = () => {
- const editingDS = editingDataSource.value;
- if (!editingDS) return;
- testConnection(editingDS, /* !silent */ false);
-};
</script>
<style lang="postcss" scoped>
diff --git a/frontend/src/components/InstanceForm/InfoPanel.vue b/frontend/src/components/InstanceForm/InfoPanel.vue
new file mode 100644
index 0000000000..6c5083a07c
--- /dev/null
+++ b/frontend/src/components/InstanceForm/InfoPanel.vue
@@ -0,0 +1,62 @@
+<template>
+ <Teleport to="body">
+ <Transition name="info-panel">
+ <div
+ v-if="visible"
+ class="fixed inset-0 z-50 flex justify-end"
+ @click.self="$emit('close')"
+ >
+ <div
+ class="w-80 bg-white border-l border-block-border shadow-lg flex flex-col h-full"
+ >
+ <!-- Sticky header -->
+ <div
+ class="sticky top-0 z-10 flex items-center justify-between px-4 py-3 border-b border-block-border bg-white"
+ >
+ <h3 class="text-sm font-semibold text-main truncate">
+ {{ title }}
+ </h3>
+ <button
+ class="text-control-light hover:text-main p-0.5 rounded"
+ @click="$emit('close')"
+ >
+ <XIcon class="w-4 h-4" />
+ </button>
+ </div>
+ <!-- Scrollable content -->
+ <div class="flex-1 overflow-y-auto px-4 py-4">
+ <slot />
+ </div>
+ </div>
+ </div>
+ </Transition>
+ </Teleport>
+</template>
+
+<script lang="ts" setup>
+import { XIcon } from "lucide-vue-next";
+
+defineProps<{
+ visible: boolean;
+ title: string;
+}>();
+
+defineEmits<{
+ close: [];
+}>();
+</script>
+
+<style scoped>
+.info-panel-enter-active,
+.info-panel-leave-active {
+ transition: transform 0.2s ease;
+}
+.info-panel-enter-active > div,
+.info-panel-leave-active > div {
+ transition: transform 0.2s ease;
+}
+.info-panel-enter-from > div,
+.info-panel-leave-to > div {
+ transform: translateX(100%);
+}
+</style>
diff --git a/frontend/src/components/InstanceForm/InfoPanelContent.vue b/frontend/src/components/InstanceForm/InfoPanelContent.vue
new file mode 100644
index 0000000000..f57a828ac4
--- /dev/null
+++ b/frontend/src/components/InstanceForm/InfoPanelContent.vue
@@ -0,0 +1,62 @@
+<template>
+ <div v-if="snippet" class="flex flex-col gap-y-3">
+ <p class="text-sm text-main leading-relaxed">
+ {{ snippet.content }}
+ </p>
+ <div v-if="snippet.codeBlock" class="flex flex-col gap-y-1">
+ <div class="flex flex-row">
+ <NConfigProvider
+ class="flex-1 min-w-0 w-full inline-flex items-center px-3 py-2 border border-control-border bg-gray-50 text-xs whitespace-pre-line rounded-l-[3px] overflow-x-auto"
+ :hljs="hljs"
+ >
+ <NCode
+ word-wrap
+ :language="snippet.codeBlock.language"
+ :code="snippet.codeBlock.code"
+ />
+ </NConfigProvider>
+ <div
+ class="flex items-center -ml-px px-2 py-2 border border-gray-300 text-sm font-medium text-control-light bg-gray-50 hover:bg-gray-100 rounded-r-[3px]"
+ >
+ <CopyButton :content="snippet.codeBlock.code" />
+ </div>
+ </div>
+ </div>
+ <div
+ v-if="snippet.learnMoreLinks && snippet.learnMoreLinks.length > 0"
+ class="flex flex-col gap-y-1"
+ >
+ <a
+ v-for="link in snippet.learnMoreLinks"
+ :key="link.url"
+ :href="link.url"
+ target="_blank"
+ rel="noopener noreferrer"
+ class="text-xs accent-link"
+ >
+ {{ link.title }}
+ </a>
+ </div>
+ </div>
+ <div v-else class="text-sm text-control-light italic">
+ {{ $t("instance.info-panel.no-info") }}
+ </div>
+</template>
+
+<script lang="ts" setup>
+import hljs from "highlight.js/lib/core";
+import { NCode, NConfigProvider } from "naive-ui";
+import { computed } from "vue";
+import { CopyButton } from "@/components/v2";
+import type { Engine } from "@/types/proto-es/v1/common_pb";
+import { getInfoContent, type InfoSection } from "./info-content";
+
+const props = defineProps<{
+ engine: Engine;
+ section: InfoSection;
+}>();
+
+const snippet = computed(() => {
+ return getInfoContent(props.engine, props.section);
+});
+</script>
diff --git a/frontend/src/components/InstanceForm/InfoTrigger.vue b/frontend/src/components/InstanceForm/InfoTrigger.vue
new file mode 100644
index 0000000000..481db60e29
--- /dev/null
+++ b/frontend/src/components/InstanceForm/InfoTrigger.vue
@@ -0,0 +1,17 @@
+<template>
+ <button
+ class="inline-flex items-center gap-x-0.5 text-control-light hover:text-accent cursor-pointer ml-1"
+ @click.prevent.stop="$emit('click')"
+ >
+ <InfoIcon class="w-3.5 h-3.5" />
+ <span class="text-xs">{{ $t("common.info") }}</span>
+ </button>
+</template>
+
+<script lang="ts" setup>
+import { InfoIcon } from "lucide-vue-next";
+
+defineEmits<{
+ click: [];
+}>();
+</script>
diff --git a/frontend/src/components/InstanceForm/info-content.ts b/frontend/src/components/InstanceForm/info-content.ts
new file mode 100644
index 0000000000..8cfc263ace
--- /dev/null
+++ b/frontend/src/components/InstanceForm/info-content.ts
@@ -0,0 +1,209 @@
+import { DATASOURCE_ADMIN_USER_NAME } from "@/types";
+import { Engine } from "@/types/proto-es/v1/common_pb";
+
+export type InfoSection =
+ | "host"
+ | "port"
+ | "authentication"
+ | "ssl"
+ | "ssh"
+ | "database";
+
+export interface InfoSnippet {
+ title: string;
+ content: string;
+ codeBlock?: {
+ language: string;
+ code: string;
+ };
+ learnMoreLinks?: {
+ title: string;
+ url: string;
+ }[];
+}
+
+const postgresqlContent: Partial<Record<InfoSection, InfoSnippet>> = {
+ host: {
+ title: "PostgreSQL Host",
+ content:
+ "Enter the hostname or IP address of your PostgreSQL server. For cloud-hosted databases, use the endpoint provided by your cloud provider.",
+ learnMoreLinks: [
+ {
+ title: "Connect Your Instance",
+ url: "https://docs.bytebase.com/get-started/instance?source=console",
+ },
+ ],
+ },
+ authentication: {
+ title: "PostgreSQL Authentication",
+ content: `Create a dedicated user "${DATASOURCE_ADMIN_USER_NAME}" for Bytebase to manage your database. Run the following SQL as a superuser:`,
+ codeBlock: {
+ language: "sql",
+ code: `CREATE USER ${DATASOURCE_ADMIN_USER_NAME} WITH ENCRYPTED PASSWORD 'YOUR_DB_PWD';
+
+ALTER USER ${DATASOURCE_ADMIN_USER_NAME} WITH SUPERUSER;`,
+ },
+ learnMoreLinks: [
+ {
+ title: "Configure Database User",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#configure-a-database-user",
+ },
+ ],
+ },
+ ssl: {
+ title: "SSL Connection",
+ content:
+ "Cloud-hosted PostgreSQL databases (AWS RDS, Google Cloud SQL, Azure Database) typically require SSL connections. Enable SSL and upload the CA certificate provided by your cloud provider.",
+ learnMoreLinks: [
+ {
+ title: "SSL/TLS Connection",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#ssltls-connection",
+ },
+ ],
+ },
+ ssh: {
+ title: "SSH Tunnel",
+ content:
+ "Use an SSH tunnel to connect to databases in private networks that are not directly accessible from Bytebase. This routes the connection through a bastion/jump host.",
+ learnMoreLinks: [
+ {
+ title: "SSH Tunnel",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#ssh-tunnel",
+ },
+ ],
+ },
+};
+
+const mysqlContent: Partial<Record<InfoSection, InfoSnippet>> = {
+ host: {
+ title: "MySQL Host",
+ content:
+ "Enter the hostname or IP address of your MySQL server. For cloud-hosted databases (AWS RDS, Google Cloud SQL), use the endpoint provided by your cloud provider.",
+ learnMoreLinks: [
+ {
+ title: "Connect Your Instance",
+ url: "https://docs.bytebase.com/get-started/instance?source=console",
+ },
+ ],
+ },
+ authentication: {
+ title: "MySQL Authentication",
+ content: `Create a dedicated user "${DATASOURCE_ADMIN_USER_NAME}" for Bytebase to manage your database. Run the following SQL:`,
+ codeBlock: {
+ language: "sql",
+ code: `CREATE USER ${DATASOURCE_ADMIN_USER_NAME}@'%' IDENTIFIED BY 'YOUR_DB_PWD';
+
+GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE VIEW,
+DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, PROCESS, REFERENCES,
+SELECT, SHOW DATABASES, SHOW VIEW, TRIGGER, UPDATE, USAGE,
+RELOAD, LOCK TABLES, REPLICATION CLIENT, REPLICATION SLAVE
+/*!80000 , SET_USER_ID */
+ON *.* to ${DATASOURCE_ADMIN_USER_NAME}@'%';`,
+ },
+ learnMoreLinks: [
+ {
+ title: "Configure Database User",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#configure-a-database-user",
+ },
+ ],
+ },
+ ssl: {
+ title: "SSL Connection",
+ content:
+ "Cloud-hosted MySQL databases (AWS RDS, Google Cloud SQL, Azure Database) typically require SSL connections. Enable SSL and upload the CA certificate provided by your cloud provider.",
+ learnMoreLinks: [
+ {
+ title: "SSL/TLS Connection",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#ssltls-connection",
+ },
+ ],
+ },
+ ssh: {
+ title: "SSH Tunnel",
+ content:
+ "Use an SSH tunnel to connect to databases in private networks that are not directly accessible from Bytebase. This routes the connection through a bastion/jump host.",
+ learnMoreLinks: [
+ {
+ title: "SSH Tunnel",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#ssh-tunnel",
+ },
+ ],
+ },
+};
+
+const mongodbContent: Partial<Record<InfoSection, InfoSnippet>> = {
+ host: {
+ title: "MongoDB Host",
+ content:
+ "Enter the hostname or IP address of your MongoDB server. For MongoDB Atlas, use the connection string host from your cluster's connect dialog.",
+ learnMoreLinks: [
+ {
+ title: "Connect Your Instance",
+ url: "https://docs.bytebase.com/get-started/instance?source=console",
+ },
+ ],
+ },
+ authentication: {
+ title: "MongoDB Authentication",
+ content: `Create a dedicated user "${DATASOURCE_ADMIN_USER_NAME}" for Bytebase in the admin database:`,
+ codeBlock: {
+ language: "javascript",
+ code: `use admin;
+db.createUser({
+ user: "${DATASOURCE_ADMIN_USER_NAME}",
+ pwd: "YOUR_DB_PWD",
+ roles: [
+ {role: "readWriteAnyDatabase", db: "admin"},
+ {role: "dbAdminAnyDatabase", db: "admin"},
+ {role: "userAdminAnyDatabase", db: "admin"}
+ ]
+});`,
+ },
+ learnMoreLinks: [
+ {
+ title: "Configure Database User",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#configure-a-database-user",
+ },
+ ],
+ },
+ ssl: {
+ title: "SSL Connection",
+ content:
+ "MongoDB Atlas and other cloud-hosted MongoDB services require SSL connections by default. Enable SSL and provide the CA certificate if needed.",
+ learnMoreLinks: [
+ {
+ title: "SSL/TLS Connection",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#ssltls-connection",
+ },
+ ],
+ },
+ ssh: {
+ title: "SSH Tunnel",
+ content:
+ "Use an SSH tunnel to connect to MongoDB instances in private networks. This is useful when the database is behind a firewall or in a VPC.",
+ learnMoreLinks: [
+ {
+ title: "SSH Tunnel",
+ url: "https://docs.bytebase.com/get-started/instance?source=console#ssh-tunnel",
+ },
+ ],
+ },
+};
+
+const engineContentMap: Partial<
+ Record<Engine, Partial<Record<InfoSection, InfoSnippet>>>
+> = {
+ [Engine.POSTGRES]: postgresqlContent,
+ [Engine.MYSQL]: mysqlContent,
+ [Engine.TIDB]: mysqlContent,
+ [Engine.MARIADB]: mysqlContent,
+ [Engine.OCEANBASE]: mysqlContent,
+ [Engine.MONGODB]: mongodbContent,
+};
+
+export const getInfoContent = (
+ engine: Engine,
+ section: InfoSection
+): InfoSnippet | undefined => {
+ return engineContentMap[engine]?.[section];
+};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index ad100001b4..f2cf6c5ab2 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1383,6 +1383,14 @@
"snowflake-web-console": "Snowflake Web Console",
"external-link": "External Link",
"connection-info": "Connection info",
+ "connection-options": "Connection Options",
+ "section": {
+ "basic-info": "Basic Info",
+ "connection": "Connection"
+ },
+ "info-panel": {
+ "no-info": "No additional information available for this engine."
+ },
"role-arn": "Role ARN",
"role-arn-placeholder": "arn:aws:iam::123456789012:role/CrossAccountRole",
"role-arn-description": "IAM role to assume for cross-account access. Leave empty for same-account access.",
@@ -2332,7 +2340,7 @@
"assign-license": "Assign License",
"require-license": "Require instance license",
"missing-license-attention": "You need to assign license to the instance to enable this feature.",
- "n-license-remain": "remain {n}",
+ "n-license-remain": "{n} remaining",
"manage-license": "Manage Instance License",
"used-and-total-license": "Assigned / Total Instance License",
"used-and-total-user": "Active / Total User Limit",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 746b31a04f..43673dc8dd 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1383,6 +1383,14 @@
"snowflake-web-console": "Consola web de Snowflake",
"external-link": "Enlace externo",
"connection-info": "Información de conexión",
+ "connection-options": "Opciones de conexión",
+ "section": {
+ "basic-info": "Información básica",
+ "connection": "Conexión"
+ },
+ "info-panel": {
+ "no-info": "No hay información adicional disponible para este motor."
+ },
"role-arn": "ARN del rol",
"role-arn-placeholder": "arn:aws:iam::123456789012:role/CrossAccountRole",
"role-arn-description": "Rol IAM para asumir en acceso entre cuentas. Dejar vacío para acceso en la misma cuenta.",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 302b08906b..d9ff37a3a8 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1383,6 +1383,14 @@
"snowflake-web-console": "スノーフレークウェブコンソール",
"external-link": "外部リンク",
"connection-info": "接続情報",
+ "connection-options": "接続オプション",
+ "section": {
+ "basic-info": "基本情報",
+ "connection": "接続"
+ },
+ "info-panel": {
+ "no-info": "このエンジンの追加情報はありません。"
+ },
"role-arn": "ロール ARN",
"role-arn-placeholder": "arn:aws:iam::123456789012:role/CrossAccountRole",
"role-arn-description": "クロスアカウントアクセス用の IAM ロール。同一アカウントアクセスの場合は空のままにしてください。",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 8c9eefa9e9..db6e96683b 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1383,6 +1383,14 @@
"snowflake-web-console": "Bảng điều khiển web Snowflake",
"external-link": "Liên kết ngoài",
"connection-info": "Thông tin kết nối",
+ "connection-options": "Tùy chọn kết nối",
+ "section": {
+ "basic-info": "Thông tin cơ bản",
+ "connection": "Kết nối"
+ },
+ "info-panel": {
+ "no-info": "Không có thông tin bổ sung cho engine này."
+ },
"role-arn": "ARN vai trò",
"role-arn-placeholder": "arn:aws:iam::123456789012:role/CrossAccountRole",
"role-arn-description": "Vai trò IAM để đảm nhận cho truy cập xuyên tài khoản. Để trống cho truy cập cùng tài khoản.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 31433841fd..cc133337cf 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1383,6 +1383,14 @@
"snowflake-web-console": "Snowflake Web 控制台",
"external-link": "外部链接",
"connection-info": "连接信息",
+ "connection-options": "连接选项",
+ "section": {
+ "basic-info": "基本信息",
+ "connection": "连接"
+ },
+ "info-panel": {
+ "no-info": "暂无该引擎的额外信息。"
+ },
"role-arn": "角色 ARN",
"role-arn-placeholder": "arn:aws:iam::123456789012:role/CrossAccountRole",
"role-arn-description": "用于跨账户访问的 IAM 角色。同账户访问请留空。",
@@ -2332,7 +2340,7 @@
"assign-license": "分配证书",
"require-license": "需要实例证书",
"missing-license-attention": "请给实例分配证书以解锁该功能。",
- "n-license-remain": "剩余 {n}",
+ "n-license-remain": "剩余 {n} 个",
"manage-license": "管理证书",
"used-and-total-license": "已分配 / 总实例证书",
"used-and-total-user": "活跃/总用户限制",
diff --git a/frontend/src/router/dashboard/instance.ts b/frontend/src/router/dashboard/instance.ts
index 90ac807465..e0e30b1151 100644
--- a/frontend/src/router/dashboard/instance.ts
+++ b/frontend/src/router/dashboard/instance.ts
@@ -3,10 +3,25 @@ import InstanceLayout from "@/layouts/InstanceLayout.vue";
import { t } from "@/plugins/i18n";
import { INSTANCE_ROUTE_DASHBOARD } from "./workspaceRoutes";
+export const INSTANCE_ROUTE_CREATE = `${INSTANCE_ROUTE_DASHBOARD}.create`;
export const INSTANCE_ROUTE_DETAIL = `${INSTANCE_ROUTE_DASHBOARD}.detail`;
export const INSTANCE_ROUTE_DATABASE_DETAIL = `${INSTANCE_ROUTE_DASHBOARD}.database.detail`;
const instanceRoutes: RouteRecordRaw[] = [
+ {
+ path: "instances/new",
+ name: INSTANCE_ROUTE_CREATE,
+ meta: {
+ title: () => t("instance.new-instance"),
+ requiredPermissionList: () => ["bb.instances.create"],
+ getQuickActionList: () => [],
+ },
+ components: {
+ content: () => import("@/views/CreateInstancePage.vue"),
+ leftSidebar: () => import("@/views/DashboardSidebar.vue"),
+ },
+ props: { content: true },
+ },
{
path: "instances/:instanceId",
components: {
diff --git a/frontend/src/views/CreateInstancePage.vue b/frontend/src/views/CreateInstancePage.vue
new file mode 100644
index 0000000000..6da48ef2c3
--- /dev/null
+++ b/frontend/src/views/CreateInstancePage.vue
@@ -0,0 +1,110 @@
+<template>
+ <div class="flex flex-col h-full">
+ <InstanceForm @dismiss="goBack">
+ <!-- Header -->
+ <div
+ class="sticky top-0 z-10 bg-white border-b border-block-border px-6 py-4"
+ >
+ <h1 class="text-lg font-medium">
+ {{ $t("quick-action.add-instance") }}
+ </h1>
+ </div>
+
+ <!-- Body -->
+ <div class="flex-1 overflow-auto px-6 py-4">
+ <InstanceFormBody />
+ </div>
+
+ <!-- Sticky footer -->
+ <div class="sticky bottom-0 z-10 bg-white px-6">
+ <InstanceFormButtons />
+ </div>
+ </InstanceForm>
+
+ <InfoPanel
+ :visible="!!activeInfoSection"
+ :title="infoPanelTitle"
+ @close="activeInfoSection = undefined"
+ >
+ <InfoPanelContent
+ v-if="activeInfoSection"
+ :engine="currentEngine"
+ :section="activeInfoSection"
+ />
+ </InfoPanel>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed, onMounted, provide, ref } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRouter } from "vue-router";
+import {
+ InstanceForm,
+ Form as InstanceFormBody,
+ Buttons as InstanceFormButtons,
+} from "@/components/InstanceForm/";
+import InfoPanel from "@/components/InstanceForm/InfoPanel.vue";
+import InfoPanelContent from "@/components/InstanceForm/InfoPanelContent.vue";
+import type { InfoSection } from "@/components/InstanceForm/info-content";
+import { INSTANCE_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
+import {
+ pushNotification,
+ useActuatorV1Store,
+ useSubscriptionV1Store,
+} from "@/store";
+import { Engine } from "@/types/proto-es/v1/common_pb";
+
+const { t } = useI18n();
+const router = useRouter();
+const subscriptionStore = useSubscriptionV1Store();
+const actuatorStore = useActuatorV1Store();
+
+const activeInfoSection = ref<InfoSection | undefined>();
+const currentEngine = ref<Engine>(Engine.MYSQL);
+
+const infoPanelTitle = computed(() => {
+ if (!activeInfoSection.value) return "";
+ const titleMap: Record<InfoSection, string> = {
+ host: t("instance.host-or-socket"),
+ port: t("instance.port"),
+ authentication: t("instance.connection-info"),
+ ssl: t("data-source.ssl-connection"),
+ ssh: t("data-source.ssh-connection"),
+ database: t("common.database"),
+ };
+ return titleMap[activeInfoSection.value] ?? "";
+});
+
+provide("infoPanel", {
+ open: (section: InfoSection) => {
+ activeInfoSection.value = section;
+ },
+ close: () => {
+ activeInfoSection.value = undefined;
+ },
+ setEngine: (engine: Engine) => {
+ currentEngine.value = engine;
+ },
+});
+
+const goBack = () => {
+ router.push({ name: INSTANCE_ROUTE_DASHBOARD });
+};
+
+onMounted(() => {
+ if (
+ subscriptionStore.instanceCountLimit <= actuatorStore.activatedInstanceCount
+ ) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("subscription.usage.instance-count.title"),
+ description: t("subscription.usage.instance-count.runoutof", {
+ total: subscriptionStore.instanceCountLimit,
+ }),
+ });
+ goBack();
+ }
+});
+</script>
diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vue
index 44b1527e1a..e130200b3d 100644
--- a/frontend/src/views/InstanceDashboard.vue
+++ b/frontend/src/views/InstanceDashboard.vue
@@ -21,7 +21,7 @@
<NButton
type="primary"
:disabled="slotProps.disabled"
- @click="showCreateInstanceDrawer"
+ @click="navigateToCreate"
>
<template #icon>
<PlusIcon class="h-4 w-4" />
@@ -52,28 +52,6 @@
/>
</div>
</div>
- <Drawer
- :auto-focus="true"
- :close-on-esc="true"
- :show="state.showCreateDrawer"
- @close="state.showCreateDrawer = false"
- >
- <InstanceForm
- :hide-advanced-features="false"
- :drawer="true"
- @dismiss="state.showCreateDrawer = false"
- >
- <DrawerContent
- :title="$t('quick-action.add-instance')"
- class="w-212.5 max-w-[100vw]"
- >
- <InstanceFormBody />
- <template #footer>
- <InstanceFormButtons :on-created="onInstanceCreated" />
- </template>
- </DrawerContent>
- </InstanceForm>
- </Drawer>
</template>
<script lang="tsx" setup>
@@ -86,18 +64,9 @@ import { BBAttention } from "@/bbkit";
import AdvancedSearch from "@/components/AdvancedSearch";
import type { ScopeOption } from "@/components/AdvancedSearch/types";
import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";
-import {
- InstanceForm,
- Form as InstanceFormBody,
- Buttons as InstanceFormButtons,
-} from "@/components/InstanceForm/";
import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import {
- Drawer,
- DrawerContent,
- InstanceOperations,
- PagedInstanceTable,
-} from "@/components/v2";
+import { InstanceOperations, PagedInstanceTable } from "@/components/v2";
+import { INSTANCE_ROUTE_CREATE } from "@/router/dashboard/instance";
import {
useActuatorV1Store,
useInstanceV1Store,
@@ -119,12 +88,11 @@ import {
interface LocalState {
params: SearchParams;
- showCreateDrawer: boolean;
showFeatureModal: boolean;
selectedInstance: Set<string>;
}
-const props = defineProps<{
+defineProps<{
onRowClick?: (instance: Instance) => void;
}>();
@@ -142,19 +110,10 @@ const state = reactive<LocalState>({
query: "",
scopes: [],
},
- showCreateDrawer: false,
showFeatureModal: false,
selectedInstance: new Set(),
});
-const onInstanceCreated = (instance: Instance) => {
- if (props.onRowClick) {
- return props.onRowClick(instance);
- }
- router.push(`/${instance.name}`);
- state.showCreateDrawer = false;
-};
-
const selectedEnvironment = computed(() => {
return getValueFromSearchParams(
state.params,
@@ -198,14 +157,14 @@ const filter = computed(() => ({
state: selectedState.value,
}));
-const showCreateInstanceDrawer = () => {
+const navigateToCreate = () => {
if (
subscriptionStore.instanceCountLimit <= actuatorStore.activatedInstanceCount
) {
state.showFeatureModal = true;
return;
}
- state.showCreateDrawer = true;
+ router.push({ name: INSTANCE_ROUTE_CREATE });
};
const scopeOptions = computed((): ScopeOption[] => {