Merge pull request #22716 from opf/feature/72971-show-inline-wiki-page-links

[#72971] added wiki tab content
This commit is contained in:
Eric Schubert
2026-04-14 13:57:42 +02:00
committed by GitHub
13 changed files with 280 additions and 2 deletions
@@ -0,0 +1,18 @@
<%=
flex_layout do |container|
container.with_row(mb: 2) { render(Primer::Beta::Text.new(font_weight: :bold)) { t(".heading") } }
if page_links.empty?
container.with_row do
render(Primer::Beta::Blankslate.new(border: false)) do |blankslate|
blankslate.with_heading(tag: :h2).with_content(t(".empty_heading"))
blankslate.with_description { t(".empty_text") }
end
end
end
page_links.each do |page_link|
container.with_row(mt: 3) { render(Wikis::PageLinkComponent.new(page_link)) }
end
end
%>
@@ -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.
#++
module Wikis
class InlinePageLinksComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
alias_method :provider, :model
def initialize(model = nil, work_package: nil, **)
@work_package = work_package
super(model, **)
end
def page_links
@page_links ||= provider.page_links
.merge(InlinePageLink.all)
.where(linkable: @work_package)
.order(created_at: :desc)
end
end
end
@@ -0,0 +1,11 @@
<%=
flex_layout(test_selector: "op-custom-fields--hierarchy-item") do |link_container|
link_container.with_column(flex_shrink: 0) do
render(Primer::Beta::Octicon.new(icon: :"op-file-doc", mr: 2))
end
link_container.with_column(classes: "ellipsis") do
render(Primer::Beta::Link.new(href: "#", scheme: :primary)) { page_title_service.read(link) }
end
end
%>
@@ -0,0 +1,42 @@
# 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 Wikis
class PageLinkComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
alias_method :link, :model
def page_title_service
@page_title_service ||= PageTitleService.new
end
end
end
@@ -0,0 +1,9 @@
<%=
render(Primer::Beta::BorderBox.new) do |box|
box.with_header do
render(Primer::Beta::Text.new(font_weight: :bold)) { provider.name }
end
box.with_row { render(Wikis::InlinePageLinksComponent.new(provider, work_package: @work_package)) }
end
%>
@@ -0,0 +1,43 @@
# 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 Wikis
class ProviderLinkGroupComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
alias_method :provider, :model
def initialize(model = nil, work_package: nil, **)
@work_package = work_package
super(model, **)
end
end
end
@@ -30,7 +30,13 @@ See COPYRIGHT and LICENSE files for more details.
<%=
content_tag("turbo-frame", id: "work-package-wikis-tab-content") do
component_wrapper do
render(Primer::Beta::Text.new) { "Hi 👋" }
flex_layout(test_selector: "op-work-package-wikis-tab-container") do |flex|
providers.each do |provider|
flex.with_row do
render(Wikis::ProviderLinkGroupComponent.new(provider, work_package:))
end
end
end
end
end
%>
@@ -33,5 +33,11 @@ module Wikis
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
alias_method :work_package, :model
def providers
Wikis::Provider.enabled
end
end
end
@@ -36,7 +36,7 @@ class WorkPackageWikisTabController < ApplicationController
before_action :set_work_package
def index
render(Wikis::WorkPackageWikisTabComponent.new, layout: false)
render(Wikis::WorkPackageWikisTabComponent.new(@work_package), layout: false)
end
private
@@ -0,0 +1,44 @@
# 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 Wikis
class PageLinkService
def count(linkable)
# Incomplete implementation until connection to Wikis API is done to fetch relation wiki page links
# from external providers.
# TODO: Replace with complete implementation
Wikis::PageLink.joins(:provider)
.merge(Wikis::Provider.enabled)
.where(linkable:)
.count
end
end
end
@@ -0,0 +1,44 @@
# 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 Wikis
class PageTitleService
def read(_page_link)
# Mock implementation until connection to Wikis API is done
# TODO: Replace with real implementation
[
"How to write wiki pages",
"Technical specifications",
"A brief introduction on how to write wiki page titles that are short enough to be memorable"
].sample
end
end
end
+4
View File
@@ -26,6 +26,10 @@ en:
wikis:
buttons:
save_and_continue: Save and continue
inline_page_links_component:
empty_heading: No inline links
empty_text: Inline links to wiki pages in the work package description will automatically also show up here.
heading: Inline page links
admin:
wiki_providers:
index_description: Add an external wiki service to link work packages to existing wiki pages or create new ones directly from OpenProject.
@@ -68,6 +68,7 @@ module OpenProject::Wikis
{ tab: :wikis },
skip_permissions_check: true,
after: :relations,
badge: ->(work_package:, **) { Wikis::PageLinkService.new.count(work_package) },
if: ->(_project) {
Wikis::Provider.enabled.exists? &&
OpenProject::FeatureDecisions.wiki_enhancements_active?