From db18ca9cc0af5bf52ec4ba2b54621abf97a825ed Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 18 Jul 2023 15:06:33 -0700 Subject: [PATCH 1/9] :broom: comment out the feature button and the featured works feature flipper The ability to use featured works has been disabled. Because of this, for now we are hiding the feature flipping ability and the feature button on the works show page since setting either will do nothing. - Issue https://github.com/scientist-softserv/utk-hyku/issues/472 --- app/views/hyrax/base/_show_actions.html.erb | 64 +++++++++++++++++++++ config/features.rb | 9 ++- 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 app/views/hyrax/base/_show_actions.html.erb diff --git a/app/views/hyrax/base/_show_actions.html.erb b/app/views/hyrax/base/_show_actions.html.erb new file mode 100644 index 00000000..d6dba8e2 --- /dev/null +++ b/app/views/hyrax/base/_show_actions.html.erb @@ -0,0 +1,64 @@ +<%# OVERRIDE Hyrax 3.5.0 to remove feature work button %> + +
+
+ <% if !workflow_restriction?(presenter) %> + <% if presenter.show_deposit_for?(collections: @user_collections) %> + + <%= button_tag t('hyrax.dashboard.my.action.add_to_collection'), + class: 'btn btn-default submits-batches submits-batches-add', + data: { toggle: "modal", target: "#collection-list-container" } %> + <% end %> + <%# OVERRIDE begin %> + <%# if presenter.work_featurable? %> + <%#= link_to t('.feature'), hyrax.featured_work_path(presenter, format: :json), + data: { behavior: 'feature' }, + class: presenter.display_feature_link? ? 'btn btn-default' : 'btn btn-default collapse' %> + + <%#= link_to t('.unfeature'), hyrax.featured_work_path(presenter, format: :json), + data: { behavior: 'unfeature' }, + class: presenter.display_unfeature_link? ? 'btn btn-default' : 'btn btn-default collapse' %> + <%# end %> + <%# OVERRIDE end %> + <% end %> + <% if Hyrax.config.analytics? %> + <% # turbolinks needs to be turned off or the page will use the cache and the %> + <% # analytics graph will not show unless the page is refreshed. %> + <%= link_to t('.analytics'), presenter.stats_path, id: 'stats', class: 'btn btn-default', data: { turbolinks: false } %> + <% end %> +
+ +
+ <% if presenter.editor? && !workflow_restriction?(presenter) %> + <%= link_to t('.edit'), edit_polymorphic_path([main_app, presenter]), class: 'btn btn-default' %> + <% if presenter.member_count > 1 %> + <%= link_to t("hyrax.file_manager.link_text"), polymorphic_path([main_app, :file_manager, presenter]), class: 'btn btn-default' %> + <% end %> + <% if presenter.valid_child_concerns.length > 0 %> +
+ + +
+ <% 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 %> + <% end %> +
+
+ + + + + <%= render 'hyrax/dashboard/collections/form_for_select_collection', user_collections: @user_collections %> + + + + + + diff --git a/config/features.rb b/config/features.rb index cab49ff0..b14951d1 100644 --- a/config/features.rb +++ b/config/features.rb @@ -9,9 +9,12 @@ default: true, description: "Shows the 'Share Your Work' button on the homepage." - feature :show_featured_works, - default: true, - description: "Shows the Featured Works tab on the homepage." + # Commenting this out means all tenants won't get this the show_featured_works flipper + # TODO: We should find a way to make this tenant specific + # ref: https://github.com/scientist-softserv/utk-hyku/issues/47 + # feature :show_featured_works, + # default: true, + # description: "Shows the Featured Works tab on the homepage." feature :show_recently_uploaded, default: true, From f490fe9e131a0fb7f4225496a637126be5454766 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 18 Jul 2023 16:04:06 -0700 Subject: [PATCH 2/9] :gear: comment out #display_featured_works since it's disabled --- app/presenters/hyrax/homepage_presenter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/presenters/hyrax/homepage_presenter.rb b/app/presenters/hyrax/homepage_presenter.rb index 76fe4bf4..026b6250 100644 --- a/app/presenters/hyrax/homepage_presenter.rb +++ b/app/presenters/hyrax/homepage_presenter.rb @@ -56,7 +56,8 @@ def display_featured_researcher? # changed to add feature flag for featured work def display_featured_works? - Flipflop.show_featured_works? + # Flipflop.show_featured_works? + false end # changed to add feature flag for recently uploaded From 3182402c5ff7c64cb6af2868999e87c872863ed9 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 18 Jul 2023 16:44:39 -0700 Subject: [PATCH 3/9] :broom: correct failing specs --- app/controllers/hyrax/homepage_controller.rb | 2 +- app/presenters/hyrax/homepage_presenter.rb | 8 +++++--- config/features.rb | 9 +++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/hyrax/homepage_controller.rb b/app/controllers/hyrax/homepage_controller.rb index 249f9624..b7f069af 100644 --- a/app/controllers/hyrax/homepage_controller.rb +++ b/app/controllers/hyrax/homepage_controller.rb @@ -36,7 +36,7 @@ def search_builder_class # OVERRIDE: Hyrax v3.4.2 - For dc_repository add @collections_list def index - @presenter = presenter_class.new(current_ability, collections) + @presenter = presenter_class.new(current_ability, collections, current_account) @featured_researcher = ContentBlock.for(:researcher) @marketing_text = ContentBlock.for(:marketing) @home_text = ContentBlock.for(:home_text) diff --git a/app/presenters/hyrax/homepage_presenter.rb b/app/presenters/hyrax/homepage_presenter.rb index 026b6250..f267b2ab 100644 --- a/app/presenters/hyrax/homepage_presenter.rb +++ b/app/presenters/hyrax/homepage_presenter.rb @@ -11,9 +11,10 @@ class HomepagePresenter self.create_work_presenter_class = Hyrax::SelectTypeListPresenter attr_reader :current_ability, :collections - def initialize(current_ability, collections) + def initialize(current_ability, collections, current_account = nil) @current_ability = current_ability @collections = collections + @current_account = current_account end # OVERRIDE: Hyrax v3.4.0 to removed: @return [Boolean] If the @@ -56,8 +57,9 @@ def display_featured_researcher? # changed to add feature flag for featured work def display_featured_works? - # Flipflop.show_featured_works? - false + return false if @current_account.name == 'dc' + + Flipflop.show_featured_works? end # changed to add feature flag for recently uploaded diff --git a/config/features.rb b/config/features.rb index b14951d1..d1ff67e8 100644 --- a/config/features.rb +++ b/config/features.rb @@ -9,12 +9,9 @@ default: true, description: "Shows the 'Share Your Work' button on the homepage." - # Commenting this out means all tenants won't get this the show_featured_works flipper - # TODO: We should find a way to make this tenant specific - # ref: https://github.com/scientist-softserv/utk-hyku/issues/47 - # feature :show_featured_works, - # default: true, - # description: "Shows the Featured Works tab on the homepage." + feature :show_featured_works, + default: false, + description: "Shows the Featured Works tab on the homepage." feature :show_recently_uploaded, default: true, From 20e836cf77738c864e9031f6e8f7b29083efa6aa Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 18 Jul 2023 17:04:28 -0700 Subject: [PATCH 4/9] :gift: add an override partial Add a partial to override the features dashboard so that the show_featured_works option is not available for the dc tenant. This will reduce user confusion because this feature has been removed for this tenant, but the feature buttons were still present as if it could do something. --- app/views/hyrax/admin/features/index.html.erb | 70 +++++++++++++++++++ config/features.rb | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 app/views/hyrax/admin/features/index.html.erb diff --git a/app/views/hyrax/admin/features/index.html.erb b/app/views/hyrax/admin/features/index.html.erb new file mode 100644 index 00000000..0ca5fd89 --- /dev/null +++ b/app/views/hyrax/admin/features/index.html.erb @@ -0,0 +1,70 @@ +<% #OVERRIDE HYRAX 3.5.0 to skip show_featured_works for the dc tenant %> +<% provide :page_header do %> +

<%= t('.header') %>

+<% end %> +
+
+
+
+
+ + + + + + + + + + + <% @feature_set.grouped_features.each do |group, features| -%> + <% if @feature_set.grouped? -%> + + + + + <% end -%> + <% #OVERRIDE HYRAX 3.5.0 to skip show_featured_works for the dc tenant %> + <% modified_features = features.reject { |item| item.instance_variable_get(:@key) == :show_featured_works && current_account.name == 'dc' } %> + <% modified_features.each do |feature| %> + + + + + + <% @feature_set.strategies.each do |strategy| -%> + <% next unless strategy.is_a? Flipflop::Strategies::ActiveRecordStrategy %> + + <% end -%> + + <% end -%> + <% end -%> + +
<%= t('.feature') %><%= t('.description') %><%= t('.action') %>
+

+ <%= t(group ? group.name : :default, scope: [:flipflop, :groups], default: group ? group.title : nil) -%> +

+
+ <%= @feature_set.status(feature) -%> + <%= feature.name.humanize -%><%= feature.description -%> +
+ <%= form_tag(hyrax.admin_feature_strategy_path(feature.key, strategy.key), method: :put) do -%> +
+ <%= submit_tag "on", + type: "submit", + class: Flipflop.enabled?(feature.name.to_sym) ? 'active' : nil, + disabled: !strategy.switchable? -%> + + <%= submit_tag "off", + type: "submit", + class: Flipflop.enabled?(feature.name.to_sym) ? nil : 'active', + disabled: !strategy.switchable? -%> +
+ <% end -%> +
+
+
+
+
+
+
\ No newline at end of file diff --git a/config/features.rb b/config/features.rb index d1ff67e8..cab49ff0 100644 --- a/config/features.rb +++ b/config/features.rb @@ -10,7 +10,7 @@ description: "Shows the 'Share Your Work' button on the homepage." feature :show_featured_works, - default: false, + default: true, description: "Shows the Featured Works tab on the homepage." feature :show_recently_uploaded, From 1f217490663f827367f8ce386ec1be36673a9f98 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 18 Jul 2023 17:48:40 -0700 Subject: [PATCH 5/9] :white_check_mark: correct failing spec --- app/views/hyrax/base/_show_actions.html.erb | 11 ++++++----- spec/controllers/hyrax/homepage_controller_spec.rb | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/hyrax/base/_show_actions.html.erb b/app/views/hyrax/base/_show_actions.html.erb index d6dba8e2..c3ee5ce3 100644 --- a/app/views/hyrax/base/_show_actions.html.erb +++ b/app/views/hyrax/base/_show_actions.html.erb @@ -10,15 +10,16 @@ data: { toggle: "modal", target: "#collection-list-container" } %> <% end %> <%# OVERRIDE begin %> - <%# if presenter.work_featurable? %> - <%#= link_to t('.feature'), hyrax.featured_work_path(presenter, format: :json), + <% if presenter.work_featurable? && current_account.name != 'dc' %> + <%= link_to t('.feature'), hyrax.featured_work_path(presenter, format: :json), data: { behavior: 'feature' }, class: presenter.display_feature_link? ? 'btn btn-default' : 'btn btn-default collapse' %> - - <%#= link_to t('.unfeature'), hyrax.featured_work_path(presenter, format: :json), + <%= link_to t('.unfeature'), hyrax.featured_work_path(presenter, format: :json), data: { behavior: 'unfeature' }, class: presenter.display_unfeature_link? ? 'btn btn-default' : 'btn btn-default collapse' %> - <%# end %> + <% end %> + + <%# OVERRIDE end %> <% end %> <% if Hyrax.config.analytics? %> diff --git a/spec/controllers/hyrax/homepage_controller_spec.rb b/spec/controllers/hyrax/homepage_controller_spec.rb index 8582df0f..54c0bc0e 100644 --- a/spec/controllers/hyrax/homepage_controller_spec.rb +++ b/spec/controllers/hyrax/homepage_controller_spec.rb @@ -110,7 +110,8 @@ it "initializes the presenter with ability and a list of collections" do expect(Hyrax::HomepagePresenter).to receive(:new).with(Ability, - [collection]) + [collection], + Account) .and_return(presenter) get :index expect(response).to be_success From f91056190d1b209a0149c6590b361651b88eea23 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 18 Jul 2023 19:55:54 -0700 Subject: [PATCH 6/9] :recycle: refactor per PR feedback about magic strings --- app/helpers/accounts_helper.rb | 1 + app/presenters/hyrax/homepage_presenter.rb | 2 +- app/views/hyrax/admin/features/index.html.erb | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index e1aaea70..ea038f61 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true module AccountsHelper + TENANTS_WITH_NO_WORK_FEATURES = ['dc'].freeze end diff --git a/app/presenters/hyrax/homepage_presenter.rb b/app/presenters/hyrax/homepage_presenter.rb index f267b2ab..f4096951 100644 --- a/app/presenters/hyrax/homepage_presenter.rb +++ b/app/presenters/hyrax/homepage_presenter.rb @@ -57,7 +57,7 @@ def display_featured_researcher? # changed to add feature flag for featured work def display_featured_works? - return false if @current_account.name == 'dc' + return false if AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(@current_account.name) Flipflop.show_featured_works? end diff --git a/app/views/hyrax/admin/features/index.html.erb b/app/views/hyrax/admin/features/index.html.erb index 0ca5fd89..38aa537d 100644 --- a/app/views/hyrax/admin/features/index.html.erb +++ b/app/views/hyrax/admin/features/index.html.erb @@ -28,8 +28,9 @@ <% end -%> - <% #OVERRIDE HYRAX 3.5.0 to skip show_featured_works for the dc tenant %> - <% modified_features = features.reject { |item| item.instance_variable_get(:@key) == :show_featured_works && current_account.name == 'dc' } %> + <% #OVERRIDE HYRAX 3.5.0 to skip show_featured_works per denylist: TENANTS_WITH_NO_WORK_FEATURES %> + <% raise '' %> + <% modified_features = features.reject { |item| item.instance_variable_get(:@key) == :show_featured_works && AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(current_account.name) } %> <% modified_features.each do |feature| %> From 138ad5a711a4e225f459396228a52d6183f21c65 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 19 Jul 2023 07:15:08 -0700 Subject: [PATCH 7/9] :broom: remove raise statement oops! --- app/views/hyrax/admin/features/index.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/hyrax/admin/features/index.html.erb b/app/views/hyrax/admin/features/index.html.erb index 38aa537d..95d151e8 100644 --- a/app/views/hyrax/admin/features/index.html.erb +++ b/app/views/hyrax/admin/features/index.html.erb @@ -29,7 +29,6 @@ <% end -%> <% #OVERRIDE HYRAX 3.5.0 to skip show_featured_works per denylist: TENANTS_WITH_NO_WORK_FEATURES %> - <% raise '' %> <% modified_features = features.reject { |item| item.instance_variable_get(:@key) == :show_featured_works && AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(current_account.name) } %> <% modified_features.each do |feature| %> From 6a85dbe51cb49da9c885c045d52b8e75402a8606 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 19 Jul 2023 07:15:08 -0700 Subject: [PATCH 8/9] :broom: remove raise statement oops! --- app/presenters/hyrax/homepage_presenter.rb | 2 +- app/views/hyrax/admin/features/index.html.erb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/presenters/hyrax/homepage_presenter.rb b/app/presenters/hyrax/homepage_presenter.rb index f4096951..f179f816 100644 --- a/app/presenters/hyrax/homepage_presenter.rb +++ b/app/presenters/hyrax/homepage_presenter.rb @@ -57,7 +57,7 @@ def display_featured_researcher? # changed to add feature flag for featured work def display_featured_works? - return false if AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(@current_account.name) + return false if AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(@current_account.name) Flipflop.show_featured_works? end diff --git a/app/views/hyrax/admin/features/index.html.erb b/app/views/hyrax/admin/features/index.html.erb index 38aa537d..95d151e8 100644 --- a/app/views/hyrax/admin/features/index.html.erb +++ b/app/views/hyrax/admin/features/index.html.erb @@ -29,7 +29,6 @@ <% end -%> <% #OVERRIDE HYRAX 3.5.0 to skip show_featured_works per denylist: TENANTS_WITH_NO_WORK_FEATURES %> - <% raise '' %> <% modified_features = features.reject { |item| item.instance_variable_get(:@key) == :show_featured_works && AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(current_account.name) } %> <% modified_features.each do |feature| %> From 9e5c88a244b81efa22458c4bba58d1b771e6b8c0 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 19 Jul 2023 07:44:20 -0700 Subject: [PATCH 9/9] :broom: update per PR feedback to replace magic string w the use of a constant --- app/views/hyrax/base/_show_actions.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/hyrax/base/_show_actions.html.erb b/app/views/hyrax/base/_show_actions.html.erb index c3ee5ce3..dd2cf2fe 100644 --- a/app/views/hyrax/base/_show_actions.html.erb +++ b/app/views/hyrax/base/_show_actions.html.erb @@ -10,7 +10,7 @@ data: { toggle: "modal", target: "#collection-list-container" } %> <% end %> <%# OVERRIDE begin %> - <% if presenter.work_featurable? && current_account.name != 'dc' %> + <% if presenter.work_featurable? && AccountsHelper::TENANTS_WITH_NO_WORK_FEATURES.include?(@current_account.name) %> <%= link_to t('.feature'), hyrax.featured_work_path(presenter, format: :json), data: { behavior: 'feature' }, class: presenter.display_feature_link? ? 'btn btn-default' : 'btn btn-default collapse' %>