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

7.2 KB
Raw Blame
<%#-- 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?(:protect_wiki_pages, @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?(:rename_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?(:change_wiki_parent_page, @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?(:delete_wiki_pages, @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_menu, @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?(:export_wiki_pages, @project)
          menu.with_item(
            tag: :a,
            label: t("js.label_export"),
            size: :medium,
            href: "",
            title: t("js.label_export"),
            classes: "modal-delivery-element--activation-link"
          ) do |item|
            item.with_leading_visual_icon(icon: :download)
          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
%>

<section data-augmented-model-wrapper
         data-modal-class-name="wiki-export---modal">
  <%= link_to t("js.label_export"),
              "",
              title: t("js.label_export"),
              style: "display: none;" %>
  <%= render partial: "wiki/wiki_export_modal" %>
</section>