Skip to content

Commit

Permalink
Merge branch 'main' into flexible_double_combo
Browse files Browse the repository at this point in the history
  • Loading branch information
laritakr authored Jul 1, 2024
2 parents 6e18484 + 3083b6f commit 9e65f4a
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 26 deletions.
13 changes: 11 additions & 2 deletions .dassie/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ gem 'coffee-rails', '~> 4.2'
gem 'dalli'
gem 'devise'
gem 'devise-guests', '~> 0.8'

# Required because grpc and google-protobuf gem's binaries are not compatible with Alpine Linux.
# To install the package in Alpine: `apk add ruby-grpc`
# The pinned versions should match the version provided by the Alpine packages.
if RUBY_PLATFORM =~ /musl/
path '/usr/lib/ruby/gems/3.2.0' do
gem 'google-protobuf', '~> 3.24.4', force_ruby_platform: true
gem 'grpc', '~> 1.59.3', force_ruby_platform: true
end
end

gemspec name: 'hyrax', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gem 'grpc', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'pg', '~> 1.3'
Expand Down
13 changes: 11 additions & 2 deletions .koppie/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ gem 'coffee-rails', '~> 4.2'
gem 'dalli'
gem 'devise'
gem 'devise-guests', '~> 0.8'
gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gem 'grpc', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux

# Required because grpc and google-protobuf gem's binaries are not compatible with Alpine Linux.
# To install the package in Alpine: `apk add ruby-grpc`
# The pinned versions should match the version provided by the Alpine packages.
if RUBY_PLATFORM =~ /musl/
path '/usr/lib/ruby/gems/3.2.0' do
gem 'google-protobuf', '~> 3.24.4', force_ruby_platform: true
gem 'grpc', '~> 1.59.3', force_ruby_platform: true
end
end

gemspec name: 'hyrax', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN apk --no-cache upgrade && \
imagemagick-tiff \
imagemagick-webp \
jemalloc \
ruby-grpc \
tzdata \
nodejs \
yarn \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Admin
module Analytics
class WorkReportsController < AnalyticsController
include Hyrax::BreadcrumbsForWorksAnalytics
before_action :authenticate_user!

def index
return unless Hyrax.config.analytics_reporting?
Expand All @@ -14,10 +15,7 @@ def index
@top_works = paginate(top_works_list, rows: 10)
@top_file_set_downloads = paginate(top_files_list, rows: 10)

if current_user.ability.admin?
@pageviews = Hyrax::Analytics.daily_events('work-view')
@downloads = Hyrax::Analytics.daily_events('file-set-download')
end
@pageviews = Hyrax::Analytics.daily_events('work-view'), @downloads = Hyrax::Analytics.daily_events('file-set-download') if current_user.ability.admin?

respond_to do |format|
format.html
Expand Down
21 changes: 16 additions & 5 deletions app/services/hyrax/admin_set_create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Hyrax
# @see Hyrax::PermissionTemplate
# @see Sipity::Workflow
class AdminSetCreateService # rubocop:disable Metrics/ClassLength
DEFAULT_ID = 'admin_set/default'
DEFAULT_ID = 'admin_set_default'
DEFAULT_TITLE = ['Default Admin Set'].freeze

class_attribute :permissions_create_service, :default_admin_set_persister
Expand Down Expand Up @@ -124,11 +124,22 @@ def find_default_admin_set
# do not support hardcoded IDs (e.g. postgres)
# @return [Hyrax::AdministrativeSet] the default admin set; nil if not found
def find_unsaved_default_admin_set
admin_set = Hyrax.query_service.find_by(id: DEFAULT_ID)
default_admin_set_persister.update(default_admin_set_id: DEFAULT_ID) if save_default?
admin_set = begin
# to support repositories still using the deprecated 'admin_set/default' as DEFAULT_ID
Hyrax.query_service.find_by(id: 'admin_set/default')
rescue Ldp::BadRequest, Valkyrie::Persistence::ObjectNotFoundError
# Fedora 6.5+ does not support slashes in IDs, hence the need to rescue Ldp::BadRequest
# if an admin set with deprecated ID 'admin_set/default' does not exist, check again for admin set with DEFAULT_ID
begin
Hyrax.query_service.find_by(id: DEFAULT_ID)
rescue Valkyrie::Persistence::ObjectNotFoundError
nil
end
end

default_admin_set_persister.update(default_admin_set_id: admin_set.id.to_s) if admin_set.present? && save_default?

admin_set
rescue Valkyrie::Persistence::ObjectNotFoundError
# a default admin set hasn't been created yet
end

# @return [String | nil] the default admin set id; returns nil if not set
Expand Down
13 changes: 6 additions & 7 deletions app/views/hyrax/base/_show_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" type="button" id="dropdown-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= t('.attach_child') %>
<ul class="dropdown-menu">
<% presenter.valid_child_concerns.each do |concern| %>
<li class="dropdown-item">
<%= link_to "Attach #{concern.human_readable_type}", polymorphic_path([main_app, :new, :hyrax, :parent, concern.model_name.singular.to_sym], parent_id: presenter.id) %>
</li>
<% end %>
</ul>
</button>
<div class="dropdown-menu">
<% presenter.valid_child_concerns.each do |concern| %>
<%= link_to "Attach #{concern.human_readable_type}", polymorphic_path([main_app, :new, :hyrax, :parent, concern.model_name.singular.to_sym], parent_id: presenter.id), class: "dropdown-item" %>
<% end %>
</div>
</div>
<% end %>
<%= link_to t('.delete'), [main_app, presenter], class: 'btn btn-danger', data: { confirm: t('.confirm_delete', work_type: presenter.human_readable_type) }, method: :delete %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'

RSpec.describe Hyrax::Admin::Analytics::WorkReportsController, type: :controller do
routes { Hyrax::Engine.routes }
describe 'GET #index' do
context 'when user is not logged in' do
it 'redirects to the login page' do
get :index
expect(response).to be_redirect
expect(flash[:alert]).to eq("You need to sign in or sign up before continuing.")
end
end
end
end
1 change: 1 addition & 0 deletions spec/features/work_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

after do
Rails::Generators.invoke('hyrax:work', ['Catapult', '--quiet'], behavior: :revoke, destination_root: Rails.root)
Hyrax::ModelRegistry.instance_variable_set(:@work_class_names, nil) # Catapult gets memoized here
end

it 'catapults should behave like generic works' do
Expand Down
10 changes: 4 additions & 6 deletions spec/services/hyrax/quick_classification_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
describe '#each' do
let(:thing) { double }

before do
# Ensure that no other test has altered the configuration:
allow(Hyrax.config).to receive(:registered_curation_concern_types).and_return(['GenericWork'])
end

it "calls the block once for every model" do
expect(thing).to receive(:test).with(GenericWork)
expect(Hyrax.config.curation_concerns.size).to be > 0
Hyrax.config.curation_concerns.each do |cc|
expect(thing).to receive(:test).with(cc)
end

query.each { |f| thing.test(f) }
end
Expand Down

0 comments on commit 9e65f4a

Please sign in to comment.