Skip to content

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

refactor(frontend): move shell banners to react (#201

boojack316b927df860
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.css
index 849c6f2ca6..742ae44e54 100644
--- a/frontend/src/assets/css/tailwind.css
+++ b/frontend/src/assets/css/tailwind.css
@@ -374,6 +374,26 @@
}
}
+.bb-banner-scroll {
+ display: inline-block;
+ animation: bb-banner-scroll 4s ease-in-out infinite;
+}
+
+@keyframes bb-banner-scroll {
+ 0% {
+ transform: translateY(100%);
+ }
+ 25% {
+ transform: translateY(0);
+ }
+ 80% {
+ transform: translateY(0);
+ }
+ 100% {
+ transform: translateY(-100%);
+ }
+}
+
.fade-slide-up-leave-active {
transition-property: opacity, transform;
transition-duration: 100ms;
diff --git a/frontend/src/components/BannersWrapper.vue b/frontend/src/components/BannersWrapper.vue
deleted file mode 100644
index 0ac57901cc..0000000000
--- a/frontend/src/components/BannersWrapper.vue
+++ /dev/null
@@ -1,49 +0,0 @@
-<template>
- <BannerUpgradeSubscription />
- <BannerDemo v-if="shouldShowDemoBanner" />
- <BannerSubscription v-if="shouldShowSubscriptionBanner" />
- <BannerExternalUrl v-if="shouldShowExternalUrlBanner" />
- <BannerAnnouncement />
-</template>
-
-<script lang="ts" setup>
-import { storeToRefs } from "pinia";
-import { computed } from "vue";
-import {
- LICENSE_EXPIRATION_THRESHOLD,
- useActuatorV1Store,
- useSubscriptionV1Store,
-} from "@/store";
-import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";
-import { isDev } from "@/utils";
-import BannerAnnouncement from "@/views/BannerAnnouncement.vue";
-import BannerDemo from "@/views/BannerDemo.vue";
-import BannerExternalUrl from "@/views/BannerExternalUrl.vue";
-import BannerSubscription from "@/views/BannerSubscription.vue";
-import BannerUpgradeSubscription from "@/views/BannerUpgradeSubscription.vue";
-
-const actuatorStore = useActuatorV1Store();
-const subscriptionStore = useSubscriptionV1Store();
-
-const { needConfigureExternalUrl } = storeToRefs(actuatorStore);
-const { isExpired, isTrialing, currentPlan, daysBeforeExpire } =
- storeToRefs(subscriptionStore);
-
-const shouldShowDemoBanner = computed(() => {
- if (!actuatorStore.serverInfo) return false;
- return actuatorStore.serverInfo.demo;
-});
-
-const shouldShowSubscriptionBanner = computed(() => {
- return (
- isExpired.value ||
- isTrialing.value ||
- (currentPlan.value !== PlanType.FREE &&
- daysBeforeExpire.value <= LICENSE_EXPIRATION_THRESHOLD)
- );
-});
-
-const shouldShowExternalUrlBanner = computed(() => {
- return !isDev() && needConfigureExternalUrl.value;
-});
-</script>
diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue
index ef33633d6e..44fcb2f3f4 100644
--- a/frontend/src/layouts/DashboardLayout.vue
+++ b/frontend/src/layouts/DashboardLayout.vue
@@ -4,21 +4,13 @@
:page-props="{ onReady: handleReady }"
/>
- <teleport v-if="targets.banner" :to="targets.banner">
- <BannersWrapper />
+ <teleport v-if="targets.body" :to="targets.body">
+ <router-view name="body" />
</teleport>
-
- <ProvideDashboardContext>
- <teleport v-if="targets.body" :to="targets.body">
- <router-view name="body" />
- </teleport>
- </ProvideDashboardContext>
</template>
<script lang="ts" setup>
import { shallowRef } from "vue";
-import BannersWrapper from "@/components/BannersWrapper.vue";
-import ProvideDashboardContext from "@/components/ProvideDashboardContext.vue";
import type { DashboardFrameShellTargets } from "@/react/dashboard-shell";
import ReactPageMount from "@/react/ReactPageMount.vue";
diff --git a/frontend/src/layouts/SQLEditorLayout.vue b/frontend/src/layouts/SQLEditorLayout.vue
index 5e4998a4d5..5f8c2d9c47 100644
--- a/frontend/src/layouts/SQLEditorLayout.vue
+++ b/frontend/src/layouts/SQLEditorLayout.vue
@@ -5,7 +5,7 @@
class="hidden text-xs font-mono max-h-[33vh] max-w-[40vw] overflow-auto fixed bottom-0 right-0 p-2 bg-white/50 border border-gray-400 z-999999"
></ul>
- <BannersWrapper />
+ <ReactPageMount page="BannersWrapper" container-class="w-full" />
<template v-if="ready">
<ProvideSQLEditorContext />
</template>
@@ -15,8 +15,8 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
-import BannersWrapper from "@/components/BannersWrapper.vue";
import ProvideSQLEditorContext from "@/components/ProvideSQLEditorContext.vue";
+import ReactPageMount from "@/react/ReactPageMount.vue";
import { useEnvironmentV1Store, useSettingV1Store } from "@/store";
import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";
import { provideSQLEditorContext } from "@/views/sql-editor/context";
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 9cf97b3b8d..23701b862b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2691,9 +2691,6 @@
"title": "SQL Review"
},
"subscription": {
- "button": {
- "upgrade": "Upgrade"
- },
"contact-to-upgrade": "Contact your Workspace admin to upgrade the plan.",
"contact-us": "Contact us",
"current": "Current",
@@ -2718,7 +2715,6 @@
"overuse-modal": {
"description": "You are using features unavailable in the {plan}. Upgrade now to ensure continued access:"
},
- "overuse-warning": "{neededPlan} on {currentPlan} will be restricted. Upgrade now to ensure continued access.",
"plan": {
"enterprise": {
"title": "Enterprise"
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 163d90d893..10b801a12d 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2691,9 +2691,6 @@
"title": "Revisión de SQL"
},
"subscription": {
- "button": {
- "upgrade": "Actualizar"
- },
"contact-to-upgrade": "Contacta al administrador de tu espacio de trabajo para actualizar el plan.",
"contact-us": "Contáctanos",
"current": "Actual",
@@ -2718,7 +2715,6 @@
"overuse-modal": {
"description": "Está utilizando una función que actualmente no está incluida en {plan}. Actualice ahora para evitar interrupciones:"
},
- "overuse-warning": "{neededPlan} puede estar restringido en {currentPlan}, actualice ahora para asegurar un uso adecuado.",
"plan": {
"enterprise": {
"title": "Empresa"
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 0a45d3f20e..b8e11e3312 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2691,9 +2691,6 @@
"title": "SQL レビューポリシー"
},
"subscription": {
- "button": {
- "upgrade": "アップグレード"
- },
"contact-to-upgrade": "試用版にアップグレードするには、ワークスペースの所有者に問い合わせてください。",
"contact-us": "お問い合わせ",
"current": "現在",
@@ -2718,7 +2715,6 @@
"overuse-modal": {
"description": "現在「{plan}」に含まれていない機能を使用しています。使用に影響を与えないように、すぐにアップグレードしてください。"
},
- "overuse-warning": "{neededPlan} は {currentPlan} で制限されます。通常どおり使用できるように、できるだけ早くアップグレードしてください。",
"plan": {
"enterprise": {
"title": "エンタープライズ"
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 4dc6eca746..eabdaf7d39 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2691,9 +2691,6 @@
"title": "Đánh giá SQL"
},
"subscription": {
- "button": {
- "upgrade": "Nâng cấp"
- },
"contact-to-upgrade": "Liên hệ với quản trị viên Không gian làm việc của bạn để nâng cấp gói.",
"contact-us": "Liên hệ chúng tôi",
"current": "Hiện tại",
@@ -2718,7 +2715,6 @@
"overuse-modal": {
"description": "Bạn đang sử dụng các tính năng không có trong {plan}. Nâng cấp ngay để đảm bảo quyền truy cập liên tục:"
},
- "overuse-warning": "{neededPlan} trên {currentPlan} sẽ bị hạn chế. Nâng cấp ngay để đảm bảo quyền truy cập liên tục.",
"plan": {
"enterprise": {
"title": "Doanh nghiệp"
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f722242da8..fe280a340e 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2691,9 +2691,6 @@
"title": "SQL 审核策略"
},
"subscription": {
- "button": {
- "upgrade": "升级"
- },
"contact-to-upgrade": "请联系工作空间所有者来升级到试用版。",
"contact-us": "联系我们",
"current": "当前",
@@ -2718,7 +2715,6 @@
"overuse-modal": {
"description": "您正在使用当前「{plan}」不包含的功能。立即升级避免影响使用。"
},
- "overuse-warning": "{neededPlan}在{currentPlan}将会受限,请尽快升级以确保正常使用。",
"plan": {
"enterprise": {
"title": "企业版"
diff --git a/frontend/src/react/components/BannersWrapper.test.tsx b/frontend/src/react/components/BannersWrapper.test.tsx
new file mode 100644
index 0000000000..dbbdcc159d
--- /dev/null
+++ b/frontend/src/react/components/BannersWrapper.test.tsx
@@ -0,0 +1,264 @@
+import type { ReactElement, ReactNode } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+import {
+ Announcement_AlertLevel,
+ type WorkspaceProfileSetting,
+} from "@/types/proto-es/v1/setting_service_pb";
+import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ getMinimumRequiredPlan: vi.fn(),
+ isDev: vi.fn(),
+ navigatePush: vi.fn(),
+ t: vi.fn(),
+ urlfy: vi.fn((value: string) => `https://${value}`),
+ useAppStore: vi.fn(),
+ usePlanFeature: vi.fn(),
+ useServerState: vi.fn(),
+ useSubscriptionState: vi.fn(),
+ useWorkspacePermission: vi.fn(),
+ useWorkspaceProfile: vi.fn(),
+}));
+
+const translations: Record<string, string> = {
+ "banner.cloud": "Cloud",
+ "banner.deploy": "Self Host",
+ "banner.external-url": "Bytebase has not configured --external-url",
+ "banner.license-expired": "{{plan}} expired on {{expireAt}}",
+ "banner.license-expires": "{{plan}} expires in {{days}} days on {{expireAt}}",
+ "banner.request-demo": "Book a demo",
+ "banner.trial-expires":
+ "{{plan}} trial expires in {{days}} days on {{expireAt}}",
+ "common.configure-now": "Configure now",
+ "common.dismiss": "Dismiss",
+ "subscription.overuse-modal.description": "Overuse {{plan}}",
+ "subscription.overuse-warning": "{{neededPlan}} on {{currentPlan}}",
+ "subscription.plan.enterprise.title": "Enterprise",
+ "subscription.plan-features": "{{plan}} Features",
+ "subscription.plan.free.title": "Free",
+ "subscription.plan.team.title": "Pro",
+ "subscription.purchase.subscribe": "Subscribe now",
+ "subscription.purchase.update": "Update Subscription",
+ "subscription.upgrade": "Upgrade",
+ "subscription.upgrade-now": "Upgrade Now",
+};
+
+function interpolate(key: string, values?: Record<string, unknown>) {
+ let result = translations[key] ?? key;
+ for (const [name, value] of Object.entries(values ?? {})) {
+ result = result.replaceAll(`{{${name}}}`, String(value));
+ }
+ return result;
+}
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({
+ t: mocks.t,
+ }),
+ Trans: ({
+ i18nKey,
+ values,
+ }: {
+ i18nKey: string;
+ values?: Record<string, unknown>;
+ components?: Record<string, ReactNode>;
+ }) => <span>{interpolate(i18nKey, values)}</span>,
+}));
+
+vi.mock("@/react/hooks/useAppState", () => ({
+ usePlanFeature: mocks.usePlanFeature,
+ useServerState: mocks.useServerState,
+ useSubscriptionState: mocks.useSubscriptionState,
+ useWorkspacePermission: mocks.useWorkspacePermission,
+ useWorkspaceProfile: mocks.useWorkspaceProfile,
+}));
+
+vi.mock("@/react/router", () => ({
+ SETTING_ROUTE_WORKSPACE_GENERAL: "setting.workspace.general",
+ SETTING_ROUTE_WORKSPACE_SUBSCRIPTION: "setting.workspace.subscription",
+ useNavigate: () => ({
+ push: mocks.navigatePush,
+ }),
+}));
+
+vi.mock("@/react/stores/app", () => ({
+ useAppStore: mocks.useAppStore,
+}));
+
+vi.mock("@/utils", () => ({
+ isDev: mocks.isDev,
+ urlfy: mocks.urlfy,
+}));
+
+let BannersWrapper: typeof import("./BannersWrapper").BannersWrapper;
+
+const defaultSubscriptionState = {
+ currentPlan: PlanType.FREE,
+ daysBeforeExpire: -1,
+ expireAt: "",
+ isExpired: false,
+ isTrialing: false,
+};
+
+function renderIntoContainer(element: ReactElement) {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ act(() => {
+ root.render(element);
+ });
+ return {
+ container,
+ unmount: () => {
+ act(() => root.unmount());
+ container.remove();
+ },
+ };
+}
+
+beforeEach(async () => {
+ mocks.getMinimumRequiredPlan.mockReset();
+ mocks.getMinimumRequiredPlan.mockReturnValue(PlanType.FREE);
+ mocks.isDev.mockReset();
+ mocks.isDev.mockReturnValue(false);
+ mocks.navigatePush.mockReset();
+ mocks.t.mockReset();
+ mocks.t.mockImplementation(interpolate);
+ mocks.urlfy.mockClear();
+ mocks.usePlanFeature.mockReset();
+ mocks.usePlanFeature.mockReturnValue(false);
+ mocks.useServerState.mockReset();
+ mocks.useServerState.mockReturnValue({
+ needConfigureExternalUrl: false,
+ serverInfo: undefined,
+ });
+ mocks.useSubscriptionState.mockReset();
+ mocks.useSubscriptionState.mockReturnValue(defaultSubscriptionState);
+ mocks.useWorkspacePermission.mockReset();
+ mocks.useWorkspacePermission.mockReturnValue(false);
+ mocks.useWorkspaceProfile.mockReset();
+ mocks.useWorkspaceProfile.mockReturnValue(undefined);
+ mocks.useAppStore.mockReset();
+ mocks.useAppStore.mockImplementation((selector) =>
+ selector({
+ getMinimumRequiredPlan: mocks.getMinimumRequiredPlan,
+ })
+ );
+ ({ BannersWrapper } = await import("./BannersWrapper"));
+});
+
+describe("BannersWrapper", () => {
+ test("renders and dismisses demo banner", () => {
+ mocks.useServerState.mockReturnValue({
+ needConfigureExternalUrl: false,
+ serverInfo: { demo: true },
+ });
+ const { container, unmount } = renderIntoContainer(<BannersWrapper />);
+
+ expect(container.textContent).toContain("Book a demo");
+
+ const dismissButton = Array.from(container.querySelectorAll("button")).find(
+ (button) => button.textContent === "Dismiss"
+ );
+ act(() => {
+ dismissButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(container.textContent).not.toContain("Book a demo");
+ unmount();
+ });
+
+ test("renders trialing subscription banner with subscription action", () => {
+ mocks.useSubscriptionState.mockReturnValue({
+ ...defaultSubscriptionState,
+ currentPlan: PlanType.TEAM,
+ daysBeforeExpire: 3,
+ expireAt: "2030-01-01",
+ isTrialing: true,
+ });
+ const { container, unmount } = renderIntoContainer(<BannersWrapper />);
+
+ expect(container.textContent).toContain(
+ "Pro trial expires in 3 days on 2030-01-01"
+ );
+ expect(container.textContent).toContain("Subscribe now");
+ unmount();
+ });
+
+ test("renders external URL banner with configure action for permitted users", () => {
+ mocks.useServerState.mockReturnValue({
+ needConfigureExternalUrl: true,
+ serverInfo: undefined,
+ });
+ mocks.useWorkspacePermission.mockReturnValue(true);
+ const { container, unmount } = renderIntoContainer(<BannersWrapper />);
+
+ expect(container.textContent).toContain(
+ "Bytebase has not configured --external-url"
+ );
+
+ const configureButton = Array.from(
+ container.querySelectorAll("button")
+ ).find((button) => button.textContent?.includes("Configure now"));
+ act(() => {
+ configureButton?.dispatchEvent(
+ new MouseEvent("click", { bubbles: true })
+ );
+ });
+
+ expect(mocks.navigatePush).toHaveBeenCalledWith({
+ name: "setting.workspace.general",
+ });
+ unmount();
+ });
+
+ test("hides external URL banner in dev mode", () => {
+ mocks.isDev.mockReturnValue(true);
+ mocks.useServerState.mockReturnValue({
+ needConfigureExternalUrl: true,
+ serverInfo: undefined,
+ });
+ const { container, unmount } = renderIntoContainer(<BannersWrapper />);
+
+ expect(container.textContent).not.toContain(
+ "Bytebase has not configured --external-url"
+ );
+ unmount();
+ });
+
+ test("renders announcement only when feature is available", () => {
+ mocks.usePlanFeature.mockReturnValue(true);
+ mocks.useWorkspaceProfile.mockReturnValue({
+ announcement: {
+ level: Announcement_AlertLevel.INFO,
+ link: "example.com/path",
+ text: "Maintenance window",
+ },
+ } as WorkspaceProfileSetting);
+ const { container, unmount } = renderIntoContainer(<BannersWrapper />);
+
+ const link = container.querySelector("a");
+ expect(container.textContent).toContain("Maintenance window");
+ expect(link?.getAttribute("href")).toBe("https://example.com/path");
+ unmount();
+ });
+
+ test("renders upgrade banner for unlicensed features above current plan", () => {
+ mocks.useServerState.mockReturnValue({
+ needConfigureExternalUrl: false,
+ serverInfo: { unlicensedFeatures: ["FEATURE_BATCH_QUERY"] },
+ });
+ mocks.getMinimumRequiredPlan.mockReturnValue(PlanType.TEAM);
+ const { container, unmount } = renderIntoContainer(<BannersWrapper />);
+
+ expect(container.textContent).toContain("Pro Features on Free");
+ expect(container.textContent).toContain("Upgrade");
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/BannersWrapper.tsx b/frontend/src/react/components/BannersWrapper.tsx
new file mode 100644
index 0000000000..416ca1f70d
--- /dev/null
+++ b/frontend/src/react/components/BannersWrapper.tsx
@@ -0,0 +1,419 @@
+import {
+ AlertCircle,
+ ArrowRight,
+ Cloud,
+ Download,
+ ShoppingCart,
+ Sparkles,
+ Wrench,
+ X,
+} from "lucide-react";
+import { useMemo, useState } from "react";
+import { Trans, useTranslation } from "react-i18next";
+import { Button } from "@/react/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+} from "@/react/components/ui/dialog";
+import {
+ usePlanFeature,
+ useServerState,
+ useSubscriptionState,
+ useWorkspacePermission,
+ useWorkspaceProfile,
+} from "@/react/hooks/useAppState";
+import {
+ SETTING_ROUTE_WORKSPACE_GENERAL,
+ SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ useNavigate,
+} from "@/react/router";
+import { useAppStore } from "@/react/stores/app";
+import {
+ type Announcement,
+ Announcement_AlertLevel,
+} from "@/types/proto-es/v1/setting_service_pb";
+import {
+ PlanFeature,
+ PlanType,
+} from "@/types/proto-es/v1/subscription_service_pb";
+import { isDev, urlfy } from "@/utils";
+
+const LICENSE_EXPIRATION_THRESHOLD = 7;
+
+const planLabelKey: Partial<Record<PlanType, string>> = {
+ [PlanType.FREE]: "free",
+ [PlanType.TEAM]: "team",
+ [PlanType.ENTERPRISE]: "enterprise",
+};
+
+function planTitleKey(plan: PlanType) {
+ return `subscription.plan.${planLabelKey[plan] ?? "enterprise"}.title`;
+}
+
+function planFeatureFromKey(key: string): PlanFeature {
+ const feature = PlanFeature[key as keyof typeof PlanFeature];
+ return typeof feature === "number"
+ ? feature
+ : PlanFeature.FEATURE_UNSPECIFIED;
+}
+
+function BannerDismissButton({
+ onClick,
+ label,
+}: {
+ readonly onClick: () => void;
+ readonly label: string;
+}) {
+ return (
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="size-8 text-white hover:bg-white/10 hover:text-white"
+ onClick={onClick}
+ >
+ <span className="sr-only">{label}</span>
+ <X className="size-5" />
+ </Button>
+ );
+}
+
+function BannerDemo() {
+ const { t } = useTranslation();
+ const [show, setShow] = useState(true);
+
+ if (!show) return null;
+
+ return (
+ <div className="bg-accent">
+ <div className="mx-auto px-3 py-1">
+ <div className="flex flex-wrap items-center justify-between">
+ <div className="flex w-0 flex-1 items-center">
+ <p className="flex items-center truncate font-medium text-white">
+ <a
+ href="https://cal.com/bytebase/product-walkthrough"
+ target="_blank"
+ rel="noreferrer"
+ className="flex items-center gap-x-1 underline"
+ >
+ {t("banner.request-demo")}
+ </a>
+ </p>
+ </div>
+ <div className="order-3 my-2 flex w-full shrink-0 flex-row gap-x-4 sm:order-2 sm:my-0 sm:w-auto sm:py-1">
+ <a
+ href="https://docs.bytebase.com/get-started/self-host-vs-cloud/?source=demo"
+ target="_blank"
+ rel="noreferrer"
+ className="flex items-center justify-center rounded-xs border border-transparent bg-white py-1 pr-2 pl-4 text-base font-medium text-accent hover:bg-indigo-50"
+ >
+ {t("banner.deploy")}
+ <Download className="ml-1 size-5" />
+ </a>
+ <a
+ href="https://hub.bytebase.com/workspace?source=demo"
+ target="_blank"
+ rel="noreferrer"
+ className="flex items-center justify-center rounded-xs border border-transparent bg-white py-1 pr-2 pl-4 text-base font-medium text-accent hover:bg-indigo-50"
+ >
+ {t("banner.cloud")}
+ <Cloud className="ml-1 size-5" />
+ </a>
+ </div>
+ <div className="order-2 -mr-1 shrink-0 sm:order-3 sm:ml-3">
+ <BannerDismissButton
+ label={t("common.dismiss")}
+ onClick={() => setShow(false)}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function BannerExternalUrl() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const hasPermission = useWorkspacePermission(
+ "bb.settings.setWorkspaceProfile"
+ );
+ const [show, setShow] = useState(true);
+
+ if (!show) return null;
+
+ return (
+ <div className="bg-accent">
+ <div className="mx-auto px-3 py-3">
+ <div className="flex flex-wrap items-center justify-between">
+ <div className="flex w-0 flex-1 items-center">
+ <p className="ml-3 truncate font-medium text-white">
+ {t("banner.external-url")}
+ </p>
+ </div>
+ {hasPermission ? (
+ <div className="order-3 mt-2 w-full shrink-0 sm:order-2 sm:mt-0 sm:w-auto">
+ <Button
+ type="button"
+ className="h-auto rounded-md bg-white py-2 pr-2 pl-4 text-base font-medium text-accent shadow-xs hover:bg-indigo-50"
+ onClick={() => {
+ void navigate.push({ name: SETTING_ROUTE_WORKSPACE_GENERAL });
+ }}
+ >
+ {t("common.configure-now")}
+ <Wrench className="ml-1 size-5" />
+ </Button>
+ </div>
+ ) : null}
+ <div className="order-2 -mr-1 shrink-0 sm:order-3 sm:ml-3">
+ <BannerDismissButton
+ label={t("common.dismiss")}
+ onClick={() => setShow(false)}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function BannerSubscription() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const { currentPlan, daysBeforeExpire, expireAt, isExpired, isTrialing } =
+ useSubscriptionState();
+
+ const content = useMemo(() => {
+ if (currentPlan === PlanType.FREE) return "";
+
+ const plan = t(planTitleKey(currentPlan));
+ if (isTrialing) {
+ return t("banner.trial-expires", {
+ days: daysBeforeExpire,
+ expireAt,
+ plan,
+ });
+ }
+ if (isExpired) {
+ return t("banner.license-expired", { expireAt, plan });
+ }
+ if (daysBeforeExpire <= LICENSE_EXPIRATION_THRESHOLD) {
+ return t("banner.license-expires", {
+ days: daysBeforeExpire,
+ expireAt,
+ plan,
+ });
+ }
+ return "";
+ }, [currentPlan, daysBeforeExpire, expireAt, isExpired, isTrialing, t]);
+
+ if (!content) return null;
+
+ return (
+ <div className="bg-info">
+ <div className="mx-auto px-3 py-1">
+ <div className="flex flex-wrap items-center justify-center gap-x-2">
+ <p className="ml-3 truncate text-base font-medium text-white">
+ {content}
+ </p>
+ <button
+ type="button"
+ className="flex cursor-pointer items-center justify-center py-1 text-base font-medium text-white underline hover:opacity-80"
+ onClick={() => {
+ void navigate.push({
+ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ });
+ }}
+ >
+ {t(
+ isTrialing
+ ? "subscription.purchase.subscribe"
+ : "subscription.purchase.update"
+ )}
+ <ShoppingCart className="ml-1 size-5 text-white" />
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+function announcementColors(level: Announcement["level"] | undefined) {
+ switch (level) {
+ case Announcement_AlertLevel.WARNING:
+ return "bg-warning hover:bg-warning-hover";
+ case Announcement_AlertLevel.CRITICAL:
+ return "bg-error hover:bg-error-hover";
+ default:
+ return "bg-info hover:bg-info-hover";
+ }
+}
+
+function BannerAnnouncement() {
+ const workspaceProfile = useWorkspaceProfile();
+ const hasAnnouncementFeature = usePlanFeature(
+ PlanFeature.FEATURE_DASHBOARD_ANNOUNCEMENT
+ );
+ const announcement = workspaceProfile?.announcement;
+ const text = announcement?.text ?? "";
+ const rawLink = announcement?.link ?? "";
+ const link = rawLink ? urlfy(rawLink) : "";
+
+ if (!text || !hasAnnouncementFeature) return null;
+
+ return (
+ <div
+ className={`mx-auto flex w-full flex-row flex-wrap justify-center px-3 py-1 text-center font-medium text-white ${announcementColors(
+ announcement?.level
+ )}`}
+ >
+ {link ? (
+ <a
+ href={link}
+ target="_blank"
+ rel="noreferrer"
+ className="flex flex-row items-center hover:underline"
+ >
+ <p className="px-1">{text}</p>
+ <ArrowRight className="mr-3 size-5" />
+ </a>
+ ) : (
+ <p>{text}</p>
+ )}
+ </div>
+ );
+}
+
+function BannerUpgradeSubscription() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const { serverInfo } = useServerState();
+ const { currentPlan } = useSubscriptionState();
+ const getMinimumRequiredPlan = useAppStore(
+ (state) => state.getMinimumRequiredPlan
+ );
+ const [showModal, setShowModal] = useState(false);
+ const unlicensedFeatures = serverInfo?.unlicensedFeatures ?? [];
+ const neededPlan = useMemo(() => {
+ let plan = PlanType.FREE;
+ for (const featureKey of unlicensedFeatures) {
+ const requiredPlan = getMinimumRequiredPlan(
+ planFeatureFromKey(featureKey)
+ );
+ if (requiredPlan > plan) {
+ plan = requiredPlan;
+ }
+ }
+ return plan;
+ }, [getMinimumRequiredPlan, unlicensedFeatures]);
+ const showBanner = unlicensedFeatures.length > 0 && neededPlan > currentPlan;
+ const currentPlanTitle = t(planTitleKey(currentPlan));
+ const neededPlanTitle = t(planTitleKey(neededPlan));
+ const neededPlanFeatures = t("subscription.plan-features", {
+ plan: neededPlanTitle,
+ });
+
+ const gotoSubscriptionPage = () => {
+ setShowModal(false);
+ void navigate.push({ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION });
+ };
+
+ if (!showBanner) return null;
+
+ return (
+ <>
+ <div className="overflow-clip bg-gray-200">
+ <div className="bb-banner-scroll h-10 w-full">
+ <div className="mx-auto flex w-full flex-row flex-wrap items-center justify-center px-3 py-1">
+ <div className="flex flex-row items-center">
+ <AlertCircle className="mr-1 h-auto w-5 text-gray-800" />
+ <Trans
+ t={t}
+ i18nKey="subscription.overuse-warning"
+ values={{
+ currentPlan: currentPlanTitle,
+ neededPlan: neededPlanFeatures,
+ }}
+ components={{
+ neededPlan: (
+ <button
+ type="button"
+ className="cursor-pointer underline hover:opacity-60"
+ onClick={() => setShowModal(true)}
+ >
+ {neededPlanFeatures}
+ </button>
+ ),
+ }}
+ />
+ </div>
+ <div className="ml-2">
+ <Button size="sm" onClick={gotoSubscriptionPage}>
+ {t("subscription.upgrade")}
+ <Sparkles className="ml-1 h-auto w-4 text-accent" />
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <Dialog open={showModal} onOpenChange={setShowModal}>
+ <DialogContent className="max-w-lg">
+ <div className="p-6">
+ <DialogTitle className="mb-4 text-base font-medium">
+ {t("subscription.upgrade-now")}?
+ </DialogTitle>
+ <p>
+ {t("subscription.overuse-modal.description", {
+ plan: currentPlanTitle,
+ })}
+ </p>
+ <div className="my-2 pl-4">
+ <ul className="list-inside list-disc">
+ {unlicensedFeatures.map((featureKey) => {
+ const feature = planFeatureFromKey(featureKey);
+ const requiredPlan = getMinimumRequiredPlan(feature);
+ return (
+ <li key={featureKey}>
+ {t(`dynamic.subscription.features.${featureKey}.title`)} (
+ {t(planTitleKey(requiredPlan))})
+ </li>
+ );
+ })}
+ </ul>
+ </div>
+ <div className="mt-3 mb-4 w-full">
+ <Button className="w-full" onClick={gotoSubscriptionPage}>
+ {t("subscription.upgrade-now")}
+ </Button>
+ </div>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+}
+
+export function BannersWrapper() {
+ const { serverInfo, needConfigureExternalUrl } = useServerState();
+ const { currentPlan, daysBeforeExpire, isExpired, isTrialing } =
+ useSubscriptionState();
+
+ const shouldShowSubscriptionBanner =
+ isExpired ||
+ isTrialing ||
+ (currentPlan !== PlanType.FREE &&
+ daysBeforeExpire <= LICENSE_EXPIRATION_THRESHOLD);
+ const shouldShowExternalUrlBanner = !isDev() && needConfigureExternalUrl;
+
+ return (
+ <>
+ <BannerUpgradeSubscription />
+ {serverInfo?.demo ? <BannerDemo /> : null}
+ {shouldShowSubscriptionBanner ? <BannerSubscription /> : null}
+ {shouldShowExternalUrlBanner ? <BannerExternalUrl /> : null}
+ <BannerAnnouncement />
+ </>
+ );
+}
diff --git a/frontend/src/react/components/DashboardFrameShell.test.tsx b/frontend/src/react/components/DashboardFrameShell.test.tsx
index 71ddd8e940..1e4396e0ff 100644
--- a/frontend/src/react/components/DashboardFrameShell.test.tsx
+++ b/frontend/src/react/components/DashboardFrameShell.test.tsx
@@ -1,14 +1,58 @@
import { act } from "react";
import { createRoot } from "react-dom/client";
-import { describe, expect, test, vi } from "vitest";
-import { DashboardFrameShell } from "./DashboardFrameShell";
+import { beforeEach, describe, expect, test, vi } from "vitest";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
).IS_REACT_ACT_ENVIRONMENT = true;
+const mocks = vi.hoisted(() => ({
+ getOrFetchSettingByName: vi.fn(),
+ fetchEnvironments: vi.fn(),
+ loadEnvironmentList: vi.fn(),
+ loadWorkspaceProfile: vi.fn(),
+ useAppStore: vi.fn(),
+}));
+
+vi.mock("@/store", () => ({
+ useEnvironmentV1Store: () => ({
+ fetchEnvironments: mocks.fetchEnvironments,
+ }),
+ useSettingV1Store: () => ({
+ getOrFetchSettingByName: mocks.getOrFetchSettingByName,
+ }),
+}));
+
+vi.mock("@/react/stores/app", () => ({
+ useAppStore: mocks.useAppStore,
+}));
+
+vi.mock("./BannersWrapper", () => ({
+ BannersWrapper: () => <div data-testid="banners-wrapper" />,
+}));
+
+let DashboardFrameShell: typeof import("./DashboardFrameShell").DashboardFrameShell;
+
+beforeEach(async () => {
+ mocks.getOrFetchSettingByName.mockReset();
+ mocks.fetchEnvironments.mockReset();
+ mocks.loadEnvironmentList.mockReset();
+ mocks.loadWorkspaceProfile.mockReset();
+ mocks.getOrFetchSettingByName.mockResolvedValue(undefined);
+ mocks.fetchEnvironments.mockResolvedValue([]);
+ mocks.loadEnvironmentList.mockResolvedValue([]);
+ mocks.loadWorkspaceProfile.mockResolvedValue(undefined);
+ mocks.useAppStore.mockImplementation((selector) =>
+ selector({
+ loadEnvironmentList: mocks.loadEnvironmentList,
+ loadWorkspaceProfile: mocks.loadWorkspaceProfile,
+ })
+ );
+ ({ DashboardFrameShell } = await import("./DashboardFrameShell"));
+});
+
describe("DashboardFrameShell", () => {
- test("reports stable banner and body targets", () => {
+ test("reports stable banner and body targets after initialization", async () => {
const container = document.createElement("div");
document.body.appendChild(container);
const root = createRoot(container);
@@ -18,13 +62,53 @@ describe("DashboardFrameShell", () => {
root.render(<DashboardFrameShell onReady={onReady} />);
});
+ expect(onReady).not.toHaveBeenCalled();
+ expect(container.querySelector(".animate-spin")).not.toBeNull();
+
+ await act(async () => {
+ await Promise.resolve();
+ });
+
expect(onReady).toHaveBeenCalled();
+ expect(mocks.fetchEnvironments).toHaveBeenCalled();
+ expect(mocks.getOrFetchSettingByName).toHaveBeenCalled();
const targets = onReady.mock.lastCall?.[0];
expect(targets.banner).toBeInstanceOf(HTMLDivElement);
expect(targets.body).toBeInstanceOf(HTMLDivElement);
expect(container.querySelector(".h-screen")).not.toBeNull();
+ expect(
+ container.querySelector('[data-testid="banners-wrapper"]')
+ ).not.toBeNull();
+ expect(container.querySelector(".animate-spin")).toBeNull();
+
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ });
+
+ test("keeps body target hidden while bootstrap requests are pending", () => {
+ let resolveEnvironmentList: (value: []) => void = () => {};
+ mocks.loadEnvironmentList.mockReturnValue(
+ new Promise((resolve) => {
+ resolveEnvironmentList = resolve;
+ })
+ );
+ mocks.loadWorkspaceProfile.mockResolvedValue(undefined);
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ const onReady = vi.fn();
+
+ act(() => {
+ root.render(<DashboardFrameShell onReady={onReady} />);
+ });
+
+ expect(onReady).not.toHaveBeenCalled();
+ expect(container.querySelector(".animate-spin")).not.toBeNull();
act(() => {
+ resolveEnvironmentList([]);
root.unmount();
});
container.remove();
diff --git a/frontend/src/react/components/DashboardFrameShell.tsx b/frontend/src/react/components/DashboardFrameShell.tsx
index f188eb1252..98fae3ada0 100644
--- a/frontend/src/react/components/DashboardFrameShell.tsx
+++ b/frontend/src/react/components/DashboardFrameShell.tsx
@@ -1,21 +1,66 @@
-import { useEffect, useRef } from "react";
+import { LoaderCircle } from "lucide-react";
+import { useEffect, useRef, useState } from "react";
import type { DashboardFrameShellProps } from "@/react/dashboard-shell";
+import { useAppStore } from "@/react/stores/app";
+import { useEnvironmentV1Store, useSettingV1Store } from "@/store";
+import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";
+import { BannersWrapper } from "./BannersWrapper";
+
+const loadLegacyDashboardState = () => {
+ return Promise.all([
+ useEnvironmentV1Store().fetchEnvironments(),
+ useSettingV1Store().getOrFetchSettingByName(
+ Setting_SettingName.WORKSPACE_PROFILE
+ ),
+ ]);
+};
export function DashboardFrameShell({ onReady }: DashboardFrameShellProps) {
const bannerRef = useRef<HTMLDivElement>(null);
const bodyRef = useRef<HTMLDivElement>(null);
+ const [initialized, setInitialized] = useState(false);
+ const loadEnvironmentList = useAppStore((state) => state.loadEnvironmentList);
+ const loadWorkspaceProfile = useAppStore(
+ (state) => state.loadWorkspaceProfile
+ );
+
+ useEffect(() => {
+ let mounted = true;
+ void Promise.all([
+ loadEnvironmentList(),
+ loadWorkspaceProfile(),
+ loadLegacyDashboardState(),
+ ])
+ .catch(() => undefined)
+ .then(() => {
+ if (mounted) {
+ setInitialized(true);
+ }
+ });
+ return () => {
+ mounted = false;
+ };
+ }, [loadEnvironmentList, loadWorkspaceProfile]);
useEffect(() => {
+ if (!initialized) return;
onReady?.({
banner: bannerRef.current,
body: bodyRef.current,
});
- }, [onReady]);
+ }, [initialized, onReady]);
return (
<div className="relative flex h-screen flex-col overflow-hidden">
- <div ref={bannerRef} />
+ <div ref={bannerRef}>
+ <BannersWrapper />
+ </div>
<div ref={bodyRef} className="min-h-0 flex-1" />
+ {!initialized ? (
+ <div className="absolute inset-0 z-10 flex items-center justify-center bg-white">
+ <LoaderCircle className="size-6 animate-spin text-accent" />
+ </div>
+ ) : null}
</div>
);
}
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 6779b8c100..1ee0a7fd80 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -157,7 +157,13 @@
},
"auth.token-expired-title": "Token expired",
"banner": {
- "external-url": "Bytebase has not configured --external-url"
+ "cloud": "Cloud",
+ "deploy": "Self Host",
+ "external-url": "Bytebase has not configured --external-url",
+ "license-expired": "Your license for {{plan}} has expired on {{expireAt}}.",
+ "license-expires": "Your license for {{plan}} will expire in {{days}} days on {{expireAt}}.",
+ "request-demo": "Book a 30-minute product demo.",
+ "trial-expires": "Your free trial for {{plan}} will expire in {{days}} days on {{expireAt}}."
},
"bbkit": {
"confirm-button": {
@@ -3495,6 +3501,10 @@
"used-and-total-user": "Active / Total User Limit"
},
"max-instance-count": "Max instance count",
+ "overuse-modal": {
+ "description": "You are using features unavailable in the {{plan}}. Upgrade now to ensure continued access:"
+ },
+ "overuse-warning": "<neededPlan>{{neededPlan}}</neededPlan> on {{currentPlan}} will be restricted. Upgrade now to ensure continued access.",
"plan": {
"enterprise": {
"desc": "Extra security, compliance, and permission features. Dedicated support with SLA.",
@@ -3515,6 +3525,7 @@
"try": "Start free trial"
},
"plan-compare": "Compare features between different plans",
+ "plan-features": "{{plan}} Features",
"purchase": {
"accept-terms-prefix": "I accept the",
"and": "and",
@@ -3561,6 +3572,8 @@
"title": "Successfully updated license"
}
},
+ "upgrade": "Upgrade",
+ "upgrade-now": "Upgrade Now",
"upload-license": "Upload license",
"usage": {
"instance-count": {
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index 8e4f924493..bd47fc4d8a 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -156,7 +156,13 @@
},
"auth.token-expired-title": "Token expirado",
"banner": {
- "external-url": "Bytebase no ha configurado --external-url"
+ "cloud": "Cloud",
+ "deploy": "Auto Hospedaje",
+ "external-url": "Bytebase no ha configurado --external-url",
+ "license-expired": "Su licencia para {{plan}} ha expirado el {{expireAt}}.",
+ "license-expires": "Su licencia para {{plan}} ha caducado el {{expireAt}}.",
+ "request-demo": "Reserva una demo de producto de 30 minutos.",
+ "trial-expires": "Su prueba gratuita para {{plan}} caducará en {{days}} días el {{expireAt}}."
},
"bbkit": {
"confirm-button": {
@@ -3481,6 +3487,10 @@
"used-and-total-user": "Límite de usuarios activos/totales"
},
"max-instance-count": "Recuento máximo de instancias",
+ "overuse-modal": {
+ "description": "Está utilizando funciones no disponibles en {{plan}}. Actualice ahora para garantizar el acceso continuo:"
+ },
+ "overuse-warning": "<neededPlan>{{neededPlan}}</neededPlan> puede estar restringido en {{currentPlan}}, actualice ahora para asegurar un uso adecuado.",
"plan": {
"enterprise": {
"desc": "Funciones adicionales de seguridad, cumplimiento y permisos. Soporte dedicado con SLA.",
@@ -3501,6 +3511,7 @@
"try": "Empezar la prueba gratuita"
},
"plan-compare": "Compara características entre los diferentes planes",
+ "plan-features": "{{plan}} función",
"purchase": {
"accept-terms-prefix": "Acepto los",
"and": "y",
@@ -3547,6 +3558,8 @@
"title": "Licencia actualizada con éxito"
}
},
+ "upgrade": "Actualizar",
+ "upgrade-now": "Actualizar ahora",
"upload-license": "Subir licencia",
"usage": {
"instance-count": {
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index 532a35bb21..becfeb974c 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -156,7 +156,13 @@
},
"auth.token-expired-title": "トークンの期限切れ",
"banner": {
- "external-url": "Bytebase は --extern-url を設定していません"
+ "cloud": "クラウドサービス",
+ "deploy": "ローカル展開",
+ "external-url": "Bytebase は --extern-url を設定していません",
+ "license-expired": "{{plan}} のライセンスは {{expireAt}} に期限切れになりました。",
+ "license-expires": "{{plan}} ライセンスは {{expireAt}} に期限切れになりました",
+ "request-demo": "30 分間の製品デモを予約してください。",
+ "trial-expires": "{{plan}} トライアルは {{days}} 日後に期限切れになります"
},
"bbkit": {
"confirm-button": {
@@ -3481,6 +3487,10 @@
"used-and-total-user": "アクティブ/合計ユーザー制限"
},
"max-instance-count": "最大インスタンス数",
+ "overuse-modal": {
+ "description": "{{plan}} では使用できない機能を使用しています。通常どおり使用できるように、できるだけ早くアップグレードしてください:"
+ },
+ "overuse-warning": "<neededPlan>{{neededPlan}}</neededPlan> は {{currentPlan}} で制限されます。通常どおり使用できるように、できるだけ早くアップグレードしてください。",
"plan": {
"enterprise": {
"desc": "追加のセキュリティ、コンプライアンス、および権限機能。SLA付きの専任サポート。",
@@ -3501,6 +3511,7 @@
"try": "無料トライアルを開始する"
},
"plan-compare": "異なるプラン間の機能を比較する",
+ "plan-features": "{{plan}} の機能",
"purchase": {
"accept-terms-prefix": "以下に同意します:",
"and": "および",
@@ -3547,6 +3558,8 @@
"title": "ライセンスが正常に更新されました"
}
},
+ "upgrade": "アップグレード",
+ "upgrade-now": "今すぐアップグレード",
"upload-license": "ライセンスのアップロード",
"usage": {
"instance-count": {
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index 1fbf691a13..b64c6e5454 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -156,7 +156,13 @@
},
"auth.token-expired-title": "Mã thông báo đã hết hạn",
"banner": {
- "external-url": "Bytebase chưa được cấu hình --external-url"
+ "cloud": "Đám mây",
+ "deploy": "Tự lưu trữ",
+ "external-url": "Bytebase chưa được cấu hình --external-url",
+ "license-expired": "Giấy phép {{plan}} của bạn đã hết hạn vào {{expireAt}}.",
+ "license-expires": "Giấy phép {{plan}} của bạn sẽ hết hạn sau {{days}} ngày vào {{expireAt}}.",
+ "request-demo": "Đặt lịch giới thiệu sản phẩm 30 phút.",
+ "trial-expires": "Bản dùng thử miễn phí {{plan}} của bạn sẽ hết hạn trong {{days}} ngày nữa vào {{expireAt}}."
},
"bbkit": {
"confirm-button": {
@@ -3481,6 +3487,10 @@
"used-and-total-user": "Giới hạn người dùng đang hoạt động / Tổng số"
},
"max-instance-count": "Số lượng phiên bản tối đa",
+ "overuse-modal": {
+ "description": "Bạn đang sử dụng các tính năng không có trong {{plan}}. Nâng cấp ngay để đảm bảo quyền truy cập liên tục:"
+ },
+ "overuse-warning": "<neededPlan>{{neededPlan}}</neededPlan> trên {{currentPlan}} sẽ bị hạn chế. Nâng cấp ngay để đảm bảo quyền truy cập liên tục.",
"plan": {
"enterprise": {
"desc": "Các tính năng bảo mật, tuân thủ và quyền bổ sung. Hỗ trợ chuyên dụng với SLA.",
@@ -3501,6 +3511,7 @@
"try": "Bắt đầu dùng thử miễn phí"
},
"plan-compare": "So sánh tính năng giữa các gói khác nhau",
+ "plan-features": "Tính năng của {{plan}}",
"purchase": {
"accept-terms-prefix": "Tôi chấp nhận",
"and": "và",
@@ -3547,6 +3558,8 @@
"title": "Đã cập nhật thành công giấy phép"
}
},
+ "upgrade": "Nâng cấp",
+ "upgrade-now": "Nâng cấp ngay",
"upload-license": "Tải lên giấy phép",
"usage": {
"instance-count": {
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index 356b07fe32..381d90ffb7 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -156,7 +156,13 @@
},
"auth.token-expired-title": "令牌已过期",
"banner": {
- "external-url": "Bytebase 还没有配置 --external-url"
+ "cloud": "云服务",
+ "deploy": "本地部署",
+ "external-url": "Bytebase 还没有配置 --external-url",
+ "license-expired": "您的{{plan}}证书已在 {{expireAt}} 过期",
+ "license-expires": "您的{{plan}}证书将在 {{days}} 天后({{expireAt}})过期",
+ "request-demo": "预约一个 30 分钟的产品演示。",
+ "trial-expires": "您的{{plan}}试用将在 {{days}} 天后({{expireAt}})过期"
},
"bbkit": {
"confirm-button": {
@@ -3481,6 +3487,10 @@
"used-and-total-user": "活跃/总用户限制"
},
"max-instance-count": "最多实例数",
+ "overuse-modal": {
+ "description": "您正在使用{{plan}}不可用的功能。请尽快升级以确保正常使用:"
+ },
+ "overuse-warning": "<neededPlan>{{neededPlan}}</neededPlan>在{{currentPlan}}将会受限,请尽快升级以确保正常使用。",
"plan": {
"enterprise": {
"desc": "额外的安全,合规,权限功能,SLA 支持。",
@@ -3501,6 +3511,7 @@
"try": "免费试用"
},
"plan-compare": "比较不同版本的功能,寻找适合您的方案",
+ "plan-features": "{{plan}}功能",
"purchase": {
"accept-terms-prefix": "我接受",
"and": "和",
@@ -3547,6 +3558,8 @@
"title": "证书更新成功"
}
},
+ "upgrade": "升级",
+ "upgrade-now": "现在升级",
"upload-license": "上传证书",
"usage": {
"instance-count": {
diff --git a/frontend/src/react/pages/settings/EnvironmentsPage.tsx b/frontend/src/react/pages/settings/EnvironmentsPage.tsx
index 81e388a786..ebaf2f050b 100644
--- a/frontend/src/react/pages/settings/EnvironmentsPage.tsx
+++ b/frontend/src/react/pages/settings/EnvironmentsPage.tsx
@@ -54,6 +54,7 @@ import {
TabsPanel,
TabsTrigger,
} from "@/react/components/ui/tabs";
+import { useEnvironmentList } from "@/react/hooks/useAppState";
import { useVueState } from "@/react/hooks/useVueState";
import { cn } from "@/react/lib/utils";
import { useAppStore } from "@/react/stores/app";
@@ -667,9 +668,7 @@ function EnvironmentDetail({
subscriptionStore.hasInstanceFeature(PlanFeature.FEATURE_ENVIRONMENT_TIERS)
);
- const environmentList = useVueState(() => [
- ...environmentStore.environmentList,
- ]);
+ const environmentList = useEnvironmentList();
// Reset state when environment changes
useEffect(() => {
@@ -1446,9 +1445,7 @@ export function EnvironmentsPage() {
(state) => state.refreshEnvironmentList
);
- const environmentList = useVueState(() => [
- ...environmentStore.environmentList,
- ]);
+ const environmentList = useEnvironmentList();
const environmentListKey = getEnvironmentListKey(environmentList);
const [selectedId, setSelectedId] = useState("");
@@ -1461,6 +1458,10 @@ export function EnvironmentsPage() {
const canEdit = hasWorkspacePermissionV2("bb.settings.setEnvironment");
+ useEffect(() => {
+ void environmentStore.fetchEnvironments();
+ }, [environmentStore]);
+
// Initialize selected tab and intro state
useEffect(() => {
if (!uiStateStore.getIntroStateByKey("environment.visit")) {
@@ -1581,9 +1582,8 @@ export function EnvironmentsPage() {
style: "SUCCESS",
title: t("common.deleted"),
});
- await refreshEnvironmentList();
+ const remaining = await refreshEnvironmentList();
// Select first remaining environment
- const remaining = environmentStore.environmentList;
if (remaining.length > 0) {
selectTab(remaining[0].id);
}
diff --git a/frontend/src/views/BannerAnnouncement.vue b/frontend/src/views/BannerAnnouncement.vue
deleted file mode 100644
index 56f305dca0..0000000000
--- a/frontend/src/views/BannerAnnouncement.vue
+++ /dev/null
@@ -1,76 +0,0 @@
-<template>
- <div
- v-if="showBanner"
- class="max-auto py-1 px-3 w-full flex flex-row justify-center flex-wrap text-center text-white font-medium"
- :class="[bgColor, bgColorHover]"
- >
- <a
- v-if="announcementLink !== ''"
- :href="announcementLink"
- target="_blank"
- class="hover:underline flex flex-row items-center"
- >
- <p class="px-1">{{ announcementText }}</p>
- <heroicons-solid:arrow-long-right class="mr-3 w-5 h-5" />
- </a>
- <p v-else>{{ announcementText }}</p>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { computed } from "vue";
-import { hasFeature, useSettingV1Store } from "@/store";
-import { Announcement_AlertLevel } from "@/types/proto-es/v1/setting_service_pb";
-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-import { urlfy } from "@/utils";
-
-const settingStore = useSettingV1Store();
-
-const announcement = computed(() => settingStore.workspaceProfile.announcement);
-
-const showBanner = computed(() => {
- return (
- announcementText.value !== "" &&
- hasFeature(PlanFeature.FEATURE_DASHBOARD_ANNOUNCEMENT)
- );
-});
-
-const bgColor = computed(() => {
- switch (announcement.value?.level) {
- case Announcement_AlertLevel.INFO:
- return "bg-info";
- case Announcement_AlertLevel.WARNING:
- return "bg-warning";
- case Announcement_AlertLevel.CRITICAL:
- return "bg-error";
- default:
- return "bg-info";
- }
-});
-
-const bgColorHover = computed(() => {
- switch (announcement.value?.level) {
- case Announcement_AlertLevel.INFO:
- return "hover:bg-info-hover";
- case Announcement_AlertLevel.WARNING:
- return "hover:bg-warning-hover";
- case Announcement_AlertLevel.CRITICAL:
- return "hover:bg-error-hover";
- default:
- return "hover:bg-info-hover";
- }
-});
-
-const announcementText = computed(() => {
- return announcement.value?.text ?? "";
-});
-
-const announcementLink = computed(() => {
- const link = announcement.value?.link ?? "";
- if (link.length === 0) {
- return link;
- }
-
- return urlfy(link);
-});
-</script>
diff --git a/frontend/src/views/BannerDemo.vue b/frontend/src/views/BannerDemo.vue
deleted file mode 100644
index efe6c09f32..0000000000
--- a/frontend/src/views/BannerDemo.vue
+++ /dev/null
@@ -1,57 +0,0 @@
-<template>
- <div v-if="show" class="bg-accent">
- <div class="mx-auto py-1 px-3">
- <div class="flex items-center justify-between flex-wrap">
- <div class="w-0 flex-1 flex items-center">
- <p class="flex font-medium text-white items-center truncate">
- 📆
- <a
- href="https://cal.com/bytebase/product-walkthrough"
- target="_blank"
- class="flex underline ml-1"
- >
- {{ $t("banner.request-demo") }}
- </a>
- </p>
- </div>
- <div
- class="flex flex-row gap-x-4 order-3 my-2 shrink-0 w-full sm:order-2 sm:py-1 sm:my-0 sm:w-auto"
- >
- <a
- href="https://docs.bytebase.com/get-started/self-host-vs-cloud/?source=demo"
- target="_blank"
- class="flex items-center justify-center pl-4 pr-2 py-1 border border-transparent rounded-xs text-base font-medium text-accent bg-white hover:bg-indigo-50"
- >
- {{ $t("banner.deploy") }}
- <heroicons-outline:arrow-down-tray class="ml-1 w-6 h-6" />
- </a>
- <a
- href="https://hub.bytebase.com/workspace?source=demo"
- target="_blank"
- class="flex items-center justify-center pl-4 pr-2 py-1 border border-transparent rounded-xs text-base font-medium text-accent bg-white hover:bg-indigo-50"
- >
- {{ $t("banner.cloud") }}
- <heroicons-outline:cloud class="ml-1 w-6 h-6" />
- </a>
- </div>
-
- <div class="order-2 shrink-0 sm:order-3 sm:ml-3 -mr-1">
- <NButton quaternary size="small" @click.prevent="show = false">
- <span class="sr-only">{{ $t("common.dismiss") }}</span>
- <template #icon>
- <!-- Heroicon name: outline/x -->
- <heroicons-outline:x class="h-6 w-6 text-white" />
- </template>
- </NButton>
- </div>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
-import { ref } from "vue";
-
-const show = ref(true);
-</script>
diff --git a/frontend/src/views/BannerExternalUrl.vue b/frontend/src/views/BannerExternalUrl.vue
deleted file mode 100644
index d9c00645d9..0000000000
--- a/frontend/src/views/BannerExternalUrl.vue
+++ /dev/null
@@ -1,49 +0,0 @@
-<template>
- <div v-if="show" class="bg-accent">
- <div class="mx-auto py-3 px-3">
- <div class="flex items-center justify-between flex-wrap">
- <div class="w-0 flex-1 flex items-center">
- <p class="ml-3 font-medium text-white truncate">
- <span>
- {{ $t("banner.external-url") }}
- </span>
- </p>
- </div>
- <div
- v-if="hasPermission"
- class="order-3 mt-2 shrink-0 w-full sm:order-2 sm:mt-0 sm:w-auto"
- >
- <router-link
- :to="{ name: SETTING_ROUTE_WORKSPACE_GENERAL }"
- class="flex items-center justify-center pl-4 pr-2 py-2 border border-transparent rounded-md shadow-xs text-base font-medium text-accent bg-white hover:bg-indigo-50"
- >
- {{ $t("common.configure-now") }}
- <heroicons-outline:wrench-screwdriver class="ml-1 w-5 h-5" />
- </router-link>
- </div>
- <div class="order-2 shrink-0 sm:order-3 sm:ml-3 -mr-1">
- <NButton quaternary size="small" @click.prevent="show = false">
- <span class="sr-only">{{ $t("common.dismiss") }}</span>
- <template #icon>
- <!-- Heroicon name: outline/x -->
- <heroicons-outline:x class="h-6 w-6 text-white" />
- </template>
- </NButton>
- </div>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
-import { computed, ref } from "vue";
-import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";
-import { hasWorkspacePermissionV2 } from "@/utils";
-
-const show = ref(true);
-
-const hasPermission = computed(() =>
- hasWorkspacePermissionV2("bb.settings.setWorkspaceProfile")
-);
-</script>
diff --git a/frontend/src/views/BannerSubscription.vue b/frontend/src/views/BannerSubscription.vue
deleted file mode 100644
index 333c72f22e..0000000000
--- a/frontend/src/views/BannerSubscription.vue
+++ /dev/null
@@ -1,77 +0,0 @@
-<template>
- <div class="bg-info">
- <div class="mx-auto py-1 px-3">
- <div class="flex items-center justify-center flex-wrap gap-x-2">
- <p class="ml-3 text-base font-medium text-white truncate">
- {{ content }}
- </p>
- <router-link
- :to="{ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION }"
- class="flex items-center justify-center py-1 text-base font-medium cursor-pointer text-white underline hover:opacity-80"
- exact-active-class=""
- >
- {{
- $t(
- isTrialing
- ? "subscription.purchase-license"
- : "subscription.update-license"
- )
- }}
- <heroicons-outline:shopping-cart class="ml-1 h-6 w-6 text-white" />
- </router-link>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { storeToRefs } from "pinia";
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
-import { SETTING_ROUTE_WORKSPACE_SUBSCRIPTION } from "@/router/dashboard/workspaceSetting";
-import { LICENSE_EXPIRATION_THRESHOLD, useSubscriptionV1Store } from "@/store";
-import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";
-
-const { t } = useI18n();
-const subscriptionStore = useSubscriptionV1Store();
-
-const currentPlanText = 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 content = computed(() => {
- if (currentPlan.value !== PlanType.FREE) {
- if (isTrialing.value) {
- return t("banner.trial-expires", {
- plan: currentPlanText.value,
- days: daysBeforeExpire.value,
- expireAt: expireAt.value,
- });
- }
- if (isExpired.value) {
- return t("banner.license-expired", {
- plan: currentPlanText.value,
- expireAt: expireAt.value,
- });
- } else if (daysBeforeExpire.value <= LICENSE_EXPIRATION_THRESHOLD) {
- return t("banner.license-expires", {
- plan: currentPlanText.value,
- days: daysBeforeExpire.value,
- expireAt: expireAt.value,
- });
- }
- }
- return "";
-});
-
-const { expireAt, isExpired, isTrialing, daysBeforeExpire, currentPlan } =
- storeToRefs(subscriptionStore);
-</script>
diff --git a/frontend/src/views/BannerUpgradeSubscription.vue b/frontend/src/views/BannerUpgradeSubscription.vue
deleted file mode 100644
index f54cfa884f..0000000000
--- a/frontend/src/views/BannerUpgradeSubscription.vue
+++ /dev/null
@@ -1,159 +0,0 @@
-<template>
- <div v-if="showBanner" class="bg-gray-200 overflow-clip">
- <div class="w-full h-10 scroll-animation">
- <div
- class="mx-auto py-1 px-3 w-full flex flex-row items-center justify-center flex-wrap"
- >
- <div class="flex flex-row items-center">
- <heroicons-outline:exclamation-circle
- class="w-5 h-auto text-gray-800 mr-1"
- />
- <i18n-t tag="p" keypath="subscription.overuse-warning">
- <template #neededPlan>
- <span
- class="underline cursor-pointer hover:opacity-60"
- @click="state.showModal = true"
- >{{
- t("subscription.plan-features", {
- plan: t(
- `subscription.plan.${PlanType[neededPlan].toLowerCase()}.title`
- ),
- })
- }}</span
- >
- </template>
- <template #currentPlan>
- {{ currentPlan }}
- </template>
- </i18n-t>
- </div>
- <div class="ml-2">
- <NButton size="small" @click="gotoSubscriptionPage">
- {{ $t("subscription.button.upgrade") }}
- <SparklesIcon class="w-4 h-auto text-accent ml-1" />
- </NButton>
- </div>
- </div>
- </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 unlicensedFeatures" :key="feature">
- {{ $t(`dynamic.subscription.features.${feature}.title`) }}
- ({{
- $t(
- `subscription.plan.${PlanType[
- subscriptionStore.getMinimumRequiredPlan(
- PlanFeature[feature as keyof typeof PlanFeature] ??
- PlanFeature.FEATURE_UNSPECIFIED
- )
- ].toLowerCase()}.title`
- )
- }})
- </li>
- </ul>
- </div>
- <div class="mt-3 mb-4 w-full">
- <NButton type="primary" style="width: 100%" @click="gotoSubscriptionPage">
- {{ $t("subscription.upgrade-now") }}
- </NButton>
- </div>
- </BBModal>
-</template>
-
-<script lang="ts" setup>
-import { SparklesIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { computed, reactive } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import { BBModal } from "@/bbkit";
-import { SETTING_ROUTE_WORKSPACE_SUBSCRIPTION } from "@/router/dashboard/workspaceSetting";
-import { useActuatorV1Store, useSubscriptionV1Store } from "@/store";
-import {
- PlanFeature,
- PlanType,
-} from "@/types/proto-es/v1/subscription_service_pb";
-
-interface LocalState {
- showModal: boolean;
-}
-
-const { t } = useI18n();
-const router = useRouter();
-const subscriptionStore = useSubscriptionV1Store();
-const actuatorStore = useActuatorV1Store();
-const state = reactive<LocalState>({
- showModal: false,
-});
-
-const showBanner = computed(() => {
- return (
- unlicensedFeatures.value.length > 0 &&
- neededPlan.value > subscriptionStore.currentPlan
- );
-});
-
-const unlicensedFeatures = computed(() => {
- return actuatorStore.serverInfo?.unlicensedFeatures ?? [];
-});
-
-const neededPlan = computed(() => {
- let plan = PlanType.FREE;
-
- for (const feature of unlicensedFeatures.value) {
- const featureEnum =
- PlanFeature[feature as keyof typeof PlanFeature] ??
- PlanFeature.FEATURE_UNSPECIFIED;
- const requiredPlan = subscriptionStore.getMinimumRequiredPlan(featureEnum);
- if (requiredPlan > plan) {
- plan = requiredPlan;
- }
- }
-
- return plan;
-});
-
-const currentPlan = computed(() => {
- return t(
- `subscription.plan.${PlanType[subscriptionStore.currentPlan].toLowerCase()}.title`
- );
-});
-
-const gotoSubscriptionPage = () => {
- state.showModal = false;
- return router.push({ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION });
-};
-</script>
-
-<style>
-.scroll-animation {
- display: inline-block;
- animation: scroll 4s ease-in-out infinite;
-}
-
-@keyframes scroll {
- 0% {
- transform: translateY(100%);
- }
- 25% {
- transform: translateY(0);
- }
- 80% {
- transform: translateY(0);
- }
- 100% {
- transform: translateY(-100%);
- }
-}
-</style>