Skip to content

Commit

Permalink
deprecate helper curation_concern_page_title
Browse files Browse the repository at this point in the history
we introduced a decorator in previous work, encourage users to use that
decorator directly, instead of using a simple helper.

in addition to depending less directly on model behavior (which was the initail
goal of this work, re: Valkyrie), this should better insulate downstream
applications from future helper changes. that is: applications can now change
behavior by providing a new decorator class, instead of directly overriding
helper behavior.
  • Loading branch information
tom johnson authored and Tom Johnson committed May 6, 2020
1 parent 040b068 commit 0dffbf8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion app/helpers/hyrax/title_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ def construct_page_title(*elements)
(elements.flatten.compact + [application_name]).join(' // ')
end

##
# @deprecated
def curation_concern_page_title(curation_concern)
Hyrax::PageTitleDecorator.new(curation_concern).page_title
Deprecation.warn 'The curation_concern_page_title helper will be removed in Hyrax 4.0.' \
"\n\tUse title_presenter(curation_concern).page_title instead."
title_presenter(curation_concern).page_title
end

def default_page_title
text = controller_name.singularize.titleize
text = "#{action_name.titleize} " + text if action_name
construct_page_title(text)
end

def title_presenter(resource)
Hyrax::PageTitleDecorator.new(resource)
end
end
2 changes: 1 addition & 1 deletion app/views/hyrax/base/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% provide :page_title, curation_concern_page_title(curation_concern) %>
<% provide :page_title, title_presenter(curation_concern).page_title %>
<% provide :page_header do %>
<h1><span class="fa fa-edit" aria-hidden="true"></span><%= t("hyrax.works.update.header") %></h1>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/base/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% provide :page_title, curation_concern_page_title(curation_concern) %>
<% provide :page_title, title_presenter(curation_concern).page_title %>
<% provide :page_header do %>
<h1><%= t("hyrax.works.create.header", type: curation_concern.human_readable_type) %></h1>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/file_sets/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render "shared/nav_safety_modal" %>
<% provide :page_title, curation_concern_page_title(curation_concern) %>
<% provide :page_title, title_presenter(curation_concern).page_title %>
<% provide :page_header do %>
<h1><span class="fa fa-edit" aria-hidden="true"></span><%= t('.header', file_set: curation_concern) %></h1>
<% end %>
Expand Down

0 comments on commit 0dffbf8

Please sign in to comment.