Skip to content

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

chore: optimize subscription (#5655)

ecmadaoa593a9fdb10f
diff --git a/frontend/src/components/PricingTable/PricingTable.vue b/frontend/src/components/PricingTable/PricingTable.vue
index cfdf183220..f78cae9a5a 100644
--- a/frontend/src/components/PricingTable/PricingTable.vue
+++ b/frontend/src/components/PricingTable/PricingTable.vue
@@ -61,6 +61,7 @@
</div>
<button
+ v-if="plan.buttonText"
type="button"
:class="[
plan.highlight
@@ -73,7 +74,7 @@
{{ plan.buttonText }}
</button>
<div
- v-if="plan.trialDays"
+ v-if="plan.canTrial && subscriptionStore.canTrial"
class="font-bold text-sm my-2 text-center"
>
{{ $t("subscription.free-trial") }}
@@ -138,8 +139,16 @@
<tr class="border-t border-gray-200">
<th class="sr-only" scope="row">Choose your plan</th>
<td v-for="plan in plans" :key="plan.type" class="py-5 px-6">
+ <a
+ v-if="plan.type == PlanType.ENTERPRISE"
+ class="block w-full bg-gray-800 border border-gray-800 rounded-md py-2 text-lg font-semibold text-white text-center hover:bg-gray-900"
+ target="__blank"
+ :href="enterprisePlanFormLink"
+ >
+ {{ $t("subscription.button.contact-us") }}
+ </a>
<button
- v-if="!plan.isFreePlan"
+ v-else-if="plan.buttonText"
class="block w-full bg-gray-800 border border-gray-800 rounded-md py-2 text-lg font-semibold text-white text-center hover:bg-gray-900"
@click="onButtonClick(plan)"
>
@@ -196,6 +205,7 @@
</div>
<button
+ v-if="plan.buttonText"
type="button"
:class="[
plan.highlight
@@ -207,7 +217,10 @@
>
{{ plan.buttonText }}
</button>
- <div v-if="plan.trialDays" class="font-bold text-sm my-2 text-center">
+ <div
+ v-if="plan.canTrial && subscriptionStore.canTrial"
+ class="font-bold text-sm my-2 text-center"
+ >
{{ $t("subscription.free-trial") }}
</div>
@@ -258,8 +271,21 @@
</template>
</tbody>
</table>
+ <a
+ v-if="plan.type == PlanType.ENTERPRISE"
+ :class="[
+ plan.highlight
+ ? 'border-indigo-500 text-white bg-indigo-500 hover:bg-indigo-600 hover:border-indigo-600'
+ : 'border-accent text-accent hover:bg-accent',
+ 'mt-8 block w-full border rounded-md py-4 text-lg font-semibold text-center hover:text-white whitespace-nowrap overflow-hidden',
+ ]"
+ target="__blank"
+ :href="enterprisePlanFormLink"
+ >
+ {{ $t("subscription.button.contact-us") }}
+ </a>
<button
- v-if="!plan.isFreePlan"
+ v-else-if="plan.buttonText"
type="button"
:class="[
plan.highlight
@@ -300,6 +326,8 @@ const state = reactive<LocalState>({
instanceCount:
subscriptionStore.subscription?.instanceCount ?? minimumInstanceCount,
});
+const enterprisePlanFormLink =
+ "https://docs.google.com/forms/d/e/1FAIpQLSfe1JvroV4ckBMJo8hDXBYGeuzN0Sn1Ylg1lIUamN2jqu9Fcw/viewform";
watch(
() => subscriptionStore.subscription,
@@ -316,7 +344,6 @@ const plans = computed((): LocalPlan[] => {
buttonText: getButtonText(plan),
highlight: plan.type === PlanType.TEAM,
isAvailable: plan.type === PlanType.TEAM,
- isFreePlan: plan.type === PlanType.FREE,
label: t(`subscription.plan.${plan.title}.label`),
pricing:
plan.type === PlanType.ENTERPRISE
@@ -329,37 +356,76 @@ const plans = computed((): LocalPlan[] => {
: plan.type === PlanType.ENTERPRISE
? ""
: t("subscription.per-month"),
+ // only support free trial for enterprise in console.
+ canTrial: plan.type === PlanType.ENTERPRISE && plan.trialDays > 0,
}));
});
const getButtonText = (plan: Plan): string => {
- if (plan.type === PlanType.FREE) return t("subscription.deploy");
- if (plan.type === PlanType.ENTERPRISE) return t("subscription.contact-us");
-
- if (subscriptionStore.isTrialing) return t("subscription.subscribe");
- if (plan.type === subscriptionStore.currentPlan)
- return t("subscription.upgrade");
- if (plan.trialDays) return t("subscription.start-trial");
-
- return t("subscription.subscribe");
+ switch (plan.type) {
+ case PlanType.FREE:
+ return "";
+ case PlanType.TEAM:
+ if (subscriptionStore.currentPlan === PlanType.FREE) {
+ return t("subscription.button.upgrade");
+ }
+ if (subscriptionStore.currentPlan === PlanType.TEAM) {
+ return t("subscription.button.view-subscription");
+ }
+ if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {
+ return "";
+ }
+ break;
+ case PlanType.ENTERPRISE:
+ if (subscriptionStore.currentPlan === PlanType.FREE) {
+ return t("subscription.button.free-trial", {
+ days: subscriptionStore.trialingDays,
+ });
+ }
+ if (subscriptionStore.currentPlan === PlanType.TEAM) {
+ return t("subscription.button.free-trial", {
+ days: subscriptionStore.trialingDays,
+ });
+ }
+ if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {
+ if (subscriptionStore.isTrialing) {
+ return t("subscription.button.contact-us");
+ }
+ return t("subscription.button.view-subscription");
+ }
+ break;
+ }
+ return "";
};
const onButtonClick = (plan: Plan) => {
- if (plan.type === PlanType.TEAM) {
- if (subscriptionStore.canTrial && !subscriptionStore.isTrialing) {
- emit("on-trial");
+ switch (plan.type) {
+ case PlanType.TEAM:
+ if (subscriptionStore.currentPlan === PlanType.FREE) {
+ window.open(
+ "https://hub.bytebase.com/workspace?source=console.subscription",
+ "__blank"
+ );
+ } else if (subscriptionStore.currentPlan === PlanType.TEAM) {
+ window.open(
+ "https://hub.bytebase.com/subscription?source=console.subscription",
+ "__blank"
+ );
+ }
return;
- }
- window.open(
- "https://hub.bytebase.com/subscription?source=console.subscription",
- "__blank"
- );
- } else if (plan.type === PlanType.ENTERPRISE) {
- window.open(
- "https://docs.google.com/forms/d/e/1FAIpQLSfe1JvroV4ckBMJo8hDXBYGeuzN0Sn1Ylg1lIUamN2jqu9Fcw/viewform"
- );
- } else {
- window.open("https://bytebase.com/docs?source=console", "_self");
+ case PlanType.ENTERPRISE:
+ if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {
+ if (subscriptionStore.isTrialing) {
+ window.open(enterprisePlanFormLink, "__blank");
+ } else {
+ window.open(
+ "https://hub.bytebase.com/subscription?source=console.subscription",
+ "__blank"
+ );
+ }
+ } else {
+ emit("on-trial");
+ }
}
};
</script>
diff --git a/frontend/src/components/PricingTable/types.ts b/frontend/src/components/PricingTable/types.ts
index a7ad4fcfb4..64e32a39ab 100644
--- a/frontend/src/components/PricingTable/types.ts
+++ b/frontend/src/components/PricingTable/types.ts
@@ -5,9 +5,9 @@ export interface LocalPlan extends Plan {
image: string;
buttonText: string;
highlight: boolean;
- isFreePlan: boolean;
isAvailable: boolean;
pricing: string;
pricePrefix: string;
priceSuffix: string;
+ canTrial: boolean;
}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 2ad2695eb8..bd3eb94136 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1721,6 +1721,15 @@
"unknown-event": "Unexpected event type, OAuth failed."
},
"subscription": {
+ "try-for-free": "Free trial",
+ "inquire-enterprise-plan": "Inquire Enterprise Plan",
+ "enterprise-free-trial": "{days}-day free Enterprise trial",
+ "button": {
+ "free-trial": "{days}-day free trial",
+ "upgrade": "Upgrade",
+ "contact-us": "Contact us",
+ "view-subscription": "View subscription"
+ },
"trial-start-modal": {
"title": "Start your {plan} trial",
"content": "Your {plan} trial has started! You can access {plan} features before {date}.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index a85b008679..f5d4add269 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1720,6 +1720,15 @@
"unknown-event": "未知的事件类型,认证失败"
},
"subscription": {
+ "try-for-free": "免费试用",
+ "inquire-enterprise-plan": "企业版询价",
+ "enterprise-free-trial": "企业版 {days} 天免费试用",
+ "button": {
+ "free-trial": "{days} 天免费试用",
+ "upgrade": "升级",
+ "contact-us": "联系我们",
+ "view-subscription": "查看订阅"
+ },
"trial-start-modal": {
"title": "已开启{plan}试用",
"content": "您的{plan}试用已开启!在 {date} 之前所有{plan}功能将不受限制。",
diff --git a/frontend/src/types/plan.yaml b/frontend/src/types/plan.yaml
index c5f43599dc..7959dddcec 100644
--- a/frontend/src/types/plan.yaml
+++ b/frontend/src/types/plan.yaml
@@ -192,7 +192,7 @@ planList:
- pitr
- type: 2
title: enterprise
- trialDays: 0
+ trialDays: 14
unitPrice: 0
trialPrice: 0
freeSeatCount: -1
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index 475f97253a..66c9d22b9f 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -45,12 +45,56 @@
</dt>
<dd class="mt-1 text-4xl">{{ instanceCount }}</dd>
</div>
- <div class="my-3">
+ <div v-if="!subscriptionStore.isFreePlan" class="my-3">
<dt class="text-gray-400">
{{ $t("subscription.expires-at") }}
</dt>
<dd class="mt-1 text-4xl">{{ expireAt || "n/a" }}</dd>
</div>
+ <div
+ v-if="canTrial && subscriptionStore.currentPlan != PlanType.ENTERPRISE"
+ class="my-3"
+ >
+ <dt class="text-gray-400">
+ {{ $t("subscription.try-for-free") }}
+ </dt>
+
+ <dd class="mt-1">
+ <button
+ type="button"
+ class="btn-primary inline-flex justify-center ml-auto"
+ @click="state.showTrialModal = true"
+ >
+ {{
+ $t("subscription.enterprise-free-trial", {
+ days: subscriptionStore.trialingDays,
+ })
+ }}
+ </button>
+ </dd>
+ </div>
+ <div
+ v-if="
+ subscriptionStore.isTrialing &&
+ subscriptionStore.currentPlan == PlanType.ENTERPRISE
+ "
+ class="my-3"
+ >
+ <dt class="text-gray-400">
+ {{ $t("subscription.inquire-enterprise-plan") }}
+ </dt>
+
+ <dd class="mt-1">
+ <a
+ type="button"
+ class="btn-primary inline-flex justify-center ml-auto"
+ target="_blank"
+ href="https://docs.google.com/forms/d/e/1FAIpQLSfe1JvroV4ckBMJo8hDXBYGeuzN0Sn1Ylg1lIUamN2jqu9Fcw/viewform"
+ >
+ {{ $t("subscription.contact-us") }}
+ </a>
+ </dd>
+ </div>
</dl>
<div v-if="canManageSubscription" class="w-full mt-5 flex flex-col">
<textarea
@@ -84,8 +128,8 @@
</div>
</template>
-<script lang="ts">
-import { computed, defineComponent, reactive } from "vue";
+<script lang="ts" setup>
+import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import PricingTable from "../components/PricingTable/";
import { PlanType } from "@/types/proto/v1/subscription_service";
@@ -103,102 +147,80 @@ interface LocalState {
showTrialModal: boolean;
}
-export default defineComponent({
- name: "SettingWorkspaceSubscription",
- components: {
- PricingTable,
- },
- setup() {
- const subscriptionStore = useSubscriptionStore();
- const { t } = useI18n();
- const currentUser = useCurrentUser();
+const subscriptionStore = useSubscriptionStore();
+const { t } = useI18n();
+const currentUser = useCurrentUser();
- const state = reactive<LocalState>({
- loading: false,
- license: "",
- showTrialModal: false,
- });
-
- const disabled = computed((): boolean => {
- return state.loading || !state.license;
- });
-
- const uploadLicense = async () => {
- if (disabled.value) return;
- state.loading = true;
+const state = reactive<LocalState>({
+ loading: false,
+ license: "",
+ showTrialModal: false,
+});
- try {
- await subscriptionStore.patchSubscription(state.license);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("subscription.update.success.title"),
- description: t("subscription.update.success.description"),
- });
- } catch {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("subscription.update.failure.title"),
- description: t("subscription.update.failure.description"),
- });
- } finally {
- state.loading = false;
- state.license = "";
- }
- };
+const disabled = computed((): boolean => {
+ return state.loading || !state.license;
+});
- const { subscription, expireAt, isTrialing, isExpired } =
- storeToRefs(subscriptionStore);
+const uploadLicense = async () => {
+ if (disabled.value) return;
+ state.loading = true;
- const instanceCount = computed((): string => {
- const count = subscription.value?.instanceCount ?? 5;
- if (count > 0) {
- return `${count}`;
- }
- return t("subscription.unlimited");
+ try {
+ await subscriptionStore.patchSubscription(state.license);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("subscription.update.success.title"),
+ description: t("subscription.update.success.description"),
});
-
- const currentPlan = computed((): string => {
- const plan = subscriptionStore.currentPlan;
- switch (plan) {
- case PlanType.TEAM:
- return t("subscription.plan.team.title");
- case PlanType.ENTERPRISE:
- return t("subscription.plan.enterprise.title");
- default:
- return t("subscription.plan.free.title");
- }
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("subscription.update.failure.title"),
+ description: t("subscription.update.failure.description"),
});
+ } finally {
+ state.loading = false;
+ state.license = "";
+ }
+};
- const canTrial = computed((): boolean => {
- return subscriptionStore.canTrial;
- });
+const { subscription, expireAt, isTrialing, isExpired } =
+ storeToRefs(subscriptionStore);
- const openTrialModal = () => {
- state.showTrialModal = true;
- };
+const instanceCount = computed((): string => {
+ const count = subscription.value?.instanceCount ?? 5;
+ if (count > 0) {
+ return `${count}`;
+ }
+ return t("subscription.unlimited");
+});
- const canManageSubscription = computed((): boolean => {
- return hasWorkspacePermission(
- "bb.permission.workspace.manage-subscription",
- currentUser.value.role
- );
- });
+const currentPlan = computed((): string => {
+ const plan = subscriptionStore.currentPlan;
+ switch (plan) {
+ case PlanType.TEAM:
+ return t("subscription.plan.team.title");
+ case PlanType.ENTERPRISE:
+ return t("subscription.plan.enterprise.title");
+ default:
+ return t("subscription.plan.free.title");
+ }
+});
+
+const canTrial = computed((): boolean => {
+ return subscriptionStore.canTrial;
+});
+
+const openTrialModal = () => {
+ state.showTrialModal = true;
+};
- return {
- state,
- disabled,
- canTrial,
- expireAt,
- isTrialing,
- isExpired,
- currentPlan,
- instanceCount,
- uploadLicense,
- openTrialModal,
- canManageSubscription,
- };
- },
+const canManageSubscription = computed((): boolean => {
+ return hasWorkspacePermission(
+ "bb.permission.workspace.manage-subscription",
+ currentUser.value.role
+ );
});
</script>