<%
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton 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 Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>

<div class="header py-4">
	<div class="container">
		<div class="d-flex">
			<%= link_to (current_user ? current_user.main_room : root_path), class: "header-brand" do %>
				<%= image_tag(Rails.configuration.branding_image,class: "header-brand-img") %>
			<% end %>

			<div class="d-flex ml-auto">
				<% if current_user %>
					<a id="create-room" class="px-5 ml-2 mt-1" href="" data-toggle="modal" data-target="#createRoomModal">
						<i class="fas fa-plus"></i>&nbsp; <%= t("header.create_room") %>
					</a>
					<div class="dropdown">
						<a href="#" class="nav-link pr-0" data-toggle="dropdown">
							<% if current_user.image.blank? %>
								<span class="avatar"><%= current_user.name.first %></span>
							<% else %>
								<span id="user-avatar" class="avatar d-none"><%= current_user.name.first %></span>
								<%= image_tag(current_user.image, id: "user-image", class: "avatar") %>
							<% end %>
							<span class="ml-2 d-none d-lg-block">
								<span class="text-default username"><%= current_user.name %></span>
							</span>
						</a>
						<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow" x-placement="bottom-end">
							<%= link_to current_user.main_room, class: "dropdown-item" do %>
								<i class="dropdown-icon fas fa-home"></i> <%= t("header.dropdown.home") %>
							<% end %>
							<%= link_to get_user_recordings_path(current_user), class: "dropdown-item" do %>
								<i class="dropdown-icon fas fa-video"></i> <%= t("room.recordings") %>
							<% end %>
							<%= link_to edit_user_path(current_user), class: "dropdown-item" do %>
								<i class="dropdown-icon fas fa-cog"></i> <%= t("header.dropdown.settings") %>
							<% end %>
							<div class="dropdown-divider"></div>
							<a class="dropdown-item" href="http://docs.bigbluebutton.org/install/greenlight-v2.html" target="_blank">
								<i class="dropdown-icon far fa-question-circle"></i> <%= t("header.dropdown.help") %>
							</a>
							<%= link_to logout_path, class: "dropdown-item" do %>
								<i class="dropdown-icon fas fa-sign-out-alt"></i> <%= t("header.dropdown.signout") %>
							<% end %>
						</div>
					</div>
        <% else %>
          <% allow_greenlight_accounts = allow_greenlight_accounts? %>
          <% if Rails.configuration.omniauth_ldap %>
            <%= link_to t("login"), omniauth_login_url(:ldap), :class => "btn btn-pill btn-outline-primary mx-2 sign-in-button" %>
          <% elsif allow_greenlight_accounts %>
            <%= link_to t("login"), "#loginModal", :class => "btn btn-pill btn-outline-primary mx-2 sign-in-button", "data-toggle": "modal" %>
          <% else %>
            <%= link_to t("login"), omniauth_login_url(:bn_launcher), :class => "btn btn-pill btn-outline-primary mx-2 sign-in-button" %>
          <% end %>

          <% if allow_user_signup? && allow_greenlight_accounts %>
            <%= link_to t("signup.title"), signup_path, :class => "btn btn-pill btn-outline-primary mx-2 sign-in-button" %>
          <% end %>

          <%= render "shared/modals/login_modal" %>
        <% end %>
      </div>
    </div>
  </div>
</div>
