Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Route self-hosted app upgrades through Pulse Account

rcourtmane4fa4824b9a0
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
index 7cd841e406..b98d2b1993 100644
--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
@@ -426,7 +426,10 @@ Transition rule:
1. existing utility pages may remain as entry points or compatibility shims
2. new commercial/account workflows should prefer the Pulse Account shell
-3. utility pages should shrink toward redirects or lightweight recovery
+3. in-product self-hosted upgrade CTAs should hand off into `Pulse Account`
+ billing first, even when plan comparison or checkout still continues on the
+ public site as the next step
+4. utility pages should shrink toward redirects or lightweight recovery
handoffs once equivalent Pulse Account areas exist
## Forbidden Drift
@@ -457,7 +460,9 @@ Accepted as sufficient for RC and GA:
1. Cloud/MSP control-plane portal exists
2. self-hosted recovery and billing utilities exist
-3. commercial surfaces are functional but fragmented
+3. in-product self-hosted upgrade surfaces may hand off into `Pulse Account`
+ billing before the portal absorbs full purchase depth
+4. commercial surfaces are functional but fragmented
### Candidate lane target
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 49f04fea46..30f69e9076 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -498,6 +498,11 @@ self-hosted commercial history is relevant to the signed-in account, so
hosted-only accounts do not render self-hosted license, refund, privacy, or
self-hosted escalation paths by default, and self-hosted-only accounts do not
front-load an empty hosted-billing block before the real self-hosted jobs.
+That same runtime handoff contract now also covers product-originated
+self-hosted upgrade arrivals: `/portal?service=upgrade&feature=...` may open a
+portal-owned upgrade job inside `Billing`, but it must not fabricate broader
+self-hosted commercial history or reveal retrieve/refund/privacy panels for a
+hosted-only account that only arrived through an upgrade CTA.
That same typed bootstrap/runtime contract must also derive the default signed-
in shell section from account shape: hosted accounts open on `Workspaces`,
self-hosted-only accounts open on `Billing`, and the signed-in shell keeps
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 4b8fd54497..090acc21c3 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -407,9 +407,13 @@ The same commercial handoff rule also covers the legacy `/pricing` route in
`frontend-modern/src/pages/PricingHandoff.tsx` and
`frontend-modern/src/utils/pricingHandoff.ts`: compatibility handoff may keep
product-owned destinations such as monitored-system billing or Cloud plans
-inside the app, but public self-hosted pricing must leave the product for the
-canonical website rather than rendering a second public pricing surface inside
-Pulse.
+inside the app, but self-hosted commercial upgrade intents now hand off to
+`Pulse Account` first instead of treating the public pricing page as the app's
+canonical destination. The portal may continue the next step on the public
+self-hosted pricing site while the authenticated account shell is still
+absorbing new-purchase depth, but Pulse itself must not render a second public
+pricing surface inside the runtime or dump upgrade CTAs straight to marketing
+as though that were the product-owned commercial surface.
That destination split is canonical commercial truth, but navigation semantics
are not owned here. `frontend-modern/src/utils/pricingHandoff.ts` and
`frontend-modern/src/stores/license.ts` decide which href each commercial
@@ -1074,6 +1078,15 @@ Inline workspace counts and shell copy follow the same account-shape and
permission rule: hosted-only accounts must not mention self-hosted billing
utilities by default, and hosted view-only roles must say when hosted billing
still needs owner/admin authority.
+That same portal runtime contract now also owns explicit self-hosted upgrade
+arrivals from the product: when Pulse hands a self-hosted commercial upgrade
+intent into `/portal`, the billing shell may expose an `Upgrade` job even when
+the signed-in account has no existing self-hosted commercial history, but that
+arrival must stay narrower than the full self-hosted utility set. Hosted-only
+accounts may not suddenly render retrieve/refund/privacy tools by default just
+because they arrived from an upgrade CTA; only the specific portal-owned
+upgrade path may appear until the account actually has relevant self-hosted
+history.
The same rule applies to the compact account-context strip: it must describe
the current user's effective hosted tasks, not restate full access-control and
billing capability when those actions are blocked behind owner/admin roles.
diff --git a/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx b/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
index 2d3536c2e7..20db29a847 100644
--- a/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
+++ b/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
@@ -8,7 +8,7 @@ import {
getNoActiveProLicenseState,
getTrialEndedProLicenseNotice,
} from '@/utils/licensePresentation';
-import { getPublicPricingUrl } from '@/utils/pricingHandoff';
+import { getPulseAccountPortalUpgradeUrl } from '@/utils/pricingHandoff';
import { resolveUpgradeDestination } from '@/utils/upgradeNavigation';
import { CommercialStatGrid } from './CommercialBillingSections';
import { SELF_HOSTED_PRO_BILLING_PRESENTATION } from './selfHostedBillingPresentation';
@@ -55,13 +55,8 @@ export const ProLicensePlanSection: Component<ProLicensePlanSectionProps> = (pro
const trialEndedNotice = props.trialEnded ? getTrialEndedProLicenseNotice() : null;
const inactiveProUpsellNotice =
!props.hasPaidFeatures && !props.trialEnded ? getInactiveProUpsellNotice() : null;
- const monitoredSystemUpgradeDestination = () => {
- const destination = getUpgradeActionDestination('max_monitored_systems');
- if (destination.external) {
- return destination;
- }
- return resolveUpgradeDestination(getPublicPricingUrl('max_monitored_systems'));
- };
+ const monitoredSystemUpgradeDestination = () =>
+ resolveUpgradeDestination(getPulseAccountPortalUpgradeUrl('max_monitored_systems'));
return (
<>
diff --git a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
index b5a8caceb6..ba4c4a32f7 100644
--- a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
@@ -8,6 +8,7 @@ import proLicensePanelStateSource from '../useProLicensePanelState.ts?raw';
import proLicensePlanSectionSource from '../ProLicensePlanSection.tsx?raw';
import selfHostedCommercialActivationSectionSource from '../SelfHostedCommercialActivationSection.tsx?raw';
import {
+ getPulseAccountPortalUpgradeUrl,
getPublicPricingUrl,
SELF_HOSTED_PRO_BILLING_PLAN_HREF,
SELF_HOSTED_PRO_BILLING_PLAN_SECTION_ID,
@@ -360,7 +361,7 @@ describe('ProLicensePanel', () => {
expect(screen.getByText('Need a higher monitored-system cap?')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Compare plans' })).toHaveAttribute(
'href',
- getPublicPricingUrl('max_monitored_systems'),
+ getPulseAccountPortalUpgradeUrl('max_monitored_systems'),
);
});
@@ -554,7 +555,9 @@ describe('ProLicensePanel', () => {
expect(proLicensePlanSectionSource).toContain(
'monitoredSystemUpgradeArrivalTitle',
);
- expect(proLicensePlanSectionSource).toContain("getUpgradeActionDestination('max_monitored_systems')");
+ expect(proLicensePlanSectionSource).toContain(
+ "getPulseAccountPortalUpgradeUrl('max_monitored_systems')",
+ );
expect(proLicensePlanSectionSource).not.toContain('Your Pro trial has ended');
expect(proLicensePlanSectionSource).not.toContain('Unlock Pulse Patrol, alert analysis, auto-fix, and more.');
expect(selfHostedCommercialActivationSectionSource).toContain(
diff --git a/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts b/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts
index 8c03e7cf91..db1bd1d88d 100644
--- a/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts
+++ b/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts
@@ -31,6 +31,6 @@ export const SELF_HOSTED_PRO_BILLING_PRESENTATION: SelfHostedProBillingPresentat
usageSectionTitle: 'Usage',
monitoredSystemUpgradeArrivalTitle: 'Need a higher monitored-system cap?',
monitoredSystemUpgradeArrivalBody:
- 'Compare plans on the public pricing site, then activate the new Pulse Pro license key here once you purchase it.',
+ 'Open Pulse Account to continue with self-hosted plan comparison and checkout, then activate the new Pulse Pro license key here once you purchase it.',
monitoredSystemUpgradeArrivalActionLabel: 'Compare plans',
};
diff --git a/frontend-modern/src/pages/PricingHandoff.tsx b/frontend-modern/src/pages/PricingHandoff.tsx
index 613e9f16ca..28321d2188 100644
--- a/frontend-modern/src/pages/PricingHandoff.tsx
+++ b/frontend-modern/src/pages/PricingHandoff.tsx
@@ -5,12 +5,22 @@ import {
getPricingRouteDestination,
handoffToExternalPricing,
isExternalPricingDestination,
+ isPulseAccountPortalDestination,
} from '@/utils/pricingHandoff';
export default function PricingHandoff() {
const location = useLocation();
const destination = createMemo(() => getPricingRouteDestination(location.search));
const externalDestination = createMemo(() => isExternalPricingDestination(destination()));
+ const pulseAccountDestination = createMemo(() =>
+ isPulseAccountPortalDestination(destination()),
+ );
+ const handoffLabel = createMemo(() =>
+ pulseAccountDestination() ? 'Pulse Account' : 'pricing',
+ );
+ const handoffLinkLabel = createMemo(() =>
+ pulseAccountDestination() ? 'continue to Pulse Account' : 'continue to the public pricing site',
+ );
onMount(() => {
trackPaywallViewed('pricing', 'pricing_handoff');
@@ -23,14 +33,13 @@ export default function PricingHandoff() {
<Show when={externalDestination()} fallback={<Navigate href={destination()} />}>
<div class="flex min-h-[50vh] items-center justify-center">
<div class="space-y-2 text-center">
- <h1 class="text-lg font-semibold text-base-content">Redirecting to pricing</h1>
+ <h1 class="text-lg font-semibold text-base-content">
+ Redirecting to {handoffLabel()}
+ </h1>
<p class="text-sm text-muted">
If the handoff does not start automatically,{' '}
- <a
- href={destination()}
- class="text-blue-600 hover:underline dark:text-blue-400"
- >
- continue to the public pricing site
+ <a href={destination()} class="text-blue-600 hover:underline dark:text-blue-400">
+ {handoffLinkLabel()}
</a>
.
</p>
diff --git a/frontend-modern/src/pages/__tests__/PricingHandoff.test.tsx b/frontend-modern/src/pages/__tests__/PricingHandoff.test.tsx
index e5b2302d97..133e54dbb5 100644
--- a/frontend-modern/src/pages/__tests__/PricingHandoff.test.tsx
+++ b/frontend-modern/src/pages/__tests__/PricingHandoff.test.tsx
@@ -32,7 +32,7 @@ describe('PricingHandoff', () => {
window.history.replaceState({}, '', '/');
});
- it('hands public pricing requests off to the website', async () => {
+ it('hands self-hosted upgrade requests off to Pulse Account', async () => {
window.history.replaceState({}, '', '/pricing?feature=relay');
render(() => (
@@ -43,14 +43,14 @@ describe('PricingHandoff', () => {
await waitFor(() => {
expect(handoffToExternalPricingMock).toHaveBeenCalledWith(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=relay',
+ 'https://cloud.pulserelay.pro/portal?feature=relay&service=upgrade',
);
});
- expect(screen.getByRole('heading', { name: 'Redirecting to pricing' })).toBeInTheDocument();
- expect(screen.getByRole('link', { name: /continue to the public pricing site/i })).toHaveAttribute(
+ expect(screen.getByRole('heading', { name: 'Redirecting to Pulse Account' })).toBeInTheDocument();
+ expect(screen.getByRole('link', { name: /continue to Pulse Account/i })).toHaveAttribute(
'href',
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=relay',
+ 'https://cloud.pulserelay.pro/portal?feature=relay&service=upgrade',
);
});
diff --git a/frontend-modern/src/stores/__tests__/license.test.ts b/frontend-modern/src/stores/__tests__/license.test.ts
index 73d0a8eca3..f1272966c0 100644
--- a/frontend-modern/src/stores/__tests__/license.test.ts
+++ b/frontend-modern/src/stores/__tests__/license.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it, vi, beforeEach } from 'vitest';
import { LicenseAPI, type LicenseEntitlements } from '@/api/license';
+import { getPulseAccountPortalUpgradeUrl } from '@/utils/pricingHandoff';
import {
loadLicenseStatus,
startProTrial,
@@ -310,12 +311,10 @@ describe('license store', () => {
});
describe('getUpgradeActionUrlOrFallback', () => {
- it('routes missing self-hosted upgrades to the public pricing site when no upgrade reasons exist', async () => {
+ it('routes missing self-hosted upgrades to Pulse Account when no upgrade reasons exist', async () => {
vi.mocked(LicenseAPI.getEntitlements).mockResolvedValue(mockFreeEntitlements);
await loadLicenseStatus(true);
- expect(getUpgradeActionUrlOrFallback('relay')).toBe(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=relay',
- );
+ expect(getUpgradeActionUrlOrFallback('relay')).toBe(getPulseAccountPortalUpgradeUrl('relay'));
});
it('routes monitored-system limit fallbacks to the billing upgrade arrival', async () => {
@@ -335,11 +334,11 @@ describe('license store', () => {
expect(getUpgradeActionUrlOrFallback('cloud')).toBe('/cloud');
});
- it('routes generic upgrade fallbacks to the public pricing site', async () => {
+ it('routes generic upgrade fallbacks to Pulse Account', async () => {
vi.mocked(LicenseAPI.getEntitlements).mockResolvedValue(mockFreeEntitlements);
await loadLicenseStatus(true);
expect(getUpgradeActionUrlOrFallback('upgrade')).toBe(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=upgrade',
+ getPulseAccountPortalUpgradeUrl('upgrade'),
);
});
@@ -360,11 +359,11 @@ describe('license store', () => {
);
});
- it('routes unknown keys to the public pricing site as a last resort', async () => {
+ it('routes unknown keys to Pulse Account as a last resort', async () => {
vi.mocked(LicenseAPI.getEntitlements).mockResolvedValue(mockFreeEntitlements);
await loadLicenseStatus(true);
expect(getUpgradeActionUrlOrFallback('feature1')).toBe(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=feature1',
+ getPulseAccountPortalUpgradeUrl('feature1'),
);
});
});
diff --git a/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts b/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts
index 265e4b46b9..bd68a0cef9 100644
--- a/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts
+++ b/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts
@@ -3,6 +3,7 @@ import {
getSelfHostedBillingHref,
getSelfHostedBillingPlanIntent,
getSelfHostedBillingUsageDetail,
+ getPulseAccountPortalUpgradeUrl,
getPricingRouteDestination,
getPublicPricingUrl,
getUpgradeFallbackDestination,
@@ -30,9 +31,9 @@ describe('pricingHandoff', () => {
expect(getUpgradeFallbackDestination('cloud')).toBe('/cloud');
});
- it('routes self-hosted upgrades to the public pricing site', () => {
+ it('routes self-hosted upgrades to Pulse Account first', () => {
expect(getUpgradeFallbackDestination('relay')).toBe(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=relay',
+ getPulseAccountPortalUpgradeUrl('relay'),
);
});
@@ -44,7 +45,10 @@ describe('pricingHandoff', () => {
it('preserves extra query parameters when handing off the legacy pricing route', () => {
expect(getPricingRouteDestination('?feature=relay&utm_content=legacy-bookmark')).toBe(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=relay&utm_content=legacy-bookmark',
+ getPulseAccountPortalUpgradeUrl(
+ 'relay',
+ new URLSearchParams('feature=relay&utm_content=legacy-bookmark'),
+ ),
);
});
@@ -118,22 +122,18 @@ describe('pricingHandoff', () => {
});
expect(
scopeSelfHostedBillingDestination(
- { href: getPublicPricingUrl('relay'), external: true },
+ { href: getPulseAccountPortalUpgradeUrl('relay'), external: true },
'usage',
{ detail: SELF_HOSTED_PRO_BILLING_COUNTING_RULES_DETAIL },
),
).toEqual({
- href: getPublicPricingUrl('relay'),
+ href: getPulseAccountPortalUpgradeUrl('relay'),
external: true,
});
});
it('detects external pricing destinations', () => {
- expect(
- isExternalPricingDestination(
- 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade',
- ),
- ).toBe(true);
+ expect(isExternalPricingDestination(getPulseAccountPortalUpgradeUrl('relay'))).toBe(true);
expect(isExternalPricingDestination('/cloud')).toBe(false);
});
});
diff --git a/frontend-modern/src/utils/pricingHandoff.ts b/frontend-modern/src/utils/pricingHandoff.ts
index 49a7592d05..367816834e 100644
--- a/frontend-modern/src/utils/pricingHandoff.ts
+++ b/frontend-modern/src/utils/pricingHandoff.ts
@@ -5,6 +5,8 @@ import {
const DEFAULT_PUBLIC_PRICING_URL =
'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade';
+const DEFAULT_PULSE_ACCOUNT_PORTAL_URL = 'https://cloud.pulserelay.pro/portal';
+const PULSE_ACCOUNT_PORTAL_UPGRADE_SERVICE = 'upgrade';
export const SELF_HOSTED_PRO_BILLING_ROUTE = '/settings/system/billing';
export const SELF_HOSTED_PRO_BILLING_PLAN_ROUTE = `${SELF_HOSTED_PRO_BILLING_ROUTE}/plan`;
@@ -89,8 +91,53 @@ export function getPublicPricingUrl(feature?: string | null): string {
return url.toString();
}
+export function getPulseAccountPortalUrl(options: {
+ email?: string | null;
+ feature?: string | null;
+ service?: string | null;
+ searchParams?: URLSearchParams;
+} = {}): string {
+ const url = new URL(DEFAULT_PULSE_ACCOUNT_PORTAL_URL);
+ if (options.searchParams) {
+ for (const [key, value] of options.searchParams.entries()) {
+ const normalizedValue = value.trim();
+ if (normalizedValue) {
+ url.searchParams.set(key, normalizedValue);
+ }
+ }
+ }
+
+ const normalizedEmail = options.email?.trim();
+ if (normalizedEmail) {
+ url.searchParams.set('email', normalizedEmail);
+ }
+
+ const normalizedFeature = normalizeFeatureKey(options.feature);
+ if (normalizedFeature) {
+ url.searchParams.set('feature', normalizedFeature);
+ }
+
+ const normalizedService = options.service?.trim();
+ if (normalizedService) {
+ url.searchParams.set('service', normalizedService);
+ }
+
+ return url.toString();
+}
+
+export function getPulseAccountPortalUpgradeUrl(
+ feature?: string | null,
+ searchParams?: URLSearchParams,
+): string {
+ return getPulseAccountPortalUrl({
+ feature,
+ searchParams,
+ service: PULSE_ACCOUNT_PORTAL_UPGRADE_SERVICE,
+ });
+}
+
export function getUpgradeFallbackDestination(feature?: string | null): string {
- return getInProductPricingDestination(feature) || getPublicPricingUrl(feature);
+ return getInProductPricingDestination(feature) || getPulseAccountPortalUpgradeUrl(feature);
}
export function getSelfHostedBillingUsageDetail(
@@ -226,6 +273,10 @@ export function getPricingRouteDestination(search: string): string {
return inProductDestination;
}
+ if (normalizeFeatureKey(feature)) {
+ return getPulseAccountPortalUpgradeUrl(feature, params);
+ }
+
const url = new URL(DEFAULT_PUBLIC_PRICING_URL);
for (const [key, value] of params.entries()) {
const normalizedValue = value.trim();
@@ -240,6 +291,22 @@ export function isExternalPricingDestination(destination: string): boolean {
return isExternalUpgradeHref(destination);
}
+export function isPulseAccountPortalDestination(destination: string): boolean {
+ if (!isExternalUpgradeHref(destination)) {
+ return false;
+ }
+
+ try {
+ const url = new URL(destination);
+ return (
+ url.origin === new URL(DEFAULT_PULSE_ACCOUNT_PORTAL_URL).origin &&
+ url.pathname === new URL(DEFAULT_PULSE_ACCOUNT_PORTAL_URL).pathname
+ );
+ } catch {
+ return false;
+ }
+}
+
export function handoffToExternalPricing(destination: string): void {
window.location.replace(destination);
}
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index 3b7df84d58..73676ee8fe 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,5 +1,5 @@
{
- "source_hash": "8cda796f9a573443304df3d61c11f26041c8cd7f050fc737b67e3c056cd09b6c",
+ "source_hash": "5bb02fe9e6ac203e482678c5afae4d00462fc57457971908f10beb6e9a1ed579",
"build_inputs": [
"package.json",
"tsconfig.json",
diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.js
index 9cf73140f2..21ff4c8657 100644
--- a/internal/cloudcp/portal/dist/portal_app.js
+++ b/internal/cloudcp/portal/dist/portal_app.js
@@ -825,6 +825,7 @@
function createPortalBillingState() {
return {
openBillingPanelID: "",
+ upgradeFeatureKey: "",
flows: {
manage: newVerificationFlowState(),
retrieve: newVerificationFlowState(),
@@ -1397,7 +1398,13 @@
function renderOpenBillingPanels(openBillingPanelID) {
var shell = document.querySelector(".billing-shell");
var detailShell = getElement3("billing-detail-shell");
- var panels = ["manage-billing-panel", "retrieve-billing-panel", "refund-billing-panel", "data-billing-panel"];
+ var panels = [
+ "upgrade-billing-panel",
+ "manage-billing-panel",
+ "retrieve-billing-panel",
+ "refund-billing-panel",
+ "data-billing-panel"
+ ];
var hasOpenPanel = !!openBillingPanelID;
if (shell) {
shell.classList.toggle("billing-shell-job-open", hasOpenPanel);
@@ -2011,6 +2018,58 @@
var accounts = Array.isArray(bootstrap.accounts) ? bootstrap.accounts : [];
return bootstrap.has_self_hosted_commercial === true || !hasHostedAccounts(accounts);
}
+ function normalizeUpgradeFeatureKey(featureKey) {
+ return String(featureKey || "").trim();
+ }
+ function selfHostedUpgradeActionTitle(featureKey) {
+ return normalizeUpgradeFeatureKey(featureKey) === "max_monitored_systems" ? "Upgrade monitored-system cap" : "Upgrade self-hosted plan";
+ }
+ function selfHostedUpgradeActionDescription(featureKey) {
+ return normalizeUpgradeFeatureKey(featureKey) === "max_monitored_systems" ? "Compare self-hosted plans and choose a higher monitored-system allowance." : "Compare self-hosted plans and continue into the commercial checkout path.";
+ }
+ function selfHostedUpgradeActionHighlights(featureKey) {
+ return normalizeUpgradeFeatureKey(featureKey) === "max_monitored_systems" ? ["Monitored-system cap", "Plan comparison"] : ["Plan comparison", "Checkout handoff"];
+ }
+ function selfHostedUpgradePricingURL(bootstrap, featureKey) {
+ var publicSiteURL = String(bootstrap.public_site_url || "https://pulserelay.pro").trim();
+ var normalizedFeature = normalizeUpgradeFeatureKey(featureKey);
+ try {
+ var url = new URL("/pricing", publicSiteURL);
+ if (normalizedFeature) {
+ url.searchParams.set("feature", normalizedFeature);
+ }
+ url.searchParams.set("utm_source", "pulse-account");
+ url.searchParams.set("utm_medium", "portal");
+ url.searchParams.set("utm_campaign", "self_hosted_upgrade");
+ return url.toString();
+ } catch {
+ return "https://pulserelay.pro/pricing";
+ }
+ }
+ function renderSelfHostedUpgradeActionRow(context) {
+ var featureKey = normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ return renderBillingActionRow(
+ "open-upgrade-billing",
+ selfHostedUpgradeActionTitle(featureKey),
+ "Open",
+ selfHostedUpgradeActionDescription(featureKey),
+ "upgrade-billing-panel",
+ "upgrade-billing-link",
+ selfHostedUpgradeActionHighlights(featureKey)
+ );
+ }
+ function renderSelfHostedUpgradeBillingPanel(context) {
+ var featureKey = normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ var pricingURL = selfHostedUpgradePricingURL(context.bootstrap, featureKey);
+ var linkLabel = featureKey === "max_monitored_systems" ? "Compare monitored-system plans" : "View self-hosted plans";
+ var helperCopy = featureKey === "max_monitored_systems" ? "Choose the self-hosted tier that matches the monitored-system allowance you need, then return to Pulse Pro to activate the new license." : "Choose the self-hosted tier that fits this upgrade, then return to Pulse Pro to activate the new license.";
+ return renderBillingTaskPanel(
+ selfHostedUpgradeActionTitle(featureKey),
+ "Pulse Account owns the commercial handoff. Plan selection and checkout continue on the public self-hosted pricing site.",
+ "upgrade-billing-panel",
+ '<div class="form-actions"><a class="btn-primary" id="upgrade-billing-link" href="' + escapeAttr(pricingURL) + '" target="_blank" rel="noopener">' + escapeHTML(linkLabel) + '</a></div><div class="helper-text">' + escapeHTML(helperCopy) + "</div>"
+ );
+ }
function countWorkspaces(accounts) {
var total = 0;
for (var i = 0; i < accounts.length; i += 1) {
@@ -2366,6 +2425,8 @@
var accounts = Array.isArray(context.bootstrap.accounts) ? context.bootstrap.accounts : [];
var hosted = hasHostedAccounts(accounts);
var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);
+ var showSelfHostedUpgradeHandoff = !!normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ var showSelfHostedBillingShell = showSelfHostedCommercial || showSelfHostedUpgradeHandoff;
var shellSections = visibleShellSections(context.bootstrap);
var preferredSection = context.activeSection || preferredPortalShellSection(context.bootstrap);
var activeSection = shellSections.some(function(entry) {
@@ -2379,27 +2440,36 @@
var accessContent = accounts.length ? accounts.map(function(account) {
return '<section class="account-surface">' + renderAccountAccessSection(account) + "</section>";
}).join("") : renderNoHostedAccessSection();
- return '<div class="portal-shell" data-shell-section="' + activeSection + '"><div class="portal-shell-main">' + renderIdentityBar(accounts, showSelfHostedCommercial) + renderTabBar(context.bootstrap, activeSection) + (hosted ? '<section class="portal-content-panel portal-content-panel-workspaces">' + workspacesContent + '</section><section class="portal-content-panel portal-content-panel-access">' + accessContent + '</section><section class="portal-content-panel portal-content-panel-overview">' + renderShellOverviewSection(context) + "</section>" : "") + '<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' + (hosted ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : "") + (showSelfHostedCommercial ? '<div class="billing-shell billing-shell-idle"><div class="billing-shell-main"><div class="billing-shell-main-head"><h3>Self-hosted billing</h3><p>Use self-hosted billing only for self-hosted purchases.</p></div><div class="billing-action-list">' + renderBillingActionRow("open-manage-billing", "Manage subscriptions", "Open", "Open Stripe for self-hosted plan, invoice, and payment changes.", "manage-billing-panel", "manage-inline-email", ["Plan changes", "Invoices"]) + renderBillingActionRow("open-retrieve-billing", "Retrieve licenses", "Open", "Recover the latest active self-hosted license and invoice link.", "retrieve-billing-panel", "retrieve-inline-email", ["Latest active license", "Invoice lookup"]) + renderBillingActionRow("open-refund-billing", "Refund requests", "Open", "Request a self-serve refund when the purchase is still eligible.", "refund-billing-panel", "refund-inline-email", ["Eligibility check", "Revocation"]) + renderBillingActionRow("open-data-billing", "Data and privacy", "Open", "Request export or deletion for commercial account data.", "data-billing-panel", "data-export-email", ["Export", "Deletion"]) + '</div><div class="billing-inline-support"><h4>Support</h4><p>' + selfHostedBillingEscalationCopy + '</p><div class="billing-inline-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></div><div class="billing-shell-detail" id="billing-detail-shell" hidden>' + renderBillingTaskPanel(
- "Manage subscriptions",
- "Open Stripe for self-hosted plan, invoice, and payment changes.",
- "manage-billing-panel",
- '<div id="manage-billing-root"></div>'
- ) + renderBillingTaskPanel(
- "Retrieve licenses",
- "Recover the latest active self-hosted license and invoice link.",
- "retrieve-billing-panel",
- '<div id="retrieve-billing-root"></div>'
- ) + renderBillingTaskPanel(
- "Refund requests",
- "Request a self-serve refund when the purchase is still eligible.",
- "refund-billing-panel",
- '<div id="refund-billing-root"></div>'
- ) + renderBillingTaskPanel(
- "Data and privacy",
- "Request export or deletion for commercial account data.",
- "data-billing-panel",
- '<div class="subsection"><div id="data-export-root"></div></div><div class="subsection"><div id="data-delete-root"></div></div><div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + "</a>.</div>"
- ) + "</div></div>" : "") + '</section><section class="portal-content-panel portal-content-panel-support">' + renderSupportSection(context) + "</section></div></div>";
+ var selfHostedBillingLeadCopy = showSelfHostedCommercial ? "Use self-hosted billing only for self-hosted purchases." : "Pulse Account owns the commercial handoff for self-hosted upgrades from the app.";
+ var selfHostedBillingActionsHTML = renderSelfHostedUpgradeActionRow(context);
+ if (showSelfHostedCommercial) {
+ selfHostedBillingActionsHTML += renderBillingActionRow("open-manage-billing", "Manage subscriptions", "Open", "Open Stripe for self-hosted plan, invoice, and payment changes.", "manage-billing-panel", "manage-inline-email", ["Plan changes", "Invoices"]) + renderBillingActionRow("open-retrieve-billing", "Retrieve licenses", "Open", "Recover the latest active self-hosted license and invoice link.", "retrieve-billing-panel", "retrieve-inline-email", ["Latest active license", "Invoice lookup"]) + renderBillingActionRow("open-refund-billing", "Refund requests", "Open", "Request a self-serve refund when the purchase is still eligible.", "refund-billing-panel", "refund-inline-email", ["Eligibility check", "Revocation"]) + renderBillingActionRow("open-data-billing", "Data and privacy", "Open", "Request export or deletion for commercial account data.", "data-billing-panel", "data-export-email", ["Export", "Deletion"]);
+ }
+ var selfHostedBillingPanelsHTML = renderSelfHostedUpgradeBillingPanel(context);
+ if (showSelfHostedCommercial) {
+ selfHostedBillingPanelsHTML += renderBillingTaskPanel(
+ "Manage subscriptions",
+ "Open Stripe for self-hosted plan, invoice, and payment changes.",
+ "manage-billing-panel",
+ '<div id="manage-billing-root"></div>'
+ ) + renderBillingTaskPanel(
+ "Retrieve licenses",
+ "Recover the latest active self-hosted license and invoice link.",
+ "retrieve-billing-panel",
+ '<div id="retrieve-billing-root"></div>'
+ ) + renderBillingTaskPanel(
+ "Refund requests",
+ "Request a self-serve refund when the purchase is still eligible.",
+ "refund-billing-panel",
+ '<div id="refund-billing-root"></div>'
+ ) + renderBillingTaskPanel(
+ "Data and privacy",
+ "Request export or deletion for commercial account data.",
+ "data-billing-panel",
+ '<div class="subsection"><div id="data-export-root"></div></div><div class="subsection"><div id="data-delete-root"></div></div><div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + "</a>.</div>"
+ );
+ }
+ return '<div class="portal-shell" data-shell-section="' + activeSection + '"><div class="portal-shell-main">' + renderIdentityBar(accounts, showSelfHostedCommercial) + renderTabBar(context.bootstrap, activeSection) + (hosted ? '<section class="portal-content-panel portal-content-panel-workspaces">' + workspacesContent + '</section><section class="portal-content-panel portal-content-panel-access">' + accessContent + '</section><section class="portal-content-panel portal-content-panel-overview">' + renderShellOverviewSection(context) + "</section>" : "") + '<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' + (hosted ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : "") + (showSelfHostedBillingShell ? '<div class="billing-shell billing-shell-idle"><div class="billing-shell-main"><div class="billing-shell-main-head"><h3>Self-hosted billing</h3><p>' + escapeHTML(selfHostedBillingLeadCopy) + '</p></div><div class="billing-action-list">' + selfHostedBillingActionsHTML + '</div><div class="billing-inline-support"><h4>Support</h4><p>' + selfHostedBillingEscalationCopy + '</p><div class="billing-inline-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></div><div class="billing-shell-detail" id="billing-detail-shell" hidden>' + selfHostedBillingPanelsHTML + "</div></div>" : "") + '</section><section class="portal-content-panel portal-content-panel-support">' + renderSupportSection(context) + "</section></div></div>";
}
function renderAuthScopeRow(title, copy) {
return '<article class="portal-auth-scope-row"><h3>' + escapeHTML(title) + "</h3><p>" + escapeHTML(copy) + "</p></article>";
@@ -2450,6 +2520,7 @@
var portalBootstrap = deps.store.getBootstrap();
userInfo.innerHTML = renderHeaderHTML({
bootstrap: portalBootstrap,
+ billingState: deps.store.getBillingState(),
loginState: deps.store.getLoginState(),
signupPath: portalBootstrap.signup_path,
accountAPIBasePath: portalBootstrap.account_api_base_path
@@ -2462,6 +2533,7 @@
var portalBootstrap = deps.store.getBootstrap();
var context = {
bootstrap: portalBootstrap,
+ billingState: deps.store.getBillingState(),
loginState: deps.store.getLoginState(),
signupPath: portalBootstrap.signup_path,
accountAPIBasePath: portalBootstrap.account_api_base_path,
@@ -2650,6 +2722,8 @@
}
function normalizeHandoffBillingPanel(value) {
switch (String(value || "").trim()) {
+ case "upgrade":
+ return "upgrade-billing-panel";
case "manage":
return "manage-billing-panel";
case "retrieve":
@@ -2662,17 +2736,22 @@
return "";
}
}
+ function normalizeUpgradeFeatureKey2(value) {
+ return String(value || "").trim();
+ }
function readPortalRuntimeHandoff(locationHref = window.location.href) {
try {
var params = new URL(locationHref).searchParams;
return {
email: normalizeHandoffEmail(params.get("email")),
- openBillingPanelID: normalizeHandoffBillingPanel(params.get("service"))
+ openBillingPanelID: normalizeHandoffBillingPanel(params.get("service")),
+ upgradeFeatureKey: normalizeUpgradeFeatureKey2(params.get("feature"))
};
} catch {
return {
email: "",
- openBillingPanelID: ""
+ openBillingPanelID: "",
+ upgradeFeatureKey: ""
};
}
}
@@ -2708,8 +2787,15 @@
}, { notify: false });
}
if (handoff.openBillingPanelID) {
+ store.setActiveShellSection("billing");
store.updateBillingState(function(billingState) {
billingState.openBillingPanelID = handoff.openBillingPanelID;
+ billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
+ }, { notify: false });
+ } else if (handoff.upgradeFeatureKey) {
+ store.setActiveShellSection("billing");
+ store.updateBillingState(function(billingState) {
+ billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
}, { notify: false });
}
return {
diff --git a/internal/cloudcp/portal/frontend/src/app.test.ts b/internal/cloudcp/portal/frontend/src/app.test.ts
index 6cb6a2f3f9..a854bf05f0 100644
--- a/internal/cloudcp/portal/frontend/src/app.test.ts
+++ b/internal/cloudcp/portal/frontend/src/app.test.ts
@@ -150,6 +150,7 @@ describe('portal app', function() {
{
openBillingPanelID: 'retrieve-billing-panel',
+ upgradeFeatureKey: '',
}
);
diff --git a/internal/cloudcp/portal/frontend/src/billing_view.ts b/internal/cloudcp/portal/frontend/src/billing_view.ts
index da69d783ef..8663f674cb 100644
--- a/internal/cloudcp/portal/frontend/src/billing_view.ts
+++ b/internal/cloudcp/portal/frontend/src/billing_view.ts
@@ -78,7 +78,13 @@ export function renderButton(id: string | undefined, disabled: boolean, label: s
export function renderOpenBillingPanels(openBillingPanelID: string): void {
var shell = document.querySelector('.billing-shell') as HTMLElement | null;
var detailShell = getElement('billing-detail-shell');
- var panels = ['manage-billing-panel', 'retrieve-billing-panel', 'refund-billing-panel', 'data-billing-panel'];
+ var panels = [
+ 'upgrade-billing-panel',
+ 'manage-billing-panel',
+ 'retrieve-billing-panel',
+ 'refund-billing-panel',
+ 'data-billing-panel',
+ ];
var hasOpenPanel = !!openBillingPanelID;
if (shell) {
shell.classList.toggle('billing-shell-job-open', hasOpenPanel);
diff --git a/internal/cloudcp/portal/frontend/src/runtime.test.ts b/internal/cloudcp/portal/frontend/src/runtime.test.ts
index bfac3ab4df..3ef7440e46 100644
--- a/internal/cloudcp/portal/frontend/src/runtime.test.ts
+++ b/internal/cloudcp/portal/frontend/src/runtime.test.ts
@@ -63,10 +63,11 @@ describe('portal runtime', function() {
});
it('derives canonical email and billing handoff from the portal URL', function() {
- var handoff = readPortalRuntimeHandoff('https://cloud.pulserelay.pro/portal?email=buyer%40example.com&service=retrieve');
+ var handoff = readPortalRuntimeHandoff('https://cloud.pulserelay.pro/portal?email=buyer%40example.com&service=upgrade&feature=max_monitored_systems');
expect(handoff.email).toBe('[email protected]');
- expect(handoff.openBillingPanelID).toBe('retrieve-billing-panel');
+ expect(handoff.openBillingPanelID).toBe('upgrade-billing-panel');
+ expect(handoff.upgradeFeatureKey).toBe('max_monitored_systems');
});
it('applies email and billing handoff to the initial portal store', function() {
@@ -80,6 +81,7 @@ describe('portal runtime', function() {
{
openBillingPanelID: 'refund-billing-panel',
+ upgradeFeatureKey: '',
}
);
@@ -88,4 +90,24 @@ describe('portal runtime', function() {
expect(runtime.store.getBillingState().refund.emailValue).toBe('[email protected]');
expect(runtime.store.getBillingState().openBillingPanelID).toBe('refund-billing-panel');
});
+
+ it('promotes upgrade handoff intents into the billing shell state', function() {
+ var runtime = createPortalRuntime(
+ {
+ authenticated: false,
+ email: '',
+ has_self_hosted_commercial: false,
+ accounts: [],
+ },
+ {
+ email: '',
+ openBillingPanelID: 'upgrade-billing-panel',
+ upgradeFeatureKey: 'max_monitored_systems',
+ }
+ );
+
+ expect(runtime.store.getShellState().activeSection).toBe('billing');
+ expect(runtime.store.getBillingState().openBillingPanelID).toBe('upgrade-billing-panel');
+ expect(runtime.store.getBillingState().upgradeFeatureKey).toBe('max_monitored_systems');
+ });
});
diff --git a/internal/cloudcp/portal/frontend/src/runtime.ts b/internal/cloudcp/portal/frontend/src/runtime.ts
index 6d1e21d504..cc2d3477eb 100644
--- a/internal/cloudcp/portal/frontend/src/runtime.ts
+++ b/internal/cloudcp/portal/frontend/src/runtime.ts
@@ -5,6 +5,7 @@ import type { PortalBootstrapData } from './types';
export interface PortalRuntimeHandoff {
email: string;
openBillingPanelID: string;
+ upgradeFeatureKey: string;
}
export interface PortalRuntime {
@@ -32,6 +33,8 @@ function normalizeHandoffEmail(value: string | null): string {
function normalizeHandoffBillingPanel(value: string | null): string {
switch (String(value || '').trim()) {
+ case 'upgrade':
+ return 'upgrade-billing-panel';
case 'manage':
return 'manage-billing-panel';
case 'retrieve':
@@ -45,17 +48,23 @@ function normalizeHandoffBillingPanel(value: string | null): string {
}
}
+function normalizeUpgradeFeatureKey(value: string | null): string {
+ return String(value || '').trim();
+}
+
export function readPortalRuntimeHandoff(locationHref: string | undefined = window.location.href): PortalRuntimeHandoff {
try {
var params = new URL(locationHref).searchParams;
return {
email: normalizeHandoffEmail(params.get('email')),
openBillingPanelID: normalizeHandoffBillingPanel(params.get('service')),
+ upgradeFeatureKey: normalizeUpgradeFeatureKey(params.get('feature')),
};
} catch {
return {
email: '',
openBillingPanelID: '',
+ upgradeFeatureKey: '',
};
}
}
@@ -100,8 +109,15 @@ export function createPortalRuntime(
}, { notify: false });
}
if (handoff.openBillingPanelID) {
+ store.setActiveShellSection('billing');
store.updateBillingState(function(billingState) {
billingState.openBillingPanelID = handoff.openBillingPanelID;
+ billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
+ }, { notify: false });
+ } else if (handoff.upgradeFeatureKey) {
+ store.setActiveShellSection('billing');
+ store.updateBillingState(function(billingState) {
+ billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
}, { notify: false });
}
return {
diff --git a/internal/cloudcp/portal/frontend/src/shell.ts b/internal/cloudcp/portal/frontend/src/shell.ts
index 8ff67bfd81..02855a0783 100644
--- a/internal/cloudcp/portal/frontend/src/shell.ts
+++ b/internal/cloudcp/portal/frontend/src/shell.ts
@@ -46,6 +46,7 @@ export function installShell(deps: ShellDeps): void {
var portalBootstrap = deps.store.getBootstrap();
userInfo.innerHTML = renderHeaderHTML({
bootstrap: portalBootstrap,
+ billingState: deps.store.getBillingState(),
loginState: deps.store.getLoginState(),
signupPath: portalBootstrap.signup_path,
accountAPIBasePath: portalBootstrap.account_api_base_path,
@@ -59,6 +60,7 @@ export function installShell(deps: ShellDeps): void {
var portalBootstrap = deps.store.getBootstrap();
var context = {
bootstrap: portalBootstrap,
+ billingState: deps.store.getBillingState(),
loginState: deps.store.getLoginState(),
signupPath: portalBootstrap.signup_path,
accountAPIBasePath: portalBootstrap.account_api_base_path,
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.test.ts b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
index 3c5345e75a..8bfb4def8d 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
-import type { PortalBootstrapData, PortalLoginState } from './types';
+import type { PortalBillingState, PortalBootstrapData, PortalLoginState } from './types';
import {
renderAccountsHTML,
renderAuthenticatedPortalHTML,
@@ -42,9 +42,70 @@ function createLoginState(overrides: Partial<PortalLoginState> = {}): PortalLogi
};
}
+function createBillingState(overrides: Partial<PortalBillingState> = {}): PortalBillingState {
+ return {
+ openBillingPanelID: '',
+ upgradeFeatureKey: '',
+ flows: {
+ manage: {
+ pendingEmail: '',
+ request: { pending: false, error: '' },
+ confirm: { pending: false, error: '' },
+ step2Visible: false,
+ status: { visible: false, message: '', error: false },
+ result: null,
+ emailValue: '',
+ codeValue: '',
+ checkboxChecked: false,
+ },
+ retrieve: {
+ pendingEmail: '',
+ request: { pending: false, error: '' },
+ confirm: { pending: false, error: '' },
+ step2Visible: false,
+ status: { visible: false, message: '', error: false },
+ result: null,
+ emailValue: '',
+ codeValue: '',
+ checkboxChecked: false,
+ },
+ export: {
+ pendingEmail: '',
+ request: { pending: false, error: '' },
+ confirm: { pending: false, error: '' },
+ step2Visible: false,
+ status: { visible: false, message: '', error: false },
+ result: null,
+ emailValue: '',
+ codeValue: '',
+ checkboxChecked: false,
+ },
+ delete: {
+ pendingEmail: '',
+ request: { pending: false, error: '' },
+ confirm: { pending: false, error: '' },
+ step2Visible: false,
+ status: { visible: false, message: '', error: false },
+ result: null,
+ emailValue: '',
+ codeValue: '',
+ checkboxChecked: false,
+ },
+ },
+ refund: {
+ emailValue: '',
+ tokenValue: '',
+ submit: { pending: false, error: '' },
+ status: { visible: false, message: '', error: false },
+ },
+ ...overrides,
+ };
+}
+
function createContext(overrides: Partial<ShellViewContext> = {}): ShellViewContext {
return {
bootstrap: createBootstrap(),
+ billingState: createBillingState(),
loginState: createLoginState(),
signupPath: '/signup',
accountAPIBasePath: '/api/accounts',
@@ -253,9 +314,11 @@ describe('shell view', function() {
expect(html).toContain('Self-hosted billing');
expect(html).toContain('Use self-hosted billing only for self-hosted purchases.');
+ expect(html).toContain('id="open-upgrade-billing"');
expect(html).toContain('id="open-retrieve-billing"');
expect(html).toContain('id="billing-detail-shell" hidden');
expect(html).toContain('data-account-billing-action="clear-billing-panel"');
+ expect(html).toContain('id="upgrade-billing-panel"');
expect(html).toContain('id="data-billing-panel"');
expect(html).toContain('licenses, refunds, or privacy');
expect(html).toContain('Escalate with the same hosted billing action or self-hosted path and the exact failed step.');
@@ -588,6 +651,7 @@ describe('shell view', function() {
expect(html).not.toContain('data-shell-section="access"');
expect(html).toContain('Self-hosted billing');
expect(html).toContain('Use self-hosted billing only for self-hosted purchases.');
+ expect(html).toContain('Upgrade self-hosted plan');
expect(html).toContain('Escalate with the same self-hosted billing path and the exact failed step.');
expect(html).toContain('Billing');
expect(html).not.toContain('Escalate with the same hosted billing action or self-hosted path and the exact failed step.');
@@ -596,6 +660,41 @@ describe('shell view', function() {
expect(html).not.toContain('Self-hosted commercial services');
});
+ it('renders a portal-owned self-hosted upgrade path when the app hands off an upgrade intent', function() {
+ var html = renderAuthenticatedPortalHTML(
+ createContext({
+ bootstrap: createBootstrap({
+ has_self_hosted_commercial: false,
+ accounts: [
+ {
+ id: 'acct_hosted',
+ name: 'Hosted Account',
+ kind: 'cloud',
+ kind_label: 'Cloud',
+ role: 'owner',
+ can_manage: true,
+ has_billing: true,
+ members: [],
+ workspaces: [],
+ },
+ ],
+ }),
+ billingState: createBillingState({
+ openBillingPanelID: 'upgrade-billing-panel',
+ upgradeFeatureKey: 'max_monitored_systems',
+ }),
+ activeSection: 'billing',
+ })
+ );
+
+ expect(html).toContain('Pulse Account owns the commercial handoff for self-hosted upgrades from the app.');
+ expect(html).toContain('Upgrade monitored-system cap');
+ expect(html).toContain('Compare monitored-system plans');
+ expect(html).toContain('utm_source=pulse-account');
+ expect(html).not.toContain('id="open-manage-billing"');
+ expect(html).not.toContain('id="open-retrieve-billing"');
+ });
+
it('renders signed-out portal with error and success login states', function() {
var errorHTML = renderSignedOutPortalHTML(
createContext({
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.ts b/internal/cloudcp/portal/frontend/src/shell_view.ts
index 9c44e3b4b5..7598b34b1b 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.ts
@@ -1,5 +1,6 @@
import type {
PortalAccountSummary,
+ PortalBillingState,
PortalBootstrapData,
PortalLoginState,
PortalShellSection,
@@ -11,6 +12,7 @@ import { workspaceHealthLabel, workspaceHealthState, workspaceRowNote, workspace
export interface ShellViewContext {
bootstrap: PortalBootstrapData;
+ billingState: PortalBillingState;
loginState: PortalLoginState;
signupPath: string;
accountAPIBasePath: string;
@@ -128,6 +130,85 @@ function hasSelfHostedCommercial(bootstrap: PortalBootstrapData): boolean {
return bootstrap.has_self_hosted_commercial === true || !hasHostedAccounts(accounts);
}
+function normalizeUpgradeFeatureKey(featureKey: string): string {
+ return String(featureKey || '').trim();
+}
+
+function selfHostedUpgradeActionTitle(featureKey: string): string {
+ return normalizeUpgradeFeatureKey(featureKey) === 'max_monitored_systems'
+ ? 'Upgrade monitored-system cap'
+ : 'Upgrade self-hosted plan';
+}
+
+function selfHostedUpgradeActionDescription(featureKey: string): string {
+ return normalizeUpgradeFeatureKey(featureKey) === 'max_monitored_systems'
+ ? 'Compare self-hosted plans and choose a higher monitored-system allowance.'
+ : 'Compare self-hosted plans and continue into the commercial checkout path.';
+}
+
+function selfHostedUpgradeActionHighlights(featureKey: string): string[] {
+ return normalizeUpgradeFeatureKey(featureKey) === 'max_monitored_systems'
+ ? ['Monitored-system cap', 'Plan comparison']
+ : ['Plan comparison', 'Checkout handoff'];
+}
+
+function selfHostedUpgradePricingURL(
+ bootstrap: PortalBootstrapData,
+ featureKey: string,
+): string {
+ var publicSiteURL = String(bootstrap.public_site_url || 'https://pulserelay.pro').trim();
+ var normalizedFeature = normalizeUpgradeFeatureKey(featureKey);
+ try {
+ var url = new URL('/pricing', publicSiteURL);
+ if (normalizedFeature) {
+ url.searchParams.set('feature', normalizedFeature);
+ }
+ url.searchParams.set('utm_source', 'pulse-account');
+ url.searchParams.set('utm_medium', 'portal');
+ url.searchParams.set('utm_campaign', 'self_hosted_upgrade');
+ return url.toString();
+ } catch {
+ return 'https://pulserelay.pro/pricing';
+ }
+}
+
+function renderSelfHostedUpgradeActionRow(context: ShellViewContext): string {
+ var featureKey = normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ return renderBillingActionRow(
+ 'open-upgrade-billing',
+ selfHostedUpgradeActionTitle(featureKey),
+ 'Open',
+ selfHostedUpgradeActionDescription(featureKey),
+ 'upgrade-billing-panel',
+ 'upgrade-billing-link',
+ selfHostedUpgradeActionHighlights(featureKey),
+ );
+}
+
+function renderSelfHostedUpgradeBillingPanel(context: ShellViewContext): string {
+ var featureKey = normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ var pricingURL = selfHostedUpgradePricingURL(context.bootstrap, featureKey);
+ var linkLabel = featureKey === 'max_monitored_systems'
+ ? 'Compare monitored-system plans'
+ : 'View self-hosted plans';
+ var helperCopy = featureKey === 'max_monitored_systems'
+ ? 'Choose the self-hosted tier that matches the monitored-system allowance you need, then return to Pulse Pro to activate the new license.'
+ : 'Choose the self-hosted tier that fits this upgrade, then return to Pulse Pro to activate the new license.';
+ return renderBillingTaskPanel(
+ selfHostedUpgradeActionTitle(featureKey),
+ 'Pulse Account owns the commercial handoff. Plan selection and checkout continue on the public self-hosted pricing site.',
+ 'upgrade-billing-panel',
+ '<div class="form-actions">' +
+ '<a class="btn-primary" id="upgrade-billing-link" href="' +
+ escapeAttr(pricingURL) +
+ '" target="_blank" rel="noopener">' +
+ escapeHTML(linkLabel) +
+ '</a>' +
+ '</div>' +
+ '<div class="helper-text">' + escapeHTML(helperCopy) + '</div>',
+ );
+}
+
function countWorkspaces(accounts: PortalAccountSummary[]): number {
var total = 0;
for (var i = 0; i < accounts.length; i += 1) {
@@ -1182,6 +1263,8 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
var accounts = Array.isArray(context.bootstrap.accounts) ? context.bootstrap.accounts : [];
var hosted = hasHostedAccounts(accounts);
var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);
+ var showSelfHostedUpgradeHandoff = !!normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ var showSelfHostedBillingShell = showSelfHostedCommercial || showSelfHostedUpgradeHandoff;
var shellSections = visibleShellSections(context.bootstrap);
var preferredSection = context.activeSection || preferredPortalShellSection(context.bootstrap);
var activeSection = shellSections.some(function(entry) {
@@ -1215,6 +1298,51 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
);
}).join('')
: renderNoHostedAccessSection();
+ var selfHostedBillingLeadCopy = showSelfHostedCommercial
+ ? 'Use self-hosted billing only for self-hosted purchases.'
+ : 'Pulse Account owns the commercial handoff for self-hosted upgrades from the app.';
+ var selfHostedBillingActionsHTML = renderSelfHostedUpgradeActionRow(context);
+ if (showSelfHostedCommercial) {
+ selfHostedBillingActionsHTML +=
+ renderBillingActionRow('open-manage-billing', 'Manage subscriptions', 'Open', 'Open Stripe for self-hosted plan, invoice, and payment changes.', 'manage-billing-panel', 'manage-inline-email', ['Plan changes', 'Invoices']) +
+ renderBillingActionRow('open-retrieve-billing', 'Retrieve licenses', 'Open', 'Recover the latest active self-hosted license and invoice link.', 'retrieve-billing-panel', 'retrieve-inline-email', ['Latest active license', 'Invoice lookup']) +
+ renderBillingActionRow('open-refund-billing', 'Refund requests', 'Open', 'Request a self-serve refund when the purchase is still eligible.', 'refund-billing-panel', 'refund-inline-email', ['Eligibility check', 'Revocation']) +
+ renderBillingActionRow('open-data-billing', 'Data and privacy', 'Open', 'Request export or deletion for commercial account data.', 'data-billing-panel', 'data-export-email', ['Export', 'Deletion']);
+ }
+ var selfHostedBillingPanelsHTML = renderSelfHostedUpgradeBillingPanel(context);
+ if (showSelfHostedCommercial) {
+ selfHostedBillingPanelsHTML +=
+ renderBillingTaskPanel(
+ 'Manage subscriptions',
+ 'Open Stripe for self-hosted plan, invoice, and payment changes.',
+ 'manage-billing-panel',
+ '<div id="manage-billing-root"></div>'
+ ) +
+ renderBillingTaskPanel(
+ 'Retrieve licenses',
+ 'Recover the latest active self-hosted license and invoice link.',
+ 'retrieve-billing-panel',
+ '<div id="retrieve-billing-root"></div>'
+ ) +
+ renderBillingTaskPanel(
+ 'Refund requests',
+ 'Request a self-serve refund when the purchase is still eligible.',
+ 'refund-billing-panel',
+ '<div id="refund-billing-root"></div>'
+ ) +
+ renderBillingTaskPanel(
+ 'Data and privacy',
+ 'Request export or deletion for commercial account data.',
+ 'data-billing-panel',
+ '<div class="subsection"><div id="data-export-root"></div></div>' +
+ '<div class="subsection"><div id="data-delete-root"></div></div>' +
+ '<div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' +
+ escapeAttr(context.bootstrap.support_email || '') +
+ '">' +
+ escapeHTML(context.bootstrap.support_email || '') +
+ '</a>.</div>'
+ );
+ }
return (
'<div class="portal-shell" data-shell-section="' + activeSection + '">' +
@@ -1236,19 +1364,14 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
: '') +
'<section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section">' +
(hosted ? renderHostedBillingCards(accounts, showSelfHostedCommercial) : '') +
- (showSelfHostedCommercial
+ (showSelfHostedBillingShell
? ('<div class="billing-shell billing-shell-idle">' +
'<div class="billing-shell-main">' +
'<div class="billing-shell-main-head">' +
'<h3>Self-hosted billing</h3>' +
- '<p>Use self-hosted billing only for self-hosted purchases.</p>' +
- '</div>' +
- '<div class="billing-action-list">' +
- renderBillingActionRow('open-manage-billing', 'Manage subscriptions', 'Open', 'Open Stripe for self-hosted plan, invoice, and payment changes.', 'manage-billing-panel', 'manage-inline-email', ['Plan changes', 'Invoices']) +
- renderBillingActionRow('open-retrieve-billing', 'Retrieve licenses', 'Open', 'Recover the latest active self-hosted license and invoice link.', 'retrieve-billing-panel', 'retrieve-inline-email', ['Latest active license', 'Invoice lookup']) +
- renderBillingActionRow('open-refund-billing', 'Refund requests', 'Open', 'Request a self-serve refund when the purchase is still eligible.', 'refund-billing-panel', 'refund-inline-email', ['Eligibility check', 'Revocation']) +
- renderBillingActionRow('open-data-billing', 'Data and privacy', 'Open', 'Request export or deletion for commercial account data.', 'data-billing-panel', 'data-export-email', ['Export', 'Deletion']) +
+ '<p>' + escapeHTML(selfHostedBillingLeadCopy) + '</p>' +
'</div>' +
+ '<div class="billing-action-list">' + selfHostedBillingActionsHTML + '</div>' +
'<div class="billing-inline-support">' +
'<h4>Support</h4>' +
'<p>' + selfHostedBillingEscalationCopy + '</p>' +
@@ -1262,38 +1385,7 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
'</div>' +
'</div>' +
'</div>' +
- '<div class="billing-shell-detail" id="billing-detail-shell" hidden>' +
- renderBillingTaskPanel(
- 'Manage subscriptions',
- 'Open Stripe for self-hosted plan, invoice, and payment changes.',
- 'manage-billing-panel',
- '<div id="manage-billing-root"></div>'
- ) +
- renderBillingTaskPanel(
- 'Retrieve licenses',
- 'Recover the latest active self-hosted license and invoice link.',
- 'retrieve-billing-panel',
- '<div id="retrieve-billing-root"></div>'
- ) +
- renderBillingTaskPanel(
- 'Refund requests',
- 'Request a self-serve refund when the purchase is still eligible.',
- 'refund-billing-panel',
- '<div id="refund-billing-root"></div>'
- ) +
- renderBillingTaskPanel(
- 'Data and privacy',
- 'Request export or deletion for commercial account data.',
- 'data-billing-panel',
- '<div class="subsection"><div id="data-export-root"></div></div>' +
- '<div class="subsection"><div id="data-delete-root"></div></div>' +
- '<div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' +
- escapeAttr(context.bootstrap.support_email || '') +
- '">' +
- escapeHTML(context.bootstrap.support_email || '') +
- '</a>.</div>'
- ) +
- '</div>' +
+ '<div class="billing-shell-detail" id="billing-detail-shell" hidden>' + selfHostedBillingPanelsHTML + '</div>' +
'</div>')
: '') +
'</section>' +
diff --git a/internal/cloudcp/portal/frontend/src/state.test.ts b/internal/cloudcp/portal/frontend/src/state.test.ts
index 56180d33bd..1b953a473f 100644
--- a/internal/cloudcp/portal/frontend/src/state.test.ts
+++ b/internal/cloudcp/portal/frontend/src/state.test.ts
@@ -34,6 +34,7 @@ describe('portal state', function() {
expect(billingState.flows.manage.request.pending).toBe(false);
expect(billingState.flows.manage.confirm.pending).toBe(false);
expect(billingState.refund.submit.pending).toBe(false);
+ expect(billingState.upgradeFeatureKey).toBe('');
billingState.flows.manage.emailValue = '[email protected]';
syncBillingStateBootstrapEmail(billingState, '[email protected]');
diff --git a/internal/cloudcp/portal/frontend/src/state.ts b/internal/cloudcp/portal/frontend/src/state.ts
index dee203b8cd..9c4b7b08b3 100644
--- a/internal/cloudcp/portal/frontend/src/state.ts
+++ b/internal/cloudcp/portal/frontend/src/state.ts
@@ -117,6 +117,7 @@ export function syncPortalAccountStateBootstrap(accountState: PortalAccountState
export function createPortalBillingState(): PortalBillingState {
return {
openBillingPanelID: '',
+ upgradeFeatureKey: '',
flows: {
manage: newVerificationFlowState(),
retrieve: newVerificationFlowState(),
diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.ts
index d4f68ab940..ebc2ac49e2 100644
--- a/internal/cloudcp/portal/frontend/src/types.ts
+++ b/internal/cloudcp/portal/frontend/src/types.ts
@@ -115,6 +115,7 @@ export interface RefundState {
export interface PortalBillingState {
openBillingPanelID: string;
+ upgradeFeatureKey: string;
flows: Record<PortalBillingFlowID, VerificationFlowState>;
refund: RefundState;
}