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.

Normalize upgrade CTA navigation semantics

rcourtman80434b791dad
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 1587f386f6..ef95a0ba2a 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -332,6 +332,13 @@ but the canonical contract is that a successful handoff exchange must reconcile
tenant organization membership for the handed-off account member before the
browser follows the new session into protected routes, rather than landing on a
fresh `access_denied` immediately after session minting.
+Lifecycle-owned paywalls now also follow the shared commercial navigation
+contract. `frontend-modern/src/components/Settings/AgentProfilesPanel.tsx` and
+`frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts` may
+request the canonical commercial destination from the shared license boundary,
+but they must leave internal-versus-external navigation semantics to
+`frontend-primitives` instead of hardcoding pricing URLs or tab-open behavior
+inside lifecycle-owned settings surfaces.
That same platform-connections ownership now also includes mock-runtime
continuity for API-backed platforms. When `/api/system/mock-mode` flips a
running server between real and mock data, the canonical TrueNAS and VMware
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index c2d66b9762..d2539ed42a 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -116,6 +116,12 @@ compose through additive fired/resolved subscriptions instead of overwriting a
single callback slot, and alert-triggered Patrol enqueueing must stay on the
canonical unified alert bridge plus trigger-manager path rather than reviving
duplicate callback-side Patrol shortcuts.
+Commercial alert handoffs now follow the same shared navigation boundary.
+`frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx` may resolve
+the canonical `ai_alerts` destination from the shared license/commercial
+contract, but it must delegate the actual open behavior to the
+`frontend-primitives` typed upgrade-navigation owner instead of reintroducing
+alert-local `window.open(...)` or raw external-tab assumptions.
That shared alert presentation boundary now also has explicit alerts ownership.
`frontend-modern/src/utils/alertWebhookPresentation.ts` is the canonical owner
for webhook setup copy, service labels, mention-help phrasing, custom-field
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 2ee5cc3adb..340957784c 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -432,6 +432,11 @@ and `internal/cloudcp/portal/commercial_proxy.go` plus `internal/cloudcp/routes.
own the server-side proxy boundary to the shared license/commercial APIs so
the browser runtime does not widen control-plane CSP with direct cross-origin
commercial fetches.
+That same shared commercial boundary now also applies to Patrol feature
+handoffs. API-backed Patrol surfaces may consume canonical commercial hrefs
+from the shared license/commercial contract, but they must not re-decide
+internal-versus-external navigation behavior inside API-adjacent page or hook
+owners once the contract can resolve to both in-app and public destinations.
`/portal` is now one bootstrap-driven shell for both anonymous and
authenticated users, so new account frontend work must extend that shared
contract rather than inventing a second local payload shape, reviving separate
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 1bbaf1082e..cbc830ba92 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -367,6 +367,14 @@ 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.
+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
+feature resolves to; `frontend-primitives` owns the typed navigation contract
+that decides whether that href stays in-app or opens externally. Commercial
+surfaces must not re-infer that behavior locally with per-component
+`target="_blank"` or `window.open(...)` branches once a feature can resolve to
+either product-owned billing/cloud routes or the public pricing site.
The trial-start rate-limit contract is part of that same boundary. Local
`/api/license/trial/start` retries are allowed as a short human-scale burst so
operators can revisit the hosted handoff without getting locked out for a day,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 7ea7d66b5d..331dc92c7a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -133,6 +133,9 @@ work extends shared components instead of creating new local variants.
111. `frontend-modern/src/components/shared/SummaryRowActionButton.tsx`
112. `frontend-modern/src/hooks/createNonSuspendingQuery.ts`
113. `frontend-modern/src/components/shared/SummaryTableCardHeader.tsx`
+114. `frontend-modern/src/components/shared/UpgradeLink.tsx`
+115. `frontend-modern/src/components/shared/useUpgradeNavigation.ts`
+116. `frontend-modern/src/utils/upgradeNavigation.ts`
## Shared Boundaries
@@ -370,6 +373,13 @@ connections` visible as the API-backed alternative for Proxmox and
props that can collapse functions on the live Solid surface. Docker-only
controls in `ThresholdsTableDockerTab.tsx` must remain gated to real
`docker-host` resources instead of leaking onto platform-managed runtimes.
+31. Keep shared commercial upgrade navigation typed and destination-aware.
+ Shared paywall shells and upgrade actions must route internal billing or
+ cloud destinations through `frontend-modern/src/utils/upgradeNavigation.ts`,
+ `frontend-modern/src/components/shared/UpgradeLink.tsx`, and
+ `frontend-modern/src/components/shared/useUpgradeNavigation.ts` instead of
+ guessing from labels, hardcoding `target="_blank"`, or calling
+ `window.open(...)` from each feature surface.
## Current State
@@ -387,6 +397,14 @@ disk read, write, and busy charts through `HistoryChart` plus
`useHistoryChartState`, using the canonical physical-disk history resource id,
instead of reviving `diskMetricsHistory`, a page-local ring buffer, or another
storage-only live chart primitive for the same telemetry.
+That same shared-primitive floor now also owns upgrade-navigation semantics.
+`frontend-modern/src/utils/upgradeNavigation.ts` is the canonical typed
+internal-vs-external destination helper, while
+`frontend-modern/src/components/shared/UpgradeLink.tsx` and
+`frontend-modern/src/components/shared/useUpgradeNavigation.ts` own how shared
+paywall surfaces navigate those destinations. Feature shells may request a
+commercial destination, but they must not re-decide whether that destination
+opens in-app or in a new tab once the shared primitive exists.
The subsystem registry now also requires explicit proof-policy coverage for all
shared runtime files, and shared-component guardrails fail if raw table
diff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.md
index c29c50c5d6..29a833f65f 100644
--- a/docs/release-control/v6/internal/subsystems/organization-settings.md
+++ b/docs/release-control/v6/internal/subsystems/organization-settings.md
@@ -167,6 +167,11 @@ license and free-trial runtime, `useRolesPanelState.ts` plus
`useUserAssignmentsPanelState.ts` plus `UserAssignmentsDialog.tsx` own the
user-assignment runtime split. `RolesPanel.tsx` and `UserAssignmentsPanel.tsx`
remain the canonical render shells for those governed RBAC surfaces.
+That RBAC gate now also depends on the shared commercial navigation contract:
+`RBACFeatureGateSection.tsx` may request the canonical `rbac` destination from
+the shared license boundary, but it must render that destination through the
+`frontend-primitives` typed upgrade link owner instead of assuming
+organization-settings paywalls always leave the app in a new tab.
That shared RBAC free-trial runtime must also preserve backend denial reasons
through the canonical upgrade presentation helper instead of collapsing every
trial-start conflict into a generic already-used message. Organization settings
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index db2b79d15c..14a96092dd 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -128,6 +128,13 @@ overall-health summary is degraded or not fully verified. The green healthy
empty state belongs only to an actually healthy Patrol summary, while degraded
coverage or paused-runtime states must surface the governing warning/error copy
through `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`.
+Patrol paywall actions now follow the same shared commercial navigation split.
+`frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`,
+`frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx`, and
+`frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts` may resolve
+commercial destinations from the shared license boundary, but they must leave
+internal-versus-external navigation semantics to `frontend-primitives` once a
+Patrol feature can resolve to either product-owned routes or public pricing.
That degraded empty-state copy must also interpret the finding state rather
than simply replaying the primary assessment sentence verbatim: when coverage
is incomplete, the findings panel should tell the operator that Patrol has not
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index ac67c2acf5..7640be7c54 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2564,7 +2564,8 @@
"frontend-modern/src/utils/textPresentation.ts",
"frontend-modern/src/utils/toast.ts",
"frontend-modern/src/utils/typeColumnPresentation.ts",
- "frontend-modern/src/utils/updatesPresentation.ts"
+ "frontend-modern/src/utils/updatesPresentation.ts",
+ "frontend-modern/src/utils/upgradeNavigation.ts"
],
"verification": {
"allow_same_subsystem_tests": false,
@@ -2678,6 +2679,21 @@
"frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts"
]
},
+ {
+ "id": "upgrade-navigation-helper",
+ "label": "upgrade navigation helper proof",
+ "match_prefixes": [],
+ "match_files": [
+ "frontend-modern/src/utils/upgradeNavigation.ts"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/components/shared/__tests__/UpgradeLink.test.tsx",
+ "frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "frontend-modern/src/utils/__tests__/upgradeNavigation.test.ts"
+ ]
+ },
{
"id": "route-shell-and-operations",
"label": "route shell and operations proof",
@@ -2960,6 +2976,7 @@
"frontend-modern/src/components/shared/__tests__/SearchField.test.tsx",
"frontend-modern/src/components/shared/__tests__/SearchInput.test.tsx",
"frontend-modern/src/components/shared/__tests__/TagBadges.test.tsx",
+ "frontend-modern/src/components/shared/__tests__/UpgradeLink.test.tsx",
"frontend-modern/src/components/shared/__tests__/WebInterfaceUrlField.test.tsx",
"frontend-modern/src/components/shared/__tests__/WhatsNewModal.test.tsx",
"frontend-modern/src/components/shared/ColumnPicker.test.tsx",
diff --git a/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx b/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx
index 78da52d502..7bf5a295ea 100644
--- a/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx
+++ b/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx
@@ -1,10 +1,11 @@
import { Show, createSignal } from 'solid-js';
import { aiChatStore } from '@/stores/aiChat';
import type { Alert } from '@/types/api';
+import { useUpgradeNavigation } from '@/components/shared/useUpgradeNavigation';
import { getCanonicalAlertId } from '@/features/alerts/identity';
import { formatAlertValue } from '@/utils/alertFormatters';
import { resolveAlertTargetType } from '@/utils/alertTargetTypes';
-import { getUpgradeActionUrlOrFallback } from '@/stores/license';
+import { getUpgradeActionDestination } from '@/stores/license';
import { trackUpgradeClicked } from '@/utils/upgradeMetrics';
interface InvestigateAlertButtonProps {
@@ -24,6 +25,7 @@ interface InvestigateAlertButtonProps {
*/
export function InvestigateAlertButton(props: InvestigateAlertButtonProps) {
const [isHovered, setIsHovered] = createSignal(false);
+ const openUpgradeDestination = useUpgradeNavigation();
const isLocked = () => props.licenseLocked === true;
// Don't render if AI is not enabled
if (aiChatStore.enabled !== true) {
@@ -35,7 +37,7 @@ export function InvestigateAlertButton(props: InvestigateAlertButtonProps) {
e.preventDefault();
if (isLocked()) {
trackUpgradeClicked('investigate_alert_button', 'ai_alerts');
- window.open(getUpgradeActionUrlOrFallback('ai_alerts'), '_blank');
+ openUpgradeDestination(getUpgradeActionDestination('ai_alerts'));
return;
}
diff --git a/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx b/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx
index 1b1ecfcfd2..339feaf2fe 100644
--- a/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx
+++ b/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx
@@ -9,17 +9,21 @@ import { getPublicPricingUrl } from '@/utils/pricingHandoff';
const {
openWithPromptMock,
+ openUpgradeDestinationMock,
trackUpgradeClickedMock,
formatAlertValueMock,
mockAiChatStore,
+ getUpgradeActionDestinationMock,
getUpgradeActionUrlOrFallbackMock,
} =
vi.hoisted(() => {
const openWithPromptMock = vi.fn();
+ const openUpgradeDestinationMock = vi.fn();
const trackUpgradeClickedMock = vi.fn();
const formatAlertValueMock = vi.fn((value?: number, _type?: string) =>
value !== undefined ? `${value.toFixed(1)}%` : 'N/A',
);
+ const getUpgradeActionDestinationMock = vi.fn();
const getUpgradeActionUrlOrFallbackMock = vi.fn();
const mockAiChatStore = {
enabled: true as boolean | null,
@@ -27,9 +31,11 @@ const {
};
return {
openWithPromptMock,
+ openUpgradeDestinationMock,
trackUpgradeClickedMock,
formatAlertValueMock,
mockAiChatStore,
+ getUpgradeActionDestinationMock,
getUpgradeActionUrlOrFallbackMock,
};
});
@@ -39,9 +45,14 @@ vi.mock('@/stores/aiChat', () => ({
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (...args: unknown[]) => getUpgradeActionDestinationMock(...args),
getUpgradeActionUrlOrFallback: (...args: unknown[]) => getUpgradeActionUrlOrFallbackMock(...args),
}));
+vi.mock('@/components/shared/useUpgradeNavigation', () => ({
+ useUpgradeNavigation: () => openUpgradeDestinationMock,
+}));
+
vi.mock('@/utils/upgradeMetrics', () => ({
trackUpgradeClicked: (...args: unknown[]) => trackUpgradeClickedMock(...args),
}));
@@ -89,8 +100,14 @@ beforeEach(() => {
openWithPromptMock.mockReset();
trackUpgradeClickedMock.mockReset();
formatAlertValueMock.mockClear();
+ openUpgradeDestinationMock.mockReset();
+ getUpgradeActionDestinationMock.mockReset();
getUpgradeActionUrlOrFallbackMock.mockReset();
mockAiChatStore.enabled = true;
+ getUpgradeActionDestinationMock.mockReturnValue({
+ href: getPublicPricingUrl('ai_alerts'),
+ external: true,
+ });
getUpgradeActionUrlOrFallbackMock.mockReturnValue(getPublicPricingUrl('ai_alerts'));
vi.spyOn(window, 'open').mockImplementation(() => null);
});
@@ -211,7 +228,10 @@ describe('InvestigateAlertButton', () => {
await fireEvent.click(button);
expect(trackUpgradeClickedMock).toHaveBeenCalledWith('investigate_alert_button', 'ai_alerts');
- expect(window.open).toHaveBeenCalledWith(getPublicPricingUrl('ai_alerts'), '_blank');
+ expect(openUpgradeDestinationMock).toHaveBeenCalledWith({
+ href: getPublicPricingUrl('ai_alerts'),
+ external: true,
+ });
expect(openWithPromptMock).not.toHaveBeenCalled();
});
@@ -271,7 +291,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={makeAlert()} />);
await fireEvent.click(screen.getByRole('button'));
expect(trackUpgradeClickedMock).not.toHaveBeenCalled();
- expect(window.open).not.toHaveBeenCalled();
+ expect(openUpgradeDestinationMock).not.toHaveBeenCalled();
});
it('calls formatAlertValue for value and threshold', async () => {
diff --git a/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx b/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx
index 3baf3334eb..5430fc1a03 100644
--- a/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx
+++ b/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx
@@ -2,7 +2,8 @@ import { Component, Show } from 'solid-js';
import Smartphone from 'lucide-solid/icons/smartphone';
import X from 'lucide-solid/icons/x';
import { Card } from '@/components/shared/Card';
-import { getUpgradeActionUrlOrFallback } from '@/stores/license';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
+import { getUpgradeActionDestination } from '@/stores/license';
import {
RELAY_ONBOARDING_DESCRIPTION,
RELAY_ONBOARDING_DISCONNECTED_LABEL,
@@ -48,15 +49,13 @@ export const RelayOnboardingCard: Component = () => {
when={state.hasRelay()}
fallback={
<>
- <a
+ <UpgradeLink
class="inline-flex items-center rounded-md bg-blue-600 px-3 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700"
- href={getUpgradeActionUrlOrFallback('relay')}
- target="_blank"
- rel="noopener noreferrer"
+ destination={getUpgradeActionDestination('relay')}
onClick={state.handleUpgradeClick}
>
{RELAY_ONBOARDING_UPGRADE_LABEL}
- </a>
+ </UpgradeLink>
<button
type="button"
class="inline-flex items-center rounded-md border border-border bg-surface px-3 py-2 text-sm font-medium text-base-content shadow-sm hover:bg-surface-hover disabled:opacity-50"
diff --git a/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx
index a8bfeb4ed4..c00787be23 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx
@@ -6,6 +6,7 @@ import relayOnboardingCardStateSource from '../useRelayOnboardingCardState.ts?ra
// ── Hoisted mocks ──────────────────────────────────────────────────────
const {
+ getUpgradeActionDestinationMock,
mockNavigate,
loadLicenseStatusMock,
startProTrialMock,
@@ -20,6 +21,7 @@ const {
licenseLoadedMock,
getUpgradeActionUrlOrFallbackMock,
} = vi.hoisted(() => ({
+ getUpgradeActionDestinationMock: vi.fn(),
mockNavigate: vi.fn(),
loadLicenseStatusMock: vi.fn(),
startProTrialMock: vi.fn(),
@@ -40,6 +42,7 @@ vi.mock('@solidjs/router', () => ({
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (...args: unknown[]) => getUpgradeActionDestinationMock(...args),
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
licenseLoaded: (...args: unknown[]) => licenseLoadedMock(...args),
@@ -96,6 +99,7 @@ function resetAllMocks() {
getRelayStatusMock.mockReset();
hasFeatureMock.mockReset();
licenseLoadedMock.mockReset();
+ getUpgradeActionDestinationMock.mockReset();
getUpgradeActionUrlOrFallbackMock.mockReset();
}
@@ -110,6 +114,10 @@ function setupWithRelayFeature(statusOverride?: { connected: boolean; active_cha
hasFeatureMock.mockReturnValue(true);
isUpsellSnoozedMock.mockReturnValue(false);
getRelayStatusMock.mockResolvedValue(defaultStatus);
+ getUpgradeActionDestinationMock.mockReturnValue({
+ href: getPublicPricingUrl('relay'),
+ external: true,
+ });
getUpgradeActionUrlOrFallbackMock.mockReturnValue(getPublicPricingUrl('relay'));
}
@@ -121,6 +129,10 @@ function setupWithoutRelayFeature() {
licenseLoadedMock.mockReturnValue(true);
hasFeatureMock.mockReturnValue(false);
isUpsellSnoozedMock.mockReturnValue(false);
+ getUpgradeActionDestinationMock.mockReturnValue({
+ href: getPublicPricingUrl('relay'),
+ external: true,
+ });
getUpgradeActionUrlOrFallbackMock.mockReturnValue(getPublicPricingUrl('relay'));
}
diff --git a/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx b/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
index ab4b5b1ac3..591b0fd872 100644
--- a/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
+++ b/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
@@ -2,6 +2,7 @@ import { Component, Show } from 'solid-js';
import type { AIControlLevel } from '@/utils/aiControlLevelPresentation';
import type { AISettingsState } from '@/components/Settings/useAISettingsState';
import { HelpIcon } from '@/components/shared/HelpIcon';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { Toggle } from '@/components/shared/Toggle';
import { TERMS_DOC_URL } from '@/utils/docsLinks';
import {
@@ -239,15 +240,13 @@ export const AIRuntimeControlsSection: Component<AIRuntimeControlsSectionProps>
</Show>
<Show when={state.form.controlLevel === 'autonomous' && state.autoFixLocked()}>
<p class="text-xs text-muted">
- <a
+ <UpgradeLink
class="text-blue-600 dark:text-blue-400 font-medium hover:underline"
- href={state.upgradeAutofixUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ destination={state.upgradeAutofixDestination()}
onClick={() => trackUpgradeClicked('settings_ai_patrol_autofix', 'ai_autofix')}
>
{UPGRADE_ACTION_LABEL}
- </a>{' '}
+ </UpgradeLink>{' '}
to enable autonomous mode.
<Show when={state.canStartTrial()}>
{' '}
diff --git a/frontend-modern/src/components/Settings/AgentProfilesPanel.tsx b/frontend-modern/src/components/Settings/AgentProfilesPanel.tsx
index 9d6fa17ffb..2bf192b32e 100644
--- a/frontend-modern/src/components/Settings/AgentProfilesPanel.tsx
+++ b/frontend-modern/src/components/Settings/AgentProfilesPanel.tsx
@@ -2,6 +2,7 @@ import { Component, For, Show } from 'solid-js';
import { Card } from '@/components/shared/Card';
import SettingsPanel from '@/components/shared/SettingsPanel';
import { Dialog } from '@/components/shared/Dialog';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { SuggestProfileModal } from './SuggestProfileModal';
import { KNOWN_SETTINGS, type SelectSetting, type StringSetting } from './agentProfileSettings';
import {
@@ -35,8 +36,8 @@ export const AgentProfilesPanel: Component = () => {
getProfileOptionLabel,
getSettingsCount,
getStatusIndicatorBadgeToneClasses,
+ getUpgradeActionDestination,
getUpgradeActionButtonClass,
- getUpgradeActionUrlOrFallback,
handleAssign,
handleCreate,
handleDelete,
@@ -97,10 +98,8 @@ export const AgentProfilesPanel: Component = () => {
monitoring, logging levels, and reporting intervals from a central location.
</p>
<div class="flex flex-wrap items-center gap-3">
- <a
- href={getUpgradeActionUrlOrFallback('agent_profiles')}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={getUpgradeActionDestination('agent_profiles')}
class={getUpgradeActionButtonClass({ tone: 'warning', mobileFullWidth: false })}
onClick={() =>
trackUpgradeClicked('settings_agent_profiles_panel', 'agent_profiles')
@@ -108,7 +107,7 @@ export const AgentProfilesPanel: Component = () => {
>
<Crown class="w-4 h-4" />
{UPGRADE_ACTION_LABEL}
- </a>
+ </UpgradeLink>
<Show when={canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/AuditLogPanel.tsx b/frontend-modern/src/components/Settings/AuditLogPanel.tsx
index f812d858fa..dfd28de129 100644
--- a/frontend-modern/src/components/Settings/AuditLogPanel.tsx
+++ b/frontend-modern/src/components/Settings/AuditLogPanel.tsx
@@ -7,6 +7,7 @@ import Play from 'lucide-solid/icons/play';
import X from 'lucide-solid/icons/x';
import ShieldAlert from 'lucide-solid/icons/shield-alert';
import { showTooltip, hideTooltip } from '@/components/shared/Tooltip';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import Toggle from '@/components/shared/Toggle';
import SettingsPanel from '@/components/shared/SettingsPanel';
import { PulseDataGrid } from '@/components/shared/PulseDataGrid';
@@ -77,7 +78,7 @@ export default function AuditLogPanel() {
successFilter,
totalEvents,
totalPages,
- upgradeActionUrl,
+ upgradeDestination,
verification,
verificationFilter,
verificationSummary,
@@ -166,15 +167,13 @@ export default function AuditLogPanel() {
</p>
</div>
<div class="flex flex-col items-center gap-2">
- <a
- href={upgradeActionUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={upgradeDestination()}
class={getUpgradeActionButtonClass({ mobileFullWidth: false })}
onClick={handleUpgradeClick}
>
{UPGRADE_ACTION_LABEL}
- </a>
+ </UpgradeLink>
<Show when={canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx b/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx
index fceb254cff..ced05fb864 100644
--- a/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx
+++ b/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx
@@ -5,6 +5,7 @@ import Plus from 'lucide-solid/icons/plus';
import Trash2 from 'lucide-solid/icons/trash-2';
import ExternalLink from 'lucide-solid/icons/external-link';
import { Card } from '@/components/shared/Card';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import SettingsPanel from '@/components/shared/SettingsPanel';
import { formControl } from '@/components/shared/Form';
import {
@@ -43,7 +44,7 @@ export const AuditWebhookPanel: Component<AuditWebhookPanelProps> = (props) => {
saving,
setNewUrl,
startingTrial,
- upgradeActionUrl,
+ upgradeDestination,
webhookUrls,
} = useAuditWebhookPanelState(props.canManage);
const featureGateCopy = () => getAuditWebhookFeatureGateCopy();
@@ -66,17 +67,15 @@ export const AuditWebhookPanel: Component<AuditWebhookPanelProps> = (props) => {
</p>
</div>
<div class="flex flex-col sm:flex-row items-center gap-2">
- <a
- href={upgradeActionUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={upgradeDestination()}
class={getUpgradeActionButtonClass()}
onClick={() =>
trackUpgradeClicked('settings_audit_webhook_panel', 'audit_logging')
}
>
{UPGRADE_ACTION_LABEL}
- </a>
+ </UpgradeLink>
<Show when={canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx b/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
index d5b4b409d4..340147e8d6 100644
--- a/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
+++ b/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
@@ -1,6 +1,7 @@
import { Component, For, Show } from 'solid-js';
import RefreshCw from 'lucide-solid/icons/refresh-cw';
-import { getUpgradeActionUrlOrFallback, licenseLoadError } from '@/stores/license';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
+import { getUpgradeActionDestination, licenseLoadError } from '@/stores/license';
import {
getInactiveProUpsellNotice,
getLicenseStatusLoadingState,
@@ -81,14 +82,12 @@ export const ProLicensePlanSection: Component<ProLicensePlanSectionProps> = (pro
<div class={`mb-4 rounded-md border p-3 text-sm ${trialEndedNotice?.tone ?? ''}`}>
<p class="font-medium">{trialEndedNotice?.title}</p>
<p class="text-xs mt-1 opacity-90">{trialEndedNotice?.body}</p>
- <a
+ <UpgradeLink
class="inline-flex items-center gap-1 mt-2 text-xs font-medium hover:underline"
- href={getUpgradeActionUrlOrFallback('trial_expired')}
- target="_blank"
- rel="noreferrer"
+ destination={getUpgradeActionDestination('trial_expired')}
>
{trialEndedNotice?.actionLabel}
- </a>
+ </UpgradeLink>
</div>
</Show>
<Show when={licenseLoadError()}>
@@ -159,14 +158,12 @@ export const ProLicensePlanSection: Component<ProLicensePlanSectionProps> = (pro
<div class={`rounded-md border p-3 text-sm ${inactiveProUpsellNotice?.tone ?? ''}`}>
<p class="font-medium">{inactiveProUpsellNotice?.title}</p>
<p class="text-xs mt-1 opacity-90">{inactiveProUpsellNotice?.body}</p>
- <a
+ <UpgradeLink
class="inline-flex items-center gap-1 mt-2 text-xs font-medium hover:underline"
- href={getUpgradeActionUrlOrFallback('ai_autofix')}
- target="_blank"
- rel="noreferrer"
+ destination={getUpgradeActionDestination('ai_autofix')}
>
{inactiveProUpsellNotice?.actionLabel}
- </a>
+ </UpgradeLink>
</div>
</Show>
</Show>
diff --git a/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx b/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx
index d04236c0e5..2abcc2cb68 100644
--- a/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx
+++ b/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx
@@ -1,5 +1,6 @@
import { Component, Show } from 'solid-js';
-import { getUpgradeActionUrlOrFallback } from '@/stores/license';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
+import { getUpgradeActionDestination } from '@/stores/license';
import type { RBACFeatureGateCopy } from '@/utils/rbacPresentation';
import { trackUpgradeClicked } from '@/utils/upgradeMetrics';
import {
@@ -26,15 +27,13 @@ export const RBACFeatureGateSection: Component<RBACFeatureGateSectionProps> = (p
<p class="text-sm text-muted mt-1">{props.copy.body}</p>
</div>
<div class="flex flex-col sm:flex-row items-center gap-2">
- <a
- href={getUpgradeActionUrlOrFallback('rbac')}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={getUpgradeActionDestination('rbac')}
class={getUpgradeActionButtonClass()}
onClick={() => trackUpgradeClicked(props.paywallLocation, 'rbac')}
>
{UPGRADE_ACTION_LABEL}
- </a>
+ </UpgradeLink>
<Show when={props.canStartTrial}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx b/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx
index 65b7dd0de1..ed8d33b779 100644
--- a/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx
+++ b/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx
@@ -4,6 +4,7 @@ import SettingsPanel from '@/components/shared/SettingsPanel';
import { StatusDot } from '@/components/shared/StatusDot';
import { Toggle } from '@/components/shared/Toggle';
import { Card } from '@/components/shared/Card';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { formField, labelClass, controlClass, formHelpText } from '@/components/shared/Form';
import { trackUpgradeClicked } from '@/utils/upgradeMetrics';
import { getSettingsConfigurationLoadingState } from '@/utils/settingsShellPresentation';
@@ -50,15 +51,13 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =>
</div>
</div>
<div class="flex flex-col sm:flex-row items-center gap-2">
- <a
- href={state.upgradeActionUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={state.upgradeDestination()}
class={RELAY_PRIMARY_LINK_CLASS}
onClick={() => trackUpgradeClicked('settings_relay_panel', 'relay')}
>
Upgrade
- </a>
+ </UpgradeLink>
<Show when={state.canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/ReportingPanel.tsx b/frontend-modern/src/components/Settings/ReportingPanel.tsx
index 348e052780..7358889aab 100644
--- a/frontend-modern/src/components/Settings/ReportingPanel.tsx
+++ b/frontend-modern/src/components/Settings/ReportingPanel.tsx
@@ -7,6 +7,7 @@ import OperationsPanel from '@/components/Settings/OperationsPanel';
import { CalloutCard } from '@/components/shared/CalloutCard';
import { formControl, formField, formHelpText, formLabel } from '@/components/shared/Form';
import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { useReportingPanelState } from '@/components/Settings/useReportingPanelState';
import type { ReportingFormat } from '@/components/Settings/reportingCatalogModel';
import { type ReportingRangeValue } from '@/components/Settings/reportingPanelModel';
@@ -65,7 +66,7 @@ export function ReportingPanel() {
setTitle,
startingTrial,
title,
- upgradeActionUrl,
+ upgradeDestination,
} = useReportingPanelState();
const performanceReport = () => reportingCatalog()?.performanceReport ?? null;
@@ -149,15 +150,13 @@ export function ReportingPanel() {
</Show>
</div>
<div class="flex flex-col sm:flex-row items-center gap-2">
- <a
- href={upgradeActionUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={upgradeDestination()}
class={getUpgradeActionButtonClass()}
onClick={() => trackUpgradeClicked('settings_reporting_panel', reportingCatalog()!.id)}
>
{UPGRADE_ACTION_LABEL}
- </a>
+ </UpgradeLink>
<Show when={canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/SSOProvidersPanel.tsx b/frontend-modern/src/components/Settings/SSOProvidersPanel.tsx
index 54b2e92a49..7ef2609bbb 100644
--- a/frontend-modern/src/components/Settings/SSOProvidersPanel.tsx
+++ b/frontend-modern/src/components/Settings/SSOProvidersPanel.tsx
@@ -1,6 +1,7 @@
import { Component, For, Show } from 'solid-js';
import SettingsPanel from '@/components/shared/SettingsPanel';
import { Dialog } from '@/components/shared/Dialog';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { Toggle } from '@/components/shared/Toggle';
import { formField, labelClass, controlClass, formHelpText } from '@/components/shared/Form';
import Plus from 'lucide-solid/icons/plus';
@@ -79,8 +80,8 @@ export const SSOProvidersPanel: Component<SSOProvidersPanelProps> = (props) => {
testConnection,
canTest,
fetchMetadataPreview,
+ getUpgradeActionDestination,
licenseLoaded,
- getUpgradeActionUrlOrFallback,
trackUpgradeClicked,
} = useSSOProvidersState(props);
@@ -119,10 +120,8 @@ export const SSOProvidersPanel: Component<SSOProvidersPanelProps> = (props) => {
>
Not now
</button>
- <a
- href={getUpgradeActionUrlOrFallback('advanced_sso')}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={getUpgradeActionDestination('advanced_sso')}
class={getUpgradeActionButtonClass({ mobileFullWidth: false })}
onClick={() =>
trackUpgradeClicked('settings_sso_providers_add_saml_gate', 'advanced_sso')
@@ -130,7 +129,7 @@ export const SSOProvidersPanel: Component<SSOProvidersPanelProps> = (props) => {
>
{UPGRADE_ACTION_LABEL}
<ExternalLink class="w-4 h-4" />
- </a>
+ </UpgradeLink>
<Show when={canStartTrial()}>
<button
type="button"
@@ -159,16 +158,14 @@ export const SSOProvidersPanel: Component<SSOProvidersPanelProps> = (props) => {
</p>
</div>
<div class="flex flex-col sm:flex-row items-center gap-2">
- <a
- href={getUpgradeActionUrlOrFallback('advanced_sso')}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={getUpgradeActionDestination('advanced_sso')}
class={getUpgradeActionButtonClass({ mobileFullWidth: false })}
onClick={() => trackUpgradeClicked('settings_sso_providers_banner', 'advanced_sso')}
>
{UPGRADE_ACTION_LABEL}
<ExternalLink class="w-4 h-4" />
- </a>
+ </UpgradeLink>
<Show when={canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
index 17704f97f8..787c37487d 100644
--- a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
@@ -69,6 +69,7 @@ vi.mock('@/utils/logger', () => ({
vi.mock('@/stores/license', () => ({
entitlements: (...args: unknown[]) => entitlementsMock(...args),
+ getUpgradeActionDestination: () => ({ href: 'https://example.com/upgrade', external: true }),
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
getUpgradeActionUrlOrFallback: () => '/upgrade',
diff --git a/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx
index 908ff8cdf5..694f249078 100644
--- a/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx
@@ -18,6 +18,7 @@ const unassignProfileMock = vi.fn();
const createProfileMock = vi.fn();
const updateProfileMock = vi.fn();
const deleteProfileMock = vi.fn();
+const getUpgradeActionDestinationMock = vi.hoisted(() => vi.fn());
const getUpgradeActionUrlOrFallbackMock = vi.hoisted(() => vi.fn());
vi.mock('@/hooks/useResources', () => ({
@@ -31,6 +32,7 @@ vi.mock('@/contexts/appRuntime', () => ({
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (...args: unknown[]) => getUpgradeActionDestinationMock(...args),
getUpgradeActionUrlOrFallback: (...args: unknown[]) => getUpgradeActionUrlOrFallbackMock(...args),
hasFeature: () => true,
licenseLoaded: () => true,
@@ -214,7 +216,12 @@ const makeKubernetesInfrastructureItem = (
});
beforeEach(() => {
+ getUpgradeActionDestinationMock.mockReset();
getUpgradeActionUrlOrFallbackMock.mockReset();
+ getUpgradeActionDestinationMock.mockImplementation((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ }));
getUpgradeActionUrlOrFallbackMock.mockImplementation((feature?: string) => getPublicPricingUrl(feature));
mockResources = [makeAgentResource()];
mockWsStore = {
diff --git a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
index e861a0bcb8..211c516d0c 100644
--- a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
@@ -19,6 +19,7 @@ const notificationSuccessMock = vi.fn();
const notificationErrorMock = vi.fn();
const useLocationMock = vi.fn(() => ({ search: '' }));
const navigateMock = vi.fn();
+const getUpgradeActionDestinationMock = vi.hoisted(() => vi.fn());
const getUpgradeActionUrlOrFallbackMock = vi.hoisted(() => vi.fn());
vi.mock('@solidjs/router', () => ({
@@ -27,6 +28,7 @@ vi.mock('@solidjs/router', () => ({
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (...args: unknown[]) => getUpgradeActionDestinationMock(...args),
getUpgradeActionUrlOrFallback: (...args: unknown[]) => getUpgradeActionUrlOrFallbackMock(...args),
isMultiTenantEnabled: () => true,
licenseLoadError: () => false,
@@ -68,11 +70,16 @@ describe('ProLicensePanel', () => {
notificationErrorMock.mockReset();
useLocationMock.mockReset();
navigateMock.mockReset();
+ getUpgradeActionDestinationMock.mockReset();
getUpgradeActionUrlOrFallbackMock.mockReset();
loadLicenseStatusMock.mockResolvedValue(undefined);
startProTrialMock.mockResolvedValue(undefined);
activateLicenseMock.mockResolvedValue({ success: true });
clearLicenseMock.mockResolvedValue({ success: true });
+ getUpgradeActionDestinationMock.mockImplementation((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ }));
getUpgradeActionUrlOrFallbackMock.mockImplementation((feature?: string) => getPublicPricingUrl(feature));
useLocationMock.mockReturnValue({ search: '' });
});
diff --git a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
index bea573052b..10da9928e6 100644
--- a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
@@ -19,6 +19,10 @@ const notificationErrorMock = vi.fn();
const loggerErrorMock = vi.fn();
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (feature: string) => ({
+ href: `https://example.com/upgrade?feature=${feature}`,
+ external: true,
+ }),
getUpgradeActionUrlOrFallback: (feature: string) => `/upgrade?feature=${feature}`,
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
@@ -112,7 +116,7 @@ describe('RBAC paywall settings panels', () => {
expect(screen.getByRole('link', { name: 'Upgrade to Pro' })).toHaveAttribute(
'href',
- '/upgrade?feature=rbac',
+ 'https://example.com/upgrade?feature=rbac',
);
expect(screen.getByRole('button', { name: 'New Role' })).toBeDisabled();
expect(getRolesMock).not.toHaveBeenCalled();
@@ -143,7 +147,7 @@ describe('RBAC paywall settings panels', () => {
expect(screen.getByRole('link', { name: 'Upgrade to Pro' })).toHaveAttribute(
'href',
- '/upgrade?feature=rbac',
+ 'https://example.com/upgrade?feature=rbac',
);
expect(screen.getByPlaceholderText('Search users...')).toBeDisabled();
expect(getUsersMock).not.toHaveBeenCalled();
diff --git a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx
index 314d928d74..a61b827ab8 100644
--- a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx
@@ -23,6 +23,7 @@ vi.mock('@/stores/license', () => ({
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
licenseLoaded: () => true,
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
+ getUpgradeActionDestination: () => ({ href: 'https://example.com/upgrade', external: true }),
getUpgradeActionUrlOrFallback: () => '/upgrade',
startProTrial: vi.fn(),
entitlements: () => ({ trial_eligible: false }),
@@ -160,7 +161,10 @@ describe('RelaySettingsPanel runtime', () => {
'Remote access via Pulse Relay requires a Relay license or above. Pair supported Pulse Mobile clients with this instance using a QR code or deep link.',
),
).toBeInTheDocument();
- expect(screen.getByRole('link', { name: 'Upgrade' })).toHaveAttribute('href', '/upgrade');
+ expect(screen.getByRole('link', { name: 'Upgrade' })).toHaveAttribute(
+ 'href',
+ 'https://example.com/upgrade',
+ );
});
it('loads connected relay state and generates a pairing QR payload', async () => {
diff --git a/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx
index aaeb9319fb..2796d30a1c 100644
--- a/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx
@@ -97,7 +97,10 @@ function buildState(overrides: Record<string, unknown> = {}) {
setTitle: vi.fn(),
startingTrial: () => false,
title: () => '',
- upgradeActionUrl: () => getPublicPricingUrl('advanced_reporting'),
+ upgradeDestination: () => ({
+ href: getPublicPricingUrl('advanced_reporting'),
+ external: true,
+ }),
...overrides,
};
}
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 013078be44..ea7005b0d0 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -631,14 +631,17 @@ describe('Settings architecture guardrails', () => {
it('keeps relay settings split into shell, runtime, and pairing owners', () => {
expect(relaySettingsPanelSource).toContain('./useRelaySettingsPanelState');
expect(relaySettingsPanelSource).toContain('./RelayPairingSection');
+ expect(relaySettingsPanelSource).toContain('@/components/shared/UpgradeLink');
expect(relaySettingsPanelSource).toContain('@/utils/upgradePresentation');
expect(relaySettingsPanelSource).toContain('UPGRADE_TRIAL_LABEL');
expect(relaySettingsPanelSource).not.toContain('createSignal(');
expect(relaySettingsPanelSource).not.toContain('QRCode.toDataURL(');
+ expect(relaySettingsPanelSource).not.toContain('target="_blank"');
expect(relaySettingsPanelSource).not.toContain('>Start free trial<');
expect(relaySettingsPanelStateSource).toContain(
"trackPaywallViewed('relay', 'settings_relay_panel')",
);
+ expect(relaySettingsPanelStateSource).toContain("getUpgradeActionDestination('relay')");
expect(relaySettingsPanelStateSource).toContain('setInterval(() => void loadStatus(), 5000)');
expect(relaySettingsPanelStateSource).toContain('QRCode.toDataURL(payload.deep_link');
expect(relaySettingsPanelStateSource).toContain('runStartProTrialAction({');
@@ -832,7 +835,9 @@ describe('Settings architecture guardrails', () => {
expect(userAssignmentsPanelSource).toContain('./useUserAssignmentsPanelState');
expect(userAssignmentsPanelSource).not.toContain('const handleStartTrial = async');
expect(userAssignmentsPanelSource).not.toContain('const loadData = async');
+ expect(rbacFeatureGateSectionSource).toContain('@/components/shared/UpgradeLink');
expect(rbacFeatureGateSectionSource).toContain('trackUpgradeClicked');
+ expect(rbacFeatureGateSectionSource).not.toContain('target="_blank"');
expect(rbacFeatureGateStateSource).toContain('trackPaywallViewed');
expect(rbacFeatureGateStateSource).toContain('runStartProTrialAction({');
expect(rbacFeatureGateStateSource).not.toContain('startProTrial()');
@@ -1099,11 +1104,15 @@ describe('Settings architecture guardrails', () => {
);
expect(aiModelSelectionSectionSource).toContain('@/components/Settings/aiSettingsModel');
expect(aiModelSelectionSectionSource).toContain('Advanced Model Selection');
+ expect(aiRuntimeControlsSectionSource).toContain('@/components/shared/UpgradeLink');
expect(aiRuntimeControlsSectionSource).toContain('@/utils/upgradePresentation');
expect(aiRuntimeControlsSectionSource).toContain('UPGRADE_ACTION_LABEL');
expect(aiRuntimeControlsSectionSource).toContain('UPGRADE_TRIAL_LABEL');
expect(aiRuntimeControlsSectionSource).toContain('Discovery Settings');
expect(aiRuntimeControlsSectionSource).toContain('Pulse Permission Level');
+ expect(aiRuntimeControlsSectionSource).toContain('destination={state.upgradeAutofixDestination()}');
+ expect(aiRuntimeControlsSectionSource).not.toContain('href={state.upgradeAutofixDestination().href}');
+ expect(aiRuntimeControlsSectionSource).not.toContain('window.open(state.upgradeAutofixDestination().href');
expect(aiRuntimeControlsSectionSource).not.toContain('>Upgrade to Pro<');
expect(aiRuntimeControlsSectionSource).not.toContain('>Start free trial<');
expect(aiChatMaintenanceSectionSource).toContain('Chat Session Maintenance');
@@ -1119,6 +1128,7 @@ describe('Settings architecture guardrails', () => {
expect(aiSettingsStateSource).toContain(
'const handleEnabledToggle = async (newValue: boolean) =>',
);
+ expect(aiSettingsStateSource).toContain("getUpgradeActionDestination('ai_autofix')");
expect(aiSettingsStateSource).toContain('AIAPI.getSettings()');
expect(aiSettingsStateSource).toContain(
'const payload: Record<string, unknown> = { enabled: true };',
@@ -1183,6 +1193,7 @@ describe('Settings architecture guardrails', () => {
it('keeps the reporting shell behind extracted runtime and model owners', () => {
expect(reportingPanelSource).toContain('@/components/Settings/OperationsPanel');
expect(reportingPanelSource).toContain('@/components/Settings/useReportingPanelState');
+ expect(reportingPanelSource).toContain('@/components/shared/UpgradeLink');
expect(reportingPanelSource).toContain('@/components/Settings/reportingCatalogModel');
expect(reportingPanelSource).toContain('@/components/Settings/reportingPanelModel');
expect(reportingPanelSource).toContain('reportingCatalog');
@@ -1194,6 +1205,7 @@ describe('Settings architecture guardrails', () => {
expect(reportingPanelStateSource).toContain('export const useReportingPanelState =');
expect(reportingPanelStateSource).toContain('loadLicenseStatus');
expect(reportingPanelStateSource).toContain('runStartProTrialAction({');
+ expect(reportingPanelStateSource).toContain('getUpgradeActionDestination(');
expect(reportingPanelStateSource).not.toContain('startProTrial()');
expect(reportingPanelStateSource).toContain('buildReportingRequest');
expect(reportingPanelStateSource).toContain('buildReportingCatalogRequest');
@@ -1248,15 +1260,18 @@ describe('Settings architecture guardrails', () => {
it('keeps the audit log shell behind an extracted runtime owner', () => {
expect(auditLogPanelSource).toContain('@/components/Settings/useAuditLogPanelState');
+ expect(auditLogPanelSource).toContain('@/components/shared/UpgradeLink');
expect(auditLogPanelSource).not.toContain('createLocalStorageStringSignal');
expect(auditLogPanelSource).not.toContain('const fetchAuditEvents = async (');
expect(auditLogPanelSource).not.toContain('const verifyAllEvents = async (');
expect(auditLogPanelSource).not.toContain('trackPaywallViewed');
+ expect(auditLogPanelSource).not.toContain('target="_blank"');
expect(auditLogStateSource).toContain('export const useAuditLogPanelState =');
expect(auditLogStateSource).toContain('createLocalStorageStringSignal');
expect(auditLogStateSource).toContain('const fetchAuditEvents = async (');
expect(auditLogStateSource).toContain('const verifyAllEvents = async (');
expect(auditLogStateSource).toContain('trackPaywallViewed');
+ expect(auditLogStateSource).toContain("getUpgradeActionDestination('audit_logging')");
expect(auditLogStateSource).toContain('runStartProTrialAction({');
expect(auditLogStateSource).not.toContain('startProTrial()');
expect(auditLogStateSource).not.toContain('getTrialAlreadyUsedMessage()');
@@ -1264,15 +1279,18 @@ describe('Settings architecture guardrails', () => {
it('keeps the audit webhook shell behind an extracted runtime owner', () => {
expect(auditWebhookPanelSource).toContain('@/components/Settings/useAuditWebhookPanelState');
+ expect(auditWebhookPanelSource).toContain('@/components/shared/UpgradeLink');
expect(auditWebhookPanelSource).not.toContain('loadLicenseStatus();');
expect(auditWebhookPanelSource).not.toContain('const fetchWebhooks = async () =>');
expect(auditWebhookPanelSource).not.toContain('const saveWebhooks = async (urls: string[]) =>');
expect(auditWebhookPanelSource).not.toContain('trackPaywallViewed');
+ expect(auditWebhookPanelSource).not.toContain('target="_blank"');
expect(auditWebhookStateSource).toContain('export const useAuditWebhookPanelState =');
expect(auditWebhookStateSource).toContain('loadLicenseStatus();');
expect(auditWebhookStateSource).toContain('const fetchWebhooks = async () =>');
expect(auditWebhookStateSource).toContain('const saveWebhooks = async (urls: string[]) =>');
expect(auditWebhookStateSource).toContain('trackPaywallViewed');
+ expect(auditWebhookStateSource).toContain("getUpgradeActionDestination('audit_logging')");
expect(auditWebhookStateSource).toContain('runStartProTrialAction({');
expect(auditWebhookStateSource).not.toContain('startProTrial()');
expect(auditWebhookStateSource).not.toContain('getTrialAlreadyUsedMessage()');
@@ -1280,16 +1298,19 @@ describe('Settings architecture guardrails', () => {
it('keeps the SSO providers shell behind extracted runtime owners', () => {
expect(ssoProvidersPanelSource).toContain('@/components/Settings/useSSOProvidersState');
+ expect(ssoProvidersPanelSource).toContain('@/components/shared/UpgradeLink');
expect(ssoProvidersPanelSource).toContain('@/utils/ssoProviderPresentation');
expect(ssoProvidersPanelSource).not.toContain('const loadProviders = async () =>');
expect(ssoProvidersPanelSource).not.toContain('const handleSave = async (');
expect(ssoProvidersPanelSource).not.toContain('const testConnection = async () =>');
+ expect(ssoProvidersPanelSource).not.toContain('target="_blank"');
expect(ssoProvidersStateSource).toContain('@/components/Settings/ssoProvidersModel');
expect(ssoProvidersStateSource).toContain('@/utils/ssoProviderPresentation');
expect(ssoProvidersStateSource).toContain('export const useSSOProvidersState =');
expect(ssoProvidersStateSource).toContain('const loadProviders = async () =>');
expect(ssoProvidersStateSource).toContain('const handleSave = async (event?: Event) =>');
expect(ssoProvidersStateSource).toContain('const testConnection = async () =>');
+ expect(ssoProvidersStateSource).toContain('getUpgradeActionDestination');
expect(ssoProvidersStateSource).toContain('runStartProTrialAction({');
expect(ssoProvidersStateSource).not.toContain('startProTrial()');
expect(ssoProvidersStateSource).not.toContain('getTrialAlreadyUsedMessage()');
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsReadOnlyPanels.test.tsx b/frontend-modern/src/components/Settings/__tests__/settingsReadOnlyPanels.test.tsx
index 4360d184df..999224c1c5 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsReadOnlyPanels.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/settingsReadOnlyPanels.test.tsx
@@ -24,6 +24,7 @@ vi.mock('@/stores/license', () => ({
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
licenseLoaded: () => true,
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
+ getUpgradeActionDestination: () => ({ href: 'https://example.com/upgrade', external: true }),
getUpgradeActionUrlOrFallback: () => '/upgrade',
startProTrial: vi.fn(),
entitlements: () => ({ trial_eligible: false }),
diff --git a/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts b/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
index 9bd25abe4c..0be7e1af13 100644
--- a/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
@@ -113,6 +113,10 @@ describe('useReportingPanelState', () => {
vi.doMock('@/stores/license', () => ({
entitlements: vi.fn(() => ({ trial_eligible: true })),
+ getUpgradeActionDestination: vi.fn((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ })),
getUpgradeActionUrlOrFallback: vi.fn((feature?: string) => getPublicPricingUrl(feature)),
hasFeature: vi.fn((feature: string) => feature === 'advanced_reporting' && hasReportingFeature),
licenseLoaded: vi.fn(() => true),
@@ -201,6 +205,10 @@ describe('useReportingPanelState', () => {
vi.doMock('@/stores/license', () => ({
entitlements: vi.fn(() => ({ trial_eligible: true })),
+ getUpgradeActionDestination: vi.fn((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ })),
getUpgradeActionUrlOrFallback: vi.fn((feature?: string) => getPublicPricingUrl(feature)),
hasFeature: vi.fn(() => false),
licenseLoaded: vi.fn(() => false),
@@ -254,6 +262,10 @@ describe('useReportingPanelState', () => {
vi.doMock('@/stores/license', () => ({
entitlements: vi.fn(() => ({ trial_eligible: true })),
+ getUpgradeActionDestination: vi.fn((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ })),
getUpgradeActionUrlOrFallback: vi.fn((feature?: string) => getPublicPricingUrl(feature)),
hasFeature: vi.fn((feature: string) => feature === 'advanced_reporting' && hasReportingFeature),
licenseLoaded: vi.fn(() => true),
@@ -311,6 +323,10 @@ describe('useReportingPanelState', () => {
vi.doMock('@/stores/license', () => ({
entitlements: vi.fn(() => ({ trial_eligible: true })),
+ getUpgradeActionDestination: vi.fn((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ })),
getUpgradeActionUrlOrFallback: vi.fn((feature?: string) => getPublicPricingUrl(feature)),
hasFeature: vi.fn((feature: string) => feature === 'advanced_reporting' && hasReportingFeature),
licenseLoaded: vi.fn(() => true),
@@ -357,6 +373,10 @@ describe('useReportingPanelState', () => {
vi.doMock('@/stores/license', () => ({
entitlements: vi.fn(() => ({ trial_eligible: true })),
+ getUpgradeActionDestination: vi.fn((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ })),
getUpgradeActionUrlOrFallback: vi.fn((feature?: string) => getPublicPricingUrl(feature)),
hasFeature: vi.fn((feature: string) => feature === 'advanced_reporting' && hasReportingFeature),
licenseLoaded: vi.fn(() => true),
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index af92e37b85..769e9cb683 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -12,7 +12,7 @@ import {
import { aiChatStore } from '@/stores/aiChat';
import {
entitlements,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
loadLicenseStatus,
} from '@/stores/license';
@@ -155,7 +155,7 @@ export const useAISettingsState = () => {
normalizeQuickstartReason(settings()?.quickstart_blocked_reason),
);
const canStartTrial = () => entitlements()?.trial_eligible !== false;
- const upgradeAutofixUrl = () => getUpgradeActionUrlOrFallback('ai_autofix');
+ const upgradeAutofixDestination = () => getUpgradeActionDestination('ai_autofix');
const hasProviderBackedModels = (data: AISettingsType | null | undefined) =>
(data?.configured_providers?.length ?? 0) > 0;
@@ -919,7 +919,7 @@ export const useAISettingsState = () => {
testing,
testingProvider,
quickstartBlockedReason,
- upgradeAutofixUrl,
+ upgradeAutofixDestination,
};
};
diff --git a/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts b/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts
index 715a3cc8ff..d5df99825d 100644
--- a/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts
@@ -12,7 +12,7 @@ import { useResources } from '@/hooks/useResources';
import { notificationStore } from '@/stores/notifications';
import {
entitlements,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature as hasEntitlement,
licenseLoaded,
licenseLoading,
@@ -383,8 +383,8 @@ export const useAgentProfilesPanelState = () => {
getProfileOptionLabel,
getSettingsCount,
getStatusIndicatorBadgeToneClasses,
+ getUpgradeActionDestination,
getUpgradeActionButtonClass,
- getUpgradeActionUrlOrFallback,
handleAssign,
handleCreate,
handleDelete,
diff --git a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
index ccf8599986..7a721d4269 100644
--- a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
@@ -9,7 +9,7 @@ import { apiFetch } from '@/utils/apiClient';
import { showSuccess, showToast, showWarning } from '@/utils/toast';
import {
entitlements,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
licenseLoaded,
loadLicenseStatus,
@@ -118,7 +118,7 @@ export const useAuditLogPanelState = () => {
() => licenseLoaded() && !auditLoggingEnabled() && !loading(),
);
const canStartTrial = () => entitlements()?.trial_eligible !== false;
- const upgradeActionUrl = createMemo(() => getUpgradeActionUrlOrFallback('audit_logging'));
+ const upgradeDestination = createMemo(() => getUpgradeActionDestination('audit_logging'));
const fetchAuditEvents = async (options?: { limit?: number; offset?: number }) => {
if (!auditLoggingEnabled()) {
@@ -633,7 +633,7 @@ export const useAuditLogPanelState = () => {
successFilter,
totalEvents,
totalPages,
- upgradeActionUrl,
+ upgradeDestination,
verification,
verificationFilter,
verificationSummary,
diff --git a/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts b/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
index 36ac3d4f5c..3369e792df 100644
--- a/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
@@ -4,7 +4,7 @@ import { logger } from '@/utils/logger';
import { showSuccess, showWarning } from '@/utils/toast';
import {
entitlements,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
licenseLoaded,
loadLicenseStatus,
@@ -28,7 +28,7 @@ export const useAuditWebhookPanelState = (canManageOverride?: boolean) => {
const canManage = () => canManageOverride !== false;
const canStartTrial = () => entitlements()?.trial_eligible !== false;
const isAuditLoggingEnabled = () => hasFeature('audit_logging');
- const upgradeActionUrl = () => getUpgradeActionUrlOrFallback('audit_logging');
+ const upgradeDestination = () => getUpgradeActionDestination('audit_logging');
const handleStartTrial = async () => {
if (startingTrial()) return;
@@ -129,7 +129,7 @@ export const useAuditWebhookPanelState = (canManageOverride?: boolean) => {
saving,
setNewUrl,
startingTrial,
- upgradeActionUrl,
+ upgradeDestination,
webhookUrls,
};
};
diff --git a/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts b/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts
index 155e312206..0b088957bb 100644
--- a/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts
@@ -1,7 +1,7 @@
import { createEffect, createMemo, createSignal, onCleanup, onMount } from 'solid-js';
import {
entitlements,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
licenseLoaded,
loadLicenseStatus,
@@ -36,7 +36,7 @@ export function useRelaySettingsPanelState(props: RelaySettingsPanelProps) {
const canManage = () => props.canManage !== false;
const canStartTrial = () => entitlements()?.trial_eligible !== false;
const relayEnabled = () => hasFeature('relay');
- const upgradeActionUrl = () => getUpgradeActionUrlOrFallback('relay');
+ const upgradeDestination = () => getUpgradeActionDestination('relay');
const connectionPresentation = createMemo(() =>
getRelayConnectionPresentation(config(), status()),
);
@@ -288,6 +288,6 @@ export function useRelaySettingsPanelState(props: RelaySettingsPanelProps) {
showPairing,
startingTrial,
status,
- upgradeActionUrl,
+ upgradeDestination,
};
}
diff --git a/frontend-modern/src/components/Settings/useReportingPanelState.ts b/frontend-modern/src/components/Settings/useReportingPanelState.ts
index c986838062..7439e02a73 100644
--- a/frontend-modern/src/components/Settings/useReportingPanelState.ts
+++ b/frontend-modern/src/components/Settings/useReportingPanelState.ts
@@ -4,7 +4,7 @@ import { showSuccess, showWarning } from '@/utils/toast';
import type { SelectedResource } from '@/components/Settings/ResourcePicker';
import {
entitlements,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
licenseLoaded,
loadLicenseStatus,
@@ -60,8 +60,10 @@ export const useReportingPanelState = () => {
licenseLoaded() &&
reportingFeatureId() !== '' &&
hasFeature(reportingFeatureId());
- const upgradeActionUrl = () =>
- reportingFeatureId() === '' ? '' : getUpgradeActionUrlOrFallback(reportingFeatureId());
+ const upgradeDestination = () =>
+ reportingFeatureId() === ''
+ ? getUpgradeActionDestination('')
+ : getUpgradeActionDestination(reportingFeatureId());
onMount(() => {
loadLicenseStatus();
@@ -259,6 +261,6 @@ export const useReportingPanelState = () => {
setTitle,
startingTrial,
title,
- upgradeActionUrl,
+ upgradeDestination,
};
};
diff --git a/frontend-modern/src/components/Settings/useSSOProvidersState.ts b/frontend-modern/src/components/Settings/useSSOProvidersState.ts
index f37a8c20b4..88fe200149 100644
--- a/frontend-modern/src/components/Settings/useSSOProvidersState.ts
+++ b/frontend-modern/src/components/Settings/useSSOProvidersState.ts
@@ -3,7 +3,7 @@ import { createStore } from 'solid-js/store';
import { notificationStore } from '@/stores/notifications';
import { logger } from '@/utils/logger';
import {
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
loadLicenseStatus,
licenseLoaded,
@@ -361,8 +361,8 @@ export const useSSOProvidersState = (props: SSOProvidersPanelProps) => {
testConnection,
canTest,
fetchMetadataPreview,
+ getUpgradeActionDestination,
licenseLoaded,
- getUpgradeActionUrlOrFallback,
trackUpgradeClicked,
};
};
diff --git a/frontend-modern/src/components/shared/HistoryChartOverlay.tsx b/frontend-modern/src/components/shared/HistoryChartOverlay.tsx
index 3c4fa0128b..1566ca9cdd 100644
--- a/frontend-modern/src/components/shared/HistoryChartOverlay.tsx
+++ b/frontend-modern/src/components/shared/HistoryChartOverlay.tsx
@@ -1,4 +1,5 @@
import { Component, Show } from 'solid-js';
+import { UpgradeLink } from './UpgradeLink';
import type { HistoryChartState } from './useHistoryChartState';
interface HistoryChartOverlayProps {
@@ -73,15 +74,13 @@ export const HistoryChartOverlay: Component<HistoryChartOverlayProps> = (props)
historical data retention.
</p>
<div class="flex flex-col items-center gap-2">
- <a
- href={props.chart.getUpgradeActionUrlOrFallback('long_term_metrics')}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={props.chart.getUpgradeActionDestination('long_term_metrics')}
onClick={() => props.chart.trackUpgradeClicked('history_chart', 'long_term_metrics')}
class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
>
Unlock {props.chart.lockTierLabel()} Features
- </a>
+ </UpgradeLink>
<Show when={props.chart.canStartTrial()}>
<button
type="button"
diff --git a/frontend-modern/src/components/shared/MonitoredSystemLimitWarningBanner.tsx b/frontend-modern/src/components/shared/MonitoredSystemLimitWarningBanner.tsx
index 48293b18a7..18afd32dd4 100644
--- a/frontend-modern/src/components/shared/MonitoredSystemLimitWarningBanner.tsx
+++ b/frontend-modern/src/components/shared/MonitoredSystemLimitWarningBanner.tsx
@@ -6,6 +6,7 @@ import {
MONITORED_SYSTEM_LIMIT_LEARN_MORE_LABEL,
MONITORED_SYSTEM_LIMIT_UPGRADE_LABEL,
} from './monitoredSystemLimitWarningBannerModel';
+import { UpgradeLink } from './UpgradeLink';
import { useMonitoredSystemLimitWarningBannerState } from './useMonitoredSystemLimitWarningBannerState';
export const MonitoredSystemLimitWarningBanner: Component = () => {
@@ -42,15 +43,13 @@ export const MonitoredSystemLimitWarningBanner: Component = () => {
</a>
</Show>
<Show when={state.isUrgent()}>
- <a
+ <UpgradeLink
class="text-xs font-semibold underline underline-offset-2 hover:opacity-90"
- href={state.upgradeHref()}
- target="_blank"
- rel="noreferrer"
+ destination={state.upgradeDestination()}
onClick={state.handleUpgradeClick}
>
{MONITORED_SYSTEM_LIMIT_UPGRADE_LABEL}
- </a>
+ </UpgradeLink>
</Show>
</div>
</div>
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 0e5c570eda..cc7b2e210a 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -56,6 +56,7 @@ import tooltipPortalSource from '@/components/shared/TooltipPortal.tsx?raw';
import tooltipModelSource from '@/components/shared/tooltipModel.ts?raw';
import trialBannerSource from '@/components/shared/TrialBanner.tsx?raw';
import trialBannerModelSource from '@/components/shared/trialBannerModel.ts?raw';
+import upgradeLinkSource from '@/components/shared/UpgradeLink.tsx?raw';
import interactiveSparklineSource from '@/components/shared/InteractiveSparkline.tsx?raw';
import interactiveSparklineModelSource from '@/components/shared/interactiveSparklineModel.ts?raw';
import contextualFocusSource from '@/components/shared/contextualFocus.ts?raw';
@@ -103,12 +104,14 @@ import toggleStateSource from '@/components/shared/useToggleState.ts?raw';
import searchTipsPopoverStateSource from '@/components/shared/useSearchTipsPopoverState.ts?raw';
import tooltipStateSource from '@/components/shared/useTooltipState.ts?raw';
import trialBannerStateSource from '@/components/shared/useTrialBannerState.ts?raw';
+import upgradeNavigationHookSource from '@/components/shared/useUpgradeNavigation.ts?raw';
import interactiveSparklineStateSource from '@/components/shared/useInteractiveSparklineState.ts?raw';
import monitoredSystemLimitWarningBannerStateSource from '@/components/shared/useMonitoredSystemLimitWarningBannerState.ts?raw';
import selectionCardGroupStateSource from '@/components/shared/useSelectionCardGroupState.ts?raw';
import webInterfaceUrlFieldSource from '@/components/shared/WebInterfaceUrlField.tsx?raw';
import webInterfaceUrlFieldModelSource from '@/components/shared/webInterfaceUrlFieldModel.ts?raw';
import webInterfaceUrlFieldStateSource from '@/components/shared/useWebInterfaceUrlFieldState.ts?raw';
+import upgradeNavigationSource from '@/utils/upgradeNavigation.ts?raw';
import guestRowSource from '@/components/Dashboard/GuestRow.tsx?raw';
import dashboardWorkloadTableSource from '@/components/Dashboard/DashboardWorkloadTable.tsx?raw';
import workloadPanelSource from '@/components/Dashboard/WorkloadPanel.tsx?raw';
@@ -466,7 +469,7 @@ describe('shared primitive guardrails', () => {
expect(trialBannerStateSource).toContain('createMemo');
expect(trialBannerStateSource).toContain('loadLicenseStatus');
expect(trialBannerStateSource).toContain('licenseStatus');
- expect(trialBannerStateSource).toContain('getUpgradeActionUrlOrFallback');
+ expect(trialBannerStateSource).toContain('getUpgradeActionDestination');
expect(trialBannerStateSource).toContain('snoozeUpsell');
expect(trialBannerModelSource).toContain('TRIAL_BANNER_SNOOZE_KEY');
@@ -476,6 +479,24 @@ describe('shared primitive guardrails', () => {
expect(trialBannerModelSource).toContain('TRIAL_BANNER_UPGRADE_LABEL');
});
+ it('keeps upgrade navigation split across shell, runtime, and utility owners', () => {
+ expect(upgradeLinkSource).toContain('destination.external');
+ expect(upgradeLinkSource).toContain("target={local.target ?? '_blank'}");
+ expect(upgradeLinkSource).not.toContain('window.open');
+ expect(upgradeLinkSource).not.toContain('useNavigate(');
+
+ expect(upgradeNavigationHookSource).toContain('export function useUpgradeNavigation');
+ expect(upgradeNavigationHookSource).toContain('useNavigate()');
+ expect(upgradeNavigationHookSource).toContain('navigateToUpgradeDestination');
+ expect(upgradeNavigationHookSource).not.toContain('window.open');
+
+ expect(upgradeNavigationSource).toContain('export interface UpgradeDestination');
+ expect(upgradeNavigationSource).toContain('isExternalUpgradeHref');
+ expect(upgradeNavigationSource).toContain('resolveUpgradeDestination');
+ expect(upgradeNavigationSource).toContain('navigateToUpgradeDestination');
+ expect(upgradeNavigationSource).toContain("window.open(href, '_blank', 'noopener,noreferrer')");
+ });
+
it('keeps column picker on shell, runtime, and model owners', () => {
expect(columnPickerSource).toContain('useColumnPickerState');
expect(columnPickerSource).toContain('COLUMN_PICKER_PANEL_TITLE');
diff --git a/frontend-modern/src/components/shared/TrialBanner.tsx b/frontend-modern/src/components/shared/TrialBanner.tsx
index 4ef35c39e1..f0264b4dc5 100644
--- a/frontend-modern/src/components/shared/TrialBanner.tsx
+++ b/frontend-modern/src/components/shared/TrialBanner.tsx
@@ -5,6 +5,7 @@ import {
TRIAL_BANNER_TITLE,
TRIAL_BANNER_UPGRADE_LABEL,
} from './trialBannerModel';
+import { UpgradeLink } from './UpgradeLink';
import { useTrialBannerState } from './useTrialBannerState';
export const TrialBanner: Component = () => {
@@ -24,14 +25,12 @@ export const TrialBanner: Component = () => {
</div>
<Show when={state.showActions()}>
<div class="flex items-center gap-2">
- <a
+ <UpgradeLink
class="text-xs font-semibold underline underline-offset-2 hover:opacity-90"
- href={state.upgradeHref()}
- target="_blank"
- rel="noreferrer"
+ destination={state.upgradeDestination()}
>
{TRIAL_BANNER_UPGRADE_LABEL}
- </a>
+ </UpgradeLink>
<button
type="button"
class="text-xs opacity-70 hover:opacity-100"
diff --git a/frontend-modern/src/components/shared/UpgradeLink.tsx b/frontend-modern/src/components/shared/UpgradeLink.tsx
new file mode 100644
index 0000000000..634473783a
--- /dev/null
+++ b/frontend-modern/src/components/shared/UpgradeLink.tsx
@@ -0,0 +1,27 @@
+import { A } from '@solidjs/router';
+import { Show, splitProps, type Component, type JSX } from 'solid-js';
+import type { UpgradeDestination } from '@/utils/upgradeNavigation';
+
+type UpgradeLinkProps = Omit<JSX.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {
+ destination: UpgradeDestination;
+};
+
+export const UpgradeLink: Component<UpgradeLinkProps> = (props) => {
+ const [local, others] = splitProps(props, ['destination', 'rel', 'target']);
+
+ return (
+ <Show
+ when={local.destination.external}
+ fallback={<A {...others} href={local.destination.href} />}
+ >
+ <a
+ {...others}
+ href={local.destination.href}
+ target={local.target ?? '_blank'}
+ rel={local.rel ?? 'noopener noreferrer'}
+ />
+ </Show>
+ );
+};
+
+export default UpgradeLink;
diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
index 5bea5d5e54..6770ef99c0 100644
--- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
@@ -36,6 +36,7 @@ HTMLCanvasElement.prototype.getContext = vi.fn(() => ({
})) as unknown as typeof HTMLCanvasElement.prototype.getContext;
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: () => ({ href: 'https://example.com/upgrade', external: true }),
getUpgradeActionUrlOrFallback: () => 'https://example.com/upgrade',
isRangeLocked: () => false,
licenseStatus: () => ({ subscription_state: 'active' }),
diff --git a/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx b/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx
index df7b2891e6..26c053464e 100644
--- a/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx
@@ -1,4 +1,5 @@
import { cleanup, render, screen } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import monitoredSystemLimitWarningBannerSource from '@/components/shared/MonitoredSystemLimitWarningBanner.tsx?raw';
import monitoredSystemLimitWarningBannerModelSource from '@/components/shared/monitoredSystemLimitWarningBannerModel.ts?raw';
@@ -30,11 +31,13 @@ const mockLegacyConnections = vi.hoisted(() =>
const mockTrackUpgradeMetricEvent = vi.hoisted(() => vi.fn());
const mockTrackUpgradeClicked = vi.hoisted(() => vi.fn());
const mockLoadLicenseStatus = vi.hoisted(() => vi.fn());
+const mockGetUpgradeActionDestination = vi.hoisted(() => vi.fn());
const mockGetUpgradeActionUrlOrFallback = vi.hoisted(() => vi.fn());
vi.mock('@/stores/license', () => ({
entitlements: mockEntitlements,
getLimit: mockGetLimit,
+ getUpgradeActionDestination: (...args: unknown[]) => mockGetUpgradeActionDestination(...args),
getUpgradeActionUrlOrFallback: (...args: unknown[]) => mockGetUpgradeActionUrlOrFallback(...args),
hasMigrationGap: mockHasMigrationGap,
legacyConnections: mockLegacyConnections,
@@ -62,7 +65,12 @@ describe('MonitoredSystemLimitWarningBanner', () => {
});
mockLoadLicenseStatus.mockReset();
mockLoadLicenseStatus.mockResolvedValue(undefined);
+ mockGetUpgradeActionDestination.mockReset();
mockGetUpgradeActionUrlOrFallback.mockReset();
+ mockGetUpgradeActionDestination.mockReturnValue({
+ href: '/settings/system/billing',
+ external: false,
+ });
mockGetUpgradeActionUrlOrFallback.mockReturnValue('/settings/system/billing');
});
@@ -115,7 +123,11 @@ describe('MonitoredSystemLimitWarningBanner', () => {
it('stays hidden for non-urgent pure v6 installs', async () => {
const mod = await import('../MonitoredSystemLimitWarningBanner');
- render(() => <mod.MonitoredSystemLimitWarningBanner />);
+ render(() => (
+ <Router>
+ <Route path="/" component={mod.MonitoredSystemLimitWarningBanner} />
+ </Router>
+ ));
expect(mockLoadLicenseStatus).toHaveBeenCalled();
expect(screen.queryByText(/Monitored systems:/i)).not.toBeInTheDocument();
@@ -130,7 +142,11 @@ describe('MonitoredSystemLimitWarningBanner', () => {
});
const mod = await import('../MonitoredSystemLimitWarningBanner');
- render(() => <mod.MonitoredSystemLimitWarningBanner />);
+ render(() => (
+ <Router>
+ <Route path="/" component={mod.MonitoredSystemLimitWarningBanner} />
+ </Router>
+ ));
expect(screen.queryByText(/Monitored systems:/i)).not.toBeInTheDocument();
});
@@ -139,7 +155,11 @@ describe('MonitoredSystemLimitWarningBanner', () => {
mockGetLimit.mockReturnValue({ key: 'max_monitored_systems', limit: 6, current: 5, state: 'warning' });
const mod = await import('../MonitoredSystemLimitWarningBanner');
- render(() => <mod.MonitoredSystemLimitWarningBanner />);
+ render(() => (
+ <Router>
+ <Route path="/" component={mod.MonitoredSystemLimitWarningBanner} />
+ </Router>
+ ));
expect(screen.getByText('Monitored systems: 5/6')).toBeInTheDocument();
expect(screen.getByText('Upgrade to add more')).toBeInTheDocument();
@@ -158,7 +178,11 @@ describe('MonitoredSystemLimitWarningBanner', () => {
});
const mod = await import('../MonitoredSystemLimitWarningBanner');
- render(() => <mod.MonitoredSystemLimitWarningBanner />);
+ render(() => (
+ <Router>
+ <Route path="/" component={mod.MonitoredSystemLimitWarningBanner} />
+ </Router>
+ ));
expect(screen.getByText('Monitored systems: 5/6')).toBeInTheDocument();
expect(
diff --git a/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx b/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx
index 1bc4de2566..2b2dd3e641 100644
--- a/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx
@@ -7,8 +7,16 @@ import trialBannerStateSource from '@/components/shared/useTrialBannerState.ts?r
import { TRIAL_BANNER_SNOOZE_KEY } from '@/components/shared/trialBannerModel';
import { getPublicPricingUrl } from '@/utils/pricingHandoff';
-const { getUpgradeActionUrlOrFallbackMock, licenseStatusMock, loadLicenseStatusMock, isUpsellSnoozedMock, snoozeUpsellMock } =
+const {
+ getUpgradeActionDestinationMock,
+ getUpgradeActionUrlOrFallbackMock,
+ licenseStatusMock,
+ loadLicenseStatusMock,
+ isUpsellSnoozedMock,
+ snoozeUpsellMock,
+} =
vi.hoisted(() => ({
+ getUpgradeActionDestinationMock: vi.fn(),
getUpgradeActionUrlOrFallbackMock: vi.fn(),
licenseStatusMock: vi.fn(),
loadLicenseStatusMock: vi.fn(),
@@ -17,6 +25,7 @@ const { getUpgradeActionUrlOrFallbackMock, licenseStatusMock, loadLicenseStatusM
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (...args: unknown[]) => getUpgradeActionDestinationMock(...args),
getUpgradeActionUrlOrFallback: (...args: unknown[]) => getUpgradeActionUrlOrFallbackMock(...args),
licenseStatus: (...args: unknown[]) => licenseStatusMock(...args),
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
@@ -30,11 +39,16 @@ vi.mock('@/utils/snooze', () => ({
describe('TrialBanner', () => {
beforeEach(() => {
cleanup();
+ getUpgradeActionDestinationMock.mockReset();
getUpgradeActionUrlOrFallbackMock.mockReset();
licenseStatusMock.mockReset();
loadLicenseStatusMock.mockReset();
isUpsellSnoozedMock.mockReset();
snoozeUpsellMock.mockReset();
+ getUpgradeActionDestinationMock.mockReturnValue({
+ href: getPublicPricingUrl('trial_banner'),
+ external: true,
+ });
getUpgradeActionUrlOrFallbackMock.mockReturnValue(getPublicPricingUrl('trial_banner'));
loadLicenseStatusMock.mockResolvedValue(undefined);
isUpsellSnoozedMock.mockReturnValue(false);
@@ -58,7 +72,7 @@ describe('TrialBanner', () => {
expect(trialBannerStateSource).toContain('createMemo');
expect(trialBannerStateSource).toContain('loadLicenseStatus');
expect(trialBannerStateSource).toContain('licenseStatus');
- expect(trialBannerStateSource).toContain('getUpgradeActionUrlOrFallback');
+ expect(trialBannerStateSource).toContain('getUpgradeActionDestination');
expect(trialBannerStateSource).toContain('snoozeUpsell');
expect(trialBannerModelSource).toContain('TRIAL_BANNER_SNOOZE_KEY');
diff --git a/frontend-modern/src/components/shared/__tests__/UpgradeLink.test.tsx b/frontend-modern/src/components/shared/__tests__/UpgradeLink.test.tsx
new file mode 100644
index 0000000000..70ccbfddc2
--- /dev/null
+++ b/frontend-modern/src/components/shared/__tests__/UpgradeLink.test.tsx
@@ -0,0 +1,55 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
+import { afterEach, describe, expect, it } from 'vitest';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
+
+describe('UpgradeLink', () => {
+ afterEach(() => {
+ cleanup();
+ window.history.replaceState({}, '', '/');
+ });
+
+ it('renders internal upgrade destinations as in-app links', () => {
+ render(() => (
+ <Router>
+ <Route
+ path="/"
+ component={() => (
+ <UpgradeLink destination={{ href: '/settings/system/billing', external: false }}>
+ Billing
+ </UpgradeLink>
+ )}
+ />
+ </Router>
+ ));
+
+ const link = screen.getByRole('link', { name: 'Billing' });
+ expect(link).toHaveAttribute('href', '/settings/system/billing');
+ expect(link).not.toHaveAttribute('target');
+ });
+
+ it('renders external upgrade destinations as safe new-tab links', () => {
+ render(() => (
+ <Router>
+ <Route
+ path="/"
+ component={() => (
+ <UpgradeLink
+ destination={{
+ href: 'https://pulserelay.pro/pricing?feature=relay',
+ external: true,
+ }}
+ >
+ Upgrade
+ </UpgradeLink>
+ )}
+ />
+ </Router>
+ ));
+
+ const link = screen.getByRole('link', { name: 'Upgrade' });
+ expect(link).toHaveAttribute('href', 'https://pulserelay.pro/pricing?feature=relay');
+ expect(link).toHaveAttribute('target', '_blank');
+ expect(link).toHaveAttribute('rel', 'noopener noreferrer');
+ });
+});
diff --git a/frontend-modern/src/components/shared/useHistoryChartState.ts b/frontend-modern/src/components/shared/useHistoryChartState.ts
index 78674ac2d4..572cb87dd7 100644
--- a/frontend-modern/src/components/shared/useHistoryChartState.ts
+++ b/frontend-modern/src/components/shared/useHistoryChartState.ts
@@ -7,7 +7,7 @@ import {
} from 'solid-js';
import { ChartsAPI, type HistoryTimeRange } from '@/api/charts';
import {
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
isRangeLocked,
licenseStatus,
loadLicenseStatus,
@@ -387,7 +387,7 @@ export function useHistoryChartState(props: HistoryChartProps, refs: HistoryChar
dataMax,
dataMin,
error,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
handleMouseLeave,
handleMouseMove,
handleStartTrial,
diff --git a/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts b/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts
index 4b8b1a2d94..034e365b01 100644
--- a/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts
+++ b/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts
@@ -2,7 +2,7 @@ import { createEffect, createMemo, onMount } from 'solid-js';
import {
entitlements,
getLimit,
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasMigrationGap,
legacyConnections,
loadLicenseStatus,
@@ -46,8 +46,8 @@ export function useMonitoredSystemLimitWarningBannerState() {
const migrationTextClass = createMemo(() =>
getMonitoredSystemMigrationTextClass(isUrgent()),
);
- const upgradeHref = createMemo(() =>
- getUpgradeActionUrlOrFallback(MONITORED_SYSTEM_LIMIT_KEY),
+ const upgradeDestination = createMemo(() =>
+ getUpgradeActionDestination(MONITORED_SYSTEM_LIMIT_KEY),
);
let wasUrgent = false;
@@ -88,6 +88,6 @@ export function useMonitoredSystemLimitWarningBannerState() {
overflowSummary,
showBanner,
toneClass,
- upgradeHref,
+ upgradeDestination,
};
}
diff --git a/frontend-modern/src/components/shared/useTrialBannerState.ts b/frontend-modern/src/components/shared/useTrialBannerState.ts
index 3f56ad2871..f374a32c8e 100644
--- a/frontend-modern/src/components/shared/useTrialBannerState.ts
+++ b/frontend-modern/src/components/shared/useTrialBannerState.ts
@@ -1,5 +1,5 @@
import { createMemo, createSignal, onMount } from 'solid-js';
-import { getUpgradeActionUrlOrFallback, licenseStatus, loadLicenseStatus } from '@/stores/license';
+import { getUpgradeActionDestination, licenseStatus, loadLicenseStatus } from '@/stores/license';
import { isUpsellSnoozed, snoozeUpsell } from '@/utils/snooze';
import {
getTrialBannerToneClass,
@@ -20,8 +20,8 @@ export function useTrialBannerState() {
normalizeTrialBannerDaysRemaining(licenseStatus()?.trial_days_remaining),
);
const toneClass = createMemo(() => getTrialBannerToneClass(daysRemaining()));
- const upgradeHref = createMemo(() =>
- getUpgradeActionUrlOrFallback(TRIAL_BANNER_UPGRADE_REASON),
+ const upgradeDestination = createMemo(() =>
+ getUpgradeActionDestination(TRIAL_BANNER_UPGRADE_REASON),
);
const handleSnooze = () => {
@@ -35,6 +35,6 @@ export function useTrialBannerState() {
isTrial,
showActions: () => !snoozed(),
toneClass,
- upgradeHref,
+ upgradeDestination,
};
}
diff --git a/frontend-modern/src/components/shared/useUpgradeNavigation.ts b/frontend-modern/src/components/shared/useUpgradeNavigation.ts
new file mode 100644
index 0000000000..495d252369
--- /dev/null
+++ b/frontend-modern/src/components/shared/useUpgradeNavigation.ts
@@ -0,0 +1,13 @@
+import { useNavigate } from '@solidjs/router';
+import {
+ navigateToUpgradeDestination,
+ type UpgradeDestination,
+} from '@/utils/upgradeNavigation';
+
+export function useUpgradeNavigation() {
+ const navigate = useNavigate();
+
+ return (destination: UpgradeDestination) => {
+ navigateToUpgradeDestination(destination, navigate);
+ };
+}
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
index 8269b567f6..c9cf30f0d2 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
@@ -2,6 +2,7 @@ import { Show } from 'solid-js';
import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
import SettingsIcon from 'lucide-solid/icons/settings';
import SparklesIcon from 'lucide-solid/icons/sparkles';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { formatRelativeTime } from '@/utils/format';
import { trackUpgradeClicked } from '@/utils/upgradeMetrics';
import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
@@ -39,15 +40,13 @@ export function PatrolIntelligenceBanners(props: { state: PatrolIntelligenceStat
<div class="flex-shrink-0 bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-3 py-2">
<div class="flex flex-wrap items-center justify-between gap-2">
<p class="text-xs text-blue-700 dark:text-blue-300">
- <a
+ <UpgradeLink
class="text-indigo-600 dark:text-indigo-400 font-semibold hover:underline"
- href={state.upgradeUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ destination={state.upgradeDestination()}
onClick={() => trackUpgradeClicked('ai_intelligence_banner', 'ai_autofix')}
>
Upgrade to Pro
- </a>{' '}
+ </UpgradeLink>{' '}
to unlock automatic fixes and alert-triggered analysis.
</p>
</div>
@@ -84,15 +83,13 @@ export function PatrolIntelligenceBanners(props: { state: PatrolIntelligenceStat
Open AI Settings
</a>
<Show when={state.licenseRequired()}>
- <a
- href={state.upgradeUrl()}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={state.upgradeDestination()}
class="inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-semibold text-white bg-amber-600 hover:bg-amber-700 rounded-md transition-colors"
>
<SparklesIcon class="w-3.5 h-3.5" />
Upgrade
- </a>
+ </UpgradeLink>
</Show>
</div>
</div>
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
index fb216ac9e9..1c4b54603d 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
@@ -6,6 +6,7 @@ import XIcon from 'lucide-solid/icons/x';
import SettingsIcon from 'lucide-solid/icons/settings';
import { PulsePatrolLogo } from '@/components/Brand/PulsePatrolLogo';
import { PageHeader } from '@/components/shared/PageHeader';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { Toggle, TogglePrimitive } from '@/components/shared/Toggle';
import { CountdownTimer } from '@/components/patrol';
import { formatRelativeTime } from '@/utils/format';
@@ -287,13 +288,12 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState
</div>
<Show when={state.autoFixLocked()}>
<div class="pl-1 text-[11px] text-slate-500">
- <a
- href={state.upgradeUrl()}
- target="_blank"
+ <UpgradeLink
+ destination={state.upgradeDestination()}
class="text-indigo-500 font-medium hover:underline"
>
Upgrade to Pro
- </a>{' '}
+ </UpgradeLink>{' '}
to unlock investigation and auto-fix.
<Show when={state.canStartTrial()}>
{' '}
@@ -331,13 +331,12 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState
<Show when={state.alertAnalysisLocked()}>
<div class="-my-1 pl-1 text-[11px]">
- <a
- href={state.alertAnalysisUpgradeUrl()}
- target="_blank"
+ <UpgradeLink
+ destination={state.alertAnalysisUpgradeDestination()}
class="text-indigo-500 font-medium hover:underline"
>
Upgrade
- </a>{' '}
+ </UpgradeLink>{' '}
to enable.
<Show when={state.canStartTrial()}>
<button
diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
index 10910dec53..968645a934 100644
--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
@@ -23,7 +23,7 @@ import { notificationStore } from '@/stores/notifications';
import { hasTriggeringAlert } from '@/utils/findingAlertIdentity';
import { usePatrolStream } from '@/hooks/usePatrolStream';
import {
- getUpgradeActionUrlOrFallback,
+ getUpgradeActionDestination,
hasFeature,
licenseStatus,
loadLicenseStatus,
@@ -394,8 +394,10 @@ export function usePatrolIntelligenceState() {
);
const licenseRequired = createMemo(() => patrolStatus()?.license_required ?? false);
- const upgradeUrl = createMemo(() => getUpgradeActionUrlOrFallback('ai_autofix'));
- const alertAnalysisUpgradeUrl = createMemo(() => getUpgradeActionUrlOrFallback('ai_alerts'));
+ const upgradeDestination = createMemo(() => getUpgradeActionDestination('ai_autofix'));
+ const alertAnalysisUpgradeDestination = createMemo(() =>
+ getUpgradeActionDestination('ai_alerts'),
+ );
const runtimeState = createMemo<PatrolRuntimeState>(() => {
if (!patrolEnabledLocal()) return 'disabled';
return patrolStatus()?.runtime_state ?? 'active';
@@ -706,7 +708,7 @@ export function usePatrolIntelligenceState() {
activeTab,
activePatrolFindings,
activityRefreshTrigger,
- alertAnalysisUpgradeUrl,
+ alertAnalysisUpgradeDestination,
alertAnalysisLocked,
alertTriggeredAnalysis,
autonomyLevel,
@@ -782,7 +784,7 @@ export function usePatrolIntelligenceState() {
startingTrial,
summaryStats,
triggerPatrolDisabledReason,
- upgradeUrl,
+ upgradeDestination,
};
}
diff --git a/frontend-modern/src/pages/HostedSignup.tsx b/frontend-modern/src/pages/HostedSignup.tsx
index 43e22a3a9c..79c1afb62d 100644
--- a/frontend-modern/src/pages/HostedSignup.tsx
+++ b/frontend-modern/src/pages/HostedSignup.tsx
@@ -2,8 +2,9 @@ import { For, Show, createMemo, createSignal } from 'solid-js';
import { useLocation } from '@solidjs/router';
import { Card } from '@/components/shared/Card';
import { PageHeader } from '@/components/shared/PageHeader';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
import { HostedSignupAPI, type HostedAPIError } from '@/api/hostedSignup';
-import { getUpgradeActionUrlOrFallback } from '@/stores/license';
+import { getUpgradeActionDestination } from '@/stores/license';
import { logger } from '@/utils/logger';
import {
HOSTED_SIGNUP_PRESENTATION,
@@ -55,7 +56,7 @@ export default function HostedSignup() {
return getCloudPlanForTier(params.get('tier'));
});
const selectedPlanPrice = createMemo(() => getCloudPlanPricePresentation(selectedPlan()));
- const cloudPortalURL = createMemo(() => getUpgradeActionUrlOrFallback('cloud'));
+ const cloudPortalDestination = createMemo(() => getUpgradeActionDestination('cloud'));
const canSubmit = createMemo(() => {
return isValidEmail(email()) && orgName().trim().length >= 3 && status() !== 'submitting';
@@ -205,14 +206,12 @@ export default function HostedSignup() {
</Show>
<Show when={status() === 'unavailable'}>
- <a
- href={cloudPortalURL()}
- target="_blank"
- rel="noopener noreferrer"
+ <UpgradeLink
+ destination={cloudPortalDestination()}
class="inline-flex items-center text-sm font-medium text-blue-700 hover:underline dark:text-blue-300"
>
Open hosted signup portal
- </a>
+ </UpgradeLink>
</Show>
</Card>
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 73b13b0d6b..9f15c9cfbf 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -1,6 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
+import { getPublicPricingUrl } from '@/utils/pricingHandoff';
import { AIIntelligence } from '../AIIntelligence';
@@ -102,6 +103,7 @@ const hasFeatureMock = vi.fn();
const licenseStatusMock = vi.fn();
const loadLicenseStatusMock = vi.fn();
const startProTrialMock = vi.fn();
+const getUpgradeActionDestinationMock = vi.fn();
const getUpgradeActionUrlOrFallbackMock = vi.fn();
const trackPaywallViewedMock = vi.fn();
const trackUpgradeClickedMock = vi.fn();
@@ -127,6 +129,7 @@ vi.mock('@/utils/apiClient', () => ({
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: (...args: unknown[]) => getUpgradeActionDestinationMock(...args),
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
licenseStatus: (...args: unknown[]) => licenseStatusMock(...args),
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
@@ -317,6 +320,7 @@ describe('AIIntelligence entitlement gating', () => {
licenseStatusMock.mockReset();
loadLicenseStatusMock.mockReset();
startProTrialMock.mockReset();
+ getUpgradeActionDestinationMock.mockReset();
getUpgradeActionUrlOrFallbackMock.mockReset();
trackPaywallViewedMock.mockReset();
trackUpgradeClickedMock.mockReset();
@@ -364,8 +368,12 @@ describe('AIIntelligence entitlement gating', () => {
licenseStatusMock.mockReturnValue({ subscription_state: 'expired' });
loadLicenseStatusMock.mockResolvedValue(undefined);
startProTrialMock.mockResolvedValue({ outcome: 'started' });
+ getUpgradeActionDestinationMock.mockImplementation((feature?: string) => ({
+ href: getPublicPricingUrl(feature),
+ external: true,
+ }));
getUpgradeActionUrlOrFallbackMock.mockImplementation(
- (feature?: string) => `/upgrade${feature ? `?feature=${feature}` : ''}`,
+ (feature?: string) => getPublicPricingUrl(feature),
);
getCorrelationsMock.mockResolvedValue({
correlations: [],
@@ -504,11 +512,11 @@ describe('AIIntelligence entitlement gating', () => {
expect(
screen
.getAllByRole('link', { name: 'Upgrade to Pro' })
- .some((link) => link.getAttribute('href') === '/upgrade?feature=ai_autofix'),
+ .some((link) => link.getAttribute('href') === getPublicPricingUrl('ai_autofix')),
).toBe(true);
expect(screen.getByRole('link', { name: 'Upgrade' })).toHaveAttribute(
'href',
- '/upgrade?feature=ai_alerts',
+ getPublicPricingUrl('ai_alerts'),
);
await waitFor(() => {
diff --git a/frontend-modern/src/pages/__tests__/HostedSignup.test.tsx b/frontend-modern/src/pages/__tests__/HostedSignup.test.tsx
index d644168c91..3d15962a61 100644
--- a/frontend-modern/src/pages/__tests__/HostedSignup.test.tsx
+++ b/frontend-modern/src/pages/__tests__/HostedSignup.test.tsx
@@ -15,6 +15,7 @@ vi.mock('@/api/hostedSignup', () => ({
}));
vi.mock('@/stores/license', () => ({
+ getUpgradeActionDestination: () => ({ href: '/cloud', external: false }),
getUpgradeActionUrlOrFallback: () => 'https://cloud.pulserelay.pro',
}));
diff --git a/frontend-modern/src/stores/license.ts b/frontend-modern/src/stores/license.ts
index 09adf17af9..fb3a235bb6 100644
--- a/frontend-modern/src/stores/license.ts
+++ b/frontend-modern/src/stores/license.ts
@@ -10,6 +10,10 @@ import {
getInProductPricingDestination,
getUpgradeFallbackDestination,
} from '@/utils/pricingHandoff';
+import {
+ resolveUpgradeDestination,
+ type UpgradeDestination,
+} from '@/utils/upgradeNavigation';
// Reactive signals for entitlements (canonical gating source).
const [entitlements, setEntitlements] = createSignal<LicenseEntitlements | null>(null);
@@ -187,15 +191,19 @@ export function getFirstUpgradeActionUrl(): string | undefined {
return current?.upgrade_reasons?.[0]?.action_url;
}
-export function getUpgradeActionUrlOrFallback(key: string): string {
- return (
+export function getUpgradeActionDestination(key: string): UpgradeDestination {
+ return resolveUpgradeDestination(
getUpgradeActionUrl(key) ||
- getInProductPricingDestination(key) ||
- getFirstUpgradeActionUrl() ||
- getUpgradeFallbackDestination(key)
+ getInProductPricingDestination(key) ||
+ getFirstUpgradeActionUrl() ||
+ getUpgradeFallbackDestination(key),
);
}
+export function getUpgradeActionUrlOrFallback(key: string): string {
+ return getUpgradeActionDestination(key).href;
+}
+
export function getLimit(key: string) {
const current = entitlements();
if (!current?.limits?.length) return undefined;
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 1460f29fc7..ce8c961bae 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -58,6 +58,7 @@ import tooltipSource from '@/components/shared/Tooltip.tsx?raw';
import tooltipModelSource from '@/components/shared/tooltipModel.ts?raw';
import trialBannerSource from '@/components/shared/TrialBanner.tsx?raw';
import trialBannerModelSource from '@/components/shared/trialBannerModel.ts?raw';
+import upgradeLinkSource from '@/components/shared/UpgradeLink.tsx?raw';
import monitoredSystemLimitWarningBannerSource from '@/components/shared/MonitoredSystemLimitWarningBanner.tsx?raw';
import monitoredSystemLimitWarningBannerModelSource from '@/components/shared/monitoredSystemLimitWarningBannerModel.ts?raw';
import monitoredSystemLedgerPanelSource from '@/components/Settings/MonitoredSystemLedgerPanel.tsx?raw';
@@ -93,6 +94,7 @@ import toggleStateSource from '@/components/shared/useToggleState.ts?raw';
import searchTipsPopoverStateSource from '@/components/shared/useSearchTipsPopoverState.ts?raw';
import tooltipStateSource from '@/components/shared/useTooltipState.ts?raw';
import trialBannerStateSource from '@/components/shared/useTrialBannerState.ts?raw';
+import upgradeNavigationHookSource from '@/components/shared/useUpgradeNavigation.ts?raw';
import interactiveSparklineStateSource from '@/components/shared/useInteractiveSparklineState.ts?raw';
import monitoredSystemLimitWarningBannerStateSource from '@/components/shared/useMonitoredSystemLimitWarningBannerState.ts?raw';
import infrastructureSummaryTableStateSource from '@/components/shared/useInfrastructureSummaryTableState.ts?raw';
@@ -118,6 +120,7 @@ import reportingPanelModelSource from '@/components/Settings/reportingPanelModel
import reportingPanelStateSource from '@/components/Settings/useReportingPanelState.ts?raw';
import updatesSettingsModelSource from '@/components/Settings/updatesSettingsModel.ts?raw';
import diagnosticsModelSource from '@/components/Settings/diagnosticsModel.ts?raw';
+import upgradeNavigationSource from '@/utils/upgradeNavigation.ts?raw';
import diagnosticsResultsPanelSource from '@/components/Settings/DiagnosticsResultsPanel.tsx?raw';
import diagnosticsStateSource from '@/components/Settings/useDiagnosticsPanelState.ts?raw';
import settingsShellSource from '@/components/Settings/Settings.tsx?raw';
@@ -1010,7 +1013,7 @@ describe('frontend resource type boundaries', () => {
);
expect(resourceDetailDrawerStateSource).not.toContain('createResource(');
expect(resourceDetailDrawerStateSource).not.toContain('MonitoringAPI.');
- expect(resourceDetailDrawerHistoryStateSource).toContain('createResource(');
+ expect(resourceDetailDrawerHistoryStateSource).toContain('createNonSuspendingQuery');
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from '@/components/Infrastructure/resourceDetailDiscoveryModel'",
);
@@ -2052,7 +2055,8 @@ describe('frontend resource type boundaries', () => {
expect(storageContentCardSource).toContain('useStorageContentCardModel');
expect(storageContentCardSource).toContain('DiskList');
expect(storageContentCardSource).toContain('StoragePoolsTable');
- expect(storageContentCardSource).toContain('STORAGE_CONTENT_CARD_HEADER_CLASS');
+ expect(storageContentCardSource).toContain('SummaryTableCardHeader');
+ expect(storageContentCardSource).toContain('STORAGE_CONTENT_CARD_BODY_CLASS');
expect(storageContentCardSource).not.toContain(
"props.selectedNodeId() === 'all' ? null : props.selectedNodeId()",
);
@@ -2853,13 +2857,23 @@ describe('frontend resource type boundaries', () => {
expect(trialBannerStateSource).toContain('createMemo');
expect(trialBannerStateSource).toContain('loadLicenseStatus');
expect(trialBannerStateSource).toContain('licenseStatus');
- expect(trialBannerStateSource).toContain('getUpgradeActionUrlOrFallback');
+ expect(trialBannerStateSource).toContain('getUpgradeActionDestination');
expect(trialBannerStateSource).toContain('snoozeUpsell');
expect(trialBannerModelSource).toContain('TRIAL_BANNER_SNOOZE_KEY');
expect(trialBannerModelSource).toContain('normalizeTrialBannerDaysRemaining');
expect(trialBannerModelSource).toContain('getTrialBannerToneClass');
expect(trialBannerModelSource).toContain('getTrialBannerStatusLabel');
expect(trialBannerModelSource).toContain('TRIAL_BANNER_UPGRADE_LABEL');
+ expect(upgradeLinkSource).toContain('destination.external');
+ expect(upgradeLinkSource).not.toContain('window.open');
+ expect(upgradeLinkSource).not.toContain('useNavigate(');
+ expect(upgradeNavigationHookSource).toContain('useNavigate()');
+ expect(upgradeNavigationHookSource).toContain('navigateToUpgradeDestination');
+ expect(upgradeNavigationHookSource).not.toContain('window.open');
+ expect(upgradeNavigationSource).toContain('isExternalUpgradeHref');
+ expect(upgradeNavigationSource).toContain('resolveUpgradeDestination');
+ expect(upgradeNavigationSource).toContain('navigateToUpgradeDestination');
+ expect(upgradeNavigationSource).toContain("window.open(href, '_blank', 'noopener,noreferrer')");
expect(columnPickerSource).toContain('useColumnPickerState');
expect(columnPickerSource).toContain('COLUMN_PICKER_PANEL_TITLE');
expect(columnPickerSource).not.toContain('createSignal');
@@ -3262,7 +3276,8 @@ describe('frontend resource type boundaries', () => {
expect(unifiedResourceTableModelSource).toContain('export const getOutlierEmphasis');
expect(unifiedResourceTableViewportSyncSource).toContain('window.addEventListener');
expect(unifiedResourceTableViewportSyncSource).toContain('getBoundingClientRect');
- expect(unifiedResourceTableViewportSyncSource).toContain('scrollIntoView');
+ expect(unifiedResourceTableViewportSyncSource).toContain('hostWindowing.onScroll');
+ expect(unifiedResourceTableViewportSyncSource).not.toContain('scrollIntoView');
expect(exploreStatusBlockSource).toContain('getAIExploreStatusPresentation');
expect(exploreStatusBlockSource).not.toContain('const phaseLabel =');
expect(exploreStatusBlockSource).not.toContain('const phaseClasses =');
diff --git a/frontend-modern/src/utils/__tests__/upgradeNavigation.test.ts b/frontend-modern/src/utils/__tests__/upgradeNavigation.test.ts
new file mode 100644
index 0000000000..749ba52222
--- /dev/null
+++ b/frontend-modern/src/utils/__tests__/upgradeNavigation.test.ts
@@ -0,0 +1,78 @@
+import { describe, expect, it, vi } from 'vitest';
+import {
+ isExternalUpgradeHref,
+ navigateToUpgradeDestination,
+ openExternalUpgradeDestination,
+ resolveUpgradeDestination,
+} from '@/utils/upgradeNavigation';
+
+describe('upgradeNavigation', () => {
+ it('classifies external upgrade hrefs without treating product routes as external', () => {
+ expect(isExternalUpgradeHref('https://pulserelay.pro/pricing')).toBe(true);
+ expect(isExternalUpgradeHref('http://127.0.0.1:3000/upgrade')).toBe(true);
+ expect(isExternalUpgradeHref('/settings/system/billing')).toBe(false);
+ expect(isExternalUpgradeHref(' /cloud ')).toBe(false);
+ expect(isExternalUpgradeHref('')).toBe(false);
+ expect(isExternalUpgradeHref(undefined)).toBe(false);
+ });
+
+ it('normalizes upgrade destinations and keeps the trimmed href', () => {
+ expect(resolveUpgradeDestination(' /cloud ')).toEqual({
+ href: '/cloud',
+ external: false,
+ });
+ expect(resolveUpgradeDestination(' https://pulserelay.pro/pricing ')).toEqual({
+ href: 'https://pulserelay.pro/pricing',
+ external: true,
+ });
+ });
+
+ it('routes internal destinations through the provided navigate callback', () => {
+ const navigate = vi.fn();
+ const openExternal = vi.fn();
+
+ navigateToUpgradeDestination({ href: '/settings/system/billing', external: false }, navigate, openExternal);
+
+ expect(navigate).toHaveBeenCalledWith('/settings/system/billing');
+ expect(openExternal).not.toHaveBeenCalled();
+ });
+
+ it('routes external destinations through the provided external opener', () => {
+ const navigate = vi.fn();
+ const openExternal = vi.fn();
+
+ navigateToUpgradeDestination(
+ { href: 'https://pulserelay.pro/pricing?feature=relay', external: true },
+ navigate,
+ openExternal,
+ );
+
+ expect(openExternal).toHaveBeenCalledWith(
+ 'https://pulserelay.pro/pricing?feature=relay',
+ );
+ expect(navigate).not.toHaveBeenCalled();
+ });
+
+ it('does nothing for empty destinations', () => {
+ const navigate = vi.fn();
+ const openExternal = vi.fn();
+
+ navigateToUpgradeDestination({ href: '', external: false }, navigate, openExternal);
+
+ expect(navigate).not.toHaveBeenCalled();
+ expect(openExternal).not.toHaveBeenCalled();
+ });
+
+ it('opens external upgrade destinations with a safe new-tab policy', () => {
+ const windowOpen = vi.fn();
+ vi.stubGlobal('window', { open: windowOpen });
+
+ openExternalUpgradeDestination('https://pulserelay.pro/pricing?feature=relay');
+
+ expect(windowOpen).toHaveBeenCalledWith(
+ 'https://pulserelay.pro/pricing?feature=relay',
+ '_blank',
+ 'noopener,noreferrer',
+ );
+ });
+});
diff --git a/frontend-modern/src/utils/pricingHandoff.ts b/frontend-modern/src/utils/pricingHandoff.ts
index fa2cdf0075..928624281c 100644
--- a/frontend-modern/src/utils/pricingHandoff.ts
+++ b/frontend-modern/src/utils/pricingHandoff.ts
@@ -1,3 +1,5 @@
+import { isExternalUpgradeHref } from '@/utils/upgradeNavigation';
+
const DEFAULT_PUBLIC_PRICING_URL =
'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade';
@@ -51,7 +53,7 @@ export function getPricingRouteDestination(search: string): string {
}
export function isExternalPricingDestination(destination: string): boolean {
- return /^https?:\/\//.test(destination);
+ return isExternalUpgradeHref(destination);
}
export function handoffToExternalPricing(destination: string): void {
diff --git a/frontend-modern/src/utils/upgradeNavigation.ts b/frontend-modern/src/utils/upgradeNavigation.ts
new file mode 100644
index 0000000000..112d7f8883
--- /dev/null
+++ b/frontend-modern/src/utils/upgradeNavigation.ts
@@ -0,0 +1,41 @@
+export interface UpgradeDestination {
+ href: string;
+ external: boolean;
+}
+
+function normalizeUpgradeHref(href: string | null | undefined): string {
+ return href?.trim() ?? '';
+}
+
+export function isExternalUpgradeHref(href: string | null | undefined): boolean {
+ const normalized = normalizeUpgradeHref(href);
+ return normalized !== '' && /^https?:\/\//.test(normalized);
+}
+
+export function resolveUpgradeDestination(
+ href: string | null | undefined,
+): UpgradeDestination {
+ const normalized = normalizeUpgradeHref(href);
+ return {
+ href: normalized,
+ external: isExternalUpgradeHref(normalized),
+ };
+}
+
+export function openExternalUpgradeDestination(href: string): void {
+ if (typeof window === 'undefined') return;
+ window.open(href, '_blank', 'noopener,noreferrer');
+}
+
+export function navigateToUpgradeDestination(
+ destination: UpgradeDestination,
+ navigate: (href: string) => void,
+ openExternal: (href: string) => void = openExternalUpgradeDestination,
+): void {
+ if (!destination.href) return;
+ if (destination.external) {
+ openExternal(destination.href);
+ return;
+ }
+ navigate(destination.href);
+}