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: add subscription upgrade banner (#6081)
boojack9931f40266dd
diff --git a/frontend/src/components/BannersWrapper.vue b/frontend/src/components/BannersWrapper.vueindex 838772c386..04bf5c29d5 100644--- a/frontend/src/components/BannersWrapper.vue+++ b/frontend/src/components/BannersWrapper.vue@@ -1,4 +1,5 @@<template>+ <BannerUpgradeSubscription /><template v-if="shouldShowDemoBanner"><BannerDemo /></template>@@ -34,6 +35,7 @@ import BannerDemo from "@/views/BannerDemo.vue";import BannerDebug from "@/views/BannerDebug.vue";import BannerExternalUrl from "@/views/BannerExternalUrl.vue";import BannerSubscription from "@/views/BannerSubscription.vue";+import BannerUpgradeSubscription from "@/views/BannerUpgradeSubscription.vue";const actuatorStore = useActuatorStore();const currentUser = useCurrentUser();diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex a9f5c1bc31..3f18453d11 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1839,6 +1839,7 @@"trial-for-plan": "You can start a free trial for {plan} with {days} days - no credit card required","trial-for-days": "You can start a free trial for {days} days - no credit card required","upgrade-trial": "You can upgrade your free trial to this plan",+ "upgrade-now": "Upgrade Now","update": {"success": {"title": "Successfully updated license",@@ -1849,6 +1850,12 @@"description": "Please check if your license is valid."}},+ "plan-features": "{plan} Features",+ "overuse-warning": "{neededPlan} on {currentPlan} may be lost. Upgrade now to ensure continued access.",+ "overuse-modal": {+ "description": "You are using features unavailable in the {plan}. Upgrade now to ensure continued access:",+ "instance-count-exceeds": "Instance count exceeds the limit ${count}"+ },"features": {"bb-feature-task-schedule-time": {"title": "Set task schedule time",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex eba4d68e4e..aed0abf5e3 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1828,6 +1828,7 @@"trial-for-plan": "Puedes iniciar una prueba gratuita de {plan} por {days} días - no se requiere tarjeta de crédito","trial-for-days": "Puedes iniciar una prueba gratuita por {days} días - no se requiere tarjeta de crédito","upgrade-trial": "Puedes actualizar tu prueba gratuita a este plan",+ "upgrade-now": "Actualizar ahora","update": {"success": {"title": "Licencia actualizada con éxito",@@ -1838,6 +1839,12 @@"description": "Por favor, comprueba si tu licencia es válida."}},+ "plan-features": "{plan} función",+ "overuse-warning": "{neededPlan} puede estar restringido en {currentPlan}, actualice ahora para asegurar un uso adecuado.",+ "overuse-modal": {+ "description": "Está utilizando una función que actualmente no está incluida en {plan}. Actualice ahora para evitar interrupciones.",+ "instance-count-exceeds": "El número de instancias excedió el límite {count}"+ },"features": {"bb-feature-task-schedule-time": {"title": "Establecer horario de tareas",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 9194004f62..686aba592d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1835,6 +1835,7 @@"trial-for-plan": "您可以开启{plan}的 {days} 天免费试用 - 无需任何信用卡或预付费","trial-for-days": "您可以开启 {days} 天的免费试用 - 无需任何信用卡或预付费","upgrade-trial": "您可以直接将现有的试用升级到这个版本",+ "upgrade-now": "现在升级","update": {"success": {"title": "证书更新成功",@@ -1845,6 +1846,12 @@"description": "请检查证书是否有效"}},+ "plan-features": "{plan}功能",+ "overuse-warning": "{neededPlan}在{currentPlan}可能受限,现在升级以确保正常使用。",+ "overuse-modal": {+ "description": "您正在使用当前 {plan} 不包含的功能。立即升级避免影响使用。",+ "instance-count-exceeds": "实例数量超出了限制 {count}"+ },"features": {"bb-feature-task-schedule-time": {"title": "设定任务执行时间",diff --git a/frontend/src/views/BannerUpgradeSubscription.vue b/frontend/src/views/BannerUpgradeSubscription.vuenew file mode 100644index 0000000000..c38d883c4f--- /dev/null+++ b/frontend/src/views/BannerUpgradeSubscription.vue@@ -0,0 +1,187 @@+<template>+ <div v-if="showBanner" class="bg-warning">+ <div+ class="mx-auto py-3 px-3 w-full flex flex-row items-center justify-between flex-wrap"+ >+ <div class="flex flex-row items-center">+ <heroicons-outline:megaphone class="w-8 h-auto text-gray-800 mr-1" />+ <i18n-t+ tag="p"+ keypath="subscription.overuse-warning"+ class="text-white text-lg"+ >+ <template #neededPlan>+ <span+ class="underline cursor-pointer hover:opacity-80"+ @click="state.showModal = true"+ >{{ neededPlan }}</span+ >+ </template>+ <template #currentPlan>+ {{ currentPlan }}+ </template>+ </i18n-t>+ </div>+ <button class="bg-white btn btn-normal" @click="gotoSubscriptionPage">+ {{ $t("subscription.button.upgrade") }}+ <heroicons-outline:sparkles class="w-5 h-auto text-accent ml-1" />+ </button>+ </div>+ </div>++ <BBModal+ v-if="state.showModal"+ class="!w-112"+ :title="$t('subscription.upgrade-now') + '?'"+ @close="state.showModal = false"+ >+ <p>+ {{ $t("subscription.overuse-modal.description", { plan: currentPlan }) }}+ </p>+ <div class="pl-4 my-2">+ <ul class="list-disc list-inside">+ <li v-for="feature in overusedFeatureList" :key="feature">+ {{ feature }}+ </li>+ </ul>+ </div>+ <button+ class="mt-3 mb-4 w-full btn btn-primary"+ @click="gotoSubscriptionPage"+ >+ <span class="w-full text-center">{{+ $t("subscription.upgrade-now")+ }}</span>+ </button>+ </BBModal>+</template>++<script lang="ts" setup>+import { reactive } from "vue";+import {+ useIdentityProviderStore,+ useInstanceStore,+ useSettingStore,+ useSubscriptionStore,+} from "@/store";+import { onMounted } from "vue";+import { computed } from "vue";+import { FeatureType, planTypeToString } from "@/types";+import { useEnvironmentV1Store } from "@/store/modules/v1/environment";+import { EnvironmentTier } from "@/types/proto/v1/environment_service";+import { useI18n } from "vue-i18n";+import { PlanType } from "@/types/proto/v1/subscription_service";+import { useRouter } from "vue-router";++interface LocalState {+ showModal: boolean;+}++const { t } = useI18n();+const router = useRouter();+const subscriptionStore = useSubscriptionStore();+const state = reactive<LocalState>({+ showModal: false,+});++const idpStore = useIdentityProviderStore();+const settingStore = useSettingStore();+const instanceStore = useInstanceStore();+const environmentV1Store = useEnvironmentV1Store();++const showBanner = computed(() => {+ return (+ subscriptionStore.currentPlan !== PlanType.ENTERPRISE &&+ overusedFeatureList.value.length > 0+ );+});++const neededPlan = computed(() => {+ let plan = PlanType.TEAM;+ if (overusedEnterprisePlanFeatureList.value.length > 0) {+ plan = PlanType.ENTERPRISE;+ }+ return t("subscription.plan-features", {+ plan: t(`subscription.plan.${planTypeToString(plan)}.title`),+ });+});++const currentPlan = computed(() => {+ return t(+ `subscription.plan.${planTypeToString(subscriptionStore.currentPlan)}.title`+ );+});++const overusedEnterprisePlanFeatureList = computed(() => {+ if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {+ return [];+ }++ const list: FeatureType[] = [];++ if (idpStore.identityProviderList.length > 0) {+ list.push("bb.feature.sso");+ }+ const brandingSetting = settingStore.getSettingByName("bb.branding.logo");+ if (brandingSetting && brandingSetting.value) {+ list.push("bb.feature.branding");+ }+ const watermarkSetting = settingStore.getSettingByName(+ "bb.workspace.watermark"+ );+ if (watermarkSetting && watermarkSetting.value === "1") {+ list.push("bb.feature.watermark");+ }+ if (settingStore.workspaceSetting?.disallowSignup ?? false) {+ list.push("bb.feature.disallow-signup");+ }+ if (settingStore.workspaceSetting?.require2fa ?? false) {+ list.push("bb.feature.2fa");+ }+ const openAIKeySetting = settingStore.getSettingByName(+ "bb.plugin.openai.key"+ );+ if (openAIKeySetting && openAIKeySetting.value) {+ list.push("bb.feature.plugin.openai");+ }+ for (const environment of environmentV1Store.environmentList) {+ if (environment.tier === EnvironmentTier.PROTECTED) {+ list.push("bb.feature.environment-tier-policy");+ break;+ }+ }++ return list;+});++const overusedFeatureList = computed(() => {+ const list: string[] = [];+ for (const feature of overusedEnterprisePlanFeatureList.value) {+ list.push(t(`subscription.features.${feature.split(".").join("-")}.title`));+ }+ if (instanceStore.instanceById.size > subscriptionStore.instanceCount) {+ list.push(t("subscription.overuse-modal.instance-count-exceeds"));+ }+ return list;+});++onMounted(() => {+ if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {+ return;+ }++ Promise.all([+ idpStore.fetchIdentityProviderList(),+ settingStore.fetchSetting(),+ environmentV1Store.fetchEnvironments(),+ instanceStore.fetchInstanceList(),+ ]).catch(() => {+ // ignore+ });+});++const gotoSubscriptionPage = () => {+ state.showModal = false;+ return router.push({ name: "setting.workspace.subscription" });+};+</script>