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 Primer TabNav slot instead TabPanels to avoid doubled line

Henriette Darge0b5c6d40c640
diff --git a/modules/costs/app/components/cost_settings/show_page_header_component.html.erb b/modules/costs/app/components/cost_settings/show_page_header_component.html.erb
new file mode 100644
index 00000000000..66760325833
--- /dev/null
+++ b/modules/costs/app/components/cost_settings/show_page_header_component.html.erb
@@ -0,0 +1,8 @@
+<%=
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ header.with_title { t(:label_defaults) }
+ header.with_breadcrumbs(breadcrumb_items)
+
+ helpers.render_tab_header_nav(header, tabs)
+ end
+%>
diff --git a/modules/costs/app/components/cost_settings/show_page_header_component.rb b/modules/costs/app/components/cost_settings/show_page_header_component.rb
new file mode 100644
index 00000000000..de474f75eb0
--- /dev/null
+++ b/modules/costs/app/components/cost_settings/show_page_header_component.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-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 CostSettings
+ class ShowPageHeaderComponent < ApplicationComponent
+ def breadcrumb_items
+ [
+ { href: admin_index_path, text: t("label_administration") },
+ { href: admin_time_settings_path, text: t(:project_module_costs), skip_for_mobile: true },
+ t(:label_defaults)
+ ]
+ end
+
+ def tabs
+ [
+ {
+ name: "time",
+ path: admin_time_settings_path,
+ label: t(:label_time)
+ },
+ {
+ name: "costs",
+ path: admin_costs_settings_path,
+ label: t(:label_costs)
+ }
+ ]
+ end
+ end
+end
diff --git a/modules/costs/app/controllers/admin/costs_settings_controller.rb b/modules/costs/app/controllers/admin/costs_settings_controller.rb
index d6b7d8c90ec..9d8ff23ce6a 100644
--- a/modules/costs/app/controllers/admin/costs_settings_controller.rb
+++ b/modules/costs/app/controllers/admin/costs_settings_controller.rb
@@ -30,23 +30,5 @@
module Admin
class CostsSettingsController < SettingsController
menu_item :costs_settings
-
- before_action :validate_times_enabled_for_enforcement, only: :update
-
- def update # rubocop:disable Lint/UselessMethodDefinition
- super
- end
-
- private
-
- def validate_times_enabled_for_enforcement
- allow_times = ActiveRecord::Type::Boolean.new.cast(settings_params[:allow_tracking_start_and_end_times])
- force_times = ActiveRecord::Type::Boolean.new.cast(settings_params[:enforce_tracking_start_and_end_times])
-
- if force_times && !allow_times
- flash[:error] = I18n.t("setting_enforce_without_allow")
- redirect_to action: :show
- end
- end
end
end
diff --git a/modules/costs/app/controllers/admin/time_settings_controller.rb b/modules/costs/app/controllers/admin/time_settings_controller.rb
new file mode 100644
index 00000000000..640da2ad0e1
--- /dev/null
+++ b/modules/costs/app/controllers/admin/time_settings_controller.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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
+ class TimeSettingsController < SettingsController
+ menu_item :costs_settings
+
+ before_action :validate_times_enabled_for_enforcement, only: :update
+
+ def update # rubocop:disable Lint/UselessMethodDefinition
+ super
+ end
+
+ private
+
+ def validate_times_enabled_for_enforcement
+ allow_times = ActiveRecord::Type::Boolean.new.cast(settings_params[:allow_tracking_start_and_end_times])
+ force_times = ActiveRecord::Type::Boolean.new.cast(settings_params[:enforce_tracking_start_and_end_times])
+
+ if force_times && !allow_times
+ flash[:error] = I18n.t("setting_enforce_without_allow")
+ redirect_to action: :show
+ end
+ end
+ end
+end
diff --git a/modules/costs/app/views/admin/cost_types/edit.html.erb b/modules/costs/app/views/admin/cost_types/edit.html.erb
index cf0c62043c8..803629e6ab3 100644
--- a/modules/costs/app/views/admin/cost_types/edit.html.erb
+++ b/modules/costs/app/views/admin/cost_types/edit.html.erb
@@ -41,7 +41,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs) },
+ { href: admin_time_settings_path, text: t(:project_module_costs) },
{ href: admin_cost_types_path, text: t(:label_cost_type_plural) },
title
]
diff --git a/modules/costs/app/views/admin/cost_types/index.html.erb b/modules/costs/app/views/admin/cost_types/index.html.erb
index 1e46956427b..4d61b8398d6 100644
--- a/modules/costs/app/views/admin/cost_types/index.html.erb
+++ b/modules/costs/app/views/admin/cost_types/index.html.erb
@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs) },
+ { href: admin_time_settings_path, text: t(:project_module_costs) },
I18n.t(:label_cost_type_plural)
]
)
diff --git a/modules/costs/app/views/admin/costs_settings/show.html.erb b/modules/costs/app/views/admin/costs_settings/show.html.erb
index c3408c3e163..dab2f65b85f 100644
--- a/modules/costs/app/views/admin/costs_settings/show.html.erb
+++ b/modules/costs/app/views/admin/costs_settings/show.html.erb
@@ -30,77 +30,22 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_administration), t("plugin_costs.name") %>
<%=
- render(Primer::OpenProject::PageHeader.new) do |header|
- header.with_title { t(:label_defaults) }
- header.with_breadcrumbs(
- [
- { href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs), skip_for_mobile: true },
- t(:label_defaults)
- ]
- )
- end
+ render(CostSettings::ShowPageHeaderComponent.new)
%>
-<%= render(Primer::Alpha::TabPanels.new(label: I18n.t(:project_module_costs))) do |component| %>
- <%= component.with_tab(selected: true, id: "tab-time") do |tab| %>
- <%= tab.with_text { I18n.t(:label_time) } %>
- <%= tab.with_panel do %>
- <%=
- render(
- ::EnterpriseEdition::BannerComponent.new(
- :time_entry_time_restrictions,
- variant: :medium,
- image: "enterprise/exact-time-tracking.png",
- dismissable: false
- )
- )
- %>
- <%=
- settings_primer_form_with(scope: :settings, action: :update, method: :patch) do |time_form|
- render_inline_settings_form(time_form) do |form|
- form.html_content do
- render(Primer::Beta::Subhead.new(hide_border: true)) do |subhead|
- subhead.with_heading(size: :medium) { I18n.t(:label_mandatory_fields) }
- subhead.with_description { I18n.t(:description_time_settings) }
- end
- end
-
- form.check_box(
- name: :allow_tracking_start_and_end_times,
- caption: I18n.t(:setting_allow_tracking_start_and_end_times_caption)
- )
- form.check_box(
- name: :enforce_tracking_start_and_end_times,
- caption: I18n.t(:setting_enforce_tracking_start_and_end_times_caption),
- disabled: !EnterpriseToken.allows_to?(:time_entry_time_restrictions)
- )
-
- form.submit
- end
- end
- %>
- <% end %>
- <% end %>
-<%
- component.with_tab(id: "tab-costs") do |tab|
- tab.with_text { I18n.t(:label_costs) }
- tab.with_panel do
- settings_primer_form_with(scope: :settings, action: :update, method: :patch) do |time_form|
- render_inline_settings_form(time_form) do |form|
- form.html_content do
- render(Primer::Beta::Subhead.new(hide_border: true)) do |subhead|
- subhead.with_heading(size: :medium) { I18n.t(:label_costs) }
- subhead.with_description { I18n.t(:description_costs_settings) }
- end
- end
- form.text_field(name: :costs_currency, input_width: :small)
- form.text_field(name: :costs_currency_format, input_width: :small)
-
- form.submit
+<%=
+ settings_primer_form_with(scope: :settings, action: :update, method: :patch) do |time_form|
+ render_inline_settings_form(time_form) do |form|
+ form.html_content do
+ render(Primer::Beta::Subhead.new(hide_border: true)) do |subhead|
+ subhead.with_heading(tag: :h3, size: :medium) { I18n.t(:label_costs) }
+ subhead.with_description { I18n.t(:description_costs_settings) }
end
end
+ form.text_field(name: :costs_currency, input_width: :small)
+ form.text_field(name: :costs_currency_format, input_width: :small)
+
+ form.submit
end
end
- end
%>
diff --git a/modules/costs/app/views/admin/settings/time_entry_activities/edit.html.erb b/modules/costs/app/views/admin/settings/time_entry_activities/edit.html.erb
index 9f582aabdc9..cf7880ed9f1 100644
--- a/modules/costs/app/views/admin/settings/time_entry_activities/edit.html.erb
+++ b/modules/costs/app/views/admin/settings/time_entry_activities/edit.html.erb
@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs) },
+ { href: admin_time_settings_path, text: t(:project_module_costs) },
{ href: admin_settings_time_entry_activities_path, text: TimeEntryActivity.model_name.human(count: :other) },
@enumeration.name
]
diff --git a/modules/costs/app/views/admin/settings/time_entry_activities/index.html.erb b/modules/costs/app/views/admin/settings/time_entry_activities/index.html.erb
index ab1000d3619..314c97f42e5 100644
--- a/modules/costs/app/views/admin/settings/time_entry_activities/index.html.erb
+++ b/modules/costs/app/views/admin/settings/time_entry_activities/index.html.erb
@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs) },
+ { href: admin_time_settings_path, text: t(:project_module_costs) },
TimeEntryActivity.model_name.human(count: :other)
]
)
diff --git a/modules/costs/app/views/admin/settings/time_entry_activities/new.html.erb b/modules/costs/app/views/admin/settings/time_entry_activities/new.html.erb
index 196024c158b..a2b119b18fc 100644
--- a/modules/costs/app/views/admin/settings/time_entry_activities/new.html.erb
+++ b/modules/costs/app/views/admin/settings/time_entry_activities/new.html.erb
@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs) },
+ { href: admin_time_settings_path, text: t(:project_module_costs) },
{ href: admin_settings_time_entry_activities_path, text: TimeEntryActivity.model_name.human(count: :other) },
I18n.t(:label_new_time_entry_activity)
]
diff --git a/modules/costs/app/views/admin/settings/time_entry_activities/reassign.html.erb b/modules/costs/app/views/admin/settings/time_entry_activities/reassign.html.erb
index 5c1857768a7..ac90b0b67ec 100644
--- a/modules/costs/app/views/admin/settings/time_entry_activities/reassign.html.erb
+++ b/modules/costs/app/views/admin/settings/time_entry_activities/reassign.html.erb
@@ -35,7 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t("label_administration") },
- { href: admin_costs_settings_path, text: t(:project_module_costs) },
+ { href: admin_time_settings_path, text: t(:project_module_costs) },
{ href: admin_settings_time_entry_activities_path, text: TimeEntryActivity.model_name.human(count: :other) },
@enumeration.name
]
diff --git a/modules/costs/app/views/admin/time_settings/show.html.erb b/modules/costs/app/views/admin/time_settings/show.html.erb
new file mode 100644
index 00000000000..8cb2d9b78b8
--- /dev/null
+++ b/modules/costs/app/views/admin/time_settings/show.html.erb
@@ -0,0 +1,70 @@
+<%# -- copyright
+OpenProject is an open source project management software.
+Copyright (C) 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.
+
+++#%>
+
+<% html_title t(:label_administration), t("plugin_costs.name") %>
+
+<%=
+ render(CostSettings::ShowPageHeaderComponent.new)
+%>
+
+<%=
+ render(
+ ::EnterpriseEdition::BannerComponent.new(
+ :time_entry_time_restrictions,
+ variant: :medium,
+ image: "enterprise/exact-time-tracking.png",
+ dismissable: false
+ )
+ )
+%>
+
+<%=
+ settings_primer_form_with(scope: :settings, action: :update, method: :patch) do |time_form|
+ render_inline_settings_form(time_form) do |form|
+ form.html_content do
+ render(Primer::Beta::Subhead.new(hide_border: true)) do |subhead|
+ subhead.with_heading(tag: :h3, size: :medium) { I18n.t(:label_mandatory_fields) }
+ subhead.with_description { I18n.t(:description_time_settings) }
+ end
+ end
+
+ form.check_box(
+ name: :allow_tracking_start_and_end_times,
+ caption: I18n.t(:setting_allow_tracking_start_and_end_times_caption)
+ )
+ form.check_box(
+ name: :enforce_tracking_start_and_end_times,
+ caption: I18n.t(:setting_enforce_tracking_start_and_end_times_caption),
+ disabled: !EnterpriseToken.allows_to?(:time_entry_time_restrictions)
+ )
+
+ form.submit
+ end
+ end
+%>
diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rb
index fef1b037ebb..2a3ab497020 100644
--- a/modules/costs/config/routes.rb
+++ b/modules/costs/config/routes.rb
@@ -101,5 +101,10 @@ Rails.application.routes.draw do
only: %i[show update],
controller: "costs_settings",
as: "costs_settings"
+
+ resource :time,
+ only: %i[show update],
+ controller: "time_settings",
+ as: "time_settings"
end
end