Move admin header partial to a component

This way it's easier to refactor it.

Note we're using `with_request_url` in the tests because the component
renders the locale switcher, which needs a URL in order to work. This
doesn't affect whether we're in the management section or not.
This commit is contained in:
Javi Martín
2023-01-05 14:12:19 +01:00
parent d27bfb2afd
commit 86fd14f8f0
9 changed files with 153 additions and 142 deletions

View File

@@ -1,50 +0,0 @@
<header class="header">
<div class="top-links">
<%= render "shared/locale_switcher" %>
<%= link_to root_path do %>
<%= t("admin.dashboard.index.back", org: setting["org_name"]) %>
<% end %>
</div>
<div class="expanded row admin-top-bar">
<div class="title-bar" data-responsive-toggle="responsive_menu" data-hide-for="medium">
<button class="menu-button" type="button" data-toggle="responsive_menu">
<span class="menu-icon"></span>
<span class="title-bar-title"><%= t("application.menu") %></span>
</button>
</div>
<div class="top-bar">
<div class="top-bar-left">
<% if namespace == "officing" %>
<h1>
<%= link_to "#" do %>
<%= setting["org_name"] %>
<br><small><%= namespaced_header_title %></small>
<% end %>
</h1>
<% else %>
<h1>
<%= link_to namespaced_root_path do %>
<%= setting["org_name"] %>
<br><small><%= namespaced_header_title %></small>
<% end %>
</h1>
<% end %>
</div>
<% if show_admin_menu?(current_user) || namespace != "management" %>
<div id="responsive_menu">
<div class="top-bar-right">
<ul class="menu" data-responsive-menu="medium-dropdown">
<%= render "shared/admin_login_items", current_user: current_user %>
<%= render "layouts/notification_item", current_user: current_user %>
<%= render "devise/menu/login_items", current_user: current_user %>
</ul>
</div>
</div>
<% end %>
</div>
</div>
</header>

View File

@@ -6,7 +6,7 @@
</head>
<body class="admin">
<%= render "layouts/admin_header" %>
<%= render Layout::AdminHeaderComponent.new(current_user) %>
<div class="menu-and-content">
<%= check_box_tag :show_menu, nil, false, role: "switch" %>

View File

@@ -7,7 +7,7 @@
</head>
<body class="admin">
<%= render "layouts/admin_header", current_user: manager_logged_in %>
<%= render Layout::AdminHeaderComponent.new(manager_logged_in) %>
<div class="menu-and-content">
<%= check_box_tag :show_menu, nil, false, role: "switch" %>