Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ The admin interface uses a **hybrid architecture**:

**Rails Integration**:
- Turbo for navigation (replacing Turbolinks)
- Rails UJS for legacy forms (new forms should prefer Turbo Frames)
- Turbo Frames and Streams for forms
- Custom events: `Alchemy.${name}` namespace
- View Component: Used to populate Ruby values into custom JS elements.

Expand Down
2 changes: 1 addition & 1 deletion app/assets/builds/alchemy/alchemy_admin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/builds/alchemy/alchemy_admin.min.js.map

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions app/controllers/alchemy/admin/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def relative_referer_path(referer = request.referer)
URI(referer).path
end

# Disable layout rendering for xhr and Turbo Frame requests.
# Disable layout rendering for Turbo Frame requests.
#
# Content requested by the dialog's Turbo Frame is wrapped in that frame,
# so Turbo can render it. Only the dialog's own request carries this
# frame id, so the same action rendered as a full page stays unwrapped.
def set_layout
if turbo_frame_request_id == DIALOG_FRAME_ID
"alchemy/admin/dialog"
elsif request.xhr? || turbo_frame_request?
elsif turbo_frame_request?
false
else
"alchemy/admin"
Expand All @@ -87,8 +87,6 @@ def show_error_notice(error)
@notice = error.message[0..255]
if request.format.json?
render json: {message: @notice}, status: 500
elsif request.xhr?
render action: "error_notice"
else
@trace = error.backtrace[0..50]
render "500", status: 500
Expand Down Expand Up @@ -146,10 +144,6 @@ def do_redirect_to(url_or_path)
))
end
respond_to do |format|
format.js do
@redirect_url = redirect_path
render :redirect
end
format.turbo_stream do
redirect_to(redirect_path, allow_other_host: false, status: :see_other)
end
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/alchemy_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import "handlebars"
import "@ungap/custom-elements"
import { Turbo } from "@hotwired/turbo-rails"

import Rails from "@rails/ujs"

import { translate } from "alchemy_admin/i18n"
import { currentDialog, closeCurrentDialog } from "alchemy_admin/dialog"
import Dirty from "alchemy_admin/dirty"
Expand Down Expand Up @@ -45,8 +43,6 @@ Object.assign(Alchemy, {
Spinner,
reloadPreview
})

Rails.start()
Turbo.config.forms.confirm = openConfirmDialog
document.addEventListener("turbo:load", Initializer)

Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/elements/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<% end %>
<%- else -%>
<%= turbo_frame_tag @element do %>
<%= alchemy_form_for [:admin, @element], remote: false do |form| %>
<%= alchemy_form_for [:admin, @element] do |form| %>
<%= form.hidden_field :page_version_id %>
<div class="input">
<%= form.label(:name, class: "control-label required") do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/elements/_schedule.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</alchemy-message>
<% end %>

<%= alchemy_form_for [:publish, :admin, element], remote: false, data: {turbo: true}, class: "full_width" do |f| %>
<%= alchemy_form_for [:publish, :admin, element], data: {turbo: true}, class: "full_width" do |f| %>
<%= render "alchemy/admin/elements/schedule_fields", element:, form: f %>
<div class="submit">
<button
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/layoutpages/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_frame_tag @page do %>
<%= alchemy_form_for [:admin, @page], url: alchemy.admin_layoutpage_path(@page), class: 'edit_page', remote: false do |f| %>
<%= alchemy_form_for [:admin, @page], url: alchemy.admin_layoutpage_path(@page), class: 'edit_page' do |f| %>
<%= f.input :name, autofocus: true %>
<div class="input tags">
<%= f.label :tag_list, class: "control-label" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_frame_tag page do %>
<%= alchemy_form_for [:admin, page], class: 'edit_page', remote: false do |f| %>
<%= alchemy_form_for [:admin, page], class: 'edit_page' do |f| %>
<% unless page.language_root? || page.layoutpage %>
<%= render Alchemy::Admin::PageSelect.new(page.parent) do %>
<%= f.input :parent_id, required: true %>
Expand Down
1 change: 0 additions & 1 deletion app/views/alchemy/admin/pictures/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
picture_index: picture_index
).to_h
),
remote: false,
class: "picture-form" do |f| %>
<%= f.input :name %>
<%= render "alchemy/admin/pictures/picture_description_field", f: f %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/resources/_pagination.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="pagination-wrapper">
<%= paginate resources, theme: "alchemy", remote: local_assigns[:remote] %>
<%= paginate resources, theme: "alchemy" %>
<% unless local_assigns[:hide_per_page_select] %>
<%= render "alchemy/admin/resources/per_page_select" %>
<% end %>
Expand Down
1 change: 0 additions & 1 deletion app/views/alchemy/base/error_notice.js.erb

This file was deleted.

11 changes: 0 additions & 11 deletions app/views/alchemy/base/redirect.js.erb

This file was deleted.

3 changes: 1 addition & 2 deletions app/views/kaminari/alchemy/_first_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% if current_page.first? %>
<span class="first-page disabled">
<%= render_icon("skip-left") %>
</span>
<% else %>
<sl-tooltip content="<%= Alchemy.t(:first, scope: 'pagination') %>" placement="top-start">
<%= link_to url, remote: remote, class: 'first-page' do %>
<%= link_to url, class: 'first-page' do %>
<%= render_icon("skip-left") %>
<% end %>
</sl-tooltip>
Expand Down
1 change: 0 additions & 1 deletion app/views/kaminari/alchemy/_gap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="page gap"><%= render_icon(:more) %></span>
3 changes: 1 addition & 2 deletions app/views/kaminari/alchemy/_last_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% if current_page.last? %>
<span class="last-page disabled">
<%= render_icon("skip-right") %>
</span>
<% else %>
<sl-tooltip content="<%= Alchemy.t(:last, scope: 'pagination') %>" placement="top-end">
<%= link_to url, remote: remote, class: 'last-page' do %>
<%= link_to url, class: 'last-page' do %>
<%= render_icon("skip-right") %>
<% end %>
</sl-tooltip>
Expand Down
3 changes: 1 addition & 2 deletions app/views/kaminari/alchemy/_next_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% if current_page.last? -%>
<span class="next_page disabled">
<%= render_icon("arrow-right-s") %>
</span>
<% else -%>
<sl-tooltip content="<%= Alchemy.t(:next_page, scope: 'pagination') %>" placement="top-end">
<%= link_to url, rel: 'next', remote: remote, class: 'next_page' do %>
<%= link_to url, rel: 'next', class: 'next_page' do %>
<%= render_icon("arrow-right-s") %>
<% end %>
</sl-tooltip>
Expand Down
3 changes: 1 addition & 2 deletions app/views/kaminari/alchemy/_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% if page.current? -%>
<span class="page current"><%= page -%></span>
<% else -%>
<%= link_to page, url, opts = {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil, class: 'page'} -%>
<%= link_to page, url, opts = {rel: page.next? ? 'next' : page.prev? ? 'prev' : nil, class: 'page'} -%>
<% end -%>
1 change: 0 additions & 1 deletion app/views/kaminari/alchemy/_paginator.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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
-%>
<div class="pagination">
Expand Down
3 changes: 1 addition & 2 deletions app/views/kaminari/alchemy/_prev_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<% if current_page.first? -%>
<span class="previous_page disabled">
<%= render_icon("arrow-left-s") %>
</span>
<% else -%>
<sl-tooltip class="pagination-label" content="<%= Alchemy.t(:previous_page, scope: 'pagination') %>" placement="top-start">
<%= link_to url, rel: 'prev', remote: remote, class: 'previous_page' do %>
<%= link_to url, rel: 'prev', class: 'previous_page' do %>
<%= render_icon("arrow-left-s") %>
<% end %>
</sl-tooltip>
Expand Down
1 change: 0 additions & 1 deletion config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
pin "@floating-ui/dom", to: "floating-ui.min.js", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "shoelace", to: "shoelace.min.js", preload: true
pin "@rails/ujs", to: "rails-ujs.min.js", preload: true # @7.1.2
pin "tinymce", to: "tinymce.min.js", preload: true
pin "tom-select", to: "tom-select.min.js", preload: true

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"dependencies": {
"@floating-ui/dom": "^1.8.0",
"@rails/ujs": "^7.1.502",
"@shoelace-style/shoelace": "^2.20.1",
"@ungap/custom-elements": "^1.3.0",
"clipboard": "^2.0.11",
Expand Down
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rollup.admin.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default {
"handlebars",
"@ungap/custom-elements",
"@hotwired/turbo-rails",
"@rails/ujs",
"clipboard",
"cropperjs",
"flatpickr",
Expand Down
7 changes: 0 additions & 7 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ export default [
file: "vendor/javascript/floating-ui.min.js"
}
},
{
input: "node_modules/@rails/ujs/app/assets/javascripts/rails-ujs.esm.js",
output: {
file: "vendor/javascript/rails-ujs.min.js"
},
plugins: [terser()]
},
{
input: "bundles/shoelace.js",
output: {
Expand Down
17 changes: 2 additions & 15 deletions spec/controllers/alchemy/admin/base_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,11 @@
end
end

context "for a xhr request" do
before do
expect(controller).to receive(:request) do
double(xhr?: true, format: double(json?: false))
end.twice
end

it "renders error notice" do
subject
expect(controller).to have_received(:render).with(action: "error_notice")
end
end

context "for a html request" do
before do
expect(controller).to receive(:request) do
double(xhr?: false, format: double(json?: false))
end.twice
double(format: double(json?: false))
end
error.set_backtrace(%(foo))
end

Expand Down
32 changes: 0 additions & 32 deletions spec/helpers/alchemy/admin/form_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,5 @@
it "enables browser validations" do
expect(subject).not_to have_css("form[novalidate]")
end

context "if options[:remote] is given" do
context "and set to true" do
subject { helper.alchemy_form_for(resource, remote: true) {} }

it "makes the form remote" do
expect(subject).to have_css("form[data-remote]")
end
end

context "and set to false" do
subject { helper.alchemy_form_for(resource, remote: false) {} }

it "makes the form non-remote" do
expect(subject).to have_css("form")
expect(subject).to_not have_css("form[data-remote]")
end
end
end

context "if options[:remote] is not given" do
context "and request is xhr" do
before do
allow(helper).to receive(:request).and_return(double(xhr?: true))
end

it "does not make the form remote so it submits via Turbo" do
expect(subject).to have_css("form")
expect(subject).to_not have_css("form[data-remote]")
end
end
end
end
end
Loading
Loading