Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(frontend): migrate instance page to naive-ui components (#8837)
Liu Ji09e92ffa5c47
diff --git a/frontend/src/components/CreateDataSourceExample.vue b/frontend/src/components/CreateDataSourceExample.vueindex 9f191e9bc6..cd4d7a4f09 100644--- a/frontend/src/components/CreateDataSourceExample.vue+++ b/frontend/src/components/CreateDataSourceExample.vue@@ -126,13 +126,13 @@</template><div class="mt-2 flex flex-row"><span- class="flex-1 min-w-0 w-full inline-flex items-center px-3 py-2 border border-r border-control-border bg-gray-50 sm:text-sm whitespace-pre-line"+ class="flex-1 min-w-0 w-full inline-flex items-center px-3 py-2 border border-r border-control-border bg-gray-50 sm:text-sm whitespace-pre-line rounded-l-[3px]">{{ grantStatement(props.engine, props.dataSourceType) }}</span><buttontabindex="-1"- class="-ml-px px-2 py-2 border border-gray-300 text-sm font-medium text-control-light disabled:text-gray-300 bg-gray-50 hover:bg-gray-100 disabled:bg-gray-50 focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-1 disabled:cursor-not-allowed"+ class="-ml-px px-2 py-2 border border-gray-300 text-sm font-medium text-control-light disabled:text-gray-300 bg-gray-50 hover:bg-gray-100 disabled:bg-gray-50 focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-1 disabled:cursor-not-allowed rounded-r-[3px]"@click.prevent="copyGrantStatement"><heroicons-outline:clipboard class="w-6 h-6" />diff --git a/frontend/src/components/DatabaseDetail/CreatePITRDatabaseForm.vue b/frontend/src/components/DatabaseDetail/CreatePITRDatabaseForm.vueindex c0adf4abb3..92e3aca3ad 100644--- a/frontend/src/components/DatabaseDetail/CreatePITRDatabaseForm.vue+++ b/frontend/src/components/DatabaseDetail/CreatePITRDatabaseForm.vue@@ -5,11 +5,10 @@<span class="text-red-600">*</span></label><ProjectSelect- class="mt-1"+ v-model:project="state.context.projectId"+ class="mt-1 !w-full":disabled="true":include-default-project="true"- :selected-id="state.context.projectId"- @select-project-id="(id: string) => (state.context.projectId = id)"/></div>@@ -18,13 +17,14 @@{{ $t("create-db.new-database-name") }}<span class="text-red-600">*</span></label>- <input- id="name"- v-model="state.context.databaseName"++ <NInput+ v-model:value="state.context.databaseName"required- name="name"+ name="databaseName"type="text"- class="textfield mt-1 w-full"+ class="mt-1 w-full"+ :placeholder="$t('create-db.new-database-name')"/><span v-if="isReservedName" class="text-red-600"><i18n-t keypath="create-db.reserved-db-error">@@ -41,9 +41,10 @@</label><EnvironmentSelectclass="mt-1"- :selected-id="state.context.environmentId"+ required+ name="environment":disabled="true"- @select-environment-id="(id: string) => (state.context.environmentId = id)"+ :environment="state.context.environmentId"/></div>@@ -53,12 +54,12 @@{{ $t("common.instance") }} <span class="text-red-600">*</span></label></label>+<InstanceSelect+ v-model:instance="state.context.instanceId"class="mt-1"- :selected-id="String(state.context.instanceId)"- :environment-id="state.context.environmentId"+ :environment="state.context.environmentId":filter="instanceFilter"- @select-instance-id="(id: number) => (state.context.instanceId = String(id))"/></div>@@ -70,11 +71,8 @@: $t("db.character-set")}}</label>- <input- id="charset"- v-model="state.context.characterSet"- name="charset"- type="text"+ <NInput+ v-model:value="state.context.characterSet"class="textfield mt-1 w-full":placeholder="defaultCharsetOfEngineV1(selectedInstance.engine)"/>@@ -84,11 +82,8 @@<label for="collation" class="textlabel">{{ $t("db.collation") }}</label>- <input- id="collation"- v-model="state.context.collation"- name="collation"- type="text"+ <NInput+ v-model:value="state.context.collation"class="textfield mt-1 w-full":placeholder="defaultCollationOfEngineV1(selectedInstance.engine) || 'default'@@ -101,6 +96,7 @@<script lang="ts" setup>import { cloneDeep, isEmpty } from "lodash-es";+import { NInput } from "naive-ui";import { computed, onBeforeMount, PropType, reactive, watch } from "vue";import { isPITRAvailableOnInstanceV1 } from "@/plugins/pitr";import { useDBSchemaV1Store, useInstanceV1Store } from "@/store";@@ -111,6 +107,7 @@ import {defaultCollationOfEngineV1,} from "@/types";import { Engine } from "@/types/proto/v1/common";+import { EnvironmentSelect, InstanceSelect, ProjectSelect } from "../v2";import { CreatePITRDatabaseContext } from "./utils";interface LocalState {diff --git a/frontend/src/components/InstanceForm/DataSourceSection/CreateReadOnlyDataSourceTips.vue b/frontend/src/components/InstanceForm/DataSourceSection/CreateReadOnlyDataSourceTips.vueindex ebbfde8f0b..b6efc8a9cc 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/CreateReadOnlyDataSourceTips.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/CreateReadOnlyDataSourceTips.vue@@ -9,17 +9,17 @@<span class="text-yellow-800 text-sm">{{ $t("instance.no-read-only-data-source-warn-for-owner-dba") }}</span>- <button- type="button"- class="btn-normal ml-4 text-sm"+ <NButton+ class="!ml-4 text-sm"@click.prevent="$emit('add-readonly-datasource')">{{ $t("common.create") }}- </button>+ </NButton></div></template><script setup lang="ts">+import { NButton } from "naive-ui";import { useInstanceFormContext } from "../context";defineEmits<{diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vueindex 3eccaf43a0..f5f29574d9 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue@@ -14,12 +14,9 @@<!-- For mysql, username can be empty indicating anonymous user.But it's a very bad practice to use anonymous user for admin operation,thus we make it REQUIRED here.-->- <input- id="username"- v-model="dataSource.username"- name="username"- type="text"- class="textfield mt-1 w-full"+ <NInput+ v-model:value="dataSource.username"+ class="mt-1 w-full":disabled="!allowEdit":placeholder="basicInfo.engine === Engine.CLICKHOUSE ? $t('common.default') : ''@@ -31,13 +28,14 @@<label for="password" class="textlabel block">{{ $t("common.password") }}</label>- <BBCheckbox+ <NCheckboxv-if="!isCreating && allowUsingEmptyPassword"- :title="$t('common.empty')"- :value="dataSource.useEmptyPassword"+ :checked="dataSource.useEmptyPassword":disabled="!allowEdit"- @toggle="toggleUseEmptyPassword"- />+ @update:checked="toggleUseEmptyPassword"+ >+ {{ $t("common.empty") }}+ </NCheckbox></div><div class="flex space-x-2 text-sm mb-1"><div class="text-gray-400">@@ -49,12 +47,9 @@/><FeatureBadge feature="bb.feature.external-secret-manager" /></div>- <input- id="password"- name="password"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"+ <NInput+ class="mt-1 w-full"+ :input-props="{ autocomplete: 'off' }":placeholder="dataSource.useEmptyPassword? $t('instance.no-password')@@ -62,7 +57,7 @@":disabled="!allowEdit || dataSource.useEmptyPassword":value="dataSource.useEmptyPassword ? '' : dataSource.updatedPassword"- @input="dataSource.updatedPassword = trimInputValue($event.target)"+ @update:value="dataSource.updatedPassword = $event.trim()"/></div></template>@@ -88,17 +83,12 @@{{ $t("instance.authentication-database") }}</label></div>- <input- id="authenticationDatabase"- name="authenticationDatabase"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"+ <NInput+ class="mt-1 w-full"+ :input-props="{ autocomplete: 'off' }"placeholder="admin":value="dataSource.authenticationDatabase"- @input="- dataSource.authenticationDatabase = trimInputValue($event.target)- "+ @update:value="dataSource.authenticationDatabase = $event.trim()"/></div></template>@@ -118,14 +108,11 @@{{ $t("data-source.read-replica-host") }}</label></div>- <input- id="host"- name="host"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"+ <NInput+ class="mt-1 w-full"+ :input-props="{ autocomplete: 'off' }":value="dataSource.host"- @input="handleHostInput"+ @update:value="handleHostInput"/></div>@@ -138,14 +125,12 @@{{ $t("data-source.read-replica-port") }}</label></div>- <input- id="port"- name="port"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"+ <NInput+ class="mt-1 w-full"+ :input-props="{ autocomplete: 'off' }":value="dataSource.port"- @input="handlePortInput"+ :allow-input="onlyAllowNumber"+ @update:value="handlePortInput"/></div></template>@@ -154,12 +139,9 @@<label for="database" class="textlabel block">{{ $t("common.database") }}</label>- <input- id="database"- v-model="dataSource.database"- name="database"- type="text"- class="textfield mt-1 w-full"+ <NInput+ v-model:value="dataSource.database"+ class="mt-1 w-full":disabled="!allowEdit":placeholder="$t('common.database')"/>@@ -179,13 +161,13 @@<SslCertificateForm :value="dataSource" @change="handleSSLChange" /></template><template v-else>- <button- class="btn-normal mt-2"+ <NButton+ class="!mt-2":disabled="!allowEdit"@click.prevent="handleEditSSL">{{ $t("common.edit") }} - {{ $t("common.write-only") }}- </button>+ </NButton></template></template></div>@@ -216,13 +198,13 @@/></template><template v-else>- <button- class="btn-normal mt-2"+ <NButton+ class="!mt-2":disabled="!allowEdit"@click.prevent="handleEditSSH">{{ $t("common.edit") }} - {{ $t("common.write-only") }}- </button>+ </NButton></template></template></div>@@ -230,12 +212,17 @@<script setup lang="ts">/* eslint-disable vue/no-mutating-props */+import { NButton, NCheckbox, NInput } from "naive-ui";import { DataSourceOptions } from "@/types";import { Engine } from "@/types/proto/v1/common";import { DataSource, DataSourceType } from "@/types/proto/v1/instance_service";import { EditDataSource } from "../common";import { useInstanceFormContext } from "../context";import { useInstanceSpecs } from "../specs";+import SpannerCredentialInput from "./SpannerCredentialInput.vue";+import SshConnectionForm from "./SshConnectionForm.vue";+import SslCertificateForm from "./SslCertificateForm.vue";+import { onlyAllowNumber } from "./common";const props = defineProps<{dataSource: EditDataSource;@@ -267,7 +254,7 @@ const toggleUseEmptyPassword = (on: boolean) => {ds.updatedPassword = "";}};-const handleHostInput = (event: Event) => {+const handleHostInput = (value: string) => {const ds = props.dataSource;if (ds.type === DataSourceType.READ_ONLY) {if (!hasReadonlyReplicaFeature.value) {@@ -279,10 +266,10 @@ const handleHostInput = (event: Event) => {}}}- ds.host = trimInputValue(event.target);+ ds.host = value.trim();};-const handlePortInput = (event: Event) => {+const handlePortInput = (value: string) => {const ds = props.dataSource;if (ds.type === DataSourceType.READ_ONLY) {if (!hasReadonlyReplicaFeature.value) {@@ -294,7 +281,7 @@ const handlePortInput = (event: Event) => {}}}- ds.port = trimInputValue(event.target);+ ds.port = value.trim();};const handleEditSSL = () => {const ds = props.dataSource;@@ -335,8 +322,4 @@ const handleSSHChange = (Object.assign(ds, value);ds.updateSsh = true;};--const trimInputValue = (target: Event["target"]) => {- return ((target as HTMLInputElement)?.value ?? "").trim();-};</script>diff --git a/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue b/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vueindex d1b1d0e4f2..dfba1b8ee0 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue@@ -1,53 +1,38 @@<template><div class="mt-2 sm:col-span-1 sm:col-start-1"><div class="flex items-center gap-x-4">- <label class="radio">- <input- v-model="state.mode"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- value="ServiceName"- :disabled="!allowEdit"- />- <span class="label">ServiceName</span>- </label>- <label class="radio">- <input- v-model="state.mode"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- value="SID"- :disabled="!allowEdit"- />- <span class="label">SID</span>- </label>+ <NRadio+ :checked="state.mode === 'ServiceName'"+ @update:checked="toggleMode('ServiceName', $event)"+ >+ <span class="textlabel">ServiceName</span>+ </NRadio>+ <NRadio+ :checked="state.mode === 'SID'"+ @update:checked="toggleMode('SID', $event)"+ >+ <span class="textlabel">SID</span>+ </NRadio></div>- <div>- <input+ <div class="mt-1">+ <NInputv-if="state.mode === 'ServiceName'":value="state.serviceName"- type="text"- class="textfield w-full mt-1"placeholder="ServiceName"- @input="- update(($event.target as HTMLInputElement).value, 'ServiceName')- "+ @update:value="update($event, 'ServiceName')"/>- <input+ <NInputv-if="state.mode === 'SID'":value="state.sid"- type="text"- class="textfield w-full mt-1"placeholder="SID"- @input="update(($event.target as HTMLInputElement).value, 'SID')"+ @update:value="update($event, 'SID')"/></div></div></template><script lang="ts" setup>+import { NInput, NRadio } from "naive-ui";import { reactive, watch } from "vue";type Mode = "ServiceName" | "SID";@@ -90,6 +75,11 @@ const update = (value: string, mode: Mode) => {}};+const toggleMode = (mode: Mode, checked: boolean) => {+ if (!checked) return;+ state.mode = mode;+};+watch([() => props.sid, () => props.serviceName],([sid, serviceName]) => {diff --git a/frontend/src/components/InstanceForm/DataSourceSection/SpannerCredentialInput.vue b/frontend/src/components/InstanceForm/DataSourceSection/SpannerCredentialInput.vueindex 6df4d4512a..52314d128a 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/SpannerCredentialInput.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/SpannerCredentialInput.vue@@ -17,10 +17,9 @@</p><DroppableTextarea:value="value"- :rounded="true"class="block w-full resize-none whitespace-pre-wrap h-24":placeholder="placeholder"- @update:value="(value) => $emit('update:value', value)"+ @update:value="$emit('update:value', $event ?? '')"/></div></template>diff --git a/frontend/src/components/InstanceForm/DataSourceSection/SshConnectionForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/SshConnectionForm.vueindex 8487cee88e..7b19fc09d0 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/SshConnectionForm.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/SshConnectionForm.vue@@ -1,17 +1,14 @@<template>- <div class="radio-set-row mt-2">- <label v-for="sshType in SshTypes" :key="sshType" class="radio">- <input- type="radio"- class="btn"- :value="sshType"- :checked="state.type === sshType"- @input="handleSelectType"- />- <span class="label">- {{ getSshTypeLabel(sshType) }}- </span>- </label>+ <div class="flex flex-row items-center gap-x-4 mt-2">+ <NRadio+ v-for="sshType in SshTypes"+ :key="sshType"+ :value="sshType"+ :checked="state.type === sshType"+ @update:checked="handleSelectType(sshType, $event)"+ >+ <span class="textlabel">{{ getSshTypeLabel(sshType) }}</span>+ </NRadio></div><template v-if="state.type === 'TUNNEL' || state.type === 'TUNNEL+PK'">@@ -22,12 +19,9 @@<label for="sshHost" class="textlabel block">{{ $t("data-source.ssh.host") }}</label>- <input- id="sshHost"- v-model="state.value.sshHost"- name="sshHost"- type="text"- class="textfield mt-1 w-full"+ <NInput+ v-model:value="state.value.sshHost"+ class="mt-1 w-full":placeholder="''"/></div>@@ -36,13 +30,11 @@<label for="sshPort" class="textlabel block">{{ $t("data-source.ssh.port") }}</label>- <input- id="sshPort"- v-model="state.value.sshPort"- name="sshPort"- type="text"- class="textfield mt-1 w-full"+ <NInput+ v-model:value="state.value.sshPort"+ class="mt-1 w-full":placeholder="''"+ :allow-input="onlyAllowNumber"/></div></div>@@ -54,12 +46,9 @@<label for="sshUser" class="textlabel block">{{ $t("data-source.ssh.user") }}</label>- <input- id="sshUser"- v-model="state.value.sshUser"- name="sshUser"- type="text"- class="textfield mt-1 w-full"+ <NInput+ v-model:value="state.value.sshUser"+ class="mt-1 w-full":placeholder="''"/></div>@@ -67,12 +56,9 @@<label for="sshPassword" class="textlabel block">{{ $t("data-source.ssh.password") }}</label>- <input- id="sshPassword"- v-model="state.value.sshPassword"- name="sshPassword"- type="text"- class="textfield mt-1 w-full"+ <NInput+ v-model:value="state.value.sshPassword"+ class="mt-1 w-full":placeholder="$t('instance.password-write-only')"/></div>@@ -81,14 +67,13 @@v-if="state.type === 'TUNNEL+PK'"class="mt-4 sm:col-span-3 sm:col-start-1">- <div class="mt-2 sm:col-span-1 sm:col-start-1">+ <div class="mt-2 sm:col-span-1 sm:col-start-1 flex flex-col gap-y-1"><label for="sshPrivateKey" class="textlabel block">{{ $t("data-source.ssh.ssh-key") }}</label><DroppableTextareav-model:value="state.value.sshPrivateKey"- :rounded="true"- class="mt-2 block w-full resize-none whitespace-pre-wrap h-24"+ class="block w-full resize-none whitespace-pre-wrap h-24"/></div></div>@@ -104,11 +89,13 @@<script lang="ts" setup>import { cloneDeep } from "lodash-es";+import { NInput, NRadio } from "naive-ui";import { PropType, reactive, computed, watch } from "vue";import { useI18n } from "vue-i18n";import DroppableTextarea from "@/components/misc/DroppableTextarea.vue";import { useSubscriptionV1Store } from "@/store";import { Instance } from "@/types/proto/v1/instance_service";+import { onlyAllowNumber } from "./common";const SshTypes = ["NONE", "TUNNEL", "TUNNEL+PK"] as const;@@ -166,16 +153,12 @@ const hasSSHConnectionFeature = computed(() => {);});-const handleSelectType = (e: Event) => {- const radio = e.target as HTMLInputElement;- const type = radio.value as SshType;+const handleSelectType = (type: SshType, checked: boolean) => {+ if (!checked) return;if (!hasSSHConnectionFeature.value) {if (type !== "NONE") {state.type = "NONE";- radio.checked = false;- e.preventDefault();- e.stopPropagation();state.showFeatureModal = true;return;}diff --git a/frontend/src/components/InstanceForm/DataSourceSection/SslCertificateForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/SslCertificateForm.vueindex 7ad5efd3d0..1cea431f66 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/SslCertificateForm.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/SslCertificateForm.vue@@ -1,12 +1,12 @@<template>- <div class="radio-set-row mt-2">- <label v-for="type in SslTypes" :key="type" class="radio">- <input v-model="state.type" type="radio" class="btn" :value="type" />- <span class="label">- {{ getSslTypeLabel(type) }}- </span>- </label>- </div>+ <NRadioGroup+ v-model:value="state.type"+ class="!flex flex-row items-center gap-x-4 mt-2"+ >+ <NRadio v-for="type in SslTypes" :key="type" :value="type">+ <span class="textlabel">{{ getSslTypeLabel(type) }}</span>+ </NRadio>+ </NRadioGroup><NTabsv-if="state.type === 'CA' || state.type === 'CA+KEY+CERT'"v-model:value="state.tab"@@ -53,7 +53,7 @@<script lang="ts" setup>import { cloneDeep } from "lodash-es";-import { NTabs, NTabPane } from "naive-ui";+import { NTabs, NTabPane, NRadio, NRadioGroup } from "naive-ui";import { PropType, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import DroppableTextarea from "@/components/misc/DroppableTextarea.vue";diff --git a/frontend/src/components/InstanceForm/DataSourceSection/common.ts b/frontend/src/components/InstanceForm/DataSourceSection/common.tsnew file mode 100644index 0000000000..2c38558612--- /dev/null+++ b/frontend/src/components/InstanceForm/DataSourceSection/common.ts@@ -0,0 +1,3 @@+export const onlyAllowNumber = (value: string) => {+ return value === "" || /^\d+$/.test(value);+};diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vueindex 02c88949ca..414c7588b2 100644--- a/frontend/src/components/InstanceForm/InstanceForm.vue+++ b/frontend/src/components/InstanceForm/InstanceForm.vue@@ -3,36 +3,37 @@<div class="space-y-6 divide-y divide-block-border"><div class="divide-y divide-block-border w-[850px]"><div v-if="isCreating" class="w-full mt-4 mb-6 grid grid-cols-4 gap-2">- <template v-for="engine in EngineList" :key="engine">- <div- class="flex relative justify-start p-2 border rounded cursor-pointer hover:bg-control-bg-hover"- :class="- basicInfo.engine === engine && 'font-medium bg-control-bg-hover'- "- @click.capture="changeInstanceEngine(engine)"+ <NButton+ v-for="engine in EngineList"+ :key="engine"+ class="instance-engine-button"+ size="large"+ ghost+ :type="basicInfo.engine === engine ? 'primary' : 'default'"+ @click="changeInstanceEngine(engine)"+ >+ <NRadio+ :checked="basicInfo.engine === engine"+ size="large"+ class="btn mr-2 pointer-events-none"+ />+ <img+ v-if="EngineIconPath[engine]"+ class="w-5 h-auto max-h-[20px] object-contain mr-1"+ :src="EngineIconPath[engine]"+ />+ <p+ class="text-center text-sm !text-main"+ :class="basicInfo.engine === engine && 'font-medium'">- <div class="flex flex-row justify-start items-center">- <input- type="radio"- class="btn mr-2"- :checked="basicInfo.engine === engine"- />- <img- v-if="EngineIconPath[engine]"- class="w-5 h-auto max-h-[20px] object-contain mr-1"- :src="EngineIconPath[engine]"- />- <p class="text-center text-sm">- {{ engineNameV1(engine) }}- </p>- <template v-if="isEngineBeta(engine)">- <BBBetaBadge- class="absolute -top-px -right-px rounded text-xs !bg-gray-500 px-1 !py-0"- />- </template>- </div>- </div>- </template>+ {{ engineNameV1(engine) }}+ </p>+ <template v-if="isEngineBeta(engine)">+ <BBBetaBadge+ class="absolute -top-1.5 -right-1 rounded text-xs !bg-gray-500 px-1 !py-0 z-10"+ />+ </template>+ </NButton></div><!-- Instance Name -->@@ -49,13 +50,10 @@<span class="ml-1">{{ props.instance.engineVersion }}</span></template></label>- <input- id="name"- v-model="basicInfo.title"+ <NInput+ v-model:value="basicInfo.title"required- name="name"- type="text"- class="textfield mt-1 w-full"+ class="mt-1 w-full":disabled="!allowEdit"/></div>@@ -74,12 +72,11 @@}}</router-link>)</label>- <BBSwitch+ <NSwitchclass="mt-2"- :text="false":value="basicInfo.activation":disabled="!basicInfo.activation && availableLicenseCount === 0"- @toggle="changeInstanceActivation"+ @update:value="changeInstanceActivation"/></div>@@ -103,12 +100,14 @@{{ $t("common.environment") }}</label><EnvironmentSelect- id="environment"class="mt-1 w-full"- name="environment":disabled="!isCreating"- :selected-id="environment.uid"- @select-environment-id="handleSelectEnvironmentUID"+ :environment="+ environment.uid === String(UNKNOWN_ID)+ ? undefined+ : environment.uid+ "+ @update:environment="handleSelectEnvironmentUID"/></div>@@ -131,18 +130,15 @@<span class="text-red-600 mr-2">*</span></template></label>- <input- id="host"- v-model="adminDataSource.host"+ <NInput+ v-model:value="adminDataSource.host"required- type="text"- name="host":placeholder="basicInfo.engine === Engine.SNOWFLAKE? $t('instance.your-snowflake-account-name'): $t('instance.sentence.host.snowflake')"- class="textfield mt-1 w-full"+ class="mt-1 w-full":disabled="!allowEdit"/><div@@ -164,16 +160,12 @@<label for="port" class="textlabel block">{{ $t("instance.port") }}</label>- <input- id="port"- type="text"- name="port"- class="textfield mt-1 w-full"- :value="adminDataSource.port"+ <NInput+ v-model:value="adminDataSource.port"+ class="mt-1 w-full":placeholder="defaultPort":disabled="!allowEdit || !allowEditPort"- @wheel="(e: WheelEvent) => (e.target as HTMLInputElement).blur()"- @input="adminDataSource.port = trimInputValue($event.target)"+ :allow-input="onlyAllowNumber"/></div></template>@@ -188,23 +180,18 @@>{{ $t("data-source.connection-string-schema") }}</label>- <label- v-for="type in MongoDBConnectionStringSchemaList"- :key="type"- class="radio h-7"- >- <input- type="radio"- class="btn"- name="connectionStringSchema"- :value="type"+ <div class="flex flex-col gap-y-1 mt-1">+ <NRadio+ v-for="type in MongoDBConnectionStringSchemaList"+ :key="type":checked="type === currentMongoDBConnectionSchema"- @change="handleMongodbConnectionStringSchemaChange"- />- <span class="label">- {{ type }}- </span>- </label>+ @update:checked="+ handleMongodbConnectionStringSchemaChange(type, $event)+ "+ >+ <span class="textlabel">{{ type }}</span>+ </NRadio>+ </div></div><ScanIntervalInput@@ -233,13 +220,10 @@</button></label><template v-if="basicInfo.engine === Engine.SNOWFLAKE">- <input- id="external-link"+ <NInputrequired- name="external-link"- type="text"- class="textfield mt-1 w-full"- disabled="true"+ class="mt-1 w-full"+ :disabled="true":value="instanceLink"/></template>@@ -247,14 +231,11 @@<div class="mt-1 textinfolabel">{{ $t("instance.sentence.console.snowflake") }}</div>- <input- id="external-link"- v-model="basicInfo.externalLink"+ <NInput+ v-model:value="basicInfo.externalLink"required- name="external-link"- type="text"- :disabled="!allowEdit"class="textfield mt-1 w-full"+ :disabled="!allowEdit":placeholder="SnowflakeExtraLinkPlaceHolder"/></template>@@ -278,15 +259,14 @@<div class="mt-6 pt-0 border-none"><div class="flex flex-row space-x-2">- <button- type="button"- class="btn-normal whitespace-nowrap flex items-center gap-x-1"+ <NButton+ class="whitespace-nowrap flex items-center gap-x-1":disabled="!allowCreate || state.isRequesting || !allowEdit"@click.prevent="testConnection(false /* !silent */)"><BBSpin v-if="state.isTestingConnection" /><span>{{ $t("instance.test-connection") }}</span>- </button>+ </NButton></div></div></div>@@ -359,7 +339,7 @@<script lang="ts" setup>import { cloneDeep, isEqual, omit } from "lodash-es";-import { NButton } from "naive-ui";+import { NButton, NInput, NSwitch } from "naive-ui";import { Status } from "nice-grpc-common";import {computed,@@ -372,9 +352,12 @@ import {} from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";-import EnvironmentSelect from "@/components/EnvironmentSelect.vue";import { InstanceArchiveRestoreButton } from "@/components/Instance";-import { DrawerContent, InstanceV1EngineIcon } from "@/components/v2";+import {+ DrawerContent,+ EnvironmentSelect,+ InstanceV1EngineIcon,+} from "@/components/v2";import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";import { instanceServiceClient } from "@/grpcweb";import {@@ -413,6 +396,7 @@ import {} from "@/utils";import { extractGrpcErrorMessage, getErrorCode } from "@/utils/grpcweb";import DataSourceSection from "./DataSourceSection/DataSourceSection.vue";+import { onlyAllowNumber } from "./DataSourceSection/common";import OracleSyncModeInput from "./OracleSyncModeInput.vue";import ScanIntervalInput from "./ScanIntervalInput.vue";import SpannerHostInput from "./SpannerHostInput.vue";@@ -625,8 +609,9 @@ const allowUpdate = computed((): boolean => {return true;});-const handleSelectEnvironmentUID = (uid: number | string) => {- const environment = useEnvironmentV1Store().getEnvironmentByUID(String(uid));+const handleSelectEnvironmentUID = (uid: string | undefined) => {+ if (!uid) return;+ const environment = useEnvironmentV1Store().getEnvironmentByUID(uid);basicInfo.value.environment = environment.name;};@@ -663,14 +648,14 @@ const changeScanInterval = (duration: Duration | undefined) => {basicInfo.value.options.syncInterval = duration;};-const trimInputValue = (target: Event["target"]) => {- return ((target as HTMLInputElement)?.value ?? "").trim();-};--const handleMongodbConnectionStringSchemaChange = (event: Event) => {+const handleMongodbConnectionStringSchemaChange = (+ type: string,+ on: boolean+) => {+ if (!on) return;const ds = editingDataSource.value;if (!ds) return;- switch ((event.target as HTMLInputElement).value) {+ switch (type) {case MongoDBConnectionStringSchemaList[0]:ds.srv = false;break;@@ -1153,3 +1138,9 @@ const changeInstanceActivation = async (on: boolean) => {}};</script>++<style lang="postcss" scoped>+.instance-engine-button :deep(.n-button__content) {+ @apply w-full justify-start;+}+</style>diff --git a/frontend/src/components/InstanceForm/OracleSyncModeInput.vue b/frontend/src/components/InstanceForm/OracleSyncModeInput.vueindex ac60231a9e..9ccb33737b 100644--- a/frontend/src/components/InstanceForm/OracleSyncModeInput.vue+++ b/frontend/src/components/InstanceForm/OracleSyncModeInput.vue@@ -5,34 +5,30 @@</label><div class="flex items-center gap-x-6"><label class="flex items-center gap-1.5">- <input- v-model="state.mode"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- value="DATABASE"+ <NRadio+ :checked="state.mode === 'DATABASE'":disabled="!allowEdit"- />- <span class="text-sm font-medium text-gray-700">- {{ $t("instance.sync-mode.database.self") }}- </span>+ @update:checked="toggleChecked('DATABASE', $event)"+ >+ <span class="text-sm font-medium text-gray-700">+ {{ $t("instance.sync-mode.database.self") }}+ </span>+ </NRadio></label><label class="flex items-center gap-1.5">- <input- v-model="state.mode"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- value="SCHEMA"+ <NRadio+ :checked="state.mode === 'SCHEMA'":disabled="!allowEdit"- />- <span class="text-sm font-medium text-gray-700">- {{ $t("instance.sync-mode.schema.self") }}- </span>+ @update:checked="toggleChecked('SCHEMA', $event)"+ >+ <span class="text-sm font-medium text-gray-700">+ {{ $t("instance.sync-mode.schema.self") }}+ </span>+ </NRadio></label></div>- <label class="text-xs text-control-light ml-[calc(16px+0.375rem)]">+ <label class="text-xs text-control-light ml-[1.5rem]"><template v-if="state.mode === 'DATABASE'">{{ $t("instance.sync-mode.database.description") }}</template>@@ -44,6 +40,7 @@</template><script lang="ts" setup>+import { NRadio } from "naive-ui";import { reactive, watch } from "vue";type SyncMode = "SCHEMA" | "DATABASE";@@ -70,6 +67,11 @@ const state = reactive<LocalState>({mode: guessModeFromSchemaTenantMode(props.schemaTenantMode),});+const toggleChecked = (mode: SyncMode, on: boolean) => {+ if (!on) return;+ state.mode = mode;+};+const update = (mode: SyncMode) => {emit("update:schemaTenantMode", mode === "SCHEMA" ? true : false);};diff --git a/frontend/src/components/InstanceForm/SpannerHostInput.vue b/frontend/src/components/InstanceForm/SpannerHostInput.vueindex 2201f1998a..977d15adfe 100644--- a/frontend/src/components/InstanceForm/SpannerHostInput.vue+++ b/frontend/src/components/InstanceForm/SpannerHostInput.vue@@ -5,15 +5,12 @@{{ $t("instance.project-id") }}<span style="color: red">*</span></label>- <input- v-model="state.projectId"+ <NInput+ v-model:value="state.projectId"required- type="text"placeholder="projectId"- class="textfield mt-1 w-full"- :class="[- state.dirty && !isValidProjectId && '!border-error !ring-error',- ]"+ class="mt-1 w-full"+ :status="state.dirty && !isValidProjectId ? 'error' : undefined":disabled="!allowEdit"/></div>@@ -22,15 +19,12 @@{{ $t("instance.instance-id") }}<span style="color: red">*</span></label>- <input- v-model="state.instanceId"+ <NInput+ v-model:value="state.instanceId"required- type="text"placeholder="instanceId"- class="textfield mt-1 w-full"- :class="[- state.dirty && !isValidInstanceId && '!border-error !ring-error',- ]"+ class="mt-1 w-full"+ :status="state.dirty && !isValidInstanceId ? 'error' : undefined":disabled="!allowEdit"/></div>@@ -42,14 +36,15 @@target="_blank"class="normal-link inline-flex items-center">- {{ $t("common.detailed-guide")- }}<heroicons-outline:external-link class="w-4 h-4 ml-1"- /></a>+ {{ $t("common.detailed-guide") }}+ <heroicons-outline:external-link class="w-4 h-4 ml-1" />+ </a></p></div></template><script lang="ts" setup>+import { NInput } from "naive-ui";import { computed, reactive, watch } from "vue";type LocalState = {diff --git a/frontend/src/components/misc/DroppableTextarea.vue b/frontend/src/components/misc/DroppableTextarea.vueindex b8c32cafbe..0375e80af2 100644--- a/frontend/src/components/misc/DroppableTextarea.vue+++ b/frontend/src/components/misc/DroppableTextarea.vue@@ -5,9 +5,9 @@:class="[state.reading && 'pointer-events-none']"><textarea+ ref="textareaRef"v-model="state.value"- class="textarea"- :class="[rounded && 'rounded-md']"+ class="textarea rounded-[3px]":placeholder="placeholder"v-bind="$attrs"/>@@ -16,6 +16,7 @@v-if="!state.value"class="absolute bottom-2 left-[50%] -translate-x-1/2 flex flex-col items-center justify-center border border-control-border hover:border-control-hover border-dashed text-xs text-control-placeholder hover:text-control-hover p-2 rounded-md">+ {{ borderRadius }}Or drag and drop files here.<inputtype="file"@@ -28,7 +29,9 @@<divv-if="isOverDropZone || state.reading"class="absolute inset-0 pointer-events-none flex flex-col items-center justify-center bg-white/50 border border-accent border-dashed"- :class="[rounded && 'rounded-md']"+ :style="{+ borderRadius,+ }"><heroicons-outline:arrow-up-tray v-if="isOverDropZone" class="w-8 h-8" /><BBSpin v-if="state.reading" />@@ -44,12 +47,13 @@ export default {<script lang="ts" setup>import { reactive, ref, watch } from "vue";-import { useDropZone } from "@vueuse/core";+import { useDropZone, useMutationObserver } from "@vueuse/core";import { head } from "lodash-es";import { useI18n } from "vue-i18n";import { pushNotification } from "@/store";import { BBSpin } from "@/bbkit";+import { onMounted } from "vue";type LocalState = {value: string | undefined;@@ -61,12 +65,10 @@ const props = withDefaults(value: string | undefined;placeholder?: string;maxFileSize?: number; // in MB- rounded?: boolean;}>(),{placeholder: undefined,maxFileSize: 1,- rounded: false,});@@ -80,6 +82,9 @@ const state = reactive<LocalState>({reading: false,});const container = ref<HTMLDivElement>();+const textareaRef = ref<HTMLTextAreaElement>();++const borderRadius = ref("");watch(() => props.value,@@ -130,4 +135,24 @@ const handleFileChange = (e: Event) => {};const { isOverDropZone } = useDropZone(container, onDrop);++const updateBorderRadius = (textarea: HTMLTextAreaElement) => {+ borderRadius.value = getComputedStyle(textarea).borderRadius;+};+useMutationObserver(+ textareaRef,+ (records) => {+ updateBorderRadius(records[0].target as HTMLTextAreaElement);+ },+ {+ attributeFilter: ["style", "class"],+ attributes: true,+ }+);+onMounted(() => {+ const textarea = textareaRef.value;+ if (textarea) {+ updateBorderRadius(textarea);+ }+});</script>diff --git a/frontend/src/components/v2/Select/DatabaseSelect.vue b/frontend/src/components/v2/Select/DatabaseSelect.vueindex 3f697fe62c..42dc5a2c68 100644--- a/frontend/src/components/v2/Select/DatabaseSelect.vue+++ b/frontend/src/components/v2/Select/DatabaseSelect.vue@@ -17,6 +17,7 @@<script lang="ts" setup>import { NSelect, SelectOption, SelectRenderLabel } from "naive-ui";import { computed, h, watch } from "vue";+import { useSlots } from "vue";import { useI18n } from "vue-i18n";import {useCurrentUserV1,@@ -33,6 +34,7 @@ interface DatabaseSelectOption extends SelectOption {database: ComposedDatabase;}+const slots = useSlots();const props = withDefaults(defineProps<{database?: string;@@ -125,6 +127,10 @@ const renderLabel: SelectRenderLabel = (option) => {return;}+ if (slots.default) {+ return slots.default({ database });+ }+const children = [h("div", {}, [database.databaseName])];if (database.uid !== String(UNKNOWN_ID)) {// prefix engine icon