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

Use common tab nav render helper

Oliver Günther78a8ecd687d5
diff --git a/app/components/admin/design_header_component.html.erb b/app/components/admin/design_header_component.html.erb
index 5546c157a75..3ba40976da1 100644
--- a/app/components/admin/design_header_component.html.erb
+++ b/app/components/admin/design_header_component.html.erb
@@ -37,14 +37,6 @@ See COPYRIGHT and LICENSE files for more details.
)
header.with_description { t(:label_custom_style_description) }
- if @tabs.present?
- header.with_tab_nav(label: nil) do |tab_nav|
- @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
- end
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
%>
diff --git a/app/components/attribute_help_texts/index_page_header_component.html.erb b/app/components/attribute_help_texts/index_page_header_component.html.erb
index ae9aa78a362..64a2f269b66 100644
--- a/app/components/attribute_help_texts/index_page_header_component.html.erb
+++ b/app/components/attribute_help_texts/index_page_header_component.html.erb
@@ -31,14 +31,6 @@ See COPYRIGHT and LICENSE files for more details.
header.with_title { I18n.t(:"attribute_help_texts.label_plural") }
header.with_breadcrumbs(breadcrumb_items, selected_item_font_weight: :normal)
- if @tabs.present?
- header.with_tab_nav(label: nil) do |tab_nav|
- @tabs.each do |tab|
- tab_nav.with_tab(selected: currently_selected_tab == tab, href: tab[:path]) do |t|
- t.with_text { I18n.t(tab[:label]) }
- end
- end
- end
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
%>
diff --git a/app/components/groups/edit_page_header_component.html.erb b/app/components/groups/edit_page_header_component.html.erb
index 78c4ff06639..f99070f31f3 100644
--- a/app/components/groups/edit_page_header_component.html.erb
+++ b/app/components/groups/edit_page_header_component.html.erb
@@ -64,14 +64,6 @@ See COPYRIGHT and LICENSE files for more details.
end
end
- if @tabs.present?
- header.with_tab_nav(label: nil) do |tab_nav|
- @tabs.each do |tab|
- tab_nav.with_tab(selected: selected_tab(@tabs) == tab, href: tab[:path]) do |t|
- t.with_text { I18n.t("js.#{tab[:label]}") }
- end
- end
- end
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
%>
diff --git a/app/components/placeholder_users/edit_page_header_component.html.erb b/app/components/placeholder_users/edit_page_header_component.html.erb
index 559f0a885ac..1250500a5d3 100644
--- a/app/components/placeholder_users/edit_page_header_component.html.erb
+++ b/app/components/placeholder_users/edit_page_header_component.html.erb
@@ -63,14 +63,6 @@ See COPYRIGHT and LICENSE files for more details.
end
end
- if @tabs.present?
- header.with_tab_nav(label: nil) do |tab_nav|
- @tabs.each do |tab|
- tab_nav.with_tab(selected: selected_tab(@tabs) == tab, href: tab[:path]) do |t|
- t.with_text { I18n.t("js.#{tab[:label]}") }
- end
- end
- end
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
%>
diff --git a/app/components/types/edit_page_header_component.html.erb b/app/components/types/edit_page_header_component.html.erb
index 114769838ec..dda6517afc3 100644
--- a/app/components/types/edit_page_header_component.html.erb
+++ b/app/components/types/edit_page_header_component.html.erb
@@ -31,9 +31,6 @@ See COPYRIGHT and LICENSE files for more details.
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { @type.name }
header.with_breadcrumbs(breadcrumb_items)
-
- if @tabs.present?
- helpers.render_tab_header_nav(header, @tabs)
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
%>
diff --git a/app/components/users/edit_page_header_component.html.erb b/app/components/users/edit_page_header_component.html.erb
index ccdb9aaf95b..6ef00d2c9fc 100644
--- a/app/components/users/edit_page_header_component.html.erb
+++ b/app/components/users/edit_page_header_component.html.erb
@@ -97,14 +97,6 @@ See COPYRIGHT and LICENSE files for more details.
end
end
- if @tabs.present?
- header.with_tab_nav(label: nil) do |tab_nav|
- @tabs.each do |tab|
- tab_nav.with_tab(selected: selected_tab(@tabs) == tab, href: tab[:path]) do |t|
- t.with_text { I18n.t("js.#{tab[:label]}") }
- end
- end
- end
- end
+ helpers.render_tab_header_nav(header, @tabs)
end
%>
diff --git a/app/helpers/tabs_helper.rb b/app/helpers/tabs_helper.rb
index 3772ac008c6..4d63a41b02d 100644
--- a/app/helpers/tabs_helper.rb
+++ b/app/helpers/tabs_helper.rb
@@ -40,6 +40,8 @@ module TabsHelper
end
def render_tab_header_nav(header, tabs)
+ return if tabs.blank?
+
header.with_tab_nav(label: nil) do |tab_nav|
tabs.each do |tab|
tab_nav.with_tab(selected: selected_tab(tabs) == tab, href: tab[:path]) do |t|
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 44405e749df..a220afe8b66 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2747,6 +2747,7 @@ en:
label_gantt_chart_plural: "Gantt charts"
label_general: "General"
label_generate_key: "Generate a key"
+ label_global_roles: "Global roles"
label_git_path: "Path to .git directory"
label_greater_or_equal: ">="
label_group_by: "Group by"
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index d888477bd91..30540068cf2 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -486,7 +486,6 @@ en:
label_filename: "File"
label_filesize: "Size"
label_general: "General"
- label_global_roles: "Global roles"
label_greater_or_equal: ">="
label_group: "Group"
label_group_by: "Group by"
diff --git a/lib/open_project/ui/extensible_tabs.rb b/lib/open_project/ui/extensible_tabs.rb
index 75e392149b3..c60e8bacd22 100644
--- a/lib/open_project/ui/extensible_tabs.rb
+++ b/lib/open_project/ui/extensible_tabs.rb
@@ -90,13 +90,13 @@ module OpenProject
name: "notifications",
partial: "users/notifications",
path: ->(params) { edit_user_path(params[:user], tab: :notifications) },
- label: :"notifications.settings.title"
+ label: :"js.notifications.settings.title"
},
{
name: "reminders",
partial: "users/reminders",
path: ->(params) { edit_user_path(params[:user], tab: :reminders) },
- label: :"reminders.settings.title"
+ label: :"js.reminders.settings.title"
}
]
end