diff --git a/assets/css/common/_blocks.scss b/assets/css/common/_blocks.scss index 9d0468a5..24d94ec0 100644 --- a/assets/css/common/_blocks.scss +++ b/assets/css/common/_blocks.scss @@ -32,6 +32,10 @@ border-bottom: 1px solid $border_color; } +.block__content--destroyed { + background-color: $destroyed_content_color; +} + .block__header { font-size: 14px; line-height: $block_header_height; diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index 56900901..675c2cf8 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -69,16 +69,16 @@ - else .block__header span.block__header__title User Links - = for link <- @user.verified_links, link.public or can?(@conn, :edit, link) do + = for link <- @user.verified_links, should_see_link?(@conn, @user, link) do - watchers = if link.tag, do: @watcher_counts[link.tag.id] || 0, else: 0 - .block__content.alternating-color.break-word + .block__content.alternating-color.break-word class=link_block_class(link) .center = if link.tag do .tag_list = render PhilomenaWeb.TagView, "_tag.html", tag: link.tag, conn: @conn = link(link.uri, to: link.uri) - = if current?(@user, @conn.assigns.current_user) do + = if current?(@user, @conn.assigns.current_user) or manages_links?(@conn, @user) do br ' Watched by => watchers @@ -93,6 +93,10 @@ ' • a href=Routes.profile_user_link_path(@conn, :edit, @user, link) ' Edit + - else + => unless link.public do + br + ' Hidden .block = if manages_awards?(@conn) and not hide_staff_tools?(@conn) do diff --git a/lib/philomena_web/views/profile_view.ex b/lib/philomena_web/views/profile_view.ex index 42a39620..f0260bf8 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -18,6 +18,12 @@ defmodule PhilomenaWeb.ProfileView do def manages_links?(conn, user), do: can?(conn, :edit_links, user) + def should_see_link?(conn, user, link), + do: link.public or can?(conn, :edit, link) or current?(user, conn.assigns.current_user) + + def link_block_class(%{public: false}), do: "block__content--destroyed" + def link_block_class(_link), do: nil + def award_title(%{badge_name: nil} = award), do: award.badge.title