Skip to content

HOLD: Add related-comments overview + global comments index#1866

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/comments-index-page
Draft

HOLD: Add related-comments overview + global comments index#1866
maebeale wants to merge 1 commit into
mainfrom
maebeale/comments-index-page

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

What is the goal of this PR and why is this important?

  • Comments exist on five record types (people, organizations, users, workshops, event registrations) but were only ever viewable one record at a time, so relevant context on a neighboring record was easy to miss.
  • Adds one related-comments overview reachable from every comment box that surfaces all related comments together, plus a global index for previewing every comment and the record it's about.
  • HOLD: — opening for review/discussion of the "related" definitions per type before merge.

How did you approach the change?

  • RelatedComments service decides what "related" means per commentable type — the commentable type is the signal of which comment box the button was clicked from (each box links to its own polymorphic comments path), so one place owns the mapping:
    • Registration → registrant, their user account, their active-affiliation orgs
    • Person → their user account + active orgs
    • Organization → people with an active affiliation
    • User → linked person + that person's active orgs
    • Workshop → its creator (+ creator's person/orgs)
  • comments#index now serves three modes: scoped related overview (full page, styled like the allocations index, with an "About" column labeling each comment's record), a global /comments preview of every comment, and the existing bare list for turbo-frame requests (embed/create flows untouched).
  • Shared View all related comments button added to every comment box (people, orgs, workshops, users, registrations) via a single partial, opening the overview in a new tab.
  • Active-affiliation filtering uses Affiliation.active; admin-only via the existing CommentPolicy.

Anything else to add?

  • Tests: spec/services/related_comments_spec.rb covers the per-type related set (incl. active-vs-inactive affiliation filtering); spec/requests/comments_spec.rb covers the scoped overview, the global index, admin-restriction, and the turbo-frame path.
  • Open question for reviewers: are the per-type "related" definitions the right scope (e.g. should an Organization also pull in its people's user-account comments)?
  • Global index is reachable at /comments (no nav entry yet — intentionally minimal).

Comments live on five record types (people, orgs, users, workshops,
registrations) but are only ever viewed one record at a time, so context
that lives on a neighboring record (a registrant's person/org notes, an
org's people) is easy to miss. This adds a single overview page reachable
from every comment box that surfaces all related comments at once, plus a
global index for previewing every comment and what it's about.

- RelatedComments service derives the related set from the commentable's
  type (the type is the signal of which box the button was clicked from)
- comments#index renders the full overview when scoped, a global "all
  comments" preview at /comments, and still the bare list for turbo frames
- Shared "View all related comments" button added to every comment box

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
.transform_values { |records| records.map(&:id).uniq }
end

def related_records

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 From Claude: The commentable's type is the only signal of which comment box the button was clicked from — each box links to its own polymorphic *_comments_path — so this case statement is the single place that defines "related" per type. Add a when to extend it.

# Scoped to a commentable: every comment related to that record (see
# RelatedComments). Top-level /comments: a preview of every comment in the
# system alongside the record each is about.
def index_comments

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 From Claude: Three modes share this action: scoped related overview (full page), global /comments preview (no commentable), and the existing bare turbo-frame list for embeds/create — kept intact so the inline comment widgets don't change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant