diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 350de121c857..fcc01c11a19c 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -2064,7 +2064,8 @@ def ensure_sis_max_name_length_value!(account_settings)
:enable_name_pronunciation,
:enable_limited_access_for_students,
:enable_as_k5_account,
- :use_classic_font_in_k5].freeze
+ :use_classic_font_in_k5,
+ :show_sections_in_course_tray].freeze
def permitted_account_attributes
[:name,
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 32b439464249..53ee1a0eb24b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -254,7 +254,8 @@ def js_env(hash = {}, overwrite = false)
open_registration: @domain_root_account&.open_registration?,
collapse_global_nav: @current_user&.collapse_global_nav?,
release_notes_badge_disabled: @current_user&.release_notes_badge_disabled?,
- can_add_pronouns: @domain_root_account&.can_add_pronouns?
+ can_add_pronouns: @domain_root_account&.can_add_pronouns?,
+ show_sections_in_course_tray: @domain_root_account&.show_sections_in_course_tray?
},
RAILS_ENVIRONMENT: Canvas.environment,
}
diff --git a/app/models/account.rb b/app/models/account.rb
index ae906f295dea..e637202618e9 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -394,6 +394,7 @@ def allow_student_anonymous_discussion_topics
add_setting :disable_login_search_indexing, boolean: true, root_only: true, default: false
add_setting :allow_additional_email_at_registration, boolean: true, root_only: true, default: false
add_setting :limit_personal_access_tokens, boolean: true, root_only: true, default: false
+ add_setting :show_sections_in_course_tray, boolean: true, root_only: true, default: true
# Allow enabling metrics like Heap for sandboxes and other accounts without Salesforce data
add_setting :enable_usage_metrics, boolean: true, root_only: true, default: false
diff --git a/app/views/accounts/settings.html.erb b/app/views/accounts/settings.html.erb
index abd626040f03..7d9176ae0fbb 100644
--- a/app/views/accounts/settings.html.erb
+++ b/app/views/accounts/settings.html.erb
@@ -425,6 +425,15 @@
<% end %>
+ <% if !@account.site_admin? && @account.primary_settings_root_account? %>
+
+
+ <%= settings.check_box :show_sections_in_course_tray, checked: @account.show_sections_in_course_tray? %>
+ <%= settings.label :show_sections_in_course_tray, t("Show Sections in Course Tray.") %>
+ |
+
+ <% end %>
+
<% if !@account.site_admin? && @account.primary_settings_root_account? && @account.feature_enabled?(:admin_manage_access_tokens)%>
diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb
index 07eac19867a1..e2bd345657b4 100644
--- a/spec/controllers/accounts_controller_spec.rb
+++ b/spec/controllers/accounts_controller_spec.rb
@@ -378,6 +378,37 @@ def account_with_admin(opts = {})
expect(@account.settings[:sis_assignment_name_length_input][:value]).to eq "255"
end
+ it "updates 'show_sections_in_course_tray'" do
+ account_with_admin_logged_in
+ post(
+ :update,
+ params: {
+ id: @account.id,
+ account: {
+ settings: {
+ show_sections_in_course_tray: false
+ }
+ }
+ }
+ )
+ @account.reload
+ expect(@account.settings[:show_sections_in_course_tray]).to be false
+
+ post(
+ :update,
+ params: {
+ id: @account.id,
+ account: {
+ settings: {
+ show_sections_in_course_tray: true
+ }
+ }
+ }
+ )
+ @account.reload
+ expect(@account.settings[:show_sections_in_course_tray]).to be true
+ end
+
it "allows admins to set the sis_source_id on sub accounts" do
account_with_admin_logged_in
@account = @account.sub_accounts.create!
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 338fe3251ca7..aeb032ef6358 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -339,17 +339,18 @@
end
it "gets appropriate settings from the root account" do
- root_account = double(global_id: 1, id: 1, feature_enabled?: false, open_registration?: true, can_add_pronouns?: true, settings: {}, cache_key: "key", uuid: "bleh", salesforce_id: "blah")
+ root_account = double(global_id: 1, id: 1, feature_enabled?: false, open_registration?: true, can_add_pronouns?: true, show_sections_in_course_tray?: true, settings: {}, cache_key: "key", uuid: "bleh", salesforce_id: "blah")
allow(root_account).to receive(:kill_joy?).and_return(false)
allow(HostUrl).to receive_messages(file_host: "files.example.com")
controller.instance_variable_set(:@domain_root_account, root_account)
expect(controller.js_env[:SETTINGS][:open_registration]).to be_truthy
expect(controller.js_env[:SETTINGS][:can_add_pronouns]).to be_truthy
+ expect(controller.js_env[:SETTINGS][:show_sections_in_course_tray]).to be_truthy
expect(controller.js_env[:KILL_JOY]).to be_falsey
end
it "disables fun when set" do
- root_account = double(global_id: 1, id: 1, feature_enabled?: false, open_registration?: true, can_add_pronouns?: true, settings: {}, cache_key: "key", uuid: "blah", salesforce_id: "bleh")
+ root_account = double(global_id: 1, id: 1, feature_enabled?: false, open_registration?: true, can_add_pronouns?: true, show_sections_in_course_tray?: true, settings: {}, cache_key: "key", uuid: "blah", salesforce_id: "bleh")
allow(root_account).to receive(:kill_joy?).and_return(true)
allow(HostUrl).to receive_messages(file_host: "files.example.com")
controller.instance_variable_set(:@domain_root_account, root_account)
diff --git a/ui/features/navigation_header/react/lists/SplitCoursesList.tsx b/ui/features/navigation_header/react/lists/SplitCoursesList.tsx
index 1244b04abae4..71452b2e8251 100644
--- a/ui/features/navigation_header/react/lists/SplitCoursesList.tsx
+++ b/ui/features/navigation_header/react/lists/SplitCoursesList.tsx
@@ -33,7 +33,9 @@ const UNPUBLISHED = 'unpublished'
export const CourseListItemContent = ({course}: {course: Course}) => {
const sectionNames = (course.sections || []).map(section => section.name)
- const sectionDetails = sectionNames.length > 0 ? sectionNames.sort().join(', ') : null
+ const showSections = ENV.SETTINGS?.show_sections_in_course_tray
+ const sectionDetails =
+ showSections && sectionNames.length > 0 ? sectionNames.sort().join(', ') : null
const courseDetails =
ENV.FEATURES?.courses_popout_sisid && course.sis_course_id
? course.enrollment_term_id > 1
diff --git a/ui/features/navigation_header/react/trays/__tests__/CoursesTray.test.tsx b/ui/features/navigation_header/react/trays/__tests__/CoursesTray.test.tsx
index b1054ab3fac2..2b7662dbc730 100644
--- a/ui/features/navigation_header/react/trays/__tests__/CoursesTray.test.tsx
+++ b/ui/features/navigation_header/react/trays/__tests__/CoursesTray.test.tsx
@@ -111,6 +111,7 @@ describe('CoursesTray', () => {
window.ENV.K5_USER = false
window.ENV.FEATURES.courses_popout_sisid = true
window.ENV.current_user_roles = []
+ window.ENV.SETTINGS = {show_sections_in_course_tray: true}
})
afterEach(() => {
@@ -184,6 +185,12 @@ describe('CoursesTray', () => {
expect(getByText('Section3, Section4, Section5')).toBeInTheDocument()
})
+ it('does not render sections if setting show_sections_in_course_tray is disabled', () => {
+ window.ENV.SETTINGS.show_sections_in_course_tray = false
+ const {queryByText} = render()
+ expect(queryByText('Section3, Section4, Section5')).not.toBeInTheDocument()
+ })
+
it('renders the correct URL for each course', () => {
const {getByText} = render()
expect(getByText('Course1').getAttribute('href')).toBe('/courses/1')
|