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.

Consolidate settings paywalls into a shared FeatureGateSection

rcourtman4cf737197670
diff --git a/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx b/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx
index c7f75cb96c..7a64c07281 100644
--- a/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx
+++ b/frontend-modern/src/components/Settings/AuditWebhookPanel.tsx
@@ -6,7 +6,7 @@ import Trash2 from 'lucide-solid/icons/trash-2';
import ExternalLink from 'lucide-solid/icons/external-link';
import { Card } from '@/components/shared/Card';
import { Dialog } from '@/components/shared/Dialog';
-import { UpgradeLink } from '@/components/shared/UpgradeLink';
+import { FeatureGateSection } from '@/components/shared/FeatureGateSection';
import SettingsPanel from '@/components/shared/SettingsPanel';
import { formControl } from '@/components/shared/Form';
import {
@@ -19,7 +19,6 @@ import {
getAuditWebhookFeatureGateCopy,
getAuditWebhookLoadingState,
} from '@/utils/auditWebhookPresentation';
-import { getUpgradeActionButtonClass } from '@/utils/upgradePresentation';
import { useAuditWebhookPanelState } from '@/components/Settings/useAuditWebhookPanelState';
interface AuditWebhookPanelProps {
@@ -56,24 +55,14 @@ export const AuditWebhookPanel: Component<AuditWebhookPanelProps> = (props) => {
<SettingsPanel title="Audit Webhooks">
<Show when={!loading()} fallback={<div class="text-sm text-muted">Loading...</div>}>
<Card tone="info" padding="md">
- <div class="flex flex-col sm:flex-row items-center gap-4">
- <div class="flex-1 text-center sm:text-left">
- <p class="font-semibold text-base-content">{featureGateCopy().title}</p>
- <p class="mt-1 text-sm text-muted">{featureGateCopy().body}</p>
- </div>
- <Show when={showFeatureGateAction()}>
- <div class="flex flex-col sm:flex-row items-center gap-2">
- <UpgradeLink
- destination={upgradeDestination()}
- class={getUpgradeActionButtonClass({
- tone: paidRuntimeRequired() ? 'warning' : 'primary',
- })}
- >
- {upgradeActionLabel()}
- </UpgradeLink>
- </div>
- </Show>
- </div>
+ <FeatureGateSection
+ title={featureGateCopy().title}
+ body={featureGateCopy().body}
+ upgradeDestination={upgradeDestination()}
+ showUpgradePrompts={showFeatureGateAction()}
+ upgradeLabel={upgradeActionLabel()}
+ upgradeButtonTone={paidRuntimeRequired() ? 'warning' : 'primary'}
+ />
</Card>
</Show>
</SettingsPanel>
diff --git a/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx b/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx
index 858b485644..f249fac522 100644
--- a/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx
+++ b/frontend-modern/src/components/Settings/RBACFeatureGateSection.tsx
@@ -1,11 +1,7 @@
-import { Component, Show } from 'solid-js';
-import { UpgradeLink } from '@/components/shared/UpgradeLink';
+import { Component } from 'solid-js';
+import { FeatureGateSection } from '@/components/shared/FeatureGateSection';
import { getUpgradeActionDestination } from '@/stores/licenseCommercial';
import type { RBACFeatureGateCopy } from '@/utils/rbacPresentation';
-import {
- getUpgradeActionButtonClass,
- UPGRADE_ACTION_LABEL,
-} from '@/utils/upgradePresentation';
import type { RBACFeatureGateLocation } from './useRBACFeatureGateState';
interface RBACFeatureGateSectionProps {
@@ -16,21 +12,11 @@ interface RBACFeatureGateSectionProps {
export const RBACFeatureGateSection: Component<RBACFeatureGateSectionProps> = (props) => (
<div class="bg-surface-alt p-4 sm:p-6 transition-colors border-b border-border-subtle">
- <div class="flex flex-col sm:flex-row items-center gap-4">
- <div class="flex-1 text-center sm:text-left">
- <h4 class="text-base font-semibold text-base-content">{props.copy.title}</h4>
- <p class="text-sm text-muted mt-1">{props.copy.body}</p>
- </div>
- <Show when={props.showUpgradePrompts}>
- <div class="flex flex-col sm:flex-row items-center gap-2">
- <UpgradeLink
- destination={getUpgradeActionDestination('rbac')}
- class={getUpgradeActionButtonClass()}
- >
- {UPGRADE_ACTION_LABEL}
- </UpgradeLink>
- </div>
- </Show>
- </div>
+ <FeatureGateSection
+ title={props.copy.title}
+ body={props.copy.body}
+ upgradeDestination={getUpgradeActionDestination('rbac')}
+ showUpgradePrompts={props.showUpgradePrompts}
+ />
</div>
);
diff --git a/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx b/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx
index e8309f4640..28bc09d38f 100644
--- a/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx
+++ b/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx
@@ -4,7 +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 { FeatureGateSection } from '@/components/shared/FeatureGateSection';
import { formField, labelClass, controlClass, formHelpText } from '@/components/shared/Form';
import { getSettingsConfigurationLoadingState } from '@/utils/settingsShellPresentation';
import {
@@ -16,7 +16,6 @@ import {
RELAY_PAIRING_AVAILABILITY_MESSAGE,
RELAY_PAIRING_AVAILABILITY_TITLE,
RELAY_PRIMARY_BUTTON_CLASS,
- RELAY_PRIMARY_LINK_CLASS,
RELAY_READONLY_NOTICE_CLASS,
} from '@/utils/relayPresentation';
import { RelayPairingSection } from './RelayPairingSection';
@@ -34,25 +33,13 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =>
<SettingsPanel title="Remote Access">
<Show when={!state.loading()} fallback={<div class="text-sm ">Loading...</div>}>
<Card tone="info" padding="md">
- <div class="flex flex-col sm:flex-row items-center gap-4">
- <div class="flex items-start gap-3 flex-1">
- <RadioTower size={20} class="text-blue-500 mt-0.5 flex-shrink-0" strokeWidth={2} />
- <div>
- <p class="text-sm font-medium text-base-content">Remote Access (Relay)</p>
- <p class="text-sm text-muted mt-1">{RELAY_LICENSE_REQUIRED_MESSAGE}</p>
- </div>
- </div>
- <Show when={state.showUpgradePrompts()}>
- <div class="flex flex-col sm:flex-row items-center gap-2">
- <UpgradeLink
- destination={state.upgradeDestination()}
- class={RELAY_PRIMARY_LINK_CLASS}
- >
- View plans
- </UpgradeLink>
- </div>
- </Show>
- </div>
+ <FeatureGateSection
+ icon={<RadioTower size={20} strokeWidth={2} />}
+ title="Remote Access (Relay)"
+ body={RELAY_LICENSE_REQUIRED_MESSAGE}
+ upgradeDestination={state.upgradeDestination()}
+ showUpgradePrompts={state.showUpgradePrompts()}
+ />
</Card>
</Show>
</SettingsPanel>
diff --git a/frontend-modern/src/components/Settings/ReportingPanel.tsx b/frontend-modern/src/components/Settings/ReportingPanel.tsx
index a03d8b02e1..4202954e93 100644
--- a/frontend-modern/src/components/Settings/ReportingPanel.tsx
+++ b/frontend-modern/src/components/Settings/ReportingPanel.tsx
@@ -7,14 +7,10 @@ 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 { FeatureGateSection } from '@/components/shared/FeatureGateSection';
import { useReportingPanelState } from '@/components/Settings/useReportingPanelState';
import type { ReportingFormat } from '@/components/Settings/reportingCatalogModel';
import { type ReportingRangeValue } from '@/components/Settings/reportingPanelModel';
-import {
- getUpgradeActionButtonClass,
- UPGRADE_ACTION_LABEL,
-} from '@/utils/upgradePresentation';
import { ResourcePicker } from './ResourcePicker';
const REPORTING_FORMAT_ICONS: Record<ReportingFormat, typeof FileText> = {
@@ -137,28 +133,16 @@ export function ReportingPanel() {
description={reportingCatalog()!.description}
>
<div class="p-4 sm:p-6">
- <div class="flex flex-col sm:flex-row items-center gap-4">
- <div class="flex-1 text-center sm:text-left">
- <Show when={lockedState()}>
- {(state) => (
- <>
- <h4 class="text-base font-semibold text-base-content">{state().title}</h4>
- <p class="text-sm text-muted mt-1">{state().description}</p>
- </>
- )}
- </Show>
- </div>
- <Show when={showUpgradePrompts()}>
- <div class="flex flex-col sm:flex-row items-center gap-2">
- <UpgradeLink
- destination={upgradeDestination()}
- class={getUpgradeActionButtonClass()}
- >
- {UPGRADE_ACTION_LABEL}
- </UpgradeLink>
- </div>
- </Show>
- </div>
+ <Show when={lockedState()}>
+ {(state) => (
+ <FeatureGateSection
+ title={state().title}
+ body={state().description}
+ upgradeDestination={upgradeDestination()}
+ showUpgradePrompts={showUpgradePrompts()}
+ />
+ )}
+ </Show>
</div>
</OperationsPanel>
</Show>
diff --git a/frontend-modern/src/components/shared/FeatureGateSection.tsx b/frontend-modern/src/components/shared/FeatureGateSection.tsx
new file mode 100644
index 0000000000..7fe37d801d
--- /dev/null
+++ b/frontend-modern/src/components/shared/FeatureGateSection.tsx
@@ -0,0 +1,63 @@
+import { Show, type Component, type JSX } from 'solid-js';
+import { UpgradeLink } from '@/components/shared/UpgradeLink';
+import {
+ getUpgradeActionButtonClass,
+ UPGRADE_ACTION_LABEL,
+ type UpgradeActionButtonTone,
+} from '@/utils/upgradePresentation';
+import type { UpgradeDestination } from '@/utils/upgradeNavigation';
+
+export interface FeatureGateSectionProps {
+ /** Headline naming the locked capability, e.g. "Custom Roles". */
+ title: string;
+ /** One-line explanation of what the capability does or why it is gated. */
+ body: string;
+ /** Resolved upgrade destination for this feature's key. */
+ upgradeDestination: UpgradeDestination;
+ /**
+ * Whether to render the upgrade call-to-action. Callers pass their existing
+ * gating signal (typically `!presentationPolicyHidesUpgradePrompts()`) so
+ * kiosk, white-label, and presentation sessions stay action-free.
+ */
+ showUpgradePrompts: boolean;
+ /** Optional leading icon for the capability. */
+ icon?: JSX.Element;
+ /** Upgrade button label. Defaults to the canonical "View plans". */
+ upgradeLabel?: string;
+ /** Upgrade button tone. Defaults to the primary blue treatment. */
+ upgradeButtonTone?: UpgradeActionButtonTone;
+}
+
+/**
+ * Canonical inner shell for a Pro/paid feature gate: a title and body on the
+ * left, an optional leading icon, and a single upgrade call-to-action on the
+ * right. Callers own the surrounding container (a divided `SettingsPanel`
+ * row, a standalone `Card tone="info"`, an `OperationsPanel`, ...) so the gate
+ * fits its context, while its layout, heading semantics, and upgrade button
+ * stay identical across every surface that gates a feature.
+ */
+export const FeatureGateSection: Component<FeatureGateSectionProps> = (props) => (
+ <div class="flex flex-col sm:flex-row items-center gap-4">
+ <div class="flex flex-1 items-start gap-3 text-center sm:text-left">
+ <Show when={props.icon}>
+ <span class="mt-0.5 flex-shrink-0 text-blue-500">{props.icon}</span>
+ </Show>
+ <div class="flex-1">
+ <h4 class="text-base font-semibold text-base-content">{props.title}</h4>
+ <p class="mt-1 text-sm text-muted">{props.body}</p>
+ </div>
+ </div>
+ <Show when={props.showUpgradePrompts}>
+ <div class="flex flex-col sm:flex-row items-center gap-2">
+ <UpgradeLink
+ destination={props.upgradeDestination}
+ class={getUpgradeActionButtonClass({ tone: props.upgradeButtonTone })}
+ >
+ {props.upgradeLabel ?? UPGRADE_ACTION_LABEL}
+ </UpgradeLink>
+ </div>
+ </Show>
+ </div>
+);
+
+export default FeatureGateSection;
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 5634e71710..66025a5e22 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -428,6 +428,7 @@ import organizationRolePresentationSource from '@/utils/organizationRolePresenta
import organizationSettingsPresentationSource from '@/utils/organizationSettingsPresentation.ts?raw';
import rbacFeatureGateSectionSource from '@/components/Settings/RBACFeatureGateSection.tsx?raw';
import rbacFeatureGateStateSource from '@/components/Settings/useRBACFeatureGateState.ts?raw';
+import featureGateSectionSource from '@/components/shared/FeatureGateSection.tsx?raw';
import rolesPanelSource from '@/components/Settings/RolesPanel.tsx?raw';
import rolesPanelStateSource from '@/components/Settings/useRolesPanelState.ts?raw';
@@ -1024,11 +1025,16 @@ describe('frontend resource type boundaries', () => {
expect(discoverySettingsStateSource).toContain('export function useDiscoverySettingsState');
expect(discoverySettingsStateSource).toContain('normalizeSubnetList');
expect(discoverySettingsStateSource).toContain('isValidCIDR');
- expect(reportingPanelSource).toContain('@/utils/upgradePresentation');
+ // The canonical upgrade CTA contract (button class + label) now lives in
+ // the shared FeatureGateSection; gated panels route their paywall through
+ // it instead of re-deriving the button locally.
+ expect(featureGateSectionSource).toContain('@/utils/upgradePresentation');
+ expect(featureGateSectionSource).toContain('getUpgradeActionButtonClass');
+ expect(featureGateSectionSource).toContain('UPGRADE_ACTION_LABEL');
+ expect(featureGateSectionSource).toContain('@/components/shared/UpgradeLink');
+ expect(reportingPanelSource).toContain('@/components/shared/FeatureGateSection');
expect(reportingPanelSource).toContain('@/components/Settings/useReportingPanelState');
expect(reportingPanelSource).toContain('@/components/Settings/reportingPanelModel');
- expect(reportingPanelSource).toContain('getUpgradeActionButtonClass');
- expect(reportingPanelSource).toContain('UPGRADE_ACTION_LABEL');
expect(reportingPanelSource).not.toContain('UPGRADE_TRIAL_LABEL');
expect(reportingPanelSource).not.toContain('>Upgrade to Pro<');
expect(reportingPanelSource).not.toContain('>Start free trial<');
@@ -1037,8 +1043,7 @@ describe('frontend resource type boundaries', () => {
expect(rolesPanelSource).toContain('./useRolesPanelState');
expect(userAssignmentsPanelSource).toContain('./RBACFeatureGateSection');
expect(userAssignmentsPanelSource).toContain('./useUserAssignmentsPanelState');
- expect(rbacFeatureGateSectionSource).toContain('@/utils/upgradePresentation');
- expect(rbacFeatureGateSectionSource).toContain('getUpgradeActionButtonClass');
+ expect(rbacFeatureGateSectionSource).toContain('@/components/shared/FeatureGateSection');
expect(rolesPanelStateSource).toContain('getRolesLoadErrorMessage');
expect(userAssignmentsPanelStateSource).toContain('getUserAssignmentsLoadErrorMessage');
expect(agentProfilesPanelSource).toContain('./useAgentProfilesPanelState');
@@ -1051,7 +1056,7 @@ describe('frontend resource type boundaries', () => {
'No agents connected. Install an agent to assign profiles.',
);
expect(auditLogPanelSource).toContain('@/utils/upgradePresentation');
- expect(auditWebhookPanelSource).toContain('@/utils/upgradePresentation');
+ expect(auditWebhookPanelSource).toContain('@/components/shared/FeatureGateSection');
expect(ssoProvidersPanelSource).not.toContain('@/utils/upgradePresentation');
expect(upgradePresentationSource).toContain('export const UPGRADE_ACTION_LABEL');
expect(upgradePresentationSource).not.toContain('UPGRADE_TRIAL_LABEL');