diff --git a/app/views/hyrax/file_sets/_show_details.html.erb b/app/views/hyrax/file_sets/_show_details.html.erb index d5ee520ed..878da7232 100644 --- a/app/views/hyrax/file_sets/_show_details.html.erb +++ b/app/views/hyrax/file_sets/_show_details.html.erb @@ -1,6 +1,6 @@

File Details

- <% if current_ability&.can?(:edit, @presenter.parent.id) %> + <% if @presenter.parent&.id && current_ability&.can?(:edit, @presenter.parent.id) %>
Depositor
<%= link_to_profile @presenter.depositor %>
<% end %> diff --git a/app/views/hyrax/file_sets/show.html.erb b/app/views/hyrax/file_sets/show.html.erb index d0987c1bb..2e8639723 100644 --- a/app/views/hyrax/file_sets/show.html.erb +++ b/app/views/hyrax/file_sets/show.html.erb @@ -13,7 +13,7 @@ <%# TODO: render 'show_descriptions' See https://github.com/samvera/hyrax/issues/1481 %> <%= render 'show_details' %> - <% if current_ability&.can?(:edit, @presenter.parent.id) %> + <% if @presenter.parent&.id && current_ability&.can?(:edit, @presenter.parent.id) %> <%= render 'hyrax/users/activity_log', events: @presenter.events %> <% end %> diff --git a/lib/extensions/extensions.rb b/lib/extensions/extensions.rb index 4ae7a951b..b0b7b1038 100644 --- a/lib/extensions/extensions.rb +++ b/lib/extensions/extensions.rb @@ -184,3 +184,6 @@ def attribute_will_change!(attr) # support for memoizing the member_presenter_factory Hyrax::WorkShowPresenter.prepend Extensions::Hyrax::WorkShowPresenter::MemberPresenterFactoryMemoization + +# support for rendering an orphan FileSet +Hyrax::FileSetsController.prepend Extensions::Hyrax::FileSetsController::RenderOrphanFileSet diff --git a/lib/extensions/hyrax/file_sets_controller/render_orphan_file_set.rb b/lib/extensions/hyrax/file_sets_controller/render_orphan_file_set.rb new file mode 100644 index 000000000..d49e24920 --- /dev/null +++ b/lib/extensions/hyrax/file_sets_controller/render_orphan_file_set.rb @@ -0,0 +1,20 @@ +# modified from hyrax 2.9.6 +module Extensions + module Hyrax + module FileSetsController + module RenderOrphanFileSet + + # modified from hyrax to handle missing parent without ruby error + def add_breadcrumb_for_action + case action_name + when 'edit'.freeze + add_breadcrumb I18n.t("hyrax.file_set.browse_view"), main_app.hyrax_file_set_path(params["id"]) + when 'show'.freeze + add_breadcrumb presenter.parent.to_s, main_app.polymorphic_path(presenter.parent) if presenter.parent + add_breadcrumb presenter.to_s, main_app.polymorphic_path(presenter) + end + end + end + end + end +end