Skip to content

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

chore: bq host ui (#12112)

Danny Xu0bca6b0db699
diff --git a/frontend/src/components/InstanceForm/BigQueryHostInput.vue b/frontend/src/components/InstanceForm/BigQueryHostInput.vue
new file mode 100644
index 0000000000..ee0eba94c8
--- /dev/null
+++ b/frontend/src/components/InstanceForm/BigQueryHostInput.vue
@@ -0,0 +1,83 @@
+<template>
+ <div class="grid grid-cols-2 gap-x-2 gap-y-1">
+ <div>
+ <label class="textlabel">
+ {{ $t("instance.project-id") }}
+ <span style="color: red">*</span>
+ </label>
+ <NInput
+ v-model:value="state.projectId"
+ required
+ placeholder="projectId"
+ class="mt-1 w-full"
+ :status="state.dirty && !isValidProjectId ? 'error' : undefined"
+ :disabled="!allowEdit"
+ />
+ </div>
+
+ <p class="col-span-2 textinfolabel">
+ {{ $t("instance.find-gcp-project-id-and-instance-id") }}
+ <a
+ href="https://www.bytebase.com/docs/get-started/instance/#specify-google-cloud-project-id-and-spanner-instance-id?source=console"
+ 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>
+ </p>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { NInput } from "naive-ui";
+import { computed, reactive, watch } from "vue";
+
+type LocalState = {
+ projectId: string;
+ dirty: boolean;
+};
+
+const props = defineProps<{
+ host: string;
+ allowEdit: boolean;
+}>();
+
+const emit = defineEmits<{
+ (name: "update:host", host: string): void;
+}>();
+
+const RE_PROJECT_ID = /^(?:[a-z]|[-.:]|[0-9])+$/;
+
+const state = reactive<LocalState>({
+ projectId: "",
+ dirty: false,
+});
+
+const isValidProjectId = computed(() => {
+ return RE_PROJECT_ID.test(state.projectId);
+});
+
+const update = () => {
+ if (!isValidProjectId.value) {
+ emit("update:host", "");
+ return;
+ }
+ const host = `${state.projectId}`;
+ emit("update:host", host);
+};
+
+watch([() => state.projectId], () => {
+ state.dirty = true;
+ update();
+});
+
+watch(
+ () => props.host,
+ (host) => {
+ if (!host) return;
+ state.projectId = host;
+ },
+ { immediate: true }
+);
+</script>
diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vue
index 91297476bb..49d8bcc147 100644
--- a/frontend/src/components/InstanceForm/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm/InstanceForm.vue
@@ -106,7 +106,19 @@
</div>
<div class="sm:col-span-3 sm:col-start-1">
- <template v-if="basicInfo.engine !== Engine.SPANNER">
+ <template v-if="basicInfo.engine === Engine.SPANNER">
+ <SpannerHostInput
+ v-model:host="adminDataSource.host"
+ :allow-edit="allowEdit"
+ />
+ </template>
+ <template v-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") }}
@@ -161,16 +173,11 @@
{{ $t("instance.sentence.proxy.snowflake") }}
</div>
</template>
- <SpannerHostInput
- v-else
- v-model:host="adminDataSource.host"
- :allow-edit="allowEdit"
- />
</div>
<template
v-if="
- basicInfo.engine !== Engine.SPANNER &&
+ (basicInfo.engine !== Engine.SPANNER && basicInfo.engine !== Engine.BIGQUERY) &&
adminDataSource.authenticationType !==
DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
"
@@ -541,6 +548,7 @@ import { extractGrpcErrorMessage, getErrorCode } from "@/utils/grpcweb";
import DataSourceSection from "./DataSourceSection/DataSourceSection.vue";
import ScanIntervalInput from "./ScanIntervalInput.vue";
import SpannerHostInput from "./SpannerHostInput.vue";
+import BigQueryHostInput from "./BigQueryHostInput.vue";
import type { EditDataSource } from "./common";
import { extractBasicInfo, extractDataSourceEditState } from "./common";
import {