diff --git a/app/helpers/hyrax/dashboard_helper_behavior.rb b/app/helpers/hyrax/dashboard_helper_behavior.rb
index 5f7c0f5aa6..5c7c4ac3ab 100644
--- a/app/helpers/hyrax/dashboard_helper_behavior.rb
+++ b/app/helpers/hyrax/dashboard_helper_behavior.rb
@@ -17,6 +17,19 @@ def number_of_works(user = current_user)
'n/a'
end
+ def link_to_works(user = current_user)
+ state = Blacklight::SearchState.new(params, CatalogController.blacklight_config)
+ facet_type = if Hyrax.config.use_valkyrie?
+ state.add_facet_params('generic_type_si', 'Work')
+ else
+ state.add_facet_params('generic_type_sim', 'Work')
+ end
+ facet_depositor = state.add_facet_params('depositor_ssim', user.to_s)
+ state = Hash.new {}
+ state["f"] = facet_type["f"].merge(facet_depositor["f"])
+ link_to(t("hyrax.dashboard.stats.works"), main_app.search_catalog_path(state))
+ end
+
# @param user [User]
# @return [Integer] number of FileSets the user deposited
def number_of_files(user = current_user)
diff --git a/app/views/hyrax/users/_vitals.html.erb b/app/views/hyrax/users/_vitals.html.erb
index 03b2452d74..755ef9a03f 100644
--- a/app/views/hyrax/users/_vitals.html.erb
+++ b/app/views/hyrax/users/_vitals.html.erb
@@ -9,7 +9,7 @@
<%= number_of_works(user) %>
-
<%= link_to_field('', '', t("hyrax.dashboard.stats.works"), {generic_type: "Work", depositor: user.to_s}) %>
+
<%= link_to_works(user) %>
- <%= user.total_file_views %> <%= t("hyrax.dashboard.stats.file_views").pluralize(user.total_file_views) %>
diff --git a/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb b/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb
index ba8f2265a4..f7f8da7036 100644
--- a/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb
+++ b/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb
@@ -31,6 +31,29 @@
end
end
+ describe "#link_to_works" do
+ let(:user1) { User.new(email: "abc@test") }
+ let(:user2) { User.new(email: "abc@test.123") }
+
+ before do
+ create_models("GenericWork", user1, user2)
+ end
+
+ context 'when valkyrie is not used' do
+ it "generates a link to the user's works" do
+ expect(Hyrax.config).to receive(:use_valkyrie?).and_return(false)
+ expect(helper.link_to_works(user1)).to include 'generic_type_sim%5D%5B%5D=Work'
+ end
+ end
+
+ context 'when valkyrie is used' do
+ it "generates a link to the user's works" do
+ expect(Hyrax.config).to receive(:use_valkyrie?).and_return(true)
+ expect(helper.link_to_works(user1)).to include 'generic_type_si%5D%5B%5D=Work'
+ end
+ end
+ end
+
describe "#number_of_files" do
let(:user1) { User.new(email: "abc@test") }
let(:user2) { User.new(email: "abc@test.123") }