<%
# Copyright (C) 2012 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# 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/>.
%>

<div id="fixed_bottom">
  <% if @fixed_warnings.present? %>
    <% @fixed_warnings.each_with_index do |warning, index| %>
      <div id="element_toggler_<%= index %>" class="fixed_warning" aria-expanded="true" role="banner" aria-label="<%= t("Warning") %>">
        <i class=<%= "icon-#{warning[:icon]}" %>></i>
        <b><%= warning[:title] %></b>
        <div class="warning_message">
          <%= warning[:message] %>
          <button class="element_toggler Button--icon-action" aria-controls="element_toggler_<%= index %>" >
            <i class="icon-x" aria-hidden="true"></i>
            <span class="screenreader-only"><%= t("Close warning") %></span>
          </button>
        </div>
      </div>
    <% end %>
  <% end %>
<% if @current_user && @real_current_user && @real_current_user != @current_user %>
  <% if @current_user.fake_student? %>
    <div id="masquerade_bar" class="ic-alert-masquerade-student-view">
      <% student_view_course = @current_user.all_courses.first %>
      <div class="ic-alert-masquerade-student-view-module ic-alert-masquerade-student-view-module--header">
        <div class="ic-image-text-combo">
          <i class="icon-student-view"></i>
          <div class="ic-image-text-combo__text"><%= t('student_view.warning_title', "You are currently logged into Student View") %></div>
        </div>
      </div>
      <div class="button-explanation ic-alert-masquerade-student-view-module ic-alert-masquerade-student-view-module--description">
        <%= t('student_view.reset_explanation', "Resetting the test student will clear all history for this student, allowing you to view the course as a brand new student.") %>
      </div>
      <div class="buttons ic-alert-masquerade-student-view-module ic-alert-masquerade-student-view-module--buttons">
        <%= link_to t('student_view.reset', "Reset Student"), course_test_student_path(student_view_course), 'data-method' => :delete, :rel => 'nofollow', :class => 'Button reset_test_student'%>
        <%= link_to t('student_view.leave', "Leave Student View"), course_student_view_path(student_view_course), 'data-method' => :delete, :rel => 'nofollow', :class => 'Button leave_student_view'%>
      </div>
    </div>
  <% else %>
    <div id="masquerade_bar" class="ic-alert-masquerade-student-view">
      <div class="ic-alert-masquerade-student-view-module ic-alert-masquerade-student-view-module--header">
        <div class="ic-image-text-combo">
          <% if service_enabled?(:avatars) %>
            <div class="masquerading_avatar">
              <%= avatar(@current_user, url: nil) %>
            </div>
          <% end %>
          <div class="ic-image-text-combo__text">
            <%= t("You are currently acting as %{user_name}", :user_name => @current_user.short_name) %>
          </div>
        </div>
      </div>
      <div class="buttons ic-fixed-bottom-module ic-fixed-bottom-module--buttons">
        <%= link_to t("Stop Acting as User"), user_masquerade_url(@real_current_user.id), 'data-method' => :post, :rel => 'nofollow', :class => 'Button stop_masquerading' %>
      </div>
    </div>
  <% end %>
<% end %>
</div>
