Skip to content

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

chore: feature guard to instance SSH connection (#5920)

Liu Jic95d7bfd239f
diff --git a/backend/legacyapi/plan.go b/backend/legacyapi/plan.go
index 07fb6d364e..afe2fee269 100644
--- a/backend/legacyapi/plan.go
+++ b/backend/legacyapi/plan.go
@@ -137,6 +137,8 @@ const (
// FeatureReadReplicaConnection allows user to set a read replica connection
// including host and port to data source.
FeatureReadReplicaConnection FeatureType = "bb.feature.read-replica-connection"
+ // FeatureInstanceSSHConnection provides SSH connection for instances.
+ FeatureInstanceSSHConnection FeatureType = "bb.feature.instance-ssh-connection"
// FeatureSyncSchemaAllVersions allows user to sync the base database schema all versions into target database.
FeatureSyncSchemaAllVersions FeatureType = "bb.feature.sync-schema-all-versions"
// FeatureIndexAdvisor provides the index advisor for databases.
@@ -229,6 +231,8 @@ func (e FeatureType) Name() string {
return "Point-in-time Recovery"
case FeatureReadReplicaConnection:
return "Read replica connection"
+ case FeatureInstanceSSHConnection:
+ return "Instance SSH connection"
case FeatureSyncSchemaAllVersions:
return "Synchronize schema all versions"
case FeatureIndexAdvisor:
@@ -303,6 +307,7 @@ var FeatureMatrix = map[FeatureType][3]bool{
// Database management
FeaturePITR: {false, true, true},
FeatureReadReplicaConnection: {false, false, true},
+ FeatureInstanceSSHConnection: {false, false, true},
FeatureSyncSchemaAllVersions: {false, true, true},
FeatureIndexAdvisor: {false, false, true},
// Policy Control
diff --git a/frontend/src/components/InstanceForm.vue b/frontend/src/components/InstanceForm.vue
index ce4fef2660..ba98df5407 100644
--- a/frontend/src/components/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm.vue
@@ -468,10 +468,14 @@
</div>
<div v-if="showSSH" class="mt-2 sm:col-span-3 sm:col-start-1">
- <div class="flex flex-row items-center">
+ <div class="flex flex-row items-center gap-x-1">
<label for="ssh" class="textlabel block">
{{ $t("data-source.ssh-connection") }}
</label>
+ <FeatureBadge
+ feature="bb.feature.instance-ssh-connection"
+ class="text-accent"
+ />
</div>
<SshConnectionForm
:value="currentDataSource.options"
@@ -569,8 +573,12 @@
</template>
<script lang="ts" setup>
-import { cloneDeep, isEqual, omit } from "lodash-es";
import { computed, reactive, PropType, ref, watch, onMounted } from "vue";
+import { cloneDeep, isEqual, isEmpty, omit } from "lodash-es";
+import { useI18n } from "vue-i18n";
+import { Status } from "nice-grpc-common";
+import { useRouter } from "vue-router";
+
import {
hasWorkspacePermission,
instanceHasSSL,
@@ -599,8 +607,6 @@ import {
ValidatedMessage,
DataSourceOptions,
} from "../types";
-import isEmpty from "lodash-es/isEmpty";
-import { useI18n } from "vue-i18n";
import {
hasFeature,
pushNotification,
@@ -612,9 +618,10 @@ import {
useActuatorStore,
useSQLStore,
} from "@/store";
-import { useRouter } from "vue-router";
+import { getErrorCode } from "@/utils/grpcweb";
import EnvironmentSelect from "../components/EnvironmentSelect.vue";
import InstanceEngineIcon from "../components/InstanceEngineIcon.vue";
+import FeatureBadge from "./FeatureBadge.vue";
import {
SpannerHostInput,
SpannerCredentialInput,
@@ -627,8 +634,6 @@ import {
environmentNamePrefix,
instanceNamePrefix,
} from "@/store/modules/v1/common";
-import { getErrorCode } from "@/utils/grpcweb";
-import { Status } from "nice-grpc-common";
import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";
const props = defineProps({
diff --git a/frontend/src/components/InstanceForm/SshConnectionForm.vue b/frontend/src/components/InstanceForm/SshConnectionForm.vue
index 93551e7348..cc85952eb5 100644
--- a/frontend/src/components/InstanceForm/SshConnectionForm.vue
+++ b/frontend/src/components/InstanceForm/SshConnectionForm.vue
@@ -1,7 +1,13 @@
<template>
<div class="radio-set-row mt-2">
<label v-for="type in SshTypes" :key="type" class="radio">
- <input v-model="state.type" type="radio" class="btn" :value="type" />
+ <input
+ type="radio"
+ class="btn"
+ :value="type"
+ :checked="state.type === type"
+ @input="handleSelectType"
+ />
<span class="label">
{{ getSshTypeLabel(type) }}
</span>
@@ -87,6 +93,12 @@
</div>
</div>
</template>
+
+ <FeatureModal
+ v-if="state.showFeatureModal"
+ feature="bb.feature.instance-ssh-connection"
+ @cancel="state.showFeatureModal = false"
+ />
</template>
<script lang="ts" setup>
@@ -95,6 +107,8 @@ import { useI18n } from "vue-i18n";
import { cloneDeep } from "lodash-es";
import DroppableTextarea from "../misc/DroppableTextarea.vue";
+import { hasFeature } from "@/store";
+import FeatureModal from "../FeatureModal.vue";
const SshTypes = ["NONE", "TUNNEL", "TUNNEL+PK"] as const;
@@ -112,6 +126,7 @@ type LocalState = {
type: SshType;
value: WithSshOptions;
tab: "TUNNEL" | "TUNNEL+PK";
+ showFeatureModal: boolean;
};
const props = defineProps({
@@ -137,8 +152,27 @@ const state = reactive<LocalState>({
sshPrivateKey: props.value.sshPrivateKey,
},
tab: "TUNNEL",
+ showFeatureModal: false,
});
+const handleSelectType = (e: Event) => {
+ const radio = e.target as HTMLInputElement;
+ const type = radio.value as SshType;
+
+ if (!hasFeature("bb.feature.instance-ssh-connection")) {
+ if (type !== "NONE") {
+ state.type = "NONE";
+ radio.checked = false;
+ e.preventDefault();
+ e.stopPropagation();
+ state.showFeatureModal = true;
+ return;
+ }
+ }
+
+ state.type = type;
+};
+
// Sync the latest version to local state when props.value changed.
watch(
() => props.value,
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 1731670a8d..6ed9aa4eb2 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1929,6 +1929,10 @@
"title": "Read replica connection",
"desc": "Connect to a read replica for the read-only data source."
},
+ "bb-feature-instance-ssh-connection": {
+ "title": "Instance SSH connection",
+ "desc": "Connect to a instance over SSH."
+ },
"bb-feature-index-advisor": {
"title": "Index advisor",
"desc": "Index advisor can help you to find the missing indexes in slow queries."
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 618887a571..1b9b15aa4d 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1926,6 +1926,10 @@
"title": "Read replica connection",
"desc": "使用只读副本连接到只读数据源。"
},
+ "bb-feature-instance-ssh-connection": {
+ "title": "SSH 实例连接",
+ "desc": "通过 SSH 连接实例。"
+ },
"bb-feature-index-advisor": {
"title": "索引建议",
"desc": "索引建议可以找到导致慢查询的索引,并提供相关的优化建议。"
diff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.ts
index ab44923bfb..06ccfefa17 100644
--- a/frontend/src/types/plan.ts
+++ b/frontend/src/types/plan.ts
@@ -36,6 +36,7 @@ export type FeatureType =
// Database management
| "bb.feature.pitr"
| "bb.feature.read-replica-connection"
+ | "bb.feature.instance-ssh-connection"
| "bb.feature.sync-schema-all-versions"
| "bb.feature.index-advisor"
// Policy Control