Skip to content

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

chore: feature guard (#9180)

Liu Jif1abbe738920
diff --git a/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue
index 4111514c30..e70d279b69 100644
--- a/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue
+++ b/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue
@@ -9,7 +9,9 @@
>
<NTooltip :show-arrow="true">
<template #trigger>
- <heroicons-outline:exclamation class="text-warning w-5 h-5" />
+ <slot name="default">
+ <heroicons-outline:exclamation class="text-warning w-5 h-5" />
+ </slot>
</template>
<span class="w-56 text-sm">
{{
diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSection.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSection.vue
index 6333771193..355d2196fc 100644
--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSection.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSection.vue
@@ -3,39 +3,57 @@
v-if="shouldShowGhostSection"
class="flex items-center gap-x-3 min-h-[34px]"
>
- <NTooltip>
- <template #trigger>
- <div class="textlabel flex items-center">
+ <div class="textlabel flex items-center gap-x-1">
+ <NTooltip>
+ <template #trigger>
{{ $t("task.online-migration.self") }}
- </div>
- </template>
- <template #default>
- <i18n-t
- tag="p"
- keypath="issue.migration-mode.online.description"
- class="whitespace-pre-line max-w-[20rem]"
- >
- <template #link>
- <LearnMoreLink
- url="https://www.bytebase.com/docs/change-database/online-schema-migration-for-mysql"
- color="light"
- />
- </template>
- </i18n-t>
- </template>
- </NTooltip>
+ </template>
+ <template #default>
+ <i18n-t
+ tag="p"
+ keypath="issue.migration-mode.online.description"
+ class="whitespace-pre-line max-w-[20rem]"
+ >
+ <template #link>
+ <LearnMoreLink
+ url="https://www.bytebase.com/docs/change-database/online-schema-migration-for-mysql"
+ color="light"
+ />
+ </template>
+ </i18n-t>
+ </template>
+ </NTooltip>
+ <FeatureBadge feature="bb.feature.online-migration" />
+ <FeatureBadgeForInstanceLicense
+ feature="bb.feature.online-migration"
+ :show="hasOnlineMigrationFeature"
+ :instance="instance"
+ >
+ <LockIcon class="w-4 h-4 text-accent" />
+ </FeatureBadgeForInstanceLicense>
+ </div>
+
<div class="w-[12rem] flex items-center gap-x-2">
<GhostSwitch v-if="isCreating" />
<GhostConfigButton v-if="viewType === 'ON'" />
</div>
<GhostFlagsPanel />
+
+ <FeatureModal
+ :open="showFeatureModal"
+ feature="bb.feature.online-migration"
+ @cancel="showFeatureModal = false"
+ />
</div>
</template>
<script lang="ts" setup>
+import { LockIcon } from "lucide-vue-next";
import { computed } from "vue";
-import { useIssueContext } from "@/components/IssueV1/logic";
+import FeatureBadgeForInstanceLicense from "@/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue";
+import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
+import { featureToRef } from "@/store";
import { flattenTaskV1List } from "@/utils";
import GhostConfigButton from "./GhostConfigButton.vue";
import GhostFlagsPanel from "./GhostFlagsPanel.vue";
@@ -46,9 +64,9 @@ import {
provideIssueGhostContext,
} from "./common";
-const { isCreating, issue } = useIssueContext();
+const { isCreating, issue, selectedTask: task } = useIssueContext();
-const { viewType } = provideIssueGhostContext();
+const { viewType, showFeatureModal } = provideIssueGhostContext();
const shouldShowGhostSection = computed(() => {
// We need all tasks and specs to be gh-ost-able to enable gh-ost mode.
@@ -65,4 +83,10 @@ const shouldShowGhostSection = computed(() => {
return viewType.value === "ON";
}
});
+
+const hasOnlineMigrationFeature = featureToRef("bb.feature.online-migration");
+
+const instance = computed(() => {
+ return databaseForTask(issue.value, task.value).instanceEntity;
+});
</script>
diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSwitch.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSwitch.vue
index 4b7e7eab98..d144b27d60 100644
--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSwitch.vue
+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostSwitch.vue
@@ -19,10 +19,11 @@
import { NSwitch } from "naive-ui";
import { computed, ref } from "vue";
import { specForTask, useIssueContext } from "@/components/IssueV1/logic";
-import { provideIssueGhostContext } from "./common";
+import { hasFeature } from "@/store";
+import { useIssueGhostContext } from "./common";
const { isCreating, issue, selectedTask: task } = useIssueContext();
-const { viewType, toggleGhost } = provideIssueGhostContext();
+const { viewType, toggleGhost, showFeatureModal } = useIssueGhostContext();
const isUpdating = ref(false);
const allowChange = computed(() => {
@@ -34,6 +35,11 @@ const checked = computed(() => {
});
const toggleChecked = async (on: boolean) => {
+ if (!hasFeature("bb.feature.online-migration")) {
+ showFeatureModal.value = true;
+ return;
+ }
+
const spec = specForTask(issue.value.planEntity, task.value);
if (!spec) return;
isUpdating.value = true;
diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/common.ts b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/common.ts
index 1ea583a37e..4b82f56c7f 100644
--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/common.ts
+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/common.ts
@@ -35,6 +35,7 @@ export type IssueGhostContext = {
viewType: Ref<GhostUIViewType>;
showFlagsPanel: Ref<boolean>;
denyEditGhostFlagsReasons: Ref<string[]>;
+ showFeatureModal: Ref<boolean>;
toggleGhost: (spec: Plan_Spec, on: boolean) => Promise<void>;
};
@@ -121,6 +122,8 @@ export const provideIssueGhostContext = () => {
return errors;
});
+ const showFeatureModal = ref(false);
+
const toggleGhost = async (spec: Plan_Spec, on: boolean) => {
const overrides: Record<string, string> = {};
if (on) {
@@ -146,6 +149,7 @@ export const provideIssueGhostContext = () => {
viewType,
showFlagsPanel,
denyEditGhostFlagsReasons,
+ showFeatureModal,
toggleGhost,
};