Skip to content

Show period membership on the contribution manager#376

Merged
ExtraToast merged 2 commits into
mainfrom
feature/contribution-manager-period-membership
Jun 30, 2026
Merged

Show period membership on the contribution manager#376
ExtraToast merged 2 commits into
mainfrom
feature/contribution-manager-period-membership

Conversation

@jorisjonkers-dev-agents

Copy link
Copy Markdown
Contributor

Depends on #374 and must merge after it. This branch builds on the contribution-manager restructure in #374, so until that merges this PR's diff also includes #374's commit; it collapses to just this change once #374 lands on main.

Problem

The Member/User chip on the contribution manager read the user's current MEMBER role, so a row's membership state did not reflect the contribution period being viewed. Someone who was a member during an older period but is not one now showed as "User", and a current member showed as "Member" even for a period predating their membership.

Change

The contribution manager now fetches the memberships overlapping the selected period — findMemberships with the period's from/to range, the same query the member manager already uses — alongside the period's contributions. From that response it derives the set of user ids that held a membership during the period.

That set is threaded through the contribution list to each row, which derives wasMemberDuringPeriod from it; the chip label and colour come from that set instead of user.roles. The set is cleared when no period is selected, and is covered by the same stale-response guard as the contributions, so a slow fetch for a since-deselected period cannot overwrite the current one. Both fetches run together via Promise.all.

No backend change is required: MembershipSpecifications.timeOverlap already returns the memberships whose interval overlaps the queried range.

Tests

ContributionManager.test.ts covers the membership query being issued with the period range, the set being forwarded to both lists, clearing on deselection and on a period with no memberships, and a stale response not overwriting the current period. ContributionUserList.test.ts asserts per-row forwarding for a member and a non-member. ContributionUserRow.test.ts proves the chip is driven by the period set, not roles (current member absent from the period shows "User", non-member present shows "Member", empty roles still renders "User").

Verified from services/frontend: yarn typecheck, yarn lint, and yarn test:unit (315 tests) pass.

The Member/User chip on the contribution manager read the user's current
MEMBER role, so a row's membership state did not reflect the contribution
period being viewed: someone who was a member during an older period but
is not one now showed as User, and vice versa.

The contribution manager now fetches the memberships overlapping the
selected period (findMemberships with the period's from/to range, the same
query the member manager uses) alongside the period's contributions, and
derives the set of user ids that held a membership during it. That set is
threaded through the contribution list to each row, which derives
wasMemberDuringPeriod from it; the chip and its colour come from that
instead of the user's roles. The membership set is cleared when no period
is selected and is subject to the same stale-response guard as the
contributions, so a slow fetch for a deselected period cannot overwrite
the current one.
Add coverage for the period-membership behaviour: the contribution manager
calls findMemberships with the selected period's range and forwards the
resulting user-id set to both lists, clears it on deselection and when a
period has no memberships, and ignores a stale response from a previously
selected period. The list forwards membership state per row, and the row
chip is driven by the period membership set rather than the user's roles
(a current member absent from the period shows User; a non-member present
in the period shows Member; an empty roles array still renders User).
@jorisjonkers-dev-agents jorisjonkers-dev-agents Bot force-pushed the feature/contribution-manager-period-membership branch from 4b84a73 to 27fb681 Compare June 30, 2026 16:27
@ExtraToast ExtraToast merged commit 086de2f into main Jun 30, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant