Skip to content

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

chore: move license switch to profile dropdown (#8892)

Danny Xu3dcd95fc3ada
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vue
index f38062a90b..e9e51aa5f1 100644
--- a/frontend/src/components/ProfileDropdown.vue
+++ b/frontend/src/components/ProfileDropdown.vue
@@ -77,6 +77,68 @@
</div>
</BBContextMenu>
</div>
+ <div
+ v-if="isDev"
+ class="menu-item relative"
+ @mouseenter="licenseMenu.toggle()"
+ @mouseleave="licenseMenu.toggle()"
+ @click.capture.prevent="licenseMenu.toggle()"
+ >
+ <span>{{ $t("common.license") }}</span>
+ <BBContextMenu
+ ref="licenseMenu"
+ class="origin-left absolute left-0 -top-1 -translate-x-48 transform"
+ >
+ <div
+ class="menu-item px-3 py-1 hover:bg-gray-100"
+ :class="{ 'bg-gray-100': currentPlan == PlanType.FREE }"
+ @click.prevent="switchToFree()"
+ >
+ <div class="radio text-sm">
+ <input
+ type="radio"
+ class="btn"
+ :checked="currentPlan == PlanType.FREE"
+ />
+ <label class="ml-2">{{
+ $t("subscription.plan.free.title")
+ }}</label>
+ </div>
+ </div>
+ <div
+ class="menu-item px-3 py-1 hover:bg-gray-100"
+ :class="{ 'bg-gray-100': currentPlan == PlanType.TEAM }"
+ @click.prevent="switchToTeam()"
+ >
+ <div class="radio text-sm">
+ <input
+ type="radio"
+ class="btn"
+ :checked="currentPlan == PlanType.TEAM"
+ />
+ <label class="ml-2">{{
+ $t("subscription.plan.team.title")
+ }}</label>
+ </div>
+ </div>
+ <div
+ class="menu-item px-3 py-1 hover:bg-gray-100"
+ :class="{ 'bg-gray-100': currentPlan == PlanType.ENTERPRISE }"
+ @click.prevent="switchToEnterprise()"
+ >
+ <div class="radio text-sm">
+ <input
+ type="radio"
+ class="btn"
+ :checked="currentPlan == PlanType.ENTERPRISE"
+ />
+ <label class="ml-2">
+ {{ $t("subscription.plan.enterprise.title") }}
+ </label>
+ </div>
+ </div>
+ </BBContextMenu>
+ </div>
<a
v-if="showQuickstart"
class="menu-item"
@@ -118,18 +180,22 @@ import {
useActuatorV1Store,
useAuthStore,
useCurrentUserV1,
+ useSubscriptionV1Store,
useUIStateStore,
} from "@/store";
+import { PlanType } from "@/types/proto/v1/subscription_service";
import { hasWorkspacePermissionV1, roleNameV1 } from "@/utils";
import UserAvatar from "./User/UserAvatar.vue";
const actuatorStore = useActuatorV1Store();
const authStore = useAuthStore();
+const subscriptionStore = useSubscriptionV1Store();
const uiStateStore = useUIStateStore();
const router = useRouter();
const { setLocale, locale } = useLanguage();
const menu = ref();
const languageMenu = ref();
+const licenseMenu = ref();
const currentUserV1 = useCurrentUserV1();
// For now, debug mode is a global setting and will affect all users.
@@ -140,6 +206,23 @@ const allowToggleDebug = computed(() => {
currentUserV1.value.userRole
);
});
+const { currentPlan } = storeToRefs(subscriptionStore);
+
+const switchToFree = () => {
+ subscriptionStore.patchSubscription("");
+};
+
+const switchToTeam = () => {
+ subscriptionStore.patchSubscription(
+ import.meta.env.BB_DEV_TEAM_LICENSE as string
+ );
+};
+
+const switchToEnterprise = () => {
+ subscriptionStore.patchSubscription(
+ import.meta.env.BB_DEV_ENTERPRISE_LICENSE as string
+ );
+};
const showQuickstart = computed(() => !actuatorStore.isDemo);
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index e8022375e3..50039d7216 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -270,7 +270,8 @@
"updated-at-by": "Updated {time} by {user}",
"created-at-by": "Created {time} by {user}",
"filter-by-name": "Filter by name",
- "tenant": "Tenant"
+ "tenant": "Tenant",
+ "license": "License"
},
"error-page": {
"go-back-home": "Go back home"
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index c678d68c0a..09c4ad8b47 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -270,7 +270,8 @@
"updated-at-by": "Actualizado {time} por {user}",
"created-at-by": "Creado {time} por {user}",
"filter-by-name": "Filtrar por nombre",
- "tenant": "Arrendataria"
+ "tenant": "Arrendataria",
+ "license": "Licencia"
},
"error-page": {
"go-back-home": "Volver al inicio"
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 0797916f65..8aeececbea 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -268,7 +268,8 @@
"updated-at-by": "由 {user} 更新于 {time}",
"created-at-by": "由 {user} 创建于 {time}",
"filter-by-name": "按名称过滤",
- "tenant": "租户"
+ "tenant": "租户",
+ "license": "证书"
},
"error-page": {
"go-back-home": "回到主页"
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 6ff9892dfa..7010bbe575 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -55,44 +55,6 @@
</div>
<div>
<div class="flex items-center space-x-3">
- <div
- v-if="isDevFeatures"
- class="hidden md:flex sm:flex-row items-center space-x-2 text-sm font-medium"
- >
- <div
- class="cursor-pointer hover:bg-link-hover focus:outline-none"
- :class="
- currentPlan == PlanType.FREE
- ? 'underline text-accent'
- : 'text-main'
- "
- @click.prevent="switchToFree"
- >
- {{ $t("subscription.plan.free.title") }}
- </div>
- <div
- class="cursor-pointer hover:bg-link-hover focus:outline-none"
- :class="
- currentPlan == PlanType.TEAM
- ? 'underline text-accent'
- : 'text-main'
- "
- @click.prevent="switchToTeam"
- >
- {{ $t("subscription.plan.team.title") }}
- </div>
- <div
- class="cursor-pointer hover:bg-link-hover focus:outline-none"
- :class="
- currentPlan == PlanType.ENTERPRISE
- ? 'underline text-accent'
- : 'text-main'
- "
- @click.prevent="switchToEnterprise"
- >
- {{ $t("subscription.plan.enterprise.title") }}
- </div>
- </div>
<div
v-if="currentPlan === PlanType.FREE"
class="flex justify-between items-center min-w-fit px-4 py-1 bg-emerald-500 text-sm font-medium text-white rounded-md cursor-pointer"
@@ -204,7 +166,7 @@ import ProfileBrandingLogo from "../components/ProfileBrandingLogo.vue";
import ProfileDropdown from "../components/ProfileDropdown.vue";
import { useLanguage } from "../composables/useLanguage";
import { UNKNOWN_ID } from "../types";
-import { hasWorkspacePermissionV1, isDev } from "../utils";
+import { hasWorkspacePermissionV1 } from "../utils";
interface LocalState {
showMobileMenu: boolean;
@@ -245,10 +207,6 @@ const shouldShowInstanceEntry = computed(() => {
);
});
-const isDevFeatures = computed((): boolean => {
- return isDev();
-});
-
const prepareInboxSummary = () => {
// It will also be called when user logout
if (currentUser.value.id != UNKNOWN_ID) {
@@ -314,22 +272,6 @@ const kbarActions = computed(() => [
]);
useRegisterActions(kbarActions);
-const switchToFree = () => {
- subscriptionStore.patchSubscription("");
-};
-
-const switchToTeam = () => {
- subscriptionStore.patchSubscription(
- import.meta.env.BB_DEV_TEAM_LICENSE as string
- );
-};
-
-const switchToEnterprise = () => {
- subscriptionStore.patchSubscription(
- import.meta.env.BB_DEV_ENTERPRISE_LICENSE as string
- );
-};
-
const handleWantHelp = () => {
if (locale.value === "zh-CN") {
state.showQRCodeModal = true;