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.
This commit is contained in:
inference-bot committed 2026-11-04 18:31:34 +00:00
1 parent 8b773966a2
commit db59f0d48e
1 file changed
+16 -2
+16 -2
View File
@@ -271,6 +271,8 @@ PAGE_HTML = """<!DOCTYPE html>
.pill.inactive { background: #f6e9e5; color: var(--danger); } .pill.inactive { background: #f6e9e5; color: var(--danger); }
.pill.manual { background: #f1e8da; color: #a97a4a; } .pill.manual { background: #f1e8da; color: #a97a4a; }
.pill.org { background: #e7edf5; color: #4a6a8a; } .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 /* 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. */ 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; } .trend-controls { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 0; }
@@ -749,7 +751,19 @@ function renderMembers() {
}); });
$('rows').innerHTML = rows.map(m => { $('rows').innerHTML = rows.map(m => {
const reset = m.reset_at ? m.reset_at.slice(0,10) : '—'; 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 = '<span class="pill ' + stateClass + '" title="' + esc(stateReason) + '">' +
esc(stateLabel) + '</span>' +
(stateReason && state !== 'active'
? '<div class="state-reason">' + esc(stateReason) + '</div>' : '');
const act = m.activated const act = m.activated
? '<span class="pill active">yes</span>' ? '<span class="pill active">yes</span>'
: '<span class="pill inactive">pending</span>'; : '<span class="pill inactive">pending</span>';
@@ -778,7 +792,7 @@ function renderMembers() {
return '<tr>' + return '<tr>' +
'<td><strong>' + esc(top) + '</strong>' + emailLine + mxidLine + '<td><strong>' + esc(top) + '</strong>' + emailLine + mxidLine +
(org ? '<div style="margin-top:3px">' + org + '</div>' : '') + '</td>' + (org ? '<div style="margin-top:3px">' + org + '</div>' : '') + '</td>' +
'<td><span class="pill ' + pill + '">' + pill + '</span></td>' + '<td>' + statusCell + '</td>' +
'<td>' + act + '</td>' + '<td>' + act + '</td>' +
'<td>' + src + '</td>' + '<td>' + src + '</td>' +
'<td class="num balance-col allowance-only">' + fmt(m.balance) + '</td>' + '<td class="num balance-col allowance-only">' + fmt(m.balance) + '</td>' +