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

[#55189] Use PageHeader tabs in admin/settings/project_custom_fields/:id/edit pages.

Pavel Balashou483be764151d
diff --git a/app/components/admin/settings/project_custom_fields/project_attribute_detail_header_component.html.erb b/app/components/admin/settings/project_custom_fields/project_attribute_detail_header_component.html.erb
deleted file mode 100644
index 7c5052cffc0..00000000000
--- a/app/components/admin/settings/project_custom_fields/project_attribute_detail_header_component.html.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<%#-- copyright
-OpenProject is an open source project management software.
-Copyright (C) 2012-2023 the OpenProject GmbH
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License version 3.
-
-OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-Copyright (C) 2006-2013 Jean-Philippe Lang
-Copyright (C) 2010-2013 the ChiliProject Team
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-See COPYRIGHT and LICENSE files for more details.
-
-++#%>
-<%= render(Settings::ProjectCustomFields::EditFormHeaderComponent.new(custom_field: @custom_field)) %>
-
-<%=
- render(Primer::Alpha::TabNav.new(label: nil, test_selector: :project_attribute_detail_header)) do |component|
- component.with_tab(
- selected: project_custom_field_edit_selected?,
- href: edit_admin_settings_project_custom_field_path(@custom_field)
- ) do |tab|
- tab.with_text { t(:label_details) }
- end
-
- component.with_tab(
- selected: project_custom_field_project_mappings_selected?,
- href: project_mappings_admin_settings_project_custom_field_path(@custom_field)
- ) do |tab|
- tab.with_text { I18n.t(:label_project_plural) }
- end
- end
-%>
diff --git a/app/components/admin/settings/project_custom_fields/project_attribute_detail_header_component.rb b/app/components/admin/settings/project_custom_fields/project_attribute_detail_header_component.rb
deleted file mode 100644
index be45ba21bdc..00000000000
--- a/app/components/admin/settings/project_custom_fields/project_attribute_detail_header_component.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module Admin
- module Settings
- module ProjectCustomFields
- class ProjectAttributeDetailHeaderComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
- TAB_NAVS = %i[
- project_custom_field_edit
- project_custom_field_project_mappings
- ].freeze
-
- def initialize(custom_field:, selected:)
- selected = selected.to_sym
- raise "selected must be one of the following: #{TAB_NAVS.join(', ')}" unless TAB_NAVS.include?(selected)
-
- super
- @custom_field = custom_field
- @selected = selected
- end
-
- TAB_NAVS.each do |tab_nav|
- define_method(:"#{tab_nav}_selected?") do
- @selected == tab_nav
- end
- end
- end
- end
- end
-end
diff --git a/app/components/settings/project_custom_fields/edit_form_header_component.html.erb b/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
index 9cb8f75cdd7..b6971848f72 100644
--- a/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
+++ b/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
@@ -31,5 +31,20 @@ See COPYRIGHT and LICENSE files for more details.
header.with_title { @custom_field.name }
header.with_description { t("settings.project_attributes.edit.description") }
header.with_breadcrumbs(breadcrumbs_items)
+ header.with_tab_nav(label: nil, test_selector: :project_attribute_detail_header) do |tab_nav|
+ tab_nav.with_tab(
+ selected: project_custom_field_edit_selected?,
+ href: edit_admin_settings_project_custom_field_path(@custom_field)
+ ) do |tab|
+ tab.with_text { t(:label_details) }
+ end
+
+ tab_nav.with_tab(
+ selected: project_custom_field_project_mappings_selected?,
+ href: project_mappings_admin_settings_project_custom_field_path(@custom_field)
+ ) do |tab|
+ tab.with_text { I18n.t(:label_project_plural) }
+ end
+ end
end
%>
diff --git a/app/components/settings/project_custom_fields/edit_form_header_component.rb b/app/components/settings/project_custom_fields/edit_form_header_component.rb
index 61365dec332..157bd85c452 100644
--- a/app/components/settings/project_custom_fields/edit_form_header_component.rb
+++ b/app/components/settings/project_custom_fields/edit_form_header_component.rb
@@ -29,18 +29,31 @@
module Settings
module ProjectCustomFields
class EditFormHeaderComponent < ApplicationComponent
- def initialize(custom_field:)
- super
+ TAB_NAVS = %i[
+ project_custom_field_edit
+ project_custom_field_project_mappings
+ ].freeze
+
+ def initialize(custom_field:, selected:)
+ selected = selected.to_sym
+ raise "selected must be one of the following: #{TAB_NAVS.join(', ')}" unless TAB_NAVS.include?(selected)
+ super
@custom_field = custom_field
+ @selected = selected
+ end
+
+ TAB_NAVS.each do |tab_nav|
+ define_method(:"#{tab_nav}_selected?") do
+ @selected == tab_nav
+ end
end
def breadcrumbs_items
[{ href: admin_index_path, text: t("label_administration") },
{ href: admin_settings_project_custom_fields_path, text: t("label_project_plural") },
{ href: admin_settings_project_custom_fields_path, text: t("settings.project_attributes.heading") },
- @custom_field.name
- ]
+ @custom_field.name]
end
end
end
diff --git a/app/views/admin/settings/project_custom_fields/edit.html.erb b/app/views/admin/settings/project_custom_fields/edit.html.erb
index 0ded271bed5..31d4eadf1ce 100644
--- a/app/views/admin/settings/project_custom_fields/edit.html.erb
+++ b/app/views/admin/settings/project_custom_fields/edit.html.erb
@@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.
<% local_assigns[:additional_breadcrumb] = @custom_field.name %>
<%=
- render(Admin::Settings::ProjectCustomFields::ProjectAttributeDetailHeaderComponent.new(
+ render(Settings::ProjectCustomFields::EditFormHeaderComponent.new(
custom_field: @custom_field,
selected: :project_custom_field_edit
))
diff --git a/app/views/admin/settings/project_custom_fields/project_mappings.html.erb b/app/views/admin/settings/project_custom_fields/project_mappings.html.erb
index 4bdb9e3605d..fffc0a6b119 100644
--- a/app/views/admin/settings/project_custom_fields/project_mappings.html.erb
+++ b/app/views/admin/settings/project_custom_fields/project_mappings.html.erb
@@ -27,10 +27,8 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
-<% local_assigns[:additional_breadcrumb] = @custom_field.name %>
-
<%=
- render(Admin::Settings::ProjectCustomFields::ProjectAttributeDetailHeaderComponent.new(
+ render(Settings::ProjectCustomFields::EditFormHeaderComponent.new(
custom_field: @custom_field,
selected: :project_custom_field_project_mappings
))