Skip to content

Commit

Permalink
Merge pull request #16509 from opf/feature/53808-update-pageheaders-a…
Browse files Browse the repository at this point in the history
…nd-subheaders-in-the-admin-pages

[53808] Update PageHeaders & SubHeaders in the Admin pages
  • Loading branch information
oliverguenther authored Aug 27, 2024
2 parents 68fdb2d + 8788b34 commit c2aa91b
Show file tree
Hide file tree
Showing 26 changed files with 390 additions and 124 deletions.
Binary file not shown.
65 changes: 65 additions & 0 deletions app/components/admin/backups/show_page_header_component.html.erb
Original file line number Diff line number Diff line change
@@ -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
%>
61 changes: 61 additions & 0 deletions app/components/admin/backups/show_page_header_component.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
%>
50 changes: 50 additions & 0 deletions app/components/attribute_help_texts/index_page_header_component.rb
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions app/components/custom_fields/index_page_header_component.html.erb
Original file line number Diff line number Diff line change
@@ -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
%>
50 changes: 50 additions & 0 deletions app/components/custom_fields/index_page_header_component.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions app/controllers/admin/backups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions app/controllers/attribute_help_texts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def new

def edit; end

def upsale; end

def create
call = ::AttributeHelpTexts::CreateService
.new(user: current_user)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/custom_fields_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/custom_styles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def update_themes
end

def show_local_breadcrumb
true
false
end

private
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/enterprises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit c2aa91b

Please sign in to comment.