Skip to content

Commit

Permalink
🧹 Address PR comments
Browse files Browse the repository at this point in the history
This commit addresses comments from the review but one thing that is of
note is loading the I18n translations in the application.rb file.  We
needed this because our decorators load prior to I18n loads the locales
in our config/locales directory for them to use so we were getting
missing translations.
  • Loading branch information
kirkkwang committed Dec 22, 2023
1 parent e718e51 commit 4942fe4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/services/hyrax/indexes_thumbnails_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Hyrax
module IndexesThumbnailsDecorator
# Returns the value for the thumbnail path to put into the solr document
def thumbnail_path
if object.class == Collection && UploadedCollectionThumbnailPathService.uploaded_thumbnail?(object)
if object.try(:collection?) && UploadedCollectionThumbnailPathService.uploaded_thumbnail?(object)
UploadedCollectionThumbnailPathService.call(object)
else
super
Expand Down
8 changes: 2 additions & 6 deletions app/services/hyrax/quick_classification_query_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ module QuickClassificationQueryDecorator
# @param [::User] user the current user
# @param [#call] concern_name_normalizer (String#constantize) a proc that translates names to classes
# @param [Array<String>] models the options to display, defaults to everything.
def initialize(user,
models: Site.instance.available_works,
concern_name_normalizer: ->(str) { str.constantize })
@user = user
@concern_name_normalizer = concern_name_normalizer
@models = models
def initialize(user, models: Site.instance.available_works, **kwargs)
super(user, **kwargs.merge(models:))
end

# OVERRIDE: only use work types that are enabled in the current tenant
Expand Down
1 change: 1 addition & 0 deletions app/services/hyrax/thumbnail_path_service_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

# OVERRIDE Hyrax v5.0.0rc2 - use site defaults instead of app wide defaults

module Hyrax
module ThumbnailPathServiceDecorator
def default_image
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def self.path_for(relative_path)

DerivativeRodeo::Generators::HocrGenerator.additional_tessearct_options = nil

# Load locales early so decorators can use them during initialization
I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml')]

# Allows us to use decorator files
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
Expand Down

0 comments on commit 4942fe4

Please sign in to comment.