diff --git a/app/assets/images/enterprise/attribute-help-texts.png b/app/assets/images/enterprise/attribute-help-texts.png deleted file mode 100644 index 58fa216c7a9d..000000000000 Binary files a/app/assets/images/enterprise/attribute-help-texts.png and /dev/null differ diff --git a/app/components/admin/backups/show_page_header_component.html.erb b/app/components/admin/backups/show_page_header_component.html.erb new file mode 100644 index 000000000000..4b1ddcd8bca8 --- /dev/null +++ b/app/components/admin/backups/show_page_header_component.html.erb @@ -0,0 +1,65 @@ +<%#-- 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. + +++#%> +<%= + render(Primer::OpenProject::PageHeader.new) do |header| + header.with_title { t(:label_backup) } + header.with_breadcrumbs([{ href: admin_index_path, text: t(:label_administration) }, + t(:label_backup)]) + + header.with_action_button(tag: :a, + scheme: button_scheme, + mobile_label: button_title, + mobile_icon: button_icon, + size: :medium, + href: reset_token_admin_backups_path, + aria: { label: button_title }, + title: button_title) do |button| + button.with_leading_visual_icon(icon: button_icon) + button_title + end + + if @backup_token.present? + header.with_action_button(tag: :a, + scheme: :danger, + mobile_icon: :trash, + mobile_label: t("backup.label_delete_token"), + size: :medium, + href: delete_token_admin_backups_path, + aria: { label: I18n.t("backup.label_delete_token") }, + data: { + confirm: I18n.t(:text_are_you_sure), + method: :post + }, + title: I18n.t(:button_delete)) do |button| + button.with_leading_visual_icon(icon: :trash) + t("backup.label_delete_token") + end + end + end +%> diff --git a/app/components/admin/backups/show_page_header_component.rb b/app/components/admin/backups/show_page_header_component.rb new file mode 100644 index 000000000000..3b7dc6f70b90 --- /dev/null +++ b/app/components/admin/backups/show_page_header_component.rb @@ -0,0 +1,61 @@ +# 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 + module Backups + class ShowPageHeaderComponent < ApplicationComponent + include OpPrimer::ComponentHelpers + include ApplicationHelper + + def initialize(backup_token:) + super + @backup_token = backup_token + end + + def breadcrumb_items + [{ href: admin_index_path, text: t(:label_administration) }, + t(:label_backup)] + end + + def button_title + button_action = @backup_token.present? ? "reset" : "create" + t("backup.label_#{button_action}_token") + end + + def button_icon + @backup_token.present? ? :"op-reload" : :plus + end + + def button_scheme + @backup_token.present? ? :default : :primary + end + end + end +end diff --git a/app/views/attribute_help_texts/upsale.html.erb b/app/components/attribute_help_texts/index_page_header_component.html.erb similarity index 70% rename from app/views/attribute_help_texts/upsale.html.erb rename to app/components/attribute_help_texts/index_page_header_component.html.erb index bba919c1ee1a..602390526de0 100644 --- a/app/views/attribute_help_texts/upsale.html.erb +++ b/app/components/attribute_help_texts/index_page_header_component.html.erb @@ -26,13 +26,17 @@ 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(:'attribute_help_texts.label_plural') %> - -<%= render template: 'common/upsale', - locals: { - feature_title: t(:'attribute_help_texts.label_plural'), - feature_description: t('attribute_help_texts.enterprise.description'), - feature_reference: 'enterprise-attribute-help-texts', - feature_image: 'enterprise/attribute-help-texts.png' - } %> +<%= + render(Primer::OpenProject::PageHeader.new) do |header| + header.with_title { I18n.t(:"attribute_help_texts.label_plural") } + header.with_breadcrumbs(breadcrumb_items, selected_item_font_weight: :normal) + + 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 if @tabs.present? + end +%> diff --git a/app/components/attribute_help_texts/index_page_header_component.rb b/app/components/attribute_help_texts/index_page_header_component.rb new file mode 100644 index 000000000000..0e0637a472e1 --- /dev/null +++ b/app/components/attribute_help_texts/index_page_header_component.rb @@ -0,0 +1,50 @@ +# 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. +# ++ + +class AttributeHelpTexts::IndexPageHeaderComponent < ApplicationComponent + include OpPrimer::ComponentHelpers + include ApplicationHelper + include TabsHelper + + def initialize(tabs: nil) + super + @tabs = tabs + end + + def breadcrumb_items + [{ href: admin_index_path, text: t("label_administration") }, + I18n.t("menus.breadcrumb.nested_element", section_header: t(:"attribute_help_texts.label_plural"), + title: I18n.t(currently_selected_tab[:label].to_s)).html_safe] + end + + def currently_selected_tab + @currently_selected_tab ||= selected_tab(@tabs) + end +end diff --git a/app/components/custom_fields/index_page_header_component.html.erb b/app/components/custom_fields/index_page_header_component.html.erb new file mode 100644 index 000000000000..f91e3f13d795 --- /dev/null +++ b/app/components/custom_fields/index_page_header_component.html.erb @@ -0,0 +1,42 @@ +<%#-- 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. + +++#%> +<%= + render(Primer::OpenProject::PageHeader.new) do |header| + header.with_title { I18n.t(:label_custom_field_plural) } + header.with_breadcrumbs(breadcrumb_items, selected_item_font_weight: :normal) + + header.with_tab_nav(label: nil, test_selector: "custom-fields--tab-nav") 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 if @tabs.present? + end +%> diff --git a/app/components/custom_fields/index_page_header_component.rb b/app/components/custom_fields/index_page_header_component.rb new file mode 100644 index 000000000000..bfefb5b22ec2 --- /dev/null +++ b/app/components/custom_fields/index_page_header_component.rb @@ -0,0 +1,50 @@ +# 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. +# ++ + +class CustomFields::IndexPageHeaderComponent < ApplicationComponent + include OpPrimer::ComponentHelpers + include ApplicationHelper + include TabsHelper + + def initialize(tabs: nil) + super + @tabs = tabs + end + + def breadcrumb_items + [{ href: admin_index_path, text: t("label_administration") }, + I18n.t("menus.breadcrumb.nested_element", section_header: t(:label_custom_field_plural), + title: I18n.t(currently_selected_tab[:label].to_s)).html_safe] + end + + def currently_selected_tab + @currently_selected_tab ||= selected_tab(@tabs) + end +end diff --git a/app/controllers/admin/backups_controller.rb b/app/controllers/admin/backups_controller.rb index fb50e597c75b..0be5ebdff8a0 100644 --- a/app/controllers/admin/backups_controller.rb +++ b/app/controllers/admin/backups_controller.rb @@ -76,12 +76,10 @@ def delete_token redirect_to action: "show" end - def default_breadcrumb - t(:label_backup) - end + def default_breadcrumb; end def show_local_breadcrumb - true + false end def check_enabled diff --git a/app/controllers/attribute_help_texts_controller.rb b/app/controllers/attribute_help_texts_controller.rb index 737002a40f77..44aa15e6085f 100644 --- a/app/controllers/attribute_help_texts_controller.rb +++ b/app/controllers/attribute_help_texts_controller.rb @@ -44,8 +44,6 @@ def new def edit; end - def upsale; end - def create call = ::AttributeHelpTexts::CreateService .new(user: current_user) @@ -87,16 +85,10 @@ def destroy protected - def default_breadcrumb - if action_name == "index" - t("attribute_help_texts.label_plural") - else - ActionController::Base.helpers.link_to(t("attribute_help_texts.label_plural"), attribute_help_texts_path) - end - end + def default_breadcrumb; end def show_local_breadcrumb - true + false end private diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index 644a489ec762..de3a72af308e 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -58,16 +58,10 @@ def edit protected - def default_breadcrumb - if action_name == "index" - t("label_custom_field_plural") - else - ActionController::Base.helpers.link_to(t("label_custom_field_plural"), custom_fields_path) - end - end + def default_breadcrumb; end def show_local_breadcrumb - true + false end def find_custom_field diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb index 884d8a87548f..e2e70eb61dfb 100644 --- a/app/controllers/custom_styles_controller.rb +++ b/app/controllers/custom_styles_controller.rb @@ -153,7 +153,7 @@ def update_themes end def show_local_breadcrumb - true + false end private diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 85bc3e8eb9c1..a011ec00375c 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -98,12 +98,10 @@ def render_gon helpers.write_augur_to_gon end - def default_breadcrumb - t(:label_enterprise_edition) - end + def default_breadcrumb; end def show_local_breadcrumb - true + false end def check_user_limit diff --git a/app/views/admin/backups/show.html.erb b/app/views/admin/backups/show.html.erb index 1b6f6fa64d16..b1bcd6f88465 100644 --- a/app/views/admin/backups/show.html.erb +++ b/app/views/admin/backups/show.html.erb @@ -29,40 +29,7 @@ See COPYRIGHT and LICENSE files for more details. <% html_title t(:label_administration), t(:label_backup) -%> -<%= toolbar title: t('label_backup') do %> -
<%= t("backup.reset_token.info") %> diff --git a/app/views/attribute_help_texts/edit.html.erb b/app/views/attribute_help_texts/edit.html.erb index 6cbdd2bb55d5..245d90699bf6 100644 --- a/app/views/attribute_help_texts/edit.html.erb +++ b/app/views/attribute_help_texts/edit.html.erb @@ -28,10 +28,18 @@ See COPYRIGHT and LICENSE files for more details. ++#%> <% html_title t(:label_administration), t(:'attribute_help_texts.edit', attribute_caption: @attribute_help_text.attribute_caption) %> -<% local_assigns[:additional_breadcrumb] = t(:'attribute_help_texts.edit', attribute_caption: @attribute_help_text.attribute_caption) %> -<%= breadcrumb_toolbar t(:'attribute_help_texts.edit', attribute_caption: @attribute_help_text.attribute_caption) + +<%= + render(Primer::OpenProject::PageHeader.new) do |header| + header.with_title { @attribute_help_text.attribute_caption } + header.with_breadcrumbs([{ href: admin_index_path, text: t(:label_administration) }, + { href: attribute_help_texts_path, text: t(:"attribute_help_texts.label_plural") }, + { href: attribute_help_texts_path(tab: @attribute_help_text.attribute_scope), text: @attribute_help_text.type_caption }, + @attribute_help_text.attribute_caption]) + end %> + <%= labelled_tabular_form_for @attribute_help_text, as: 'attribute_help_text', url: { action: :update }, diff --git a/app/views/attribute_help_texts/index.html.erb b/app/views/attribute_help_texts/index.html.erb index 6db28e5a33cc..44fbccd68071 100644 --- a/app/views/attribute_help_texts/index.html.erb +++ b/app/views/attribute_help_texts/index.html.erb @@ -38,21 +38,24 @@ See COPYRIGHT and LICENSE files for more details. name: 'Project', partial: 'attribute_help_texts/tab', path: attribute_help_texts_path(tab: 'Project'), - label: Project.model_name.human + label: :label_project } ] %> - -<%= toolbar title: t(:'attribute_help_texts.label_plural') do %> -