Skip to content

Commit

Permalink
Memberships: Adds Breadcrumb from Membership: Show page
Browse files Browse the repository at this point in the history
I noticed when working on the
[Journal](https://github.com/zinc-collective/convene/issues/898) that
when you click on the `Account` link, it kind of drops you into the
middle of no where.

This adds a breadcrumb, so we can find our way back! Yay!
  • Loading branch information
zspencer committed Oct 23, 2022
1 parent f6846e4 commit 6ba69af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/models/membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Membership < ApplicationRecord

validates :member, uniqueness: { scope: :space_id }

def member_name
member.display_name
end

enum status: {
active: 'active',
revoked: 'revoked'
Expand Down
3 changes: 2 additions & 1 deletion app/views/memberships/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%- breadcrumb :show_membership, membership %>
<h1><%= membership.member.name %></h1>
<p><%= membership.member.email %></p>

Expand All @@ -6,4 +7,4 @@
<ul>
<%= render membership.sent_invitations %>
</ul>
</section>
</section>
13 changes: 11 additions & 2 deletions config/breadcrumbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@

crumb :memberships do |space|
link 'Members', [space, :memberships]
parent :edit_space, space
if policy(space).edit?
parent :edit_space, Space
else
parent :root
end
end

crumb :show_membership do |membership|
link membership.member_name, [membership.space, membership]
parent :memberships, membership.space
end

crumb :invitations do |space|
Expand Down Expand Up @@ -59,4 +68,4 @@
crumb :rsvp do |rsvp|
link 'Respond to your Invitation'
parent :root, rsvp.space
end
end

0 comments on commit 6ba69af

Please sign in to comment.