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.

Align Pro settings trial CTA error handling

rcourtman2afd685877c1
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 44bfc8283a..2afcaf2813 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -237,6 +237,11 @@ copy must present the flow as starting a trial for the originating Pulse
instance, not as a generic purchase funnel. Recovery-contact fields such as
work email and optional company name must remain clearly secondary to the
instance-bound entitlement handoff.
+That same rule applies to the self-hosted Pro settings panel. Trial start
+errors in `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
+must route through the shared cloud-paid presentation helper so backend denial
+reasons, explicit already-used conflicts, and retry-later states stay aligned
+with the rest of the commercial surfaces.
redefined inline in settings feature gates, Pro license panels, or trial
upgrade nudges.
That same disclosure copy must stay professional and customer-facing. The
diff --git a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
index 62a30884bd..2646482f6a 100644
--- a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
@@ -412,6 +412,39 @@ describe('ProLicensePanel', () => {
});
});
+ it('maps explicit trial-already-used errors to the canonical message', async () => {
+ startProTrialMock.mockRejectedValue(
+ Object.assign(new Error('conflict'), {
+ status: 409,
+ code: 'trial_already_used',
+ }),
+ );
+
+ render(() => <ProLicensePanel />);
+
+ fireEvent.click(screen.getByRole('button', { name: /start 14-day pro trial/i }));
+
+ await waitFor(() => {
+ expect(notificationErrorMock).toHaveBeenCalledWith('Trial already used');
+ });
+ });
+
+ it('maps rate-limited trial starts to the canonical retry message', async () => {
+ startProTrialMock.mockRejectedValue(
+ Object.assign(new Error('rate limited'), {
+ status: 429,
+ }),
+ );
+
+ render(() => <ProLicensePanel />);
+
+ fireEvent.click(screen.getByRole('button', { name: /start 14-day pro trial/i }));
+
+ await waitFor(() => {
+ expect(notificationErrorMock).toHaveBeenCalledWith('Try again later');
+ });
+ });
+
it('keeps Pro license split into shell, runtime, and plan owners', () => {
expect(proLicensePanelSource).toContain('./useProLicensePanelState');
expect(proLicensePanelSource).toContain('./ProLicensePlanSection');
diff --git a/frontend-modern/src/components/Settings/useProLicensePanelState.ts b/frontend-modern/src/components/Settings/useProLicensePanelState.ts
index 906260020d..6e89287a37 100644
--- a/frontend-modern/src/components/Settings/useProLicensePanelState.ts
+++ b/frontend-modern/src/components/Settings/useProLicensePanelState.ts
@@ -11,9 +11,7 @@ import {
import { LicenseAPI } from '@/api/license';
import {
getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
getTrialStartErrorMessage,
- getTrialTryAgainLaterMessage,
} from '@/utils/upgradePresentation';
import {
formatLicensePlanVersion,
@@ -87,19 +85,7 @@ export function useProLicensePanelState() {
}
notificationStore.success(getProTrialStartedMessage());
} catch (error) {
- const trialError = error as { status?: number; code?: string; message?: string } | null;
- const statusCode = trialError?.status;
- if (statusCode === 409 && trialError?.code === 'trial_already_used') {
- notificationStore.error(getTrialAlreadyUsedMessage());
- } else if (statusCode === 429) {
- notificationStore.error(getTrialTryAgainLaterMessage());
- } else {
- notificationStore.error(
- getTrialStartErrorMessage(error instanceof Error ? error.message : undefined, {
- branded: true,
- }),
- );
- }
+ notificationStore.error(getTrialStartErrorMessage(error, { branded: true }));
} finally {
setStartingTrial(false);
}