Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

change design header component to use tab helper

Behrokh Satarnejade3d4e1b4a789
diff --git a/app/components/admin/design_header_component.html.erb b/app/components/admin/design_header_component.html.erb
index 9f31359a733..ba5005415e6 100644
--- a/app/components/admin/design_header_component.html.erb
+++ b/app/components/admin/design_header_component.html.erb
@@ -35,15 +35,11 @@ See COPYRIGHT and LICENSE files for more details.
t(:label_custom_style)])
header.with_description { t(:label_custom_style_description) }
header.with_tab_nav(label: nil) do |tab_nav|
- tab_nav.with_tab(selected: @selected == 1, href: custom_style_path) do |tab|
- tab.with_text { t(:"admin.custom_styles.tab_interface") }
+ @tabs.each do |tab|
+ tab_nav.with_tab(selected: selected_tab(@tabs) == tab, href: tab[:path]) do |t|
+ t.with_text { tab[:label] }
+ end
end
- tab_nav.with_tab(selected: @selected == 2, href: custom_style_branding_path) do |tab|
- tab.with_text { t(:"admin.custom_styles.tab_branding") }
- end
- tab_nav.with_tab(selected: @selected == 3, href: custom_style_pdf_export_styles_path) do |tab|
- tab.with_text { t(:"admin.custom_styles.tab_pdf_export_styles") }
- end
- end
+ end if @tabs.present?
end
%>
diff --git a/app/components/admin/design_header_component.rb b/app/components/admin/design_header_component.rb
index bbcf0c56f06..4572c866554 100644
--- a/app/components/admin/design_header_component.rb
+++ b/app/components/admin/design_header_component.rb
@@ -30,12 +30,13 @@
module Admin
class DesignHeaderComponent < ApplicationComponent
- def initialize(title:, selected:)
- super
- raise "selected must 1, 2 or 3" if [1, 2, 3].exclude?(selected)
+ include OpPrimer::ComponentHelpers
+ include ApplicationHelper
+ include TabsHelper
- @title = title
- @selected = selected
+ def initialize(tabs: nil)
+ super
+ @tabs = tabs
end
end
end