Files
openproject/app/components/wiki_pages/show_page_header_component.html.erb
Eric Schubert 4531cb2cc0 [#73440] refactor wiki permissions
- https://community.openproject.org/work_packages/73440
- merge several wiki permissions into 4 resulting ones
- fix some smaller rubocop issues
2026-05-04 10:27:00 +02:00

198 lines
7.3 KiB
Plaintext

<%#-- 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(test_selector: "wiki-page-header-title") { @page.title }
header.with_breadcrumbs(
helpers.breadcrumb_for_page(@project, @page),
data: { "test-selector": "wiki-page-header-breadcrumbs" }
)
if @editable
if show_edit?
header.with_action_button(
tag: :a,
mobile_icon: :pencil,
mobile_label: t(:button_edit),
size: :medium,
href: url_for(controller: "wiki", action: "edit", id: @page),
aria: { label: I18n.t(:button_edit) },
data: { "test-selector": "wiki-edit-action-button" },
title: I18n.t(:button_edit)
) do |button|
button.with_leading_visual_icon(icon: :pencil)
t(:button_edit)
end
end
helpers.watcher_action_button(header, @page.object)
unless @page.current_version?
header.with_action_button(
tag: :a,
mobile_icon: :book,
mobile_label: t(:label_history),
size: :medium,
href: url_for(controller: "wiki", action: "history", id: @page),
aria: { label: t(:label_history) },
title: t(:label_history)
) do |button|
button.with_leading_visual_icon(icon: "book")
t(:label_history)
end
end
end
header.with_action_menu(
menu_arguments: { anchor_align: :end },
button_arguments: {
icon: "kebab-horizontal",
"aria-label": t(:label_more),
data: { "test-selector": "wiki-more-dropdown-menu" }
}
) do |menu|
if @editable
if User.current.allowed_in_project?(:manage_wiki, @project)
menu.with_item(
label: lock_data[:label],
tag: :a,
size: :medium,
content_arguments: { data: { turbo_method: :post } },
href: url_for(controller: "wiki", action: "protect", id: @page, protected: lock_data[:protected])
) do |item|
item.with_leading_visual_icon(icon: lock_data[:icon])
end
end
if @page.current_version?
if User.current.allowed_in_project?(:edit_wiki_pages, @project)
menu.with_item(
label: t(:button_rename),
tag: :a,
size: :medium,
data: { "test-selector": "wiki-rename-action-menu-item" },
href: url_for(controller: "wiki", action: "rename", id: @page)
) do |item|
item.with_leading_visual_icon(icon: "arrow-switch")
end
end
if User.current.allowed_in_project?(:manage_wiki, @project)
menu.with_item(
label: t(:button_change_parent_page),
tag: :a,
size: :medium,
href: url_for(controller: "wiki", action: "edit_parent_page", id: @page)
) do |item|
item.with_leading_visual_icon(icon: :link)
end
end
end
if User.current.allowed_in_project?(:manage_wiki, @project)
menu.with_item(
label: t(:button_delete),
scheme: :danger,
tag: :a,
size: :medium,
content_arguments: { data: { turbo_confirm: t(:text_are_you_sure), turbo_method: :delete } },
href: url_for(controller: "wiki", action: "destroy", id: @page),
data: { "test-selector": "wiki-delete-action-menu-item" }
) do |item|
item.with_leading_visual_icon(icon: :trash)
end
end
if show_rollback?
menu.with_item(
label: t(:button_rollback),
href: url_for(controller: "wiki", action: "edit", id: @page, version: @page.version)
) do |item|
item.with_leading_visual_icon(icon: :x)
end
end
if User.current.allowed_in_project?(:view_wiki_edits, @project)
menu.with_item(
label: t(:label_history),
href: url_for(controller: "wiki", action: "history", id: @page),
data: { "test-selector": "wiki-history-action-menu-item" }
) do |item|
item.with_leading_visual_icon(icon: :history)
end
end
if User.current.allowed_in_project?(:manage_wiki, @project)
menu.with_item(
label: t(:button_manage_menu_entry),
href: url_for(controller: "/wiki_menu_items", action: "edit", project_id: @project.identifier, id: @page),
data: { "test-selector": "wiki-configure-menu-action-menu-item" }
) do |item|
item.with_leading_visual_icon(icon: :gear)
end
end
menu.with_item(
tag: :a,
label: t(:button_print),
content_arguments: { data: {
controller: "print",
action: "print#triggerPrint"
} },
title: t("wiki.print_hint"),
href: ""
) do |item|
item.with_leading_visual_icon(icon: "op-printer")
end
if User.current.allowed_in_project?(:view_wiki_pages, @project)
menu.with_sub_menu_item(
tag: :a,
label: t("js.label_export"),
title: t("js.label_export"),
size: :auto,
test_selector: "export-button"
) do |item|
item.with_leading_visual_icon(icon: :download)
if show_atom_link?
item.with_item(label: t("export.format.atom"), tag: :a, href: export_atom_link) do |subitem|
subitem.with_leading_visual_icon(icon: :"op-file-atom")
end
end
item.with_item(
label: t("text_formatting.markdown"), tag: :a, href: export_markdown_link,
test_selector: "markdown-export"
) do |subitem|
subitem.with_leading_visual_icon(icon: :file)
end
end
end
menu.with_item(
tag: :a,
label: t(:label_table_of_contents),
title: t("wiki.print_hint"),
href: url_for({ controller: "/wiki", action: "index", project_id: @project.identifier, id: @page })
) do |item|
item.with_leading_visual_icon(icon: "op-view-list")
end
end
end
end
%>