Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): add feature gate to gh-ost (#1665)
Liu Ji0ba4b1ba7f33
diff --git a/frontend/src/bbkit/BBDialog.vue b/frontend/src/bbkit/BBDialog.vueindex c541f983b5..49b02a3dc0 100644--- a/frontend/src/bbkit/BBDialog.vue+++ b/frontend/src/bbkit/BBDialog.vue@@ -30,10 +30,10 @@</template><script lang="ts" setup>-import { reactive } from "vue";+import { PropType, reactive } from "vue";import { Defer, defer } from "@/utils";-defineProps({+const props = defineProps({title: {type: String,required: true,@@ -54,6 +54,14 @@ defineProps({type: String,default: undefined,},+ onBeforePositiveClick: {+ type: Function as PropType<() => boolean>,+ default: undefined,+ },+ onBeforeNegativeClick: {+ type: Function as PropType<() => boolean>,+ default: undefined,+ },});const state = reactive({@@ -73,11 +81,23 @@ const open = () => {};const onPositiveClick = () => {+ if (props.onBeforePositiveClick) {+ if (!props.onBeforePositiveClick()) {+ return;+ }+ }+state.visible = false;state.defer?.resolve(true);};const onNegativeClick = () => {+ if (props.onBeforeNegativeClick) {+ if (!props.onBeforeNegativeClick()) {+ return;+ }+ }+state.visible = false;state.defer?.resolve(false);};diff --git a/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue b/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vueindex 096e6db054..31533ecf9f 100644--- a/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue+++ b/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue@@ -3,6 +3,7 @@ref="dialog":title="$t('issue.migration-mode.title')":positive-text="$t('common.next')"+ :on-before-positive-click="checkFeature"data-label="bb-migration-mode-dialog"><div class="w-[28rem] space-y-4 pl-8 pr-2 pb-4">@@ -32,8 +33,12 @@value="online"/><div @click="state.mode = 'online'">- <div class="textlabel space-x-2">+ <div class="textlabel flex items-center space-x-2"><span>{{ $t("issue.migration-mode.online.title") }}</span>+ <FeatureBadge+ feature="bb.feature.online-migration"+ class="text-accent"+ /><BBBetaBadge /></div><div class="textinfolabel mt-1">@@ -49,25 +54,49 @@</div></div></BBDialog>++ <FeatureModal+ v-if="state.showFeatureModal"+ feature="bb.feature.online-migration"+ @cancel="state.showFeatureModal = false"+ /></template><script lang="ts" setup>import { reactive, ref } from "vue";import { BBDialog } from "@/bbkit";import LearnMoreLink from "../LearnMoreLink.vue";+import { featureToRef } from "@/store";type Mode = "normal" | "online";type LocalState = {mode: Mode;+ showFeatureModal: boolean;};const dialog = ref<InstanceType<typeof BBDialog> | null>(null);const state = reactive<LocalState>({mode: "normal",+ showFeatureModal: false,});+const hasGhostFeature = featureToRef("bb.feature.online-migration");++const checkFeature = (): boolean => {+ if (state.mode === "normal") {+ // Don't block anything when selecting normal migration+ return true;+ }++ if (!hasGhostFeature.value) {+ state.showFeatureModal = true;+ return false;+ }+ return true;+};+const open = (): Promise<{ result: boolean; mode: Mode }> => {state.mode = "normal"; // reset statediff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex e06de64865..db2a5af479 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1308,6 +1308,10 @@"bb-feature-branding": {"title": "Branding","desc": "Customize the logo."+ },+ "bb-feature-online-migration": {+ "title": "Online migration",+ "desc": "Based on gh-ost. For large tables, it can reduce the table lock duration from hours to seconds."}},"feature-sections": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 24ad1da067..ba3e4d26eb 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1308,6 +1308,10 @@"bb-feature-branding": {"title": "自定义品牌信息","desc": "定制 Logo"+ },+ "bb-feature-online-migration": {+ "title": "在线变更",+ "desc": "基于 gh-ost。对于大表,可以把锁表的时间从小时级降低到秒级。"}},"feature-sections": {diff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.tsindex d451746986..b2682bcfa9 100644--- a/frontend/src/types/plan.ts+++ b/frontend/src/types/plan.ts@@ -7,6 +7,7 @@ export type FeatureType =| "bb.feature.multi-tenancy"| "bb.feature.dba-workflow"| "bb.feature.data-source"+ | "bb.feature.online-migration"// Policy Control| "bb.feature.approval-policy"| "bb.feature.backup-policy"@@ -52,6 +53,7 @@ export const FEATURE_MATRIX: Map<FeatureType, boolean[]> = new Map([["bb.feature.multi-tenancy", [false, true, true]],["bb.feature.dba-workflow", [false, false, true]],["bb.feature.data-source", [false, false, false]],+ ["bb.feature.online-migration", [false, true, true]],// Policy Control["bb.feature.approval-policy", [false, true, true]],["bb.feature.backup-policy", [false, true, true]],