diff --git a/frontend-modern/browser-verification/05a65b37848bd787.json b/frontend-modern/browser-verification/05a65b37848bd787.json new file mode 100644 index 0000000000..936a81d159 --- /dev/null +++ b/frontend-modern/browser-verification/05a65b37848bd787.json @@ -0,0 +1,43 @@ +{ + "version": 1, + "base_sha": "efbfd69780b17dc682c229aa5f6e7c5c2bfdc86b", + "verified_at": "2026-12-02T13:26:38Z", + "result": "passed", + "changed_paths": [ + "frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx", + "frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx", + "frontend-modern/src/components/Settings/useRBACFeatureGateState.ts", + "frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts" + ], + "content_sha256": { + "frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx": "3d021b3404512fb91c3294b619663eb0734db7c9ceaa433ef9eee6789e884486", + "frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx": "1a8f0bd889fbbdee1c4665bf89b718c696aa3d8381442a99b72d70bede554103", + "frontend-modern/src/components/Settings/useRBACFeatureGateState.ts": "cc6fe41226621c733be1f5d8bdc2a08c92a655cef3ba1480390fae9930ae6987", + "frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts": "e4b8707153320278e91dbf85365c07960b0bdc8a69620695c70a71673d6de6c4" + }, + "routes": [ + "/settings/security-users" + ], + "viewports": [ + { + "width": 1280, + "height": 800 + }, + { + "width": 390, + "height": 844 + } + ], + "states": [ + "Pro license with max_users=3 at seat cap renders 3 of 3 seats used and Upgrade for unlimited seats link to /settings/pulse-intelligence/billing/plan with zero horizontal overflow", + "Manage Access dialog on HTTP 402 max_users retains draft role checkbox, focuses the danger InlineNotice, and renders clickable View Business plan action link to /settings/pulse-intelligence/billing/plan", + "Unlimited Business license (no max_users runtime limit) omits both seat counter and upgrade link cleanly", + "Commercial-hidden presentation policy suppresses upgrade links while preserving seat usage count" + ], + "interactions": [ + "Verified summary bar seat meter and Upgrade for unlimited seats href on /settings/security-users at desktop (1280x800) and mobile (390x844)", + "Opened Manage Access dialog for unseated user, checked Viewer, submitted Save Changes against HTTP 402 max_users, verified focused notice, View Business plan href, and preserved draft selection, then dismissed with Escape", + "Reloaded /settings/security-users against unlimited Business runtime-capabilities (limits: []) and verified seat counter and upgrade link remain hidden", + "Visually inspected desktop (1280x800) and mobile (390x844) Playwright screenshots of both the summary bar and the 402 Manage Access modal" + ] +} diff --git a/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx b/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx index 4e1a6cb333..577ede942b 100644 --- a/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx +++ b/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx @@ -62,6 +62,7 @@ export const RoleAccessIdentity: Component<{ interface UserAssignmentsDialogProps { actionError?: string | null; + actionErrorUpgradeHref?: string; actionErrorRef?: (element: HTMLDivElement) => void; editingUser: UserRoleAssignment | null; formRoleIds: string[]; @@ -144,6 +145,8 @@ export const UserAssignmentsDialog: Component = (pro tone="danger" role="alert" aria-live="polite" + actionHref={props.actionErrorUpgradeHref} + actionLabel={props.actionErrorUpgradeHref ? 'View Business plan' : undefined} class="focus:outline-hidden focus:ring-2 focus:ring-blue-500 focus:ring-offset-2" > {message()} diff --git a/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx b/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx index e22e7e4544..0a0ed2a3f3 100644 --- a/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx +++ b/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx @@ -204,19 +204,45 @@ export const UserAssignmentsPanel: Component = (props 0}> -
- +
- Showing {state.filteredAssignments().length} of {state.assignmentCount()}{' '} - {state.assignmentCount() === 1 ? 'user' : 'users'} + + Showing {state.filteredAssignments().length} of {state.assignmentCount()}{' '} + {state.assignmentCount() === 1 ? 'user' : 'users'} + +
+ + {(limit) => ( +
+ + {state.seatedUserCount()} of {limit()} seats used + + + {(href) => ( + + Upgrade for unlimited seats + + )} + +
+ )}
@@ -349,6 +375,7 @@ export const UserAssignmentsPanel: Component = (props { editorFailureNotice = element; }} diff --git a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx index 4c04ed27fe..6cf1e3a13c 100644 --- a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx @@ -7,6 +7,7 @@ import { RolesPanel } from '../RolesPanel'; import { UserAssignmentsPanel } from '../UserAssignmentsPanel'; const hasFeatureMock = vi.fn(); +const getRuntimeLimitMock = vi.fn(); const loadLicenseStatusMock = vi.fn(); const loadCommercialPostureMock = vi.fn(); const startProTrialMock = vi.fn(); @@ -35,6 +36,7 @@ function deferred() { } vi.mock('@/stores/license', () => ({ + getRuntimeLimit: (...args: unknown[]) => getRuntimeLimitMock(...args), hasFeature: (...args: unknown[]) => hasFeatureMock(...args), loadRuntimeCapabilities: (...args: unknown[]) => loadLicenseStatusMock(...args), runtimeCapabilitiesLoaded: () => runtimeReady(), @@ -90,6 +92,7 @@ describe('RBAC paywall settings panels', () => { beforeEach(() => { runtimeReady = () => true; hasFeatureMock.mockReset(); + getRuntimeLimitMock.mockReset(); loadLicenseStatusMock.mockReset(); loadCommercialPostureMock.mockReset(); startProTrialMock.mockReset(); @@ -107,6 +110,7 @@ describe('RBAC paywall settings panels', () => { loggerErrorMock.mockReset(); hasFeatureMock.mockReturnValue(true); + getRuntimeLimitMock.mockReturnValue(undefined); loadLicenseStatusMock.mockResolvedValue(undefined); loadCommercialPostureMock.mockResolvedValue(undefined); startProTrialMock.mockResolvedValue({ outcome: 'started' }); @@ -1210,4 +1214,49 @@ describe('RBAC paywall settings panels', () => { expect(screen.queryByRole('button', { name: 'Start trial' })).not.toBeInTheDocument(); expect(startProTrialMock).not.toHaveBeenCalled(); }); + + it('shows the seat meter and Business upgrade links at cap, and hides commercial links when suppressed', async () => { + getRuntimeLimitMock.mockImplementation((key: string) => + key === 'max_users' + ? { key: 'max_users', limit: 3, current: 3, state: 'enforced' } + : undefined, + ); + getUsersMock.mockResolvedValue([ + { username: 'alice', roleIds: ['admin'] }, + { username: 'bob', roleIds: ['admin'] }, + { username: 'carol', roleIds: ['admin'] }, + { username: 'dave', roleIds: [] }, + ]); + updateUserRolesMock.mockRejectedValueOnce( + Object.assign(new Error('User limit reached (3/3).'), { + status: 402, + feature: 'max_users', + }), + ); + + render(() => ); + + expect(await screen.findByText('3 of 3 seats used')).toBeInTheDocument(); + expect(screen.getByRole('link', { name: 'Upgrade for unlimited seats' })).toHaveAttribute( + 'href', + 'https://example.com/upgrade?feature=rbac', + ); + + fireEvent.click(screen.getByRole('button', { name: 'Manage access for dave' })); + const dialog = await screen.findByRole('dialog'); + fireEvent.click(within(dialog).getByRole('checkbox')); + fireEvent.click(within(dialog).getByRole('button', { name: /Save/i })); + + expect(await within(dialog).findByRole('link', { name: 'View Business plan' })).toHaveAttribute( + 'href', + 'https://example.com/upgrade?feature=rbac', + ); + + cleanup(); + presentationPolicyHidesUpgradePromptsMock.mockReturnValue(true); + render(() => ); + + expect(await screen.findByText('3 of 3 seats used')).toBeInTheDocument(); + expect(screen.queryByRole('link', { name: 'Upgrade for unlimited seats' })).toBeNull(); + }); }); diff --git a/frontend-modern/src/components/Settings/__tests__/UserAccessTransport.test.tsx b/frontend-modern/src/components/Settings/__tests__/UserAccessTransport.test.tsx index dea53143e9..61f4f8200f 100644 --- a/frontend-modern/src/components/Settings/__tests__/UserAccessTransport.test.tsx +++ b/frontend-modern/src/components/Settings/__tests__/UserAccessTransport.test.tsx @@ -497,6 +497,10 @@ describe('User Access through the real RBAC transport', () => { expect(state.actionError()).toBe( 'User seat limit reached for this license. Remove a seated user or upgrade your license to assign more team members.', ); + expect(state.seatedUserCount()).toBe(1); + expect(state.seatLimit()).toBeNull(); + expect(state.seatLimitReached()).toBe(false); + expect(state.actionErrorUpgradeHref()).toBeUndefined(); expect( JSON.stringify([ state.actionError(), diff --git a/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts b/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts index 16f2840574..1a58d9b388 100644 --- a/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts +++ b/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts @@ -1,7 +1,12 @@ import { Accessor, createMemo, onMount } from 'solid-js'; -import { hasFeature, runtimeCapabilitiesLoaded } from '@/stores/license'; +import { + getRuntimeLimit, + hasFeature, + loadRuntimeCapabilities, + runtimeCapabilitiesLoaded, +} from '@/stores/license'; +import { getUpgradeActionDestination } from '@/stores/licenseCommercial'; import { presentationPolicyHidesCommercialSurfaces } from '@/stores/sessionPresentationPolicy'; -import { loadRuntimeCapabilities } from '@/stores/license'; import { getRBACFeatureGateCopy, type RBACFeatureGateCopy } from '@/utils/rbacPresentation'; export type RBACFeatureGateKind = 'roles' | 'user-assignments'; @@ -23,6 +28,15 @@ export function useRBACFeatureGateState(options: UseRBACFeatureGateStateOptions) const paywallVisible = createMemo( () => licenseReady() && !hasFeature('rbac') && !options.loading(), ); + const seatLimit = createMemo(() => { + const limit = getRuntimeLimit('max_users')?.limit; + return typeof limit === 'number' && limit > 0 ? limit : null; + }); + const upgradePlanHref = createMemo(() => { + if (!showUpgradePrompts()) return undefined; + const href = getUpgradeActionDestination('rbac').href; + return href || undefined; + }); onMount(() => { void loadRuntimeCapabilities(); @@ -33,6 +47,8 @@ export function useRBACFeatureGateState(options: UseRBACFeatureGateStateOptions) licenseReady, paywallVisible, rbacEnabled, + seatLimit, showUpgradePrompts, + upgradePlanHref, }; } diff --git a/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts b/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts index 26edca04bb..d60d0241b0 100644 --- a/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts +++ b/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts @@ -11,6 +11,7 @@ import { getUserIdentityLabel, isCompleteUserAccessInventory, sameRoleIDs, + USER_ACCESS_SEAT_LIMIT_COPY, } from '@/utils/rbacPresentation'; import { useRBACFeatureGateState } from './useRBACFeatureGateState'; @@ -341,8 +342,21 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps = : [...currentRoleIds, roleId], ); }; + const seatLimit = createMemo(() => featureGate.seatLimit?.() ?? null); + const seatedUserCount = createMemo( + () => assignments().filter((assignment) => assignment.roleIds.length > 0).length, + ); + const seatLimitReached = createMemo(() => { + const limit = seatLimit(); + return limit !== null && seatedUserCount() >= limit; + }); + const upgradePlanHref = createMemo(() => featureGate.upgradePlanHref?.()); + const actionErrorUpgradeHref = createMemo(() => + actionError() === USER_ACCESS_SEAT_LIMIT_COPY ? upgradePlanHref() : undefined, + ); return { actionError, + actionErrorUpgradeHref, assignmentCount: () => assignments().length, successNotice, accessAllowed, @@ -370,9 +384,13 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps = roles, saving, searchQuery, + seatLimit, + seatLimitReached, + seatedUserCount, setSearchQuery, showModal, toggleRole, + upgradePlanHref, userPendingDeletion, userPermissions, unconfirmedChange, diff --git a/pkg/licensing/entitlement_payload.go b/pkg/licensing/entitlement_payload.go index e84a5a92c1..a10eb266fd 100644 --- a/pkg/licensing/entitlement_payload.go +++ b/pkg/licensing/entitlement_payload.go @@ -308,6 +308,7 @@ type EntitlementUsageSnapshot struct { // system billing must be backed by an explicit canonical availability signal. Nodes int64 Guests int64 + Users int64 LegacyConnections LegacyConnectionCounts } @@ -445,6 +446,14 @@ func BuildEntitlementPayloadWithUsage( State: LimitState(usage.Guests, int64(status.MaxGuests)), }) } + if status.MaxUsers > 0 { + payload.Limits = append(payload.Limits, LimitStatus{ + Key: MaxUsersLicenseGateKey, + Limit: int64(status.MaxUsers), + Current: usage.Users, + State: LimitState(usage.Users, int64(status.MaxUsers)), + }) + } reasons := GenerateUpgradeReasons(payload.Capabilities) payload.UpgradeReasons = make([]UpgradeReason, 0, len(reasons)) diff --git a/pkg/licensing/entitlement_payload_test.go b/pkg/licensing/entitlement_payload_test.go index 1233778ede..5ea81c3926 100644 --- a/pkg/licensing/entitlement_payload_test.go +++ b/pkg/licensing/entitlement_payload_test.go @@ -359,6 +359,39 @@ func TestBuildRuntimeCapabilitiesPayloadWithUsage_CurrentValues(t *testing.T) { } } +func TestBuildRuntimeCapabilitiesPayloadWithUsage_IncludesMaxUsersSeatLimit(t *testing.T) { + status := &LicenseStatus{ + Valid: true, + Tier: TierPro, + PlanVersion: "pro_annual", + Features: append([]string(nil), TierFeatures[TierPro]...), + MaxUsers: 3, + } + + payload := BuildRuntimeCapabilitiesPayloadWithUsage(status, string(SubStateActive), EntitlementUsageSnapshot{ + Users: 3, + }) + + if len(payload.Limits) != 1 { + t.Fatalf("expected one runtime limit for max_users, got %+v", payload.Limits) + } + got := payload.Limits[0] + if got.Key != MaxUsersLicenseGateKey || got.Limit != 3 || got.Current != 3 || got.State != "enforced" { + t.Fatalf("unexpected max_users runtime limit: %+v", got) + } + + businessPayload := BuildRuntimeCapabilitiesPayloadWithUsage(&LicenseStatus{ + Valid: true, + Tier: TierBusiness, + PlanVersion: "business_annual", + Features: append([]string(nil), TierFeatures[TierBusiness]...), + MaxUsers: 0, + }, string(SubStateActive), EntitlementUsageSnapshot{Users: 8}) + if len(businessPayload.Limits) != 0 { + t.Fatalf("expected unlimited Business license to omit max_users limit, got %+v", businessPayload.Limits) + } +} + func TestBuildRuntimeCapabilitiesPayloadWithUsage_StripsInternalOnlyCapabilities(t *testing.T) { status := &LicenseStatus{ Valid: true, diff --git a/pkg/licensing/models.go b/pkg/licensing/models.go index 2df0a807c1..b3656f4c6b 100644 --- a/pkg/licensing/models.go +++ b/pkg/licensing/models.go @@ -229,6 +229,7 @@ type LicenseStatus struct { DaysRemaining int `json:"days_remaining"` Features []string `json:"features"` MaxGuests int `json:"max_guests,omitempty"` + MaxUsers int `json:"max_users,omitempty"` InGracePeriod bool `json:"in_grace_period,omitempty"` GracePeriodEnd *string `json:"grace_period_end,omitempty"` Synchronization *LicenseSynchronizationStatus `json:"synchronization,omitempty"` diff --git a/pkg/licensing/service.go b/pkg/licensing/service.go index 899f4b347b..5cf5f61e07 100644 --- a/pkg/licensing/service.go +++ b/pkg/licensing/service.go @@ -731,12 +731,16 @@ func (s *Service) Status() *LicenseStatus { if maxGuests, ok := s.evaluator.GetLimit("max_guests"); ok { status.MaxGuests = safeIntFromInt64(maxGuests) } + if maxUsers, ok := s.evaluator.GetLimit(MaxUsersLicenseGateKey); ok { + status.MaxUsers = safeIntFromInt64(maxUsers) + } default: status.Tier = TierFree status.Valid = false // Keep effective capabilities free-tier only when subscription is not entitled. status.Features = append([]string(nil), TierFeatures[TierFree]...) status.MaxGuests = 0 + status.MaxUsers = 0 } } else { // No license, no evaluator: Community remains active for core monitoring. @@ -751,9 +755,13 @@ func (s *Service) Status() *LicenseStatus { status.DaysRemaining = s.license.LicensePeriodDaysRemaining() status.Features = s.license.AllFeatures() - if maxGuests, ok := s.license.Claims.EffectiveLimits()["max_guests"]; ok { + effectiveLimits := s.license.Claims.EffectiveLimits() + if maxGuests, ok := effectiveLimits["max_guests"]; ok { status.MaxGuests = safeIntFromInt64(maxGuests) } + if maxUsers, ok := effectiveLimits[MaxUsersLicenseGateKey]; ok { + status.MaxUsers = safeIntFromInt64(maxUsers) + } if s.license.LicensePeriodExpiresAt() != nil { exp := s.license.LicensePeriodExpiresAt().Format(time.RFC3339) @@ -774,6 +782,7 @@ func (s *Service) Status() *LicenseStatus { status.Valid = false status.Features = append([]string(nil), TierFeatures[TierFree]...) status.MaxGuests = 0 + status.MaxUsers = 0 } return status