Skip to content

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

Add dev menu to quickly change plan

天舟5d740ae1c4cc
diff --git a/frontend/src/main.js b/frontend/src/main.js
index 494bcb3be8..752c806e21 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -33,6 +33,7 @@ import dataSourceType from "./directives/data-source-type";
import highlight from "./directives/highlight";
import role from "./directives/role";
import {
+ isDev,
isDemo,
isDevOrDemo,
humanizeTs,
@@ -55,6 +56,7 @@ app.config.globalProperties.window = window;
app.config.globalProperties.console = console;
app.config.globalProperties.moment = moment;
app.config.globalProperties.humanizeTs = humanizeTs;
+app.config.globalProperties.isDev = isDev();
app.config.globalProperties.isDemo = isDemo();
app.config.globalProperties.isDevOrDemo = isDevOrDemo();
app.config.globalProperties.sizeToFit = sizeToFit;
diff --git a/frontend/src/store/modules/plan.ts b/frontend/src/store/modules/plan.ts
index 18a5aaa4a8..2fca71885e 100644
--- a/frontend/src/store/modules/plan.ts
+++ b/frontend/src/store/modules/plan.ts
@@ -5,11 +5,13 @@ const FEATURE_MATRIX: Map<FeatureType, boolean[]> = new Map([
["bytebase.admin", [false, true, true]],
]);
-const state: () => PlanState = () => ({});
+const state: () => PlanState = () => ({
+ plan: PlanType.TEAM,
+});
const getters = {
currentPlan: (state: PlanState) => (): PlanType => {
- return PlanType.FREE;
+ return state.plan;
},
feature: (state: PlanState, getters: any) => (type: FeatureType): boolean => {
@@ -17,9 +19,18 @@ const getters = {
},
};
-const actions = {};
+const actions = {
+ async changePlan({ commit }: any, newPlan: PlanType) {
+ commit("setCurrentPlan", newPlan);
+ return newPlan;
+ },
+};
-const mutations = {};
+const mutations = {
+ setCurrentPlan(state: PlanState, newPlan: PlanType) {
+ state.plan = newPlan;
+ },
+};
export default {
namespaced: true,
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index ec2765fe47..178240bb20 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -593,8 +593,8 @@ export type FeatureType =
export enum PlanType {
FREE = 0,
- STANDARD = 1,
- PREMIUM = 2,
+ TEAM = 1,
+ ENTERPRISE = 2,
}
// UI State Models
@@ -657,7 +657,9 @@ export interface AuthState {
currentUser: Principal;
}
-export interface PlanState {}
+export interface PlanState {
+ plan: PlanType;
+}
export interface RoleMappingState {
roleMappingList: RoleMapping[];
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 5f6e128342..f12da5194c 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -35,7 +35,33 @@
</div>
</div>
<div>
- <div class="flex items-center">
+ <div class="flex items-center space-x-2">
+ <div
+ v-if="isDev"
+ class="hidden md:flex sm:flex-row items-center space-x-2"
+ >
+ <div
+ v-if="currentPlan != 0"
+ class="text-sm normal-link"
+ @click.prevent="switchToFree"
+ >
+ Free
+ </div>
+ <div
+ v-if="currentPlan != 1"
+ class="text-sm normal-link"
+ @click.prevent="switchToTeam"
+ >
+ Team
+ </div>
+ <div
+ v-if="currentPlan != 2"
+ class="text-sm normal-link"
+ @click.prevent="switchToEnterprise"
+ >
+ Enterprise
+ </div>
+ </div>
<div
v-if="isDevOrDemo"
class="hidden md:flex sm:flex-row items-center space-x-2"
@@ -157,6 +183,7 @@
import { computed, reactive } from "vue";
import { useStore } from "vuex";
import ProfileDropdown from "../components/ProfileDropdown.vue";
+import { PlanType } from "../types";
interface LocalState {
showMobileMenu: boolean;
@@ -174,6 +201,8 @@ export default {
const currentUser = computed(() => store.getters["auth/currentUser"]());
+ const currentPlan = computed(() => store.getters["plan/currentPlan"]());
+
const switchToOwner = () => {
store.dispatch("auth/login", {
@@ -195,12 +224,28 @@ export default {
});
};
+ const switchToFree = () => {
+ store.dispatch("plan/changePlan", PlanType.FREE);
+ };
+
+ const switchToTeam = () => {
+ store.dispatch("plan/changePlan", PlanType.TEAM);
+ };
+
+ const switchToEnterprise = () => {
+ store.dispatch("plan/changePlan", PlanType.ENTERPRISE);
+ };
+
return {
state,
currentUser,
+ currentPlan,
switchToOwner,
switchToDBA,
switchToDeveloper,
+ switchToFree,
+ switchToTeam,
+ switchToEnterprise,
};
},
};