From e1c200e5242c2e272c4a142023f30a0603b0f396 Mon Sep 17 00:00:00 2001 From: Sascha Karnatz <122262394+sascha-karnatz@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:08:40 +0100 Subject: [PATCH] Add tabs component to LinkDialog Move the last piece of the link view to a view component and remove the original view. --- .../alchemy/admin/link_dialog/tabs.rb | 21 +++++++++++++++++++ .../alchemy/admin/pages_controller.rb | 1 + app/views/alchemy/admin/pages/link.html.erb | 5 ----- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 app/components/alchemy/admin/link_dialog/tabs.rb delete mode 100644 app/views/alchemy/admin/pages/link.html.erb diff --git a/app/components/alchemy/admin/link_dialog/tabs.rb b/app/components/alchemy/admin/link_dialog/tabs.rb new file mode 100644 index 0000000000..8554e4c9e1 --- /dev/null +++ b/app/components/alchemy/admin/link_dialog/tabs.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Alchemy + module Admin + module LinkDialog + class Tabs < ViewComponent::Base + erb_template <<~ERB + + <% tabs.each do |tab| %> + <%= render tab.new %> + <% end %> + + ERB + + def tabs + Alchemy.link_dialog_tabs + end + end + end + end +end diff --git a/app/controllers/alchemy/admin/pages_controller.rb b/app/controllers/alchemy/admin/pages_controller.rb index f32bcf1fe0..68a1b610d4 100644 --- a/app/controllers/alchemy/admin/pages_controller.rb +++ b/app/controllers/alchemy/admin/pages_controller.rb @@ -163,6 +163,7 @@ def destroy end def link + render LinkDialog::Tabs.new end def fold diff --git a/app/views/alchemy/admin/pages/link.html.erb b/app/views/alchemy/admin/pages/link.html.erb deleted file mode 100644 index ee09d27184..0000000000 --- a/app/views/alchemy/admin/pages/link.html.erb +++ /dev/null @@ -1,5 +0,0 @@ - - <% Alchemy.link_dialog_tabs.each do |tab| %> - <%= render tab.new %> - <% end %> -