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

Highlight selected tab when path matches and hide "items" tab for non hierachy fields

Henriette Darge9b4baa3e4322
diff --git a/app/components/admin/custom_fields/edit_form_header_component.rb b/app/components/admin/custom_fields/edit_form_header_component.rb
index 8a21e586e20..9490ed23340 100644
--- a/app/components/admin/custom_fields/edit_form_header_component.rb
+++ b/app/components/admin/custom_fields/edit_form_header_component.rb
@@ -36,23 +36,30 @@ module Admin
end
def tabs
- [
+ tabs = [
{
name: "edit",
path: edit_custom_field_path(@custom_field),
label: t(:label_details)
- },
- {
+ }
+ ]
+
+ if @custom_field.field_format_hierarchy?
+ tabs << {
name: "items",
path: custom_field_items_path(@custom_field),
label: t(:label_item_plural)
- },
+ }
+ end
+
+ tabs <<
{
name: "custom_field_projects",
path: custom_field_projects_path(@custom_field),
label: t(:label_project_plural)
}
- ]
+
+ tabs
end
private
diff --git a/app/helpers/tabs_helper.rb b/app/helpers/tabs_helper.rb
index 7beb0f81f48..edd545f0335 100644
--- a/app/helpers/tabs_helper.rb
+++ b/app/helpers/tabs_helper.rb
@@ -65,7 +65,11 @@ module TabsHelper
end
def selected_tab(tabs)
- tabs.detect { |t| t[:name].to_s == params[:tab].to_s } || tabs.first
+ selected = tabs.detect { |t| t[:name].to_s == params[:tab].to_s } || tabs.detect { |t| current_page?(t[:path]) }
+
+ return selected unless selected.nil?
+
+ tabs.first
end
def tabs_for_key(key, params = {})
diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rb
index 0d5a5a53cfa..e2618e00909 100644
--- a/app/helpers/types_helper.rb
+++ b/app/helpers/types_helper.rb
@@ -29,7 +29,7 @@
#++
module ::TypesHelper
- # rubocop:disable Rails/HelperInstanceVariable
+ # rubocop:disable Rails/HelperInstanceVariable, Metrics/AbcSize
def types_tabs
tabs = [
{
@@ -73,7 +73,7 @@ module ::TypesHelper
tabs
end
- # rubocop:enable Rails/HelperInstanceVariable
+ # rubocop:enable Rails/HelperInstanceVariable, Metrics/AbcSize
def icon_for_type(type)
return unless type
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb
index 744767772f2..ec64abd58a9 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb
@@ -44,7 +44,7 @@ module OpenProject::TwoFactorAuthentication
name: "two_factor_authentication",
partial: "users/two_factor_authentication",
path: ->(params) { edit_user_path(params[:user], tab: :two_factor_authentication) },
- label: "two_factor_authentication.label_two_factor_authentication",
+ label: :"two_factor_authentication.label_two_factor_authentication",
only_if: ->(*) { User.current.admin? && OpenProject::TwoFactorAuthentication::TokenStrategyManager.enabled? }
config.to_prepare do