mv some js_bundle and css_bundle’s to controller

by moving these js_bundles and css_bundles to the controllers instead
Of the views, once we actually start streaming these pages, they will
end up in the <head> and so the browser will find out about them faster
than if they were left in the view.html.erb files

Test plan:
* nothing should change
* as in, in code review, you should be able to statically analyze these
  Changes and see that each of these new things in a controller action
  Was just cut/pasted from the view erb file for that action

Change-Id: I78817c12c02d41f9c9e7651cfc8352993e98382b
Reviewed-on: https://gerrit.instructure.com/202773
Tested-by: Jenkins
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Steven Burnett <sburnett@instructure.com>
This commit is contained in:
Ryan Shaw 2019-07-23 17:12:53 -06:00 committed by James Williams
parent e78c75364c
commit bced49e475
25 changed files with 63 additions and 78 deletions

View File

@ -238,6 +238,14 @@ class AssignmentsController < ApplicationController
@mark_done = MarkDonePresenter.new(self, @context, params["module_item_id"], @current_user, @assignment)
@show_locked_page = @locked && !@locked[:can_view]
if @show_locked_page
js_bundle :module_sequence_footer
else
css_bundle :assignments
js_bundle :assignment_show
end
render locals: {
eula_url: tool_eula_url,
show_moderation_link: @assignment.moderated_grading? && @assignment.permits_moderation?(@current_user)

View File

@ -288,6 +288,9 @@ class ContextController < ApplicationController
js_env(CONTEXT_USER_DISPLAY_NAME: @user.short_name)
js_bundle :user_name, "legacy/context_roster_user"
css_bundle :roster_user, :pairing_code
if @domain_root_account.enable_profiles?
@user_data = profile_data(
@user.profile,

View File

@ -110,6 +110,8 @@ class ContextModulesController < ApplicationController
session[:module_progressions_initialized] = true
end
add_body_class('padless-content')
js_bundle :context_modules
css_bundle :content_next, :context_modules2
end
end

View File

@ -497,6 +497,8 @@ class CoursesController < ApplicationController
end
end
@visible_groups = @current_user.visible_groups
css_bundle :context_list, :course_list
js_bundle :course_list
if @current_user
content_for_head helpers.auto_discovery_link_tag(:atom, feeds_user_format_path(@current_user.feed_code, :atom), {:title => t('titles.rss.course_announcements', "Course Announcements Atom Feed")})
@ -1883,6 +1885,29 @@ class CoursesController < ApplicationController
@course_home_sub_navigation_tools.reject! {|tool| tool.course_home_sub_navigation(:visibility) == 'admins'}
end
css_bundle :dashboard
css_bundle :react_todo_sidebar if planner_enabled?
case @course_home_view
when 'wiki'
js_bundle :wiki_page_show
css_bundle :wiki_page, :tinymce
when 'modules'
js_bundle :context_modules
css_bundle :content_next, :context_modules2
when 'assignments'
js_bundle :assignment_index
css_bundle :new_assignments
add_body_class('hide-content-while-scripts-not-loaded', 'with_item_groups')
when 'syllabus'
js_bundle :syllabus
css_bundle :syllabus, :tinymce
else
js_bundle :dashboard
end
js_bundle :course, 'legacy/courses_show'
css_bundle :course_show
if @context_enrollment
content_for_head helpers.auto_discovery_link_tag(:atom, feeds_course_format_path(@context_enrollment.feed_code, :atom), {:title => t("Course Atom Feed")})
elsif @context.available?

View File

@ -70,6 +70,10 @@ class QuestionBanksController < ApplicationController
@alignments = Canvas::ICU.collate_by(@bank.learning_outcome_alignments) { |a| a.learning_outcome.short_description }
@questions = @bank.assessment_questions.active.paginate(:per_page => 50, :page => 1)
end
js_bundle :quizzes_bundle, :question_bank
css_bundle :quizzes, :learning_outcomes, :tinymce, :question_bank
@page_title = @bank.title
end
def move_questions

View File

@ -358,6 +358,8 @@ class Quizzes::QuizzesController < ApplicationController
conditional_release_js_env(@quiz.assignment)
set_master_course_js_env_data(@quiz, @context)
js_bundle :quizzes_bundle
css_bundle :quizzes, :tinymce
render :new
end
end
@ -736,6 +738,7 @@ class Quizzes::QuizzesController < ApplicationController
if @quiz.require_lockdown_browser? && @quiz.require_lockdown_browser_for_results? && params[:viewing]
return unless check_lockdown_browser(:medium, named_context_url(@context, 'context_quiz_history_url', @quiz.to_param, :viewing => "1", :version => params[:version]))
end
js_bundle :quiz_history
end
end
end

View File

@ -43,6 +43,8 @@ class SubmissionsBaseController < ApplicationController
outcome_proficiency: outcome_proficiency
})
js_bundle :submissions
css_bundle :submission
render 'submissions/show'
end
format.json do

View File

@ -576,6 +576,9 @@ class UsersController < ApplicationController
content_for_head helpers.auto_discovery_link_tag(:atom, feeds_user_format_path(@current_user.feed_code, :atom), {:title => t('user_atom_feed', "User Atom Feed (All Courses)")})
end
css_bundle :dashboard
js_bundle :dashboard
add_body_class "dashboard-is-planner" if show_planner?
end
def dashboard_stream_items

View File

@ -64,6 +64,8 @@ class WikiPagesController < ApplicationController
if @page && !@page.new_record?
wiki_pages_js_env(@context)
@padless = true
js_bundle :wiki_page_show
css_bundle :wiki_page
render template: 'wiki_pages/show'
else
redirect_to polymorphic_url([@context, :wiki_pages])
@ -111,6 +113,8 @@ class WikiPagesController < ApplicationController
@padless = true
end
end
js_bundle :wiki_page_show
css_bundle :wiki_page
end
end

View File

@ -25,19 +25,13 @@
<% provide :page_title, @assignment.title %>
<% provide :right_side, render(:partial => "assignment_sidebar") %>
<% if @locked && !@locked[:can_view] %>
<% js_bundle :module_sequence_footer %>
<% if @show_locked_page %>
<h1><%= @assignment.title %></h1>
<%= @locked.is_a?(Hash) ? lock_explanation(@locked, 'assignment', @context) : t(:assignment_locked, "This assignment is currently locked.") %>
<% else %>
<%
css_bundle :assignments
js_bundle :assignment_show
%>
<% if @assignment.omit_from_final_grade %>
<div class="alert alert-info omit-from-final-warning">
<%= t("This assignment does not count toward the final grade.") %>

View File

@ -86,9 +86,6 @@
<a href="<%= user_profile_path(@current_user) %>" class="profile_url" style="display: none;">&nbsp;</a>
<% end %>
<% js_bundle :user_name %>
<% css_bundle :roster_user, :pairing_code %>
<%= render :partial => 'shared/profile' %>
<% can_manage_students = can_do(@context, @current_user, :manage_students) %>
@ -174,4 +171,3 @@
</div>
<% end %>
<% js_bundle 'legacy/context_roster_user' %>

View File

@ -125,9 +125,6 @@
</div>
<% end %>
<% js_bundle :user_name %>
<% css_bundle :roster_user, :pairing_code %>
<h1><%= @user.name %></h1>
<% can_manage_students = can_do(@context, @current_user, :manage_students) %>
<% can_manage_admins = can_do(@context, @current_user, :manage_admin_users) %>
@ -235,4 +232,3 @@
<% end %>
<% end %>
<% js_bundle 'legacy/context_roster_user' %>

View File

@ -25,8 +25,6 @@
:COURSE_ID => @context.id,
:NO_MODULE_PROGRESSIONS => @context.large_roster,
})
js_bundle :context_modules
css_bundle :content_next
%>
<% if course_home %>
<div class="screenreader-only"><%= @context.name %></div>

View File

@ -16,7 +16,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>
<% content_for :keyboard_navigation do %>
<% provide :keyboard_navigation do %>
<ul class="navigation_list" tabindex="-1">
<li>
<span class="keycode"><%= t('Up') %></span>
@ -69,4 +69,4 @@
<span class="description"><%= t("New Module") %></span>
</li>
</ul>
<% end %>
<% end %>

View File

@ -18,6 +18,5 @@
<% provide :page_title, join_title(t('titles.course_modules', "Course Modules"), @context.name) %>
<% css_bundle :context_modules2 %>
<%= render :partial => "context_modules/content_next" %>

View File

@ -16,11 +16,9 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>
<% content_for :page_title, t('titles.courses', 'Courses') %>
<% provide :page_title, t('titles.courses', 'Courses') %>
<% css_bundle :context_list, :course_list %>
<% js_bundle :course_list %>
<% @favorite_course_ids = @current_user.courses_with_primary_enrollment(:favorite_courses).map(&:id) %>
<% @show_star_column = true %>
<div class="header-bar">

View File

@ -16,8 +16,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>
<% content_for :page_title, @context.name %>
<% css_bundle :course_show %>
<% provide :page_title, @context.name %>
<% @active_tab ||= "home" %>
<h1 class='screenreader-only'><%= @context.name %></h1>
@ -150,27 +149,6 @@
<% end %>
<% end %>
<%
css_bundle :dashboard
css_bundle :react_todo_sidebar if planner_enabled?
case @course_home_view
when 'wiki'
css_bundle :tinymce
when 'modules'
js_bundle :context_modules
css_bundle :context_modules2
when 'assignments'
js_bundle :assignment_index
css_bundle :new_assignments
when 'syllabus'
js_bundle :syllabus
css_bundle :tinymce
else
js_bundle :dashboard
end
%>
<% js_bundle 'legacy/courses_show' %>
<% if @pending_enrollment %>
<%= render :partial => 'shared/dashboard_invitation', :object => @pending_enrollment %>
<% end %>
@ -181,17 +159,10 @@
<% end %>
<div id="course_home_content">
<% if @course_home_view == 'wiki' %>
<% js_bundle :wiki_page_show %>
<div id="wiki_page_show"></div>
<% elsif @course_home_view == 'modules' %>
<%= render :partial => 'context_modules/content_next', :locals => {:course_home => true} %>
<% elsif @course_home_view == 'assignments' %>
<%
@body_classes << 'hide-content-while-scripts-not-loaded'
@body_classes << 'with_item_groups'
js_bundle :assignment_index
css_bundle :new_assignments
%>
<% elsif @course_home_view == 'syllabus' %>
<%= render :partial => 'assignments/syllabus_content', :locals => {:course_home => true} %>
<% else %>
@ -209,4 +180,3 @@
<% end %>
<div id="wizard_box"></div>
<% js_bundle :course %>

View File

@ -17,12 +17,7 @@
%>
<% content_for :page_title do %><%= join_title @page.name, @category.name, @portfolio.name %><% end %>
<%
js_bundle :eportfolio
css_bundle :tinymce
@no_left_side_list_view = true
js_env({ SECTION_COUNT_IDX: @page.content_sections.count })
%>
<% js_env({ SECTION_COUNT_IDX: @page.content_sections.count }) %>
<% provide :left_side do %>
<div class="eportfolio-name">

View File

@ -15,12 +15,6 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>
<%
js_bundle :quizzes_bundle, :question_bank
css_bundle :quizzes, :learning_outcomes, :tinymce, :question_bank
provide :page_title, @bank.title
%>
<% provide :right_side do %>
<div class="rs-margin-bottom">
<% if can_do(@bank, @current_user, :manage) %>

View File

@ -195,4 +195,3 @@
<div class="user_id"><%= @submission.user_id %></div>
</div>
<% js_bundle :quiz_history %>

View File

@ -17,8 +17,6 @@
%>
<%
css_bundle :quizzes, :tinymce
js_bundle :quizzes_bundle
js_env :QUIZZES => {:QUIZ => true}
provide :page_title, (@quiz.quiz_title || !@quiz.quiz_title.empty? ? @quiz.quiz_title : t(:default_page_title, 'New Quiz'))
%>

View File

@ -41,8 +41,6 @@
"peer_review"
end
js_bundle :submissions
css_bundle :submission
js_env({
:RUBRIC_ASSESSMENT => {
assessment_type: assessment_type,

View File

@ -18,12 +18,7 @@
<% provide :page_title do %><%= t('Dashboard') %><% end %>
<%
css_bundle :dashboard
js_bundle :dashboard
if show_planner?
add_body_class "dashboard-is-planner"
# fire off these `fetch` requests now so they are ready sooner
six_months_ago = Time.now.utc.at_beginning_of_day.months_ago(6).iso8601(3)
beginning_of_day = Time.zone.now.at_beginning_of_day.utc.iso8601(3)

View File

@ -18,8 +18,6 @@
<%
provide :page_title, join_title(@page.title.to_s, @context.name)
js_bundle :wiki_page_show
css_bundle :wiki_page
%>
<% unless @page.locked_for?(@current_user, {check_policies: true, context: @context, deep_check_if_needed: true}) %>

View File

@ -51,5 +51,8 @@ module EportfolioPage
js_env :folder_id => Folder.unfiled_folder(@current_user).id,
:context_code => @current_user.asset_string
end
js_bundle :eportfolio, 'legacy/eportfolios_wizard_box'
css_bundle :tinymce
@no_left_side_list_view = true
end
end