diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 8fcb49a5311f..ae81c5fa823b 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -61,6 +61,18 @@ def update def show_plugin @partial = @plugin.settings[:partial] @settings = Setting["plugin_#{@plugin.id}"] + + page_title_key = @plugin.settings[:page_title_key] + @page_title = page_title_key ? I18n.t(page_title_key) : @plugin.name + + additional_breadcrumb_elements = @plugin.settings[:breadcrumb_elements] + if additional_breadcrumb_elements.present? + @breadcrumb_elements = if additional_breadcrumb_elements.respond_to?(:call) + instance_exec(&additional_breadcrumb_elements) + else + additional_breadcrumb_elements + end + end end def update_plugin diff --git a/app/views/admin/settings/show_plugin.html.erb b/app/views/admin/settings/show_plugin.html.erb index fbfc527ed48b..dfd8780a0fa4 100644 --- a/app/views/admin/settings/show_plugin.html.erb +++ b/app/views/admin/settings/show_plugin.html.erb @@ -29,12 +29,18 @@ See COPYRIGHT and LICENSE files for more details. <% html_title t(:label_administration), @plugin.name %> -<%= toolbar title: @plugin.name %> +<%= + render(Primer::OpenProject::PageHeader.new) do |header| + header.with_title { @page_title } + header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, + *(@breadcrumb_elements if @breadcrumb_elements.present?), + @page_title]) + end +%> +
<%= styled_form_tag({controller: '/admin/settings', action: 'update_plugin' }) do %> <%= render partial: @partial, locals: {settings: @settings}%> <%= styled_submit_tag t(:button_apply), class: '-primary' %> <% end %>
- - diff --git a/config/routes.rb b/config/routes.rb index 9caca4554e3b..994f3e3af75a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -530,7 +530,7 @@ get "/", to: redirect("/admin/settings/general") # Plugin settings - get "plugin/:id", action: :show_plugin + get "plugin/:id", action: :show_plugin, as: :show_plugin post "plugin/:id", action: :update_plugin end diff --git a/modules/avatars/app/views/settings/_openproject_avatars.html.erb b/modules/avatars/app/views/settings/_openproject_avatars.html.erb index 9e5198b9688f..394f7f9db0d0 100644 --- a/modules/avatars/app/views/settings/_openproject_avatars.html.erb +++ b/modules/avatars/app/views/settings/_openproject_avatars.html.erb @@ -1,39 +1,24 @@ <% manager = ::OpenProject::Avatars::AvatarManager %> -<%= - render(Primer::OpenProject::PageHeader.new) do |header| - header.with_title { I18n.t(:label_avatar_plural) } - header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: admin_settings_users_path, text: t(:label_user_and_permission) }, - I18n.t(:label_avatar_plural)]) - end -%> +
+ <%= t 'avatars.label_gravatar' %> -
- <%= styled_form_tag({controller: '/admin/settings', action: 'update_plugin' }) do %> -
- <%= t 'avatars.label_gravatar' %> +
+ <%= styled_label_tag 'settings-enable-gravatars', t('avatars.settings.enable_gravatars') %> + <%= hidden_field_tag 'settings[enable_gravatars]', 0 %> +
+ <%= styled_check_box_tag 'settings[enable_gravatars]', 1, manager.gravatar_enabled?, container_class: '-xslim', id: 'settings-enable-gravatars' %> +
+
+
-
- <%= styled_label_tag 'settings-enable-gravatars', t('avatars.settings.enable_gravatars') %> - <%= hidden_field_tag 'settings[enable_gravatars]', 0 %> -
- <%= styled_check_box_tag 'settings[enable_gravatars]', 1, manager.gravatar_enabled?, container_class: '-xslim', id: 'settings-enable-gravatars' %> -
-
-
- -
- <%= t 'avatars.label_local_avatar' %> -
- <%= styled_label_tag 'settings-enable-local-avatars', t('avatars.settings.enable_local_avatars') %> - <%= hidden_field_tag 'settings[enable_local_avatars]', 0 %> -
- <%= styled_check_box_tag 'settings[enable_local_avatars]', 1, manager.local_avatars_enabled?, container_class: '-xslim', id: 'settings-enable-local-avatars' %> -
-
-
- - <%= styled_submit_tag t(:button_apply), class: '-primary' %> - <% end %> - +
+ <%= t 'avatars.label_local_avatar' %> +
+ <%= styled_label_tag 'settings-enable-local-avatars', t('avatars.settings.enable_local_avatars') %> + <%= hidden_field_tag 'settings[enable_local_avatars]', 0 %> +
+ <%= styled_check_box_tag 'settings[enable_local_avatars]', 1, manager.local_avatars_enabled?, container_class: '-xslim', id: 'settings-enable-local-avatars' %> +
+
+
diff --git a/modules/avatars/lib/open_project/avatars/engine.rb b/modules/avatars/lib/open_project/avatars/engine.rb index 2e494be16b09..05f0537e71aa 100644 --- a/modules/avatars/lib/open_project/avatars/engine.rb +++ b/modules/avatars/lib/open_project/avatars/engine.rb @@ -30,6 +30,7 @@ class Engine < ::Rails::Engine enable_local_avatars: !Rails.env.test? }, partial: "settings/openproject_avatars", + breadcrumb_elements: -> { [{ href: admin_settings_users_path, text: I18n.t(:label_user_and_permission) }] }, menu_item: :user_avatars }, bundled: true do diff --git a/modules/costs/app/views/settings/_costs.html.erb b/modules/costs/app/views/settings/_costs.html.erb index d91b4dcf5f25..d1683e430c7d 100644 --- a/modules/costs/app/views/settings/_costs.html.erb +++ b/modules/costs/app/views/settings/_costs.html.erb @@ -27,32 +27,17 @@ See COPYRIGHT and LICENSE files for more details. ++#%> -<%= - render(Primer::OpenProject::PageHeader.new) do |header| - header.with_title { I18n.t(:project_module_costs) } - header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, - { href: url_for({ controller: "/admin/settings", action: "show_plugin", id: :costs }), text: t(:project_module_costs) }, - I18n.t(:label_setting_plural)]) - end -%> - -
- <%= styled_form_tag({controller: '/admin/settings', action: 'update_plugin' }) do %> - -
- <%= styled_label_tag :label_currency, t(:label_currency) %> -
- <%= styled_text_field_tag 'settings[costs_currency]', @settings['costs_currency'], container_class: '-xslim' %> -
-
- -
- <%= styled_label_tag :label_currency_format, t(:label_currency_format) %> -
- <%= styled_text_field_tag 'settings[costs_currency_format]', @settings['costs_currency_format'], container_class: '-xslim' %> -
-
- - <%= styled_submit_tag t(:button_apply), class: '-primary' %> - <% end %> + +
+ <%= styled_label_tag :label_currency, t(:label_currency) %> +
+ <%= styled_text_field_tag 'settings[costs_currency]', @settings['costs_currency'], container_class: '-xslim' %> +
+
+ +
+ <%= styled_label_tag :label_currency_format, t(:label_currency_format) %> +
+ <%= styled_text_field_tag 'settings[costs_currency_format]', @settings['costs_currency_format'], container_class: '-xslim' %> +
diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb index c495985b10e8..f51fed3c2dc3 100644 --- a/modules/costs/lib/costs/engine.rb +++ b/modules/costs/lib/costs/engine.rb @@ -40,6 +40,10 @@ class Engine < ::Rails::Engine settings: { default: { "costs_currency" => "EUR", "costs_currency_format" => "%n %u" }, partial: "settings/costs", + page_title_key: :label_setting_plural, + breadcrumb_elements: -> { + [{ href: admin_settings_show_plugin_path(:costs), text: I18n.t(:project_module_costs) }] + }, menu_item: :costs_setting } do project_module :costs do