Skip to content

Commit ce261e3

Browse files
authored
Merge pull request #1240 from ElixirTeSS/spaces-feature-toggle
Spaces feature improvements
2 parents 02036a6 + 6fb26b5 commit ce261e3

6 files changed

Lines changed: 37 additions & 3 deletions

File tree

app/models/space.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Space < ApplicationRecord
2-
FEATURES = %w[events materials elearning_materials learning_paths workflows collections trainers content_providers nodes].freeze
2+
FEATURES = %w[events materials elearning_materials learning_paths workflows collections trainers content_providers nodes spaces].freeze
33

44
include PublicActivity::Common
55
include LogParameterChanges

app/views/layouts/_footer.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<div class="footer-item">
2828
<%= link_to t('footer.about', title: TeSS::Config.site['title_short']), about_path %>
2929
</div>
30+
<% if TeSS::Config.feature['spaces'] %>
31+
<div class="footer-item">
32+
<%= link_to t('footer.browse_spaces'), spaces_path %>
33+
</div>
34+
<% end %>
3035
<div class="footer-item">
3136
<%= link_to t('footer.funding'), us_path(anchor: 'funding') %>
3237
</div>

app/views/static/home/_counters.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% features ||= ['events', 'materials', 'workflows', 'learning_paths', 'trainers'] %>
2-
<% features = features.select { |f| TeSS::Config.feature[f] } %>
2+
<% features = features.select { |f| feature_enabled?(f) } %>
33

44
<section id="counters">
55
<ul class="counter">

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ en:
860860
funding: Funding & acknowledgements
861861
privacy: Privacy
862862
cookie_preferences: Cookie preferences
863+
browse_spaces: Browse Spaces
863864
version: 'Version:'
864865
source_code: Source code
865866
api_documentation: API documentation

test/controllers/spaces_controller_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class SpacesControllerTest < ActionController::TestCase
246246
'elearning_materials': false,
247247
'learning_paths': false,
248248
'workflows': true,
249+
'spaces': true,
249250
'collections': false,
250251
'content_providers': false,
251252
'trainers': false,
@@ -255,7 +256,7 @@ class SpacesControllerTest < ActionController::TestCase
255256
with_settings(feature: features) do
256257
get :edit, params: { id: @space }
257258
assert_response :success
258-
assert_select '[name="space[enabled_features][]"]', count: 3 # +1 because of the blank input that allows you to
259+
assert_select '[name="space[enabled_features][]"]', count: 4 # +1 because of the blank input that allows you to
259260
# clear the list
260261
assert_select '#space_enabled_features_events', count: 1
261262
assert_select '#space_enabled_features_workflows', count: 1

test/controllers/static_controller_test.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,31 @@ class StaticControllerTest < ActionController::TestCase
712712
end
713713
end
714714
end
715+
716+
test 'disabled features do not show as counters on space front page' do
717+
space = spaces(:plants)
718+
space.disabled_features = ['materials']
719+
space.save!
720+
721+
with_host('plants.mytess.training') do
722+
get :home
723+
end
724+
725+
assert_select '.resource-counter a[href=?]', materials_path, count: 0
726+
assert_select '.resource-counter a[href=?]', events_path, count: 1
727+
end
728+
729+
test 'can disable spaces index from directory, but it still shows up in the footer' do
730+
space = spaces(:plants)
731+
space.disabled_features = ['spaces']
732+
space.save!
733+
734+
with_settings(feature: { 'events': false }) do
735+
with_host('plants.mytess.training') do
736+
get :home
737+
assert_select 'ul.nav.navbar-nav li a[href=?]', spaces_path, count: 0
738+
assert_select '.footer-item a[href=?]', spaces_path, count: 1
739+
end
740+
end
741+
end
715742
end

0 commit comments

Comments
 (0)