Skip to content

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

feat: update subscription page ux (#538)

ecmadao255a09b618e8
diff --git a/frontend/src/components/Counter.vue b/frontend/src/components/Counter.vue
new file mode 100644
index 0000000000..751cddd1bc
--- /dev/null
+++ b/frontend/src/components/Counter.vue
@@ -0,0 +1,78 @@
+<template>
+ <div class="h-8 w-24">
+ <div
+ class="flex flex-row h-8 w-full rounded-lg relative bg-transparent mt-1 bg-gray-200 text-gray-600 items-center"
+ >
+ <button
+ class="hover:text-gray-700 hover:bg-gray-300 h-full w-14 rounded-l cursor-pointer outline-none"
+ :disabled="state.count <= minimum"
+ @click="onClick(-5)"
+ >
+ <span class="m-auto text-xl font-thin">−</span>
+ </button>
+ <div class="w-full text-center">
+ {{ state.count }}
+ </div>
+ <button
+ class="hover:text-gray-700 hover:bg-gray-300 h-full w-14 rounded-r cursor-pointer outline-none"
+ @click="onClick(5)"
+ >
+ <span class="m-auto text-xl font-thin">+</span>
+ </button>
+ </div>
+ </div>
+</template>
+
+<script lang="ts">
+import { watch, reactive } from "vue";
+
+export default {
+ props: {
+ count: {
+ default: 0,
+ type: Number,
+ },
+ minimum: {
+ default: 1,
+ type: Number,
+ },
+ },
+ emits: ["on-change"],
+ setup(props, { emit }) {
+ const state = reactive<{ count: number }>({
+ count: props.count,
+ });
+ const onClick = (diff: number) => {
+ const count = Math.max(props.minimum, state.count + diff);
+ state.count = count;
+ };
+
+ watch(
+ () => state.count,
+ (val) => {
+ emit("on-change", val);
+ }
+ );
+
+ watch(
+ () => props.count,
+ (val) => {
+ state.count = val;
+ }
+ );
+
+ return {
+ state,
+ onClick,
+ };
+ },
+};
+</script>
+
+<style scoped>
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+</style>
diff --git a/frontend/src/components/PricingTable.vue b/frontend/src/components/PricingTable.vue
index c6b591c264..ad4b22f3eb 100644
--- a/frontend/src/components/PricingTable.vue
+++ b/frontend/src/components/PricingTable.vue
@@ -23,19 +23,38 @@
<p class="text-gray-500 mb-10">{{ plan.description }}</p>
<p class="mt-4 flex items-baseline text-gray-900">
- <span class="text-4xl font-extrabold tracking-tight">
+ <span class="text-4xl">
{{ plan.price }}
</span>
</p>
+ <div
+ :class="[
+ isAvailableToPurchase(plan) ? '' : 'opacity-0 disabled',
+ 'flex justify-center items-center mt-5',
+ ]"
+ >
+ <div>
+ Instances<br />
+ ${{ instancePricePerMonth }}/instance/month
+ </div>
+ <Counter
+ class="ml-auto"
+ :count="state.instanceCount"
+ :minimum="minimumInstanceCount"
+ @on-change="(val) => (state.instanceCount = val)"
+ />
+ </div>
+
<button
type="button"
:class="[
plan.highlight
- ? 'border-green-500 text-white bg-green-500 hover:bg-green-600 hover:border-green-600'
+ ? '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-2 lg:py-4 text-sm lg:text-xl font-semibold text-center hover:text-white whitespace-nowrap overflow-hidden',
]"
+ @click="onButtonClick(plan)"
>
{{ plan.buttonText }}
</button>
@@ -101,7 +120,7 @@
</template>
<script lang="ts">
-import { reactive, computed, PropType } from "vue";
+import { reactive, computed, watch, PropType } from "vue";
import {
Plan,
Subscription,
@@ -114,6 +133,7 @@ import {
interface LocalState {
isMonthly: boolean;
+ instanceCount: number;
}
interface LocalPlan extends Plan {
@@ -124,6 +144,9 @@ interface LocalPlan extends Plan {
isFreePlan: boolean;
}
+const minimumInstanceCount = 5;
+const instancePricePerMonth = 29;
+
export default {
name: "PricingTable",
props: {
@@ -136,8 +159,28 @@ export default {
setup(props) {
const state = reactive<LocalState>({
isMonthly: false,
+ instanceCount: props.subscription?.instanceCount ?? minimumInstanceCount,
+ });
+
+ watch(
+ () => props.subscription,
+ (val) =>
+ (state.instanceCount = val?.instanceCount ?? minimumInstanceCount)
+ );
+
+ const instancePricePerYear = computed((): number => {
+ return (
+ (state.instanceCount - minimumInstanceCount) *
+ instancePricePerMonth *
+ 12
+ );
});
+ const getPlanPrice = (plan: Plan): number => {
+ if (plan.type !== PlanType.TEAM) return plan.unitPrice;
+ return plan.unitPrice + instancePricePerYear.value;
+ };
+
const plans = computed((): LocalPlan[] => {
return [FREE_PLAN, TEAM_PLAN, ENTERPRISE_PLAN].map((plan) => ({
...plan,
@@ -148,7 +191,7 @@ export default {
price:
plan.type === PlanType.ENTERPRISE
? "Contact us"
- : `$${plan.unitPrice}/year`,
+ : `$${getPlanPrice(plan)}/year`,
buttonText: getButtonText(plan),
highlight: plan.type === PlanType.TEAM,
isFreePlan: plan.type === PlanType.FREE,
@@ -169,11 +212,31 @@ export default {
return "Subscribe now";
};
+ const onButtonClick = (plan: Plan) => {
+ if (plan.type === PlanType.TEAM) {
+ window.open("https://hub.bytebase.com/", "__blank");
+ } else if (plan.type === PlanType.ENTERPRISE) {
+ window.open(
+ "mailto:[email protected]?subject=Request for enterprise plan"
+ );
+ } else {
+ window.open("https://docs.bytebase.com/", "__blank");
+ }
+ };
+
+ const isAvailableToPurchase = (plan: Plan): boolean => {
+ return plan.type === PlanType.TEAM;
+ };
+
return {
state,
plans,
sections: FEATURE_SECTIONS,
getFeature,
+ onButtonClick,
+ minimumInstanceCount,
+ instancePricePerMonth,
+ isAvailableToPurchase,
};
},
};
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index 6ad153c773..d3705fa82d 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -1131,6 +1131,9 @@ oauth:
unknown-event: Unexpeted event type, OAuth failed.
subscription:
description: You can upload your bytebase license to unlock team/enterprise features.
+ current: Current plan
+ instance-count: Instance count
+ expires-at: Expires at
description-highlight: Purchase a license
sensitive-placeholder: Paste your license here - write only
upload-license: Upload license
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index 040cd5765f..91c8d9ba8f 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -1000,6 +1000,9 @@ oauth:
unknown-event: 未知的事件类型,认证失败
subscription:
description: 您可以在这里上传您购买的 bytebase 证书来解锁团队版/企业版功能。
+ current: 当前版本
+ instance-count: 实例数
+ expires-at: 过期时间
description-highlight: 购买证书
sensitive-placeholder: 粘贴您的证书 - 仅写入
upload-license: 上传证书
diff --git a/frontend/src/store/modules/subscription.ts b/frontend/src/store/modules/subscription.ts
index 760cab34be..994d4b2fa2 100644
--- a/frontend/src/store/modules/subscription.ts
+++ b/frontend/src/store/modules/subscription.ts
@@ -17,8 +17,7 @@ const getters = {
},
currentPlan: (state: SubscriptionState) => (): PlanType => {
- // TODO: this is used for align with current logic - TEAM plan is default plan
- return state.subscription?.plan ?? PlanType.TEAM;
+ return state.subscription?.plan ?? PlanType.FREE;
},
feature:
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index 6f6ba525bd..8205d3b86a 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -2,10 +2,32 @@
<div class="mx-auto">
<div class="textinfolabel">
{{ $t("subscription.description") }}
- <span class="text-accent">{{
- $t("subscription.description-highlight")
- }}</span>
+ <a class="text-accent" href="https://hub.bytebase.com" target="__blank">
+ {{ $t("subscription.description-highlight") }}
+ </a>
</div>
+ <dl class="text-left grid grid-cols-2 gap-x-6 my-5 sm:grid-cols-4">
+ <div class="my-3">
+ <dt class="text-gray-400">
+ {{ $t("subscription.current") }}
+ </dt>
+ <dd class="text-indigo-600 mt-1 text-4xl">
+ {{ currentPlan }}
+ </dd>
+ </div>
+ <div class="my-3">
+ <dt class="text-gray-400">
+ {{ $t("subscription.instance-count") }}
+ </dt>
+ <dd class="mt-1 text-4xl">{{ instanceCount }}</dd>
+ </div>
+ <div class="my-3 col-span-2">
+ <dt class="text-gray-400">
+ {{ $t("subscription.expires-at") }}
+ </dt>
+ <dd class="mt-1 text-4xl">{{ expiresAt }}</dd>
+ </div>
+ </dl>
<div class="w-full mt-5 flex flex-col">
<textarea
id="license"
@@ -32,15 +54,18 @@
<div class="textinfolabel">
{{ $t("subscription.plan-compare") }}
</div>
- <PricingTable />
+ <PricingTable :subscription="subscription" />
</div>
</div>
</template>
<script lang="ts">
-import { computed, ref, reactive } from "vue";
+import { computed, reactive } from "vue";
import { useStore } from "vuex";
+import { useI18n } from "vue-i18n";
+import dayjs from "dayjs";
import PricingTable from "../components/PricingTable.vue";
+import { PlanType, Subscription } from "../types";
interface LocalState {
loading: boolean;
@@ -54,6 +79,7 @@ export default {
},
setup() {
const store = useStore();
+ const { t } = useI18n();
const state = reactive<LocalState>({
loading: false,
@@ -75,9 +101,41 @@ export default {
}
};
+ const subscription = computed((): Subscription | undefined => {
+ return store.getters["subscription/subscription"]();
+ });
+
+ const instanceCount = computed((): number => {
+ return subscription.value?.instanceCount ?? 5;
+ });
+
+ const expiresAt = computed((): string => {
+ const expiresTs = subscription.value?.expiresTs ?? 0;
+ if (expiresTs <= 0) {
+ return "n/a";
+ }
+ return dayjs(expiresTs * 1000).format("YYYY-MM-DD");
+ });
+
+ const currentPlan = computed((): string => {
+ const plan = store.getters["subscription/currentPlan"]();
+ switch (plan) {
+ case PlanType.TEAM:
+ return t("setting.plan.team");
+ case PlanType.ENTERPRISE:
+ return t("setting.plan.enterprise");
+ default:
+ return t("setting.plan.free");
+ }
+ });
+
return {
state,
disabled,
+ expiresAt,
+ currentPlan,
+ instanceCount,
+ subscription,
uploadLicense,
};
},