Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Send self-hosted Enterprise buyers to the hosted Enterprise page (#8940)

Reece Brownee4053a8d0cb0
diff --git a/frontend/public/locales/en-US/translation.toml b/frontend/public/locales/en-US/translation.toml
index 6804d42eca..6f7461d927 100644
--- a/frontend/public/locales/en-US/translation.toml
+++ b/frontend/public/locales/en-US/translation.toml
@@ -9677,10 +9677,6 @@ signInToStart = "Sign in to start your trial"
stage = "Stage {{current}} of {{total}}"
stagesLabel = "Progress"
-[portal.enterprise.connect]
-ownerOnly = "Only this server’s owner can connect it. Ask them to open this page."
-unavailable = "Connecting to a Stirling account is turned off on this server. Book a call and we’ll set up your trial with you."
-
[portal.enterprise.landing]
lede = "Try it free for 14 days, then build your quote and sign your agreement here. No card required."
tickAgreement = "One agreement covering the MSA, order form, EULA and DPA"
@@ -11300,11 +11296,6 @@ hint = "Paste this key into a self-hosted instance to activate it, or keep it fo
label = "Your licence key"
trialFileHint = "This is your trial licence file. Once your agreement is in place, come back and download it again — unlike the online licence key, the .lic file won't update on its own."
-[portal.procurement.link]
-cta = "Link account"
-description = "Procurement runs on your linked Stirling account: it's how we provision the trial, price your quote, and start billing. Link an account to start."
-title = "Link your account to begin"
-
[portal.procurement.live]
description = "Your subscription is active and your licence is issued. Your team is provisioned and billing has started."
title = "You're live on Stirling Enterprise"
diff --git a/frontend/src/editor/core/tests/stubbed/account-link-dialogs.spec.ts b/frontend/src/editor/core/tests/stubbed/account-link-dialogs.spec.ts
index 5ba26d6c86..d8f13e775b 100644
--- a/frontend/src/editor/core/tests/stubbed/account-link-dialogs.spec.ts
+++ b/frontend/src/editor/core/tests/stubbed/account-link-dialogs.spec.ts
@@ -106,24 +106,22 @@ for (const path of ["/settings/account-link", "/settings/billing"]) {
});
}
-test("the Enterprise page asks an unlinked server to connect first, and only on request", async ({
+test("the Enterprise address forwards to the hosted Enterprise page, without asking to connect", async ({
page,
}) => {
- await page.goto("/enterprise");
- const connect = page.getByRole("button", {
- name: "Link account",
- exact: true,
+ // Stands in for stirling.com, so the forward is checked without loading the live site.
+ let forwardedTo: string | null = null;
+ await page.route(/^https:\/\/[^/]*stirling\.com\//, (route) => {
+ forwardedTo = route.request().url();
+ return route.fulfill({ contentType: "text/html", body: "" });
});
- await expect(connect).toBeVisible();
- await expect(page.getByRole("dialog")).toHaveCount(0);
- await connect.click();
- await expect(page.getByRole("dialog")).toHaveCount(1);
- await page
- .getByRole("dialog")
- .getByRole("button", { name: "Not now", exact: true })
- .click();
- await expect(page.getByRole("dialog")).toHaveCount(0);
- await expect(connect).toBeVisible();
+ await page.goto("/enterprise?source=sales");
+ await expect
+ .poll(() => forwardedTo)
+ .toMatch(/^https:\/\/[^/]*stirling\.com\/.*\/enterprise\?source=sales$/);
+ await expect(
+ page.getByRole("button", { name: "Link account", exact: true }),
+ ).toHaveCount(0);
});
test("late exhausted-credit responses do not reopen a dismissed dialog", async ({
diff --git a/frontend/src/editor/proprietary/contexts/CheckoutContext.tsx b/frontend/src/editor/proprietary/contexts/CheckoutContext.tsx
index 1c51bfc559..6b755d1a18 100644
--- a/frontend/src/editor/proprietary/contexts/CheckoutContext.tsx
+++ b/frontend/src/editor/proprietary/contexts/CheckoutContext.tsx
@@ -520,7 +520,7 @@ export const CheckoutProvider: React.FC<CheckoutProviderProps> = ({
onContactSales={
currentOptions.onContactSales &&
(() => {
- // Enterprise opens its own flow; leaving the checkout on top would hide it.
+ // Enterprise is its own flow, so the checkout steps aside.
const contactSales = currentOptions.onContactSales;
closeCheckout();
contactSales?.();
diff --git a/frontend/src/editor/proprietary/routes/adminRouteExtensions.tsx b/frontend/src/editor/proprietary/routes/adminRouteExtensions.tsx
index 32cafa864e..93f17f42d3 100644
--- a/frontend/src/editor/proprietary/routes/adminRouteExtensions.tsx
+++ b/frontend/src/editor/proprietary/routes/adminRouteExtensions.tsx
@@ -16,7 +16,10 @@ const PortalApp = HAS_PORTAL
})
: null;
-/** The Enterprise page reads like a website, so it carries none of the app's chrome. */
+/**
+ * The Enterprise page reads like a website, so it carries none of the app's chrome. Self-hosted
+ * builds forward it to the hosted page.
+ */
const EnterpriseApp = HAS_PORTAL
? lazy(async () => {
const m = await import("@processor/EnterpriseApp");
diff --git a/frontend/src/processor/proprietary/EnterpriseApp.test.tsx b/frontend/src/processor/proprietary/EnterpriseApp.test.tsx
new file mode 100644
index 0000000000..6ff1843d0b
--- /dev/null
+++ b/frontend/src/processor/proprietary/EnterpriseApp.test.tsx
@@ -0,0 +1,37 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { render } from "@testing-library/react";
+import { MemoryRouter } from "react-router-dom";
+import { EnterpriseApp } from "@processor/EnterpriseApp";
+
+describe("self-hosted EnterpriseApp", () => {
+ const original = window.location;
+ const replace = vi.fn();
+
+ beforeEach(() => {
+ replace.mockReset();
+ Object.defineProperty(window, "location", {
+ value: { ...original, replace },
+ writable: true,
+ });
+ });
+
+ afterEach(() => {
+ Object.defineProperty(window, "location", {
+ value: original,
+ writable: true,
+ });
+ });
+
+ it("forwards to the hosted Enterprise page, keeping the link's query and hash", () => {
+ render(
+ <MemoryRouter initialEntries={["/enterprise?source=sales#quote"]}>
+ <EnterpriseApp />
+ </MemoryRouter>,
+ );
+ expect(replace).toHaveBeenCalledOnce();
+ const target = new URL(replace.mock.calls[0][0]);
+ expect(target.pathname).toMatch(/\/enterprise$/);
+ expect(target.search).toBe("?source=sales");
+ expect(target.hash).toBe("#quote");
+ });
+});
diff --git a/frontend/src/processor/proprietary/EnterpriseApp.tsx b/frontend/src/processor/proprietary/EnterpriseApp.tsx
index e7db03afca..339e4c5aa8 100644
--- a/frontend/src/processor/proprietary/EnterpriseApp.tsx
+++ b/frontend/src/processor/proprietary/EnterpriseApp.tsx
@@ -1,37 +1,15 @@
-import { type ReactNode } from "react";
-import { useAuth } from "@editor/auth";
-import { EnterpriseAuthBoundary } from "@processor/auth/EnterpriseAuthBoundary";
-import { PortalFrame } from "@processor/PortalFrame";
-import { PortalSettingsProviders } from "@processor/components/settings/PortalSettingsProviders";
-import { ErrorBoundary } from "@processor/components/ErrorBoundary";
-import { Enterprise } from "@processor/views/Enterprise";
-
-/** The portal's providers load account data as they mount, so a visitor without one gets none. */
-function AccountProviders({ children }: { children: ReactNode }) {
- const { session, isAnonymous } = useAuth();
- return session && !isAnonymous ? (
- <PortalSettingsProviders>{children}</PortalSettingsProviders>
- ) : (
- children
- );
-}
+import { useEffect } from "react";
+import { useLocation } from "react-router-dom";
+import { hostedEnterpriseUrl } from "@processor/components/procurement/enterpriseEntry";
/**
- * The Enterprise page as its own route, served like a website separate from the app: none of the
- * portal's chrome, but the same query cache, sign-in and account link as billing, so a deal started
- * on either side shows on the other. EnterpriseAuthBoundary decides per build whether sign-in
- * comes first.
+ * Self-hosted: forwards to the hosted Enterprise page, where Enterprise is bought. The SaaS build
+ * shadows this with the page itself.
*/
export function EnterpriseApp() {
- return (
- <PortalFrame>
- <EnterpriseAuthBoundary>
- <AccountProviders>
- <ErrorBoundary>
- <Enterprise />
- </ErrorBoundary>
- </AccountProviders>
- </EnterpriseAuthBoundary>
- </PortalFrame>
- );
+ const { search, hash } = useLocation();
+ useEffect(() => {
+ window.location.replace(hostedEnterpriseUrl(`${search}${hash}`));
+ }, [search, hash]);
+ return null;
}
diff --git a/frontend/src/processor/proprietary/auth/EnterpriseAuthBoundary.tsx b/frontend/src/processor/proprietary/auth/EnterpriseAuthBoundary.tsx
deleted file mode 100644
index 298f860789..0000000000
--- a/frontend/src/processor/proprietary/auth/EnterpriseAuthBoundary.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { type ReactNode } from "react";
-import { PortalAuthBoundary } from "@processor/auth/PortalAuthBoundary";
-
-/**
- * Self-hosted: the Enterprise page is reached from the server's own billing, by an operator who is
- * already signed in, so it keeps the portal's sign-in gate. The SaaS build shadows this to let
- * visitors from the website see the page before they have an account.
- */
-export function EnterpriseAuthBoundary({ children }: { children: ReactNode }) {
- return <PortalAuthBoundary>{children}</PortalAuthBoundary>;
-}
diff --git a/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.test.tsx b/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.test.tsx
index 072470d184..c8b1fb5a8d 100644
--- a/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.test.tsx
+++ b/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.test.tsx
@@ -1,4 +1,4 @@
-import { beforeEach, describe, expect, it, vi } from "vitest";
+import { beforeEach, describe, expect, it, onTestFinished, vi } from "vitest";
import type { ReactNode } from "react";
import { act, fireEvent, render, screen } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
@@ -178,10 +178,12 @@ describe("FreeTierPlanView", () => {
});
it.each(["Get an enterprise quote", "Explore Enterprise"])(
- "opens the Enterprise page from %s, which handles connecting",
+ "opens the hosted Enterprise page from %s, with no account to connect first",
async (button) => {
+ const open = vi.spyOn(window, "open").mockReturnValue(null);
+ onTestFinished(() => open.mockRestore());
fetchFreeTier.mockResolvedValue(BALANCE);
- renderView(undefined, undefined, "/settings/billing?source=sales");
+ renderView();
await screen.findByText("120 of 500 used");
if (button === "Explore Enterprise") {
fireEvent.click(screen.getByRole("button", { name: "Compare plans" }));
@@ -190,7 +192,11 @@ describe("FreeTierPlanView", () => {
fireEvent.click(screen.getByRole("button", { name: button }));
expect(openLinkModal).not.toHaveBeenCalled();
- expect(screen.getByTestId("location")).toHaveTextContent("/enterprise");
+ expect(open).toHaveBeenCalledWith(
+ expect.stringMatching(/^https:\/\/.+\/enterprise$/),
+ "_blank",
+ "noopener,noreferrer",
+ );
},
);
diff --git a/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.tsx b/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.tsx
index 4985442e45..9ff1f52998 100644
--- a/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.tsx
+++ b/frontend/src/processor/proprietary/components/billing/FreeTierPlanView.tsx
@@ -14,7 +14,7 @@ import { usersBackend } from "@editor/portal/usersBackend";
import { HttpError } from "@processor/api/http";
import { useUI } from "@processor/contexts/UIContext";
import "@processor/components/billing/FreeTierPlanView.css";
-import { useOpenEnterprise } from "@processor/components/procurement/enterprisePath";
+import { useOpenEnterprise } from "@processor/components/procurement/enterpriseEntry";
/** {@code forbidden} is an outcome, not a failure: the endpoint is admin-only. */
type Load =
diff --git a/frontend/src/processor/proprietary/components/procurement/enterpriseEntry.ts b/frontend/src/processor/proprietary/components/procurement/enterpriseEntry.ts
new file mode 100644
index 0000000000..0c780b99c7
--- /dev/null
+++ b/frontend/src/processor/proprietary/components/procurement/enterpriseEntry.ts
@@ -0,0 +1,22 @@
+import { useCallback } from "react";
+
+const SAAS_FRONTEND_URL = (
+ import.meta.env.VITE_SAAS_FRONTEND_URL || "https://stirling.com/app"
+).replace(/\/+$/, "");
+
+/**
+ * Self-hosted: Enterprise is bought on the hosted page and reaches this server only as a licence
+ * key, so the server never runs or tracks the deal. Shadowed in the SaaS build.
+ */
+export const HOSTS_ENTERPRISE_DEAL = false;
+
+/** The hosted Enterprise page, carrying over a link's query and hash (?source=sales). */
+export function hostedEnterpriseUrl(search = ""): string {
+ return `${SAAS_FRONTEND_URL}/enterprise${search}`;
+}
+
+export function useOpenEnterprise(): () => void {
+ return useCallback(() => {
+ window.open(hostedEnterpriseUrl(), "_blank", "noopener,noreferrer");
+ }, []);
+}
diff --git a/frontend/src/processor/proprietary/components/procurement/enterprisePath.ts b/frontend/src/processor/proprietary/components/procurement/enterprisePath.ts
index 41b46c9771..06af5fc8ad 100644
--- a/frontend/src/processor/proprietary/components/procurement/enterprisePath.ts
+++ b/frontend/src/processor/proprietary/components/procurement/enterprisePath.ts
@@ -1,16 +1,12 @@
-import { useNavigate } from "react-router-dom";
-
-/** The Enterprise page: trial, quote, agreement and licence, outside the app's own chrome. */
+/**
+ * The Enterprise page: trial, quote, agreement and licence, outside the app's own chrome.
+ * Self-hosted builds forward it to the hosted page.
+ */
export const ENTERPRISE_PATH = "/enterprise";
/** An older address for the page. Sales emails and campaigns still link to it, so it redirects. */
export const LEGACY_ENTERPRISE_PATH = "/procurement";
-export function useOpenEnterprise(): () => void {
- const navigate = useNavigate();
- return () => navigate(ENTERPRISE_PATH);
-}
-
/**
* Where a billing link that set out to start the Enterprise trial (`?procurement=start`, sent in
* sales emails) now leads, keeping its other parameters; null for any other billing link.
diff --git a/frontend/src/processor/proprietary/components/procurement/useProcurement.ts b/frontend/src/processor/proprietary/components/procurement/useProcurement.ts
index c2db30c7e6..adcf91b747 100644
--- a/frontend/src/processor/proprietary/components/procurement/useProcurement.ts
+++ b/frontend/src/processor/proprietary/components/procurement/useProcurement.ts
@@ -85,12 +85,13 @@ export interface ProcurementController {
* for billing and the Enterprise page, so moving between them does not flash the loading state.
* No retry: the page gates all its content on `loading`, which backoff would hold true.
*/
-export function useProcurementSnapshot() {
+export function useProcurementSnapshot(enabled = true) {
const isLinked = usePortalLinked();
return useQuery<ProcurementSnapshot | null>({
queryKey: qk.procurement(isLinked),
queryFn: () => (isLinked ? fetchSnapshot() : Promise.resolve(null)),
retry: false,
+ enabled,
});
}
diff --git a/frontend/src/processor/proprietary/views/Enterprise.test.tsx b/frontend/src/processor/proprietary/views/Enterprise.test.tsx
index 0a6e7a884a..fb91d509fd 100644
--- a/frontend/src/processor/proprietary/views/Enterprise.test.tsx
+++ b/frontend/src/processor/proprietary/views/Enterprise.test.tsx
@@ -28,16 +28,6 @@ vi.mock("react-i18next", () => ({
const state = vi.hoisted(() => ({
controller: null as unknown as ProcurementController,
- gate: {
- loading: false,
- gated: false,
- available: true,
- error: null as string | null,
- retry: () => {},
- connect: () => {},
- },
- owner: true,
- linkProvider: true as boolean,
role: "leader",
signedIn: true,
draft: null as TrialDraft | null,
@@ -70,24 +60,12 @@ vi.mock("@processor/components/procurement/CalendlyInline", async (actual) => ({
vi.mock("@processor/components/procurement/useProcurement", () => ({
useProcurement: () => state.useProcurement(),
}));
-vi.mock("@processor/hooks/useConnectGate", () => ({
- useConnectGate: () => state.gate,
-}));
-vi.mock("@processor/hooks/useAccountLinkOwner", () => ({
- useAccountLinkOwner: () => state.owner,
-}));
vi.mock("@processor/hooks/useLinkedAccountEmail", () => ({
useLinkedAccountEmail: () => null,
}));
-vi.mock("@processor/contexts/LinkContext", () => ({
- useLinkOptional: () => (state.linkProvider ? {} : null),
-}));
vi.mock("@processor/contexts/UIContext", () => ({
useUI: () => ({ openSettings: vi.fn() }),
}));
-vi.mock("@processor/components/account-link/SaasSessionBanner", () => ({
- SaasSessionBanner: () => null,
-}));
vi.mock("@processor/components/procurement/ProcurementFlow", () => ({
ProcurementFlow: () => null,
procurementFlowStep: () => state.flowStep,
@@ -185,9 +163,6 @@ function mount() {
}
beforeEach(() => {
- state.gate = { ...state.gate, available: true, connect: vi.fn() };
- state.owner = true;
- state.linkProvider = true;
state.role = "leader";
state.signedIn = true;
state.draft = null;
@@ -198,30 +173,6 @@ beforeEach(() => {
});
describe("Enterprise page", () => {
- it("asks a server's owner to connect before anything else", () => {
- state.controller = controller({ isLinked: false, data: null });
- mount();
- fireEvent.click(
- screen.getByRole("button", { name: "portal.procurement.link.cta" }),
- );
- expect(state.gate.connect).toHaveBeenCalledOnce();
- expect(state.controller.onExploreEnterprise).not.toHaveBeenCalled();
- });
-
- it("tells another administrator that only the owner can connect", () => {
- state.owner = false;
- state.controller = controller({ isLinked: false, data: null });
- mount();
- expect(
- screen.queryByRole("button", { name: "portal.procurement.link.cta" }),
- ).not.toBeInTheDocument();
- expect(
- screen.getByText(
- "Only this server’s owner can connect it. Ask them to open this page.",
- ),
- ).toBeInTheDocument();
- });
-
it("records interest once and offers the trial setup to a leader with no deal", async () => {
state.controller = controller({ data: null });
mount();
diff --git a/frontend/src/processor/proprietary/views/Enterprise.tsx b/frontend/src/processor/proprietary/views/Enterprise.tsx
index 3021933411..62e069de18 100644
--- a/frontend/src/processor/proprietary/views/Enterprise.tsx
+++ b/frontend/src/processor/proprietary/views/Enterprise.tsx
@@ -11,12 +11,8 @@ import { FLOW_JOURNEY, type DealStage } from "@processor/api/procurement";
import { refreshWalletCache } from "@processor/api/billing";
import { qk } from "@processor/queries/keys";
import { walletQuery } from "@processor/queries/wallet";
-import { useLinkOptional } from "@processor/contexts/LinkContext";
import { useUI } from "@processor/contexts/UIContext";
-import { useConnectGate } from "@processor/hooks/useConnectGate";
-import { useAccountLinkOwner } from "@processor/hooks/useAccountLinkOwner";
import { useLinkedAccountEmail } from "@processor/hooks/useLinkedAccountEmail";
-import { SaasSessionBanner } from "@processor/components/account-link/SaasSessionBanner";
import {
useProcurement,
type ProcurementController,
@@ -56,8 +52,8 @@ const TRIAL_STAGES: DealStage[] = ["trial", "quote", "security"];
* then where the deal stands, its next action, licence key, trial, documents and a way to talk to
* us. Building a quote and signing the agreement are long enough to open over it.
*
- * Open to visitors without an account where the build allows it (the hosted page, linked from
- * the website): they read the page and fill in the trial setup, and sign in only to start it.
+ * Hosted app only, where the signed-in account is the Stirling account. Visitors without an account
+ * read the page and fill in the trial setup, and sign in only to start it.
*/
export function Enterprise({
onSignIn = signIn,
@@ -131,10 +127,6 @@ function SignedIn() {
const { user } = useAuth();
const queryClient = useQueryClient();
const procurement = useProcurement();
- const gate = useConnectGate();
- // No provider on SaaS: the signed-in account is the Stirling account, so there is nothing to link.
- const link = useLinkOptional();
- const isOwner = useAccountLinkOwner();
const email = useLinkedAccountEmail();
const { openSettings } = useUI();
// Answers given before signing in, if this visit is the return from it. Only the account they
@@ -206,10 +198,7 @@ function SignedIn() {
!procurement.error &&
!procurement.loadError &&
(!firstVisitHandled.current || busy);
- const loading =
- gate.loading ||
- (isLinked && (procurement.loading || wallet.isPending)) ||
- startingTrial;
+ const loading = procurement.loading || wallet.isPending || startingTrial;
const company =
latest?.config.businessName?.trim() || data?.businessName?.trim() || null;
@@ -218,20 +207,9 @@ function SignedIn() {
const flowOpen = flowStep != null;
const onInvite = canManage ? () => openSettings("users") : undefined;
- /** The page's main content, by how far the visitor has got: linking, then exploring, then the deal. */
+ /** The page's main content, by how far the visitor has got: exploring, then the deal. */
function body(): ReactNode {
if (loading) return <PageSkeleton />;
- if (!isLinked)
- return (
- <Landing>
- <ConnectPanel
- available={gate.available}
- isOwner={isOwner}
- onConnect={gate.connect}
- onSchedule={schedule}
- />
- </Landing>
- );
// The banner above says what failed and offers a retry.
if (procurement.loadError) return null;
if (exploring) {
@@ -280,13 +258,9 @@ function SignedIn() {
onInvite={onInvite}
scrollKey={flowOpen ? "flow" : "page"}
// A deal carries its own contact section, so the footer would only repeat it.
- onSchedule={loading || !isLinked || exploring ? schedule : undefined}
+ onSchedule={loading || exploring ? schedule : undefined}
>
<div className="ent__wrap ent__notices">
- {link && <SaasSessionBanner />}
- {gate.error && (
- <RetryBanner message={gate.error} onRetry={gate.retry} />
- )}
{wallet.isError && (
<RetryBanner
message={wallet.error.message}
@@ -495,59 +469,6 @@ function Landing({ children }: { children: ReactNode }) {
);
}
-/** Self-hosted, before the server has a Stirling account to run the trial and quote on. */
-function ConnectPanel({
- available,
- isOwner,
- onConnect,
- onSchedule,
-}: {
- available: boolean;
- isOwner: boolean;
- onConnect: () => void;
- onSchedule: () => void;
-}) {
- const { t } = useTranslation();
- if (!available) {
- return (
- <div className="ent__panel-body">
- <h2 className="ent__h2">{t("portal.procurement.link.title")}</h2>
- <p className="ent__text">
- {t(
- "portal.enterprise.connect.unavailable",
- "Connecting to a Stirling account is turned off on this server. Book a call and we’ll set up your trial with you.",
- )}
- </p>
- <div className="ent__actions">
- <Button variant="primary" onClick={onSchedule}>
- {t("portal.procurement.hero.scheduleCall")}
- </Button>
- </div>
- </div>
- );
- }
- return (
- <div className="ent__panel-body">
- <h2 className="ent__h2">{t("portal.procurement.link.title")}</h2>
- <p className="ent__text">{t("portal.procurement.link.description")}</p>
- {isOwner ? (
- <div className="ent__actions">
- <Button variant="primary" onClick={onConnect}>
- {t("portal.procurement.link.cta")}
- </Button>
- </div>
- ) : (
- <p className="ent__note">
- {t(
- "portal.enterprise.connect.ownerOnly",
- "Only this server’s owner can connect it. Ask them to open this page.",
- )}
- </p>
- )}
- </div>
- );
-}
-
/** Which stage of the journey a long step shows, when one is open. */
const FLOW_STEP_STAGE = { builder: "quote", agreement: "security" } as const;
diff --git a/frontend/src/processor/proprietary/views/Usage.test.tsx b/frontend/src/processor/proprietary/views/Usage.test.tsx
index af786ef0af..5ee3a244c7 100644
--- a/frontend/src/processor/proprietary/views/Usage.test.tsx
+++ b/frontend/src/processor/proprietary/views/Usage.test.tsx
@@ -104,14 +104,26 @@ const procurement = {
deal: null as Pick<ProcurementSnapshot, "dealId" | "stage"> | null,
error: null as Error | null,
refetch: vi.fn(),
+ enabled: undefined as boolean | undefined,
};
vi.mock("@editor/portal/components/procurement/useProcurement", () => ({
- useProcurementSnapshot: () => ({
- data: procurement.error ? undefined : procurement.deal,
- error: procurement.error,
- isSuccess: !procurement.error,
- refetch: procurement.refetch,
- }),
+ useProcurementSnapshot: (enabled?: boolean) => {
+ procurement.enabled = enabled;
+ return {
+ data: procurement.error ? undefined : procurement.deal,
+ error: procurement.error,
+ isSuccess: !procurement.error,
+ refetch: procurement.refetch,
+ };
+ },
+}));
+// Usage serves both builds; hostsDeal switches between their Enterprise entries.
+const enterprise = { hostsDeal: true, open: vi.fn() };
+vi.mock("@editor/portal/components/procurement/enterpriseEntry", () => ({
+ get HOSTS_ENTERPRISE_DEAL() {
+ return enterprise.hostsDeal;
+ },
+ useOpenEnterprise: () => enterprise.open,
}));
vi.mock("@editor/portal/components/procurement/DealStatusHero", () => ({
DealStatusHero: ({ onOpen }: { onOpen?: () => void }) => (
@@ -218,6 +230,8 @@ describe("Usage — link-free wallet renderer", () => {
procurement.deal = null;
procurement.error = null;
procurement.refetch.mockReset();
+ enterprise.hostsDeal = true;
+ enterprise.open.mockReset();
});
it("opens Team once for an over-capacity server and includes the actual allowance", async () => {
@@ -699,7 +713,22 @@ describe("Usage — link-free wallet renderer", () => {
fireEvent.click(
await screen.findByRole("button", { name: "Get an enterprise quote" }),
);
- expect(screen.getByTestId("location")).toHaveTextContent("/enterprise");
+ expect(enterprise.open).toHaveBeenCalledOnce();
+ });
+
+ it("on a self-hosted server, always offers the hosted Enterprise page and shows no deal", async () => {
+ enterprise.hostsDeal = false;
+ procurement.deal = { dealId: 1, stage: "trial" };
+ procurement.error = new Error("Snapshot unavailable");
+ fetchWallet.mockResolvedValue({ ...walletOf("free"), role: "leader" });
+ renderUsage(<Usage />);
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Get an enterprise quote" }),
+ );
+ expect(enterprise.open).toHaveBeenCalledOnce();
+ expect(screen.queryByTestId("procurement-summary")).not.toBeInTheDocument();
+ expect(screen.queryByText("Snapshot unavailable")).not.toBeInTheDocument();
+ expect(procurement.enabled).toBe(false);
});
it("still offers the quote to a buyer who asked but never started a trial", async () => {
diff --git a/frontend/src/processor/proprietary/views/Usage.tsx b/frontend/src/processor/proprietary/views/Usage.tsx
index f28e27cde6..ca635163ad 100644
--- a/frontend/src/processor/proprietary/views/Usage.tsx
+++ b/frontend/src/processor/proprietary/views/Usage.tsx
@@ -19,7 +19,10 @@ import { useLegacySubscriptions } from "@editor/hooks/useLegacySubscriptions";
import { LegacySubscriptionPlan } from "@editor/components/shared/config/LegacySubscriptionPlan";
import { useProcurementSnapshot } from "@processor/components/procurement/useProcurement";
import { DealStatusHero } from "@processor/components/procurement/DealStatusHero";
-import { useOpenEnterprise } from "@processor/components/procurement/enterprisePath";
+import {
+ HOSTS_ENTERPRISE_DEAL,
+ useOpenEnterprise,
+} from "@processor/components/procurement/enterpriseEntry";
import {
fetchWallet,
refreshWalletCache,
@@ -117,12 +120,15 @@ export function Usage({
previousSessionRevision.current = sessionRevision;
refresh();
}, [sessionRevision, refresh]);
- const dealQuery = useProcurementSnapshot();
- const deal = dealQuery.data;
+ // A self-hosted server has no deal to show: Enterprise is bought on the hosted page.
+ const dealQuery = useProcurementSnapshot(HOSTS_ENTERPRISE_DEAL);
+ const deal = HOSTS_ENTERPRISE_DEAL ? dealQuery.data : null;
// Session failures surface through the session banner; anything else is shown here, since an
// unknown deal must not be read as "no deal" and offered a fresh start.
const dealError =
- dealQuery.error && !(dealQuery.error instanceof SaasSessionRequiredError)
+ HOSTS_ENTERPRISE_DEAL &&
+ dealQuery.error &&
+ !(dealQuery.error instanceof SaasSessionRequiredError)
? dealQuery.error.message
: null;
const openEnterprise = useOpenEnterprise();
@@ -510,8 +516,9 @@ export function Usage({
}
onEnterpriseQuote={
isLeader &&
- dealQuery.isSuccess &&
- (deal?.dealId == null || deal.stage === "exploring")
+ (!HOSTS_ENTERPRISE_DEAL ||
+ (dealQuery.isSuccess &&
+ (deal?.dealId == null || deal.stage === "exploring")))
? openEnterprise
: undefined
}
diff --git a/frontend/src/processor/saas/EnterpriseApp.tsx b/frontend/src/processor/saas/EnterpriseApp.tsx
new file mode 100644
index 0000000000..60dc9599f9
--- /dev/null
+++ b/frontend/src/processor/saas/EnterpriseApp.tsx
@@ -0,0 +1,37 @@
+import { type ReactNode } from "react";
+import { useAuth } from "@editor/auth";
+import { EnterpriseAuthBoundary } from "@processor/auth/EnterpriseAuthBoundary";
+import { PortalFrame } from "@processor/PortalFrame";
+import { PortalSettingsProviders } from "@processor/components/settings/PortalSettingsProviders";
+import { ErrorBoundary } from "@processor/components/ErrorBoundary";
+import { Enterprise } from "@processor/views/Enterprise";
+
+/** The portal's providers load account data as they mount, so a visitor without one gets none. */
+function AccountProviders({ children }: { children: ReactNode }) {
+ const { session, isAnonymous } = useAuth();
+ return session && !isAnonymous ? (
+ <PortalSettingsProviders>{children}</PortalSettingsProviders>
+ ) : (
+ children
+ );
+}
+
+/**
+ * The Enterprise page as its own route, served like a website separate from the app: none of the
+ * portal's chrome, but the same query cache and sign-in as billing, so a deal started on either
+ * side shows on the other. Open to visitors without an account; sign-in comes when they start
+ * something that needs one.
+ */
+export function EnterpriseApp() {
+ return (
+ <PortalFrame>
+ <EnterpriseAuthBoundary>
+ <AccountProviders>
+ <ErrorBoundary>
+ <Enterprise />
+ </ErrorBoundary>
+ </AccountProviders>
+ </EnterpriseAuthBoundary>
+ </PortalFrame>
+ );
+}
diff --git a/frontend/src/processor/saas/components/procurement/enterpriseEntry.test.tsx b/frontend/src/processor/saas/components/procurement/enterpriseEntry.test.tsx
new file mode 100644
index 0000000000..15d4747833
--- /dev/null
+++ b/frontend/src/processor/saas/components/procurement/enterpriseEntry.test.tsx
@@ -0,0 +1,31 @@
+import { describe, expect, it } from "vitest";
+import { fireEvent, render, screen } from "@testing-library/react";
+import { MemoryRouter, useLocation } from "react-router-dom";
+import {
+ HOSTS_ENTERPRISE_DEAL,
+ useOpenEnterprise,
+} from "@processor/components/procurement/enterpriseEntry";
+
+function Probe() {
+ const open = useOpenEnterprise();
+ const { pathname } = useLocation();
+ return (
+ <>
+ <button onClick={open}>Open</button>
+ <output data-testid="location">{pathname}</output>
+ </>
+ );
+}
+
+describe("hosted useOpenEnterprise", () => {
+ it("opens the Enterprise page within the app, which runs the deal", () => {
+ render(
+ <MemoryRouter initialEntries={["/settings/billing"]}>
+ <Probe />
+ </MemoryRouter>,
+ );
+ fireEvent.click(screen.getByRole("button", { name: "Open" }));
+ expect(screen.getByTestId("location")).toHaveTextContent("/enterprise");
+ expect(HOSTS_ENTERPRISE_DEAL).toBe(true);
+ });
+});
diff --git a/frontend/src/processor/saas/components/procurement/enterpriseEntry.ts b/frontend/src/processor/saas/components/procurement/enterpriseEntry.ts
new file mode 100644
index 0000000000..9fc877be5d
--- /dev/null
+++ b/frontend/src/processor/saas/components/procurement/enterpriseEntry.ts
@@ -0,0 +1,10 @@
+import { useNavigate } from "react-router-dom";
+import { ENTERPRISE_PATH } from "@processor/components/procurement/enterprisePath";
+
+/** SaaS: this app hosts the Enterprise page and runs the deal on the signed-in account. */
+export const HOSTS_ENTERPRISE_DEAL = true;
+
+export function useOpenEnterprise(): () => void {
+ const navigate = useNavigate();
+ return () => navigate(ENTERPRISE_PATH);
+}