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 generic upgrade fallbacks to public pricing

rcourtmanb6237b6a0e39
diff --git a/frontend-modern/src/stores/__tests__/license.test.ts b/frontend-modern/src/stores/__tests__/license.test.ts
index 4a23857672..59c8ca69d8 100644
--- a/frontend-modern/src/stores/__tests__/license.test.ts
+++ b/frontend-modern/src/stores/__tests__/license.test.ts
@@ -310,10 +310,12 @@ describe('license store', () => {
});
describe('getUpgradeActionUrlOrFallback', () => {
- it('returns pricing fallback when no upgrade reasons', async () => {
+ it('routes missing self-hosted upgrades to the public pricing site when no upgrade reasons exist', async () => {
vi.mocked(LicenseAPI.getEntitlements).mockResolvedValue(mockFreeEntitlements);
await loadLicenseStatus(true);
- expect(getUpgradeActionUrlOrFallback('feature1')).toBe('/pricing?feature=feature1');
+ expect(getUpgradeActionUrlOrFallback('relay')).toBe(
+ 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade&feature=relay',
+ );
});
it('routes monitored-system limit fallbacks to billing usage', async () => {
@@ -327,6 +329,20 @@ describe('license store', () => {
);
});
+ it('routes cloud fallbacks to the in-product cloud plans page', async () => {
+ vi.mocked(LicenseAPI.getEntitlements).mockResolvedValue(mockFreeEntitlements);
+ await loadLicenseStatus(true);
+ expect(getUpgradeActionUrlOrFallback('cloud')).toBe('/cloud');
+ });
+
+ it('routes generic upgrade fallbacks to the public pricing site', 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',
+ );
+ });
+
it('prefers a specific monitored-system upgrade action when provided', async () => {
vi.mocked(LicenseAPI.getEntitlements).mockResolvedValue({
...mockProEntitlements,
@@ -343,6 +359,14 @@ describe('license store', () => {
'/upgrade/max-monitored-systems',
);
});
+
+ it('routes unknown keys to the public pricing site 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',
+ );
+ });
});
describe('getLimit', () => {
diff --git a/frontend-modern/src/stores/license.ts b/frontend-modern/src/stores/license.ts
index 9d32cac087..abb86e387b 100644
--- a/frontend-modern/src/stores/license.ts
+++ b/frontend-modern/src/stores/license.ts
@@ -183,22 +183,37 @@ export function getFirstUpgradeActionUrl(): string | undefined {
return current?.upgrade_reasons?.[0]?.action_url;
}
+const DEFAULT_PUBLIC_UPGRADE_URL =
+ 'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade';
+
const IN_PRODUCT_UPGRADE_FALLBACKS: Record<string, string> = {
// Limit-driven upsells should land on billing/usage so operators can see
// the counted-system ledger before choosing how to expand capacity.
max_monitored_systems: '/settings/system/billing',
+ cloud: '/cloud',
};
function getInProductUpgradeFallback(key: string): string | undefined {
return IN_PRODUCT_UPGRADE_FALLBACKS[key];
}
+function getPublicUpgradeFallback(key: string): string {
+ const normalizedKey = key.trim();
+ const url = new URL(DEFAULT_PUBLIC_UPGRADE_URL);
+ if (normalizedKey) {
+ // Keep frontend fallbacks aligned with the canonical public pricing origin
+ // used by pkg/licensing when entitlement-specific action URLs are missing.
+ url.searchParams.set('feature', normalizedKey);
+ }
+ return url.toString();
+}
+
export function getUpgradeActionUrlOrFallback(key: string): string {
return (
getUpgradeActionUrl(key) ||
getInProductUpgradeFallback(key) ||
getFirstUpgradeActionUrl() ||
- `/pricing?feature=${encodeURIComponent(key)}`
+ getPublicUpgradeFallback(key)
);
}