From 6ba69af44b8678689d0b17f176d9be86f2ed4769 Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Sun, 23 Oct 2022 13:38:09 -0700 Subject: [PATCH] Memberships: Adds Breadcrumb from Membership: Show page 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! --- app/models/membership.rb | 4 ++++ app/views/memberships/show.html.erb | 3 ++- config/breadcrumbs.rb | 13 +++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/models/membership.rb b/app/models/membership.rb index 74417e06b..4f5927b0e 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -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' diff --git a/app/views/memberships/show.html.erb b/app/views/memberships/show.html.erb index 6949416b1..2856e617d 100644 --- a/app/views/memberships/show.html.erb +++ b/app/views/memberships/show.html.erb @@ -1,3 +1,4 @@ +<%- breadcrumb :show_membership, membership %>

<%= membership.member.name %>

<%= membership.member.email %>

@@ -6,4 +7,4 @@ - \ No newline at end of file + diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb index 309a315e2..96c5843a8 100644 --- a/config/breadcrumbs.rb +++ b/config/breadcrumbs.rb @@ -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| @@ -59,4 +68,4 @@ crumb :rsvp do |rsvp| link 'Respond to your Invitation' parent :root, rsvp.space -end \ No newline at end of file +end