From db59f0d48ec58ab0ad0f22f2894ec6ef99415fee Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Wed, 4 Nov 2026 18:31:27 +0000 Subject: [PATCH] panel: show membership state and reason from the portal on the Members view The Members Status column now renders the portal's per-member 'state' (active / in grace / awaiting / inactive) instead of the raw active flag, with the portal's reason shown beneath the pill. The portal owns the state; the panel only displays it. Non-active states keep the member's access. --- app/main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index b9f0956..cea4491 100644 --- a/app/main.py +++ b/app/main.py @@ -271,6 +271,8 @@ PAGE_HTML = """ .pill.inactive { background: #f6e9e5; color: var(--danger); } .pill.manual { background: #f1e8da; color: #a97a4a; } .pill.org { background: #e7edf5; color: #4a6a8a; } + .pill.grace { background: #fdf3e3; color: #a97a2a; } + .state-reason { color: var(--muted); font-size: 11px; margin-top: 2px; } /* Trends tab (charts). Colours come from the same vars as the rest of the panel; the SVG is inline so there is no chart library and no CDN. */ .trend-controls { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 0; } @@ -749,7 +751,19 @@ function renderMembers() { }); $('rows').innerHTML = rows.map(m => { const reset = m.reset_at ? m.reset_at.slice(0,10) : '—'; - const pill = m.active ? 'active' : 'inactive'; + // Membership state is computed by the PORTAL (the source of truth) and + // carried on the overview row — the panel only renders it. Non-active + // states (in grace / awaiting contribution) still keep the member's access; + // the reason is shown beneath the pill. + const state = m.state || (m.active ? 'active' : 'inactive'); + const stateLabel = { active: 'active', in_grace: 'in grace', + awaiting_contribution: 'awaiting', inactive: 'inactive' }[state] || state; + const stateClass = state === 'active' ? 'active' : (state === 'inactive' ? 'inactive' : 'grace'); + const stateReason = m.state_reason || ''; + const statusCell = '' + + esc(stateLabel) + '' + + (stateReason && state !== 'active' + ? '
' + esc(stateReason) + '
' : ''); const act = m.activated ? 'yes' : 'pending'; @@ -778,7 +792,7 @@ function renderMembers() { return '' + '' + esc(top) + '' + emailLine + mxidLine + (org ? '
' + org + '
' : '') + '' + - '' + pill + '' + + '' + statusCell + '' + '' + act + '' + '' + src + '' + '' + fmt(m.balance) + '' +