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.

Unify trial CTA handling in shared UI primitives

rcourtman89c9f6f299d0
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index de4e4c6701..90a09e27f8 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -201,6 +201,12 @@ stream lifecycle, buffering, level updates, and download action. Future system
logs work must extend that split instead of pulling `EventSource`, API calls,
notification flow, or customer-facing system-log copy back into the panel
render shell.
+Shared trial CTA handling is now part of that same primitive boundary for
+settings and shared paywalls. Shared/settings runtime owners must derive trial
+eligibility from the canonical entitlements payload, including
+`trial_eligible`, and route operator-facing failure copy through
+`frontend-modern/src/utils/upgradePresentation.ts` instead of open-coding local
+409/429 branches that drift from backend denial reasons.
Top-level route files are now also expected to stay thin when a feature owns
the real product surface. `frontend-modern/src/pages/Infrastructure.tsx` now
acts only as the route boundary, while
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index e9a6ea6c4a..a983c2aae1 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -980,6 +980,8 @@ describe('Settings architecture guardrails', () => {
expect(aiSettingsStateSource).toContain('const handleSave = async (event?: Event) =>');
expect(aiSettingsStateSource).toContain('const handleEnabledToggle = async (newValue: boolean) =>');
expect(aiSettingsStateSource).toContain('AIAPI.getSettings()');
+ expect(aiSettingsStateSource).toContain('showWarning(getTrialStartErrorMessage(error));');
+ expect(aiSettingsStateSource).not.toContain('getTrialAlreadyUsedMessage()');
});
it('keeps the updates settings shell behind extracted install-guide owners', () => {
@@ -1035,6 +1037,8 @@ describe('Settings architecture guardrails', () => {
expect(reportingPanelStateSource).toContain('startProTrial');
expect(reportingPanelStateSource).toContain('buildReportingRequest');
expect(reportingPanelStateSource).toContain('getReportingGenerateSuccessMessage');
+ expect(reportingPanelStateSource).toContain('showWarning(getTrialStartErrorMessage(error));');
+ expect(reportingPanelStateSource).not.toContain('getTrialAlreadyUsedMessage()');
expect(reportingPanelModelSource).toContain('export function getReportingRangeStart');
expect(reportingPanelModelSource).toContain('export function buildReportingRequest');
expect(reportingPanelModelSource).toContain('export function buildReportingFilename');
@@ -1059,6 +1063,8 @@ describe('Settings architecture guardrails', () => {
expect(auditLogStateSource).toContain('const fetchAuditEvents = async (');
expect(auditLogStateSource).toContain('const verifyAllEvents = async (');
expect(auditLogStateSource).toContain('trackPaywallViewed');
+ expect(auditLogStateSource).toContain('showWarning(getTrialStartErrorMessage(err));');
+ expect(auditLogStateSource).not.toContain('getTrialAlreadyUsedMessage()');
});
it('keeps the audit webhook shell behind an extracted runtime owner', () => {
@@ -1072,6 +1078,8 @@ describe('Settings architecture guardrails', () => {
expect(auditWebhookStateSource).toContain('const fetchWebhooks = async () =>');
expect(auditWebhookStateSource).toContain('const saveWebhooks = async (urls: string[]) =>');
expect(auditWebhookStateSource).toContain('trackPaywallViewed');
+ expect(auditWebhookStateSource).toContain('showWarning(getTrialStartErrorMessage(error));');
+ expect(auditWebhookStateSource).not.toContain('getTrialAlreadyUsedMessage()');
});
it('keeps the SSO providers shell behind extracted runtime owners', () => {
@@ -1086,6 +1094,10 @@ describe('Settings architecture guardrails', () => {
expect(ssoProvidersStateSource).toContain('const loadProviders = async () =>');
expect(ssoProvidersStateSource).toContain('const handleSave = async (event?: Event) =>');
expect(ssoProvidersStateSource).toContain('const testConnection = async () =>');
+ expect(ssoProvidersStateSource).toContain(
+ 'notificationStore.error(getTrialStartErrorMessage(err));',
+ );
+ expect(ssoProvidersStateSource).not.toContain('getTrialAlreadyUsedMessage()');
expect(ssoProvidersModelSource).toContain('export const createEmptyProviderForm =');
expect(ssoProvidersModelSource).toContain('export const mapProviderDetailsToForm =');
expect(ssoProvidersModelSource).toContain('export const buildProviderPayload =');
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index cae567e4a6..30c198016b 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -41,7 +41,6 @@ import { showSuccess, showWarning } from '@/utils/toast';
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
} from '@/utils/upgradePresentation';
@@ -286,12 +285,7 @@ export const useAISettingsState = () => {
}
showSuccess(getProTrialStartedMessage());
} catch (error) {
- const statusCode = (error as { status?: number } | null)?.status;
- if (statusCode === 409) {
- showWarning(getTrialAlreadyUsedMessage());
- } else {
- showWarning(getTrialStartErrorMessage(error instanceof Error ? error.message : undefined));
- }
+ showWarning(getTrialStartErrorMessage(error));
} finally {
setStartingTrial(false);
}
diff --git a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
index c54a8a818a..c5c977cc36 100644
--- a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
@@ -18,7 +18,6 @@ import {
import { trackPaywallViewed, trackUpgradeClicked } from '@/utils/upgradeMetrics';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
} from '@/utils/upgradePresentation';
@@ -534,12 +533,7 @@ export const useAuditLogPanelState = () => {
}
showSuccess(getProTrialStartedMessage());
} catch (err) {
- const statusCode = (err as { status?: number } | null)?.status;
- if (statusCode === 409) {
- showWarning(getTrialAlreadyUsedMessage());
- } else {
- showWarning(getTrialStartErrorMessage(err instanceof Error ? err.message : undefined));
- }
+ showWarning(getTrialStartErrorMessage(err));
} finally {
setStartingTrial(false);
}
diff --git a/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts b/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
index a81412088d..8b4a15e863 100644
--- a/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
@@ -13,7 +13,6 @@ import {
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
} from '@/utils/upgradePresentation';
import {
@@ -46,12 +45,7 @@ export const useAuditWebhookPanelState = (canManageOverride?: boolean) => {
}
showSuccess(getProTrialStartedMessage());
} catch (error) {
- const statusCode = (error as { status?: number } | null)?.status;
- if (statusCode === 409) {
- showWarning(getTrialAlreadyUsedMessage());
- } else {
- showWarning(getTrialStartErrorMessage(error instanceof Error ? error.message : undefined));
- }
+ showWarning(getTrialStartErrorMessage(error));
} finally {
setStartingTrial(false);
}
diff --git a/frontend-modern/src/components/Settings/useReportingPanelState.ts b/frontend-modern/src/components/Settings/useReportingPanelState.ts
index f95e633781..c47a80f1e9 100644
--- a/frontend-modern/src/components/Settings/useReportingPanelState.ts
+++ b/frontend-modern/src/components/Settings/useReportingPanelState.ts
@@ -13,7 +13,6 @@ import {
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
} from '@/utils/upgradePresentation';
import {
@@ -65,12 +64,7 @@ export const useReportingPanelState = () => {
}
showSuccess(getProTrialStartedMessage());
} catch (error) {
- const statusCode = (error as { status?: number } | null)?.status;
- if (statusCode === 409) {
- showWarning(getTrialAlreadyUsedMessage());
- } else {
- showWarning(getTrialStartErrorMessage(error instanceof Error ? error.message : undefined));
- }
+ showWarning(getTrialStartErrorMessage(error));
} finally {
setStartingTrial(false);
}
diff --git a/frontend-modern/src/components/Settings/useSSOProvidersState.ts b/frontend-modern/src/components/Settings/useSSOProvidersState.ts
index d5421e5242..901ffdacda 100644
--- a/frontend-modern/src/components/Settings/useSSOProvidersState.ts
+++ b/frontend-modern/src/components/Settings/useSSOProvidersState.ts
@@ -30,7 +30,6 @@ import {
} from '@/utils/ssoProviderPresentation';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
} from '@/utils/upgradePresentation';
import type {
@@ -89,14 +88,7 @@ export const useSSOProvidersState = (props: SSOProvidersPanelProps) => {
}
notificationStore.success(getProTrialStartedMessage());
} catch (err) {
- const statusCode = (err as { status?: number } | null)?.status;
- if (statusCode === 409) {
- notificationStore.error(getTrialAlreadyUsedMessage());
- } else {
- notificationStore.error(
- getTrialStartErrorMessage(err instanceof Error ? err.message : undefined),
- );
- }
+ notificationStore.error(getTrialStartErrorMessage(err));
} finally {
setStartingTrial(false);
}
diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
index bc01b5c55c..a6807c0ea4 100644
--- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
@@ -68,6 +68,12 @@ describe('HistoryChart', () => {
expect(historyChartStateSource).toContain('setupCanvasDPR');
expect(historyChartStateSource).toContain('export function useHistoryChartState');
expect(historyChartStateSource).toContain('HISTORY_CHART_RANGES');
+ expect(historyChartStateSource).toContain('return ent.trial_eligible !== false;');
+ expect(historyChartStateSource).toContain(
+ 'notificationStore.error(getTrialStartErrorMessage(err, { branded: true }));',
+ );
+ expect(historyChartStateSource).not.toContain('getTrialAlreadyUsedMessage()');
+ expect(historyChartStateSource).not.toContain('getTrialTryAgainLaterMessage()');
expect(historyChartModelSource).toContain('formatHistoryChartTooltipValue');
expect(historyChartModelSource).toContain('HISTORY_CHART_RANGES');
diff --git a/frontend-modern/src/components/shared/useHistoryChartState.ts b/frontend-modern/src/components/shared/useHistoryChartState.ts
index 59eb727fa2..b34d2b047b 100644
--- a/frontend-modern/src/components/shared/useHistoryChartState.ts
+++ b/frontend-modern/src/components/shared/useHistoryChartState.ts
@@ -20,9 +20,7 @@ import { trackPaywallViewed, trackUpgradeClicked } from '@/utils/upgradeMetrics'
import { notificationStore } from '@/stores/notifications';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
- getTrialTryAgainLaterMessage,
} from '@/utils/upgradePresentation';
import {
HISTORY_CHART_RANGES,
@@ -58,9 +56,10 @@ export function useHistoryChartState(props: HistoryChartProps, refs: HistoryChar
const [hoveredPoint, setHoveredPoint] = createSignal<HistoryChartHoverPoint | null>(null);
const canStartTrial = createMemo(() => {
- const state = licenseStatus()?.subscription_state;
- if (!state) return false;
- return state !== 'active' && state !== 'trial';
+ const ent = licenseStatus();
+ if (!ent) return false;
+ if (ent.subscription_state === 'active' || ent.subscription_state === 'trial') return false;
+ return ent.trial_eligible !== false;
});
const handleStartTrial = async () => {
@@ -76,18 +75,7 @@ export function useHistoryChartState(props: HistoryChartProps, refs: HistoryChar
}
notificationStore.success(getProTrialStartedMessage());
} catch (err) {
- const statusCode = (err as { status?: number } | null)?.status;
- if (statusCode === 409) {
- notificationStore.error(getTrialAlreadyUsedMessage());
- } else if (statusCode === 429) {
- notificationStore.error(getTrialTryAgainLaterMessage());
- } else {
- notificationStore.error(
- getTrialStartErrorMessage(err instanceof Error ? err.message : undefined, {
- branded: true,
- }),
- );
- }
+ notificationStore.error(getTrialStartErrorMessage(err, { branded: true }));
} finally {
setStartingTrial(false);
}