Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to active admin v4
Browse files Browse the repository at this point in the history
zonque committed Mar 10, 2024
1 parent 4657354 commit 6a7da14
Showing 35 changed files with 528 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ gem 'bootstrap', '~> 5.3', '>= 5.3.2'
gem 'dartsass-rails', '~> 0.5.0'
gem 'dartsass-sprockets', '~> 3.1'
gem 'simple_form'
gem 'activeadmin'
gem 'activeadmin', "4.0.0.beta5"
gem 'base64'
gem 'redcarpet'

13 changes: 4 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -50,12 +50,11 @@ GEM
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activeadmin (3.2.0)
arbre (~> 1.2, >= 1.2.1)
activeadmin (4.0.0.beta5)
arbre (~> 2.0)
formtastic (>= 3.1)
formtastic_i18n (>= 0.4)
inherited_resources (~> 1.7)
jquery-rails (>= 4.2)
kaminari (>= 1.2.1)
railties (>= 6.1)
ransack (>= 4.0)
@@ -87,7 +86,7 @@ GEM
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
altcha-rails (0.0.5)
arbre (1.7.0)
arbre (2.0.0)
activesupport (>= 3.0.0)
ruby2_keywords (>= 0.0.2)
autoprefixer-rails (10.4.16.0)
@@ -169,10 +168,6 @@ GEM
irb (1.12.0)
rdoc
reline (>= 0.4.2)
jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
@@ -341,7 +336,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activeadmin
activeadmin (= 4.0.0.beta5)
altcha-rails
base64
bootsnap
10 changes: 4 additions & 6 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -34,12 +34,10 @@
end
end

columns do
column do
panel "Currently active" do
para "Events: #{Event.confirmed.count}"
para "Entries: #{Entry.confirmed.count}"
end
div do
panel "Currently active" do
para "Events: #{Event.confirmed.count}"
para "Entries: #{Entry.confirmed.count}"
end
end
end
4 changes: 2 additions & 2 deletions app/admin/entries.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
end

action_item :unconfirm, only: :show do
link_to "Unconfirm", unconfirm_admin_entry_path(entry), method: :post
link_to "Unconfirm", unconfirm_admin_entry_path(resource), method: :post, class: "action-item-button"
end

member_action :resend_confirmation, method: :post do
@@ -18,7 +18,7 @@
end

action_item :resend_confirmation, only: :show do
link_to "Resend confirmation", resend_confirmation_admin_entry_path(entry), method: :post
link_to "Resend confirmation", resend_confirmation_admin_entry_path(resource), method: :post, class: "action-item-button"
end


4 changes: 2 additions & 2 deletions app/admin/events.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
end

action_item :unconfirm, only: :show do
link_to "Unconfirm", unconfirm_admin_event_path(event), method: :post
link_to "Unconfirm", unconfirm_admin_event_path(resource), method: :post, class: "action-item-button"
end

member_action :resend_confirmation, method: :post do
@@ -18,7 +18,7 @@
end

action_item :resend_confirmation, only: :show do
link_to "Resend confirmation", resend_confirmation_admin_event_path(event), method: :post
link_to "Resend confirmation", resend_confirmation_admin_event_path(resource), method: :post, class: "action-item-button"
end

sidebar "Details", only: :show do
1 change: 0 additions & 1 deletion app/assets/javascripts/active_admin.js

This file was deleted.

3 changes: 3 additions & 0 deletions app/assets/stylesheets/active_admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
22 changes: 22 additions & 0 deletions app/views/active_admin/_flash_messages.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<% if flash_messages.present? %>
<div class="px-2.5 lg:px-5 mb-8">
<% flash_messages.each do |type, message| %>
<% if type == "error" %>
<div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-red-50 text-red-800 dark:bg-red-800 dark:text-red-300">
<svg class="w-5 h-5 shrink-0" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/></svg>
<%= message %>
</div>
<% elsif type == "alert" %>
<div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-yellow-50 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-300">
<svg class="w-5 h-5 shrink-0 rtl:-scale-x-100" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/></svg>
<%= message %>
</div>
<% elsif type == "notice" %>
<div class="flex items-center gap-3 p-4 mb-2 rounded-lg bg-green-50 text-green-800 dark:bg-green-800 dark:text-green-400">
<svg class="w-5 h-5 shrink-0 rtl:-scale-x-100" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/></svg>
<%= message %>
</div>
<% end %>
<% end %>
</div>
<% end %>
13 changes: 13 additions & 0 deletions app/views/active_admin/_html_head.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%= stylesheet_link_tag "active_admin" %>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<% # On page load or when changing themes, best to add inline in `head` to avoid FOUC %>
<%= javascript_tag nonce: true do %>
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
<% end %>
<%= javascript_importmap_tags "active_admin", importmap: ActiveAdmin.importmap %>
28 changes: 28 additions & 0 deletions app/views/active_admin/_main_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<div id="main-menu" class="fixed top-0 xl:top-16 bottom-0 start-0 z-40 w-72 xl:w-60 p-4 overflow-y-auto transition-transform duration-200 -translate-x-full xl:translate-x-0 bg-white dark:bg-gray-950 xl:border-e xl:border-gray-200 xl:dark:border-white/10" tabindex="-1" aria-labelledby="drawer-navigation-label">
<ul role="list" class="flex flex-1 flex-col space-y-1.5">
<% current_menu.items(self).each do |item| %>
<% children = item.items(self).presence %>
<li <%= current_menu_item?(item) && "data-open" %> class="group" data-item-id="<%= item.id %>">
<% if children %>
<button data-menu-button class="text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center w-full rounded-md p-2 gap-x-2 text-sm">
<%= item.label(self) %>
<svg class="group-data-[open]:rotate-90 group-data-[open]:rtl:-rotate-90 ms-auto h-5 w-5 shrink-0 rtl:-scale-x-100" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
</svg>
</button>
<ul role="list" class="mt-1 space-y-1 hidden group-data-[open]:block">
<% children.each do |j| %>
<li data-item-id="<%= j.id %>">
<%= link_to j.label(self), j.url(self), j.html_options.merge(class: "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white block rounded-md py-1.5 px-2 text-sm no-underline #{(current_menu_item?(j) ? "bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white selected" : "")}") %>
</li>
<% end %>
</ul>
<% elsif url = item.url(self) %>
<%= link_to item.label(self), url, item.html_options.merge(class: "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white flex items-center w-full rounded-md p-2 gap-x-2 text-sm no-underline #{(current_menu_item?(item) ? "bg-gray-100 dark:bg-white/5 text-gray-900 dark:text-white selected" : "")}") %>
<% else %>
<%= item.label(self) %>
<% end %>
</li>
<% end %>
</ul>
</div>
27 changes: 27 additions & 0 deletions app/views/active_admin/_page_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div data-test-page-header class="bg-gray-50 border-b p-4 mb-8 flex flex-col gap-4 md:flex-row md:items-center justify-between dark:border-gray-800/50 dark:bg-inherit">
<div class="flex flex-col gap-3 pt-1">
<% breadcrumb_links = build_breadcrumb_links(request.path, class: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 no-underline") %>
<% if breadcrumb_links.present? %>
<nav aria-label="breadcrumb">
<ol class="flex flex-wrap gap-1 text-sm">
<% breadcrumb_links.each_with_index do |link, index| %>
<li class="inline-flex items-center h-5 gap-1">
<% if index > 0 %>
<svg class="h-5 w-5 text-gray-300 dark:text-gray-700 flex-shrink-0 rtl:rotate-180" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd"/>
</svg>
<% end %>
<%= link %>
</li>
<% end %>
</ol>
</nav>
<% end %>
<h2 class="text-2xl font-semibold"><%= title %></h2>
</div>
<% if action_items_for_action.present? %>
<div data-test-action-items class="flex gap-2 flex-wrap lg:justify-end">
<%= render "active_admin/shared/action_items" %>
</div>
<% end %>
</div>
5 changes: 5 additions & 0 deletions app/views/active_admin/_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% unless skip_sidebar? || sidebar_sections_for_action.blank? %>
<div class="space-y-8">
<%= render "active_admin/shared/sidebar_sections" %>
</div>
<% end %>
7 changes: 7 additions & 0 deletions app/views/active_admin/_site_footer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="text-sm text-center mt-16 mx-8 pt-9 pb-12 text-gray-500 border-t dark:border-gray-800">
<%= I18n.t(
"active_admin.powered_by",
active_admin: link_to("Active Admin", "https://activeadmin.info", class: "text-gray-500 dark:text-gray-500 hover:text-gray-900 dark:hover:text-gray-400 no-underline"),
version: ActiveAdmin::VERSION
).html_safe %>
</div>
30 changes: 30 additions & 0 deletions app/views/active_admin/_site_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class="border-b border-gray-200 dark:border-white/10 dark:bg-gray-950/75 px-4 py-2 flex items-center sticky top-0 z-20 h-16 w-full backdrop-blur-md">
<button class="xl:hidden pe-3 inline-flex items-center w-8 h-8 justify-center text-sm text-gray-500 dark:text-gray-400 focus-visible:outline-none focus-visible:ring-ring focus-visible:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0" data-drawer-target="main-menu" data-drawer-show="main-menu" aria-controls="drawer-navigation">
<svg class="w-5 h-5 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15"/></svg>
</button>

<div class="grow">
<h1 data-test-site-title class="text-lg font-semibold">
<%= title %>
</h1>
</div>

<button type="button" class="dark-mode-toggle flex items-center w-9 h-9 justify-center me-1 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400 focus:outline-none text-sm">
<svg class="hidden dark:block w-5 h-5 rtl:-scale-x-100" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.509 5.75c0-1.493.394-2.96 1.144-4.25h-.081a8.5 8.5 0 1 0 7.356 12.746A8.5 8.5 0 0 1 8.509 5.75Z"/></svg>
<svg class="dark:hidden w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 3V1m0 18v-2M5.05 5.05 3.636 3.636m12.728 12.728L14.95 14.95M3 10H1m18 0h-2M5.05 14.95l-1.414 1.414M16.364 3.636 14.95 5.05M14 10a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"/></svg>
</button>

<button id="user-menu-button" class="flex items-center w-9 h-9 justify-center text-sm text-gray-500 focus:outline-none dark:text-gray-200" data-dropdown-toggle="user-menu" data-dropdown-offset-distance="3" data-dropdown-placement="bottom-end">
<svg class="w-7 h-7" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 0a10 10 0 1 0 10 10A10.011 10.011 0 0 0 10 0Zm0 5a3 3 0 1 1 0 6 3 3 0 0 1 0-6Zm0 13a8.949 8.949 0 0 1-4.951-1.488A3.987 3.987 0 0 1 9 13h2a3.987 3.987 0 0 1 3.951 3.512A8.949 8.949 0 0 1 10 18Z"/></svg>
</button>

<div id="user-menu" class="z-50 hidden min-w-max bg-white rounded shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-gray-700 py-1 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="user-menu-button">
<ul>
<% if current_active_admin_user? %>
<li><%= auto_link current_active_admin_user, class: "block px-2.5 py-2 no-underline text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-white dark:hover:bg-gray-600 dark:hover:text-white" %></li>
<li><%= link_to I18n.t("active_admin.logout"), auto_logout_link_path, class: "block px-2.5 py-2 no-underline text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-white dark:hover:bg-gray-600 dark:hover:text-white", data: { method: :delete } %></li>
<% end %>
</ul>
</div>

</div>
17 changes: 17 additions & 0 deletions app/views/active_admin/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="p-6 sm:p-8 space-y-4 md:space-y-6 w-full sm:max-w-md bg-white sm:rounded-md shadow dark:border dark:bg-gray-800 dark:border-gray-700">
<h2 class="text-xl font-bold text-gray-900 md:text-2xl dark:text-white">
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.resend_confirmation_instructions.title') %>
</h2>

<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>
<%= active_admin_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
f.inputs do
f.input :email
end
f.actions do
f.action :submit, label: t('active_admin.devise.resend_confirmation_instructions.submit'), button_html: { class: "w-full", value: t('active_admin.devise.resend_confirmation_instructions.submit') }
end
end %>

<%= render partial: "active_admin/devise/shared/links" %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password, and you can do this through the link below.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>

<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>

<p>Click the link below to unlock your account:</p>

<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
20 changes: 20 additions & 0 deletions app/views/active_admin/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="p-6 sm:p-8 space-y-4 md:space-y-6 w-full sm:max-w-md bg-white sm:rounded-md shadow dark:border dark:bg-gray-800 dark:border-gray-700">
<h2 class="text-xl font-bold text-gray-900 md:text-2xl dark:text-white">
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.change_password.title') %>
</h2>

<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>
<%= active_admin_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
f.inputs do
f.input :password
f.input :password_confirmation
f.input :reset_password_token, as: :hidden, input_html: { value: resource.reset_password_token }
end
f.actions do
f.action :submit, label: t('active_admin.devise.change_password.submit'), button_html: { class: "w-full", value: t('active_admin.devise.change_password.submit') }
end
end
%>

<%= render 'active_admin/devise/shared/links' %>
</div>
16 changes: 16 additions & 0 deletions app/views/active_admin/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="p-6 sm:p-8 space-y-4 md:space-y-6 w-full sm:max-w-md bg-white sm:rounded-md shadow dark:border dark:bg-gray-800 dark:border-gray-700">
<h2 class="text-xl font-bold text-gray-900 md:text-2xl dark:text-white">
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.reset_password.title') %>
</h2>

<%= active_admin_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
f.inputs do
f.input :email
end
f.actions do
f.action :submit, label: t('active_admin.devise.reset_password.submit'), button_html: { class: "w-full", value: t('active_admin.devise.reset_password.submit') }
end
end %>

<%= render partial: "active_admin/devise/shared/links" %>
</div>
23 changes: 23 additions & 0 deletions app/views/active_admin/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="p-6 sm:p-8 space-y-4 md:space-y-6 w-full sm:max-w-md bg-white sm:rounded-md shadow dark:border dark:bg-gray-800 dark:border-gray-700">
<h2 class="text-xl font-bold text-gray-900 md:text-2xl dark:text-white">
<%= active_admin_application.site_title(self) %> <%= set_page_title t('active_admin.devise.sign_up.title') %>
</h2>

<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>
<%= active_admin_form_for(resource, as: resource_name, url: main_app.send(:"#{scope}_registration_path"), html: { id: "registration_new" }) do |f|
f.inputs do
resource.class.authentication_keys.each_with_index { |key, index|
f.input key, label: t('active_admin.devise.'+key.to_s+'.title'), input_html: { autofocus: index.zero? }
}
f.input :password, label: t('active_admin.devise.password.title')
f.input :password_confirmation, label: t('active_admin.devise.password_confirmation.title')
end
f.actions do
f.action :submit, label: t('active_admin.devise.login.submit'), button_html: { class: "w-full", value: t('active_admin.devise.sign_up.submit') }
end
end
%>

<%= render partial: "active_admin/devise/shared/links" %>
</div>
22 changes: 22 additions & 0 deletions app/views/active_admin/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="p-6 sm:p-8 space-y-4 md:space-y-6 w-full sm:max-w-md bg-white sm:rounded-md shadow dark:border dark:bg-gray-800 dark:border-gray-700">
<h2 class="text-xl font-bold text-gray-900 md:text-2xl dark:text-white">
<%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %>
</h2>

<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= active_admin_form_for(resource, as: resource_name, url: main_app.send(:"#{scope}_session_path")) do |f|
f.inputs do
resource.class.authentication_keys.each_with_index { |key, index|
f.input key, label: t("active_admin.devise.#{key}.title"), input_html: { autofocus: index.zero? }
}
f.input :password, label: t('active_admin.devise.password.title')
f.input :remember_me, label: t('active_admin.devise.login.remember_me'), as: :boolean if devise_mapping.rememberable?
end
f.actions do
f.action :submit, label: t('active_admin.devise.login.submit'), wrapper_html: { class: "grow" }, button_html: { class: "w-full", value: t('active_admin.devise.login.submit') }
end
end
%>

<%= render partial: "active_admin/devise/shared/links" %>
</div>
15 changes: 15 additions & 0 deletions app/views/active_admin/devise/shared/_error_messages.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
%>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
35 changes: 35 additions & 0 deletions app/views/active_admin/devise/shared/_links.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="mt-6 text-sm">
<%- if controller_name != 'sessions' %>
<% scope = Devise::Mapping.find_scope!(resource_name) %>
<%= link_to t('active_admin.devise.links.sign_in'), main_app.send(:"new_#{scope}_session_path") %>
<br>
<% end -%>

<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to t('active_admin.devise.links.sign_up'), new_registration_path(resource_name) %>
<br>
<% end -%>

<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to t('active_admin.devise.links.forgot_your_password'), new_password_path(resource_name) %>
<br>
<% end -%>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to t('active_admin.devise.links.resend_confirmation_instructions'), new_confirmation_path(resource_name) %>
<br>
<% end -%>

<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to t('active_admin.devise.links.resend_unlock_instructions'), new_unlock_path(resource_name) %>
<br>
<% end -%>

<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to t('active_admin.devise.links.sign_in_with_omniauth_provider', provider: provider.to_s.titleize),
omniauth_authorize_path(resource_name, provider), method: :post %>
<br>
<% end -%>
<% end -%>
</div>
17 changes: 17 additions & 0 deletions app/views/active_admin/devise/unlocks/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="p-6 sm:p-8 space-y-4 md:space-y-6 w-full sm:max-w-md bg-white sm:rounded-md shadow dark:border dark:bg-gray-800 dark:border-gray-700">
<h2 class="text-xl font-bold text-gray-900 md:text-2xl dark:text-white">
<%= site_title %> <%= set_page_title t('active_admin.devise.unlock.title') %>
</h2>

<%= render partial: "active_admin/devise/shared/error_messages", resource: resource %>
<%= active_admin_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f|
f.inputs do
f.input :email
end
f.actions do
f.action :submit, label: t('active_admin.devise.unlock.submit'), button_html: { class: "w-full", value: t('active_admin.devise.unlock.submit') }
end
end %>

<%= render partial: "active_admin/devise/shared/links" %>
</div>
10 changes: 10 additions & 0 deletions app/views/active_admin/kaminari/_gap.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="flex items-center justify-center px-2.5 py-3 h-8 leading-tight text-gray-500 dark:text-gray-400">
<%= t('views.pagination.truncate').html_safe %>
</span>
16 changes: 16 additions & 0 deletions app/views/active_admin/kaminari/_next_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%# Link to the "Next" page
- available local variables
url: url to the next page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.last? %>
<%= link_to url, rel: 'next', remote: remote, class: "flex items-center justify-center px-2.5 py-3 h-8 leading-tight text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-white rounded no-underline" do %>
<span class="sr-only"><%= t('active_admin.pagination.next') %></span>
<svg class="w-2.5 h-2.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
</svg>
<% end %>
<% end %>
14 changes: 14 additions & 0 deletions app/views/active_admin/kaminari/_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% if page.current? %>
<%= link_to page, url, { remote: remote, rel: page.rel, class: "flex items-center justify-center px-2.5 py-3 h-8 leading-tight text-white bg-blue-500 dark:text-white dark:bg-blue-600 hover:bg-blue-500 hover:text-white dark:hover:bg-blue-600 dark:hover:text-white rounded no-underline" } %>
<% else %>
<%= link_to page, url, { remote: remote, rel: page.rel, class: "flex items-center justify-center px-2.5 py-3 h-8 leading-tight text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-white rounded no-underline" } %>
<% end %>
23 changes: 23 additions & 0 deletions app/views/active_admin/kaminari/_paginator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<%# The container tag
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
paginator: the paginator that renders the pagination tags inside
-%>
<%= paginator.render do -%>
<nav data-test-pagination class="inline-flex flex-wrap -space-x-px text-sm gap-1">
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.display_tag? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<% unless current_page.out_of_range? %>
<%= next_page_tag unless current_page.last? %>
<% end %>
</nav>
<% end -%>
16 changes: 16 additions & 0 deletions app/views/active_admin/kaminari/_prev_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%# Link to the "Previous" page
- available local variables
url: url to the previous page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% unless current_page.first? %>
<%= link_to url, rel: 'prev', remote: remote, class: "flex items-center justify-center px-2.5 py-3 h-8 leading-tight text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-white rounded no-underline" do %>
<span class="sr-only"><%= t('active_admin.pagination.previous') %></span>
<svg class="w-2.5 h-2.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
</svg>
<% end %>
<% end %>
14 changes: 14 additions & 0 deletions app/views/active_admin/resource/_index_blank_slate.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="w-full rounded-lg border-2 border-dashed border-gray-300 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-600 px-6 py-12 text-center">
<h2 class="block mb-4 only:mb-0 font-semibold leading-6 text-gray-900 dark:text-gray-200">
<%= I18n.t("active_admin.blank_slate.content", resource_name: active_admin_config.plural_resource_label) %>
</h2>
<% if new_action_authorized?(active_admin_config.resource_class) %>
<%= if page_presenter.options.has_key?(:blank_slate_link)
link = page_presenter.options[:blank_slate_link]
instance_exec(&link) if link.is_a?(Proc)
else
link_to(I18n.t("active_admin.blank_slate.link"), new_resource_path)
end
%>
<% end %>
</div>
5 changes: 5 additions & 0 deletions app/views/active_admin/resource/_index_empty_results.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="w-full rounded-lg border-2 border-dashed border-gray-300 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-600 px-6 py-12 text-center min-h-20">
<h2 class="block mb-4 only:mb-0 font-semibold leading-6 text-gray-900 dark:text-gray-200">
<%= I18n.t("active_admin.pagination.empty", model: active_admin_config.plural_resource_label) %>
</h2>
</div>
51 changes: 51 additions & 0 deletions app/views/active_admin/shared/_resource_comments.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div class="max-w-[700px]">
<div class="font-bold py-3 border-b dark:border-gray-600">
<%= ActiveAdmin::Comment.model_name.human(count: 2.1) %>
</div>
<% if authorized?(ActiveAdmin::Auth::NEW, ActiveAdmin::Comment) %>
<%= active_admin_form_for(ActiveAdmin::Comment.new, url: comment_form_url, html: { class: "mb-12 max-w-[700px]", novalidate: false }) do |f|
f.inputs do
f.input :resource_type, as: :hidden, input_html: { value: ActiveAdmin::Comment.resource_type(resource) }
f.input :resource_id, as: :hidden, input_html: { value: resource.id }
f.input :body, label: false, input_html: { size: "80x4", required: true }
end
f.actions do
f.action :submit, label: I18n.t("active_admin.comments.add")
end
end
%>
<% end %>
<div class="font-bold py-3 border-b dark:border-gray-600">
<%= I18n.t "active_admin.comments.title_content", count: comments.total_count %>
</div>
<% if comments.any? %>
<% comments.each do |comment| %>
<div class="border-b dark:border-gray-600 py-6 max-w-[700px]" id="<%= dom_id(comment, :active_admin) %>" data-test-comment-container>
<div class="flex gap-4 items-end mb-2">
<span class="font-semibold">
<%= comment.author ? auto_link(comment.author) : I18n.t("active_admin.comments.author_missing") %>
</span>
<span class="text-xs text-gray-400">
<%= pretty_format comment.created_at %>
</span>
</div>
<div class="mb-4 break-keep">
<%= simple_format(comment.body) %>
</div>
<% if authorized?(ActiveAdmin::Auth::DESTROY, comment) %>
<%= link_to I18n.t("active_admin.comments.delete"), url_for_comments(comment.id), method: :delete, data: { confirm: I18n.t("active_admin.comments.delete_confirmation") } %>
<% end %>
</div>
<% end %>
<div class="p-2 lg:p-4 flex flex-col-reverse lg:flex-row gap-4 items-center justify-between">
<div>
<%= page_entries_info(comments).html_safe %>
</div>
<%= paginate(comments, views_prefix: :active_admin, outer_window: 1, window: 2) %>
</div>
<% else %>
<div class="p-8 text-center">
<%= I18n.t("active_admin.comments.no_comments_yet") %>
</div>
<% end %>
</div>
20 changes: 20 additions & 0 deletions app/views/layouts/active_admin.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="<%= I18n.locale %>">
<head>
<title><%= html_head_site_title %></title>
<%= render "active_admin/html_head" %>
</head>
<body class="bg-white dark:bg-gray-950/95 text-gray-950 dark:text-gray-100 antialiased">
<%= render "active_admin/site_header", title: site_title %>
<div class="xl:ms-60">
<%= render "active_admin/main_navigation" %>
<%= render "active_admin/page_header", title: @page_title || page_title %>
<%= render "active_admin/flash_messages" %>
<div data-test-page-content class="px-2.5 lg:px-5 grid grid-cols-1 gap-4 lg:gap-6 lg:grid-flow-col lg:auto-cols-[minmax(0,250px)]">
<%= yield %>
<%= render "active_admin/sidebar" %>
</div>
<%= render "active_admin/site_footer" %>
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions app/views/layouts/active_admin_logged_out.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="<%= I18n.locale %>">
<head>
<title><%= html_head_site_title %></title>
<%= render "active_admin/html_head" %>
</head>
<body class="bg-gray-50 dark:bg-gray-900 text-gray-950 dark:text-gray-100 antialiased">
<div class="flex flex-col items-center justify-center min-h-screen py-4 sm:px-6 sm:py-8 mx-auto">
<%= render "active_admin/flash_messages" %>
<%= yield %>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions tailwind-active_admin.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const execSync = require('child_process').execSync;
const activeAdminPath = execSync('bundle show activeadmin', { encoding: 'utf-8' }).trim();

module.exports = {
content: [
`${activeAdminPath}/vendor/javascript/flowbite.js`,
`${activeAdminPath}/plugin.js`,
`${activeAdminPath}/app/views/**/*.{arb,erb,html,rb}`,
'./app/admin/**/*.{arb,erb,html,rb}',
'./app/views/active_admin/**/*.{arb,erb,html,rb}',
'./app/views/admin/**/*.{arb,erb,html,rb}',
'./app/javascript/**/*.js'
],
darkMode: "class",
plugins: [
require(`@activeadmin/activeadmin/plugin`)
]
}

0 comments on commit 6a7da14

Please sign in to comment.