Skip to content

Commit 9cee0e0

Browse files
authored
Extract layout and pages to partials (#8172)
* Add layout helper from base page w/titles Should be able to handle the site, page and combined titles for both layout files. Consolidate title helper into layout helper. * Extract layout file Known issue with show action when declaring a member_action to render a page, no page title is rendered. We won't include the body tag data attributes since we don't utilize that and since there's no need now as users can customize. * Add page title and presenter methods * Extract page template * Extract show template * Extract new/edit form templates * Extract index template * Remove renderer_for helper method Now that we've extracted all pages, this has no references. * Remove unused view factory class/config This predates Arbre builder method which is how we create components. This may have been used to override views entirely but with partials we provide a simpler, more Rails like way to customize the admin while minimizing the library footprint and maintainance. Note that we use the method_or_proc_helper throughout but mysteriously this is defined in view helpers but at the root level module. We already require and include the module elsewhere, e.g. menu item and scopes, so requiring it in filters/forms isn't abnormal. With the view factory removal, the test suite starting failing here but now all green. * Remove unused main_content locale * Reorganize some templates post extraction This moves sidebar to top level. The action item and sidebar block templates now go into "shared" directory. This also removes an unnecessary head partial since we'll just include the html head defaults directly into the layout file now that we have that extracted.
1 parent 320cb34 commit 9cee0e0

101 files changed

Lines changed: 362 additions & 963 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/views/active_admin/_head.html.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/views/active_admin/_page_header.html.erb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
<% end %>
1919
<h2 class="text-2xl font-semibold"><%= title %></h2>
2020
</div>
21-
<% if action_items.present? %>
21+
<% if action_items_for_action.present? %>
2222
<div data-test-action-items class="flex gap-2 flex-wrap lg:justify-end">
23-
<% action_items.each do |action_item| %>
24-
<%= render "active_admin/page_header/action_item_block", action_item: action_item %>
25-
<% end %>
23+
<%= render "active_admin/shared/action_items" %>
2624
</div>
2725
<% end %>
2826
</div>

app/views/active_admin/base_page/_sidebar.html.erb renamed to app/views/active_admin/_sidebar.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<% unless skip_sidebar? || sections.blank? %>
1+
<% unless skip_sidebar? || sidebar_sections_for_action.blank? %>
22
<div id="sidebar" class="sidebar">
3-
<% sections.each do |section| %>
3+
<% sidebar_sections_for_action.each do |section| %>
44
<%= content_tag :div, id: section.id, class: section.custom_class do %>
55
<% if section.block %>
6-
<%= render "active_admin/base_page/sidebar_section_block", section: section %>
6+
<%= render "active_admin/shared/sidebar_section_block", section: section %>
77
<% else %>
88
<%= render(section.partial_name) %>
99
<% end %>

app/views/active_admin/_site_header.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</button>
66

77
<div class="grow">
8-
<h1 data-test-site-title>
9-
<%= active_admin_namespace.site_title(self) %>
8+
<h1 data-test-site-title class="text-lg font-semibold">
9+
<%= title %>
1010
</h1>
1111
</div>
1212

app/views/active_admin/devise/confirmations/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="devise-form-container">
22
<h2 class="devise-form-title">
3-
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.resend_confirmation_instructions.title') %>
3+
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.resend_confirmation_instructions.title') %>
44
</h2>
55

66
<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>

app/views/active_admin/devise/passwords/edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="devise-form-container">
22
<h2 class="devise-form-title">
3-
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.change_password.title') %>
3+
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.change_password.title') %>
44
</h2>
55

66
<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>

app/views/active_admin/devise/passwords/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="devise-form-container">
22
<h2 class="devise-form-title">
3-
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.reset_password.title') %>
3+
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.reset_password.title') %>
44
</h2>
55

66
<%= active_admin_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|

app/views/active_admin/devise/registrations/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="devise-form-container">
22
<h2 class="devise-form-title">
3-
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.sign_up.title') %>
3+
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.sign_up.title') %>
44
</h2>
55

66
<% scope = Devise::Mapping.find_scope!(resource_name) %>

app/views/active_admin/devise/sessions/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="devise-form-container">
22
<h2 class="devise-form-title">
3-
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.login.title') %>
3+
<%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %>
44
</h2>
55

66
<% scope = Devise::Mapping.find_scope!(resource_name) %>

app/views/active_admin/devise/unlocks/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="devise-form-container">
22
<h2 class="devise-form-title">
3-
<%= active_admin_application.site_title(self) %> <%= title t('active_admin.devise.unlock.title') %>
3+
<%= site_title %> <%= set_page_title t('active_admin.devise.unlock.title') %>
44
</h2>
55

66
<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>

0 commit comments

Comments
 (0)