Skip to content

Commit 8912dce

Browse files
authored
Merge pull request #22716 from opf/feature/72971-show-inline-wiki-page-links
[#72971] added wiki tab content
2 parents 3d2a614 + 49097bf commit 8912dce

13 files changed

Lines changed: 280 additions & 2 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<%=
2+
flex_layout do |container|
3+
container.with_row(mb: 2) { render(Primer::Beta::Text.new(font_weight: :bold)) { t(".heading") } }
4+
5+
if page_links.empty?
6+
container.with_row do
7+
render(Primer::Beta::Blankslate.new(border: false)) do |blankslate|
8+
blankslate.with_heading(tag: :h2).with_content(t(".empty_heading"))
9+
blankslate.with_description { t(".empty_text") }
10+
end
11+
end
12+
end
13+
14+
page_links.each do |page_link|
15+
container.with_row(mt: 3) { render(Wikis::PageLinkComponent.new(page_link)) }
16+
end
17+
end
18+
%>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module Wikis
32+
class InlinePageLinksComponent < ApplicationComponent
33+
include ApplicationHelper
34+
include OpPrimer::ComponentHelpers
35+
36+
alias_method :provider, :model
37+
38+
def initialize(model = nil, work_package: nil, **)
39+
@work_package = work_package
40+
super(model, **)
41+
end
42+
43+
def page_links
44+
@page_links ||= provider.page_links
45+
.merge(InlinePageLink.all)
46+
.where(linkable: @work_package)
47+
.order(created_at: :desc)
48+
end
49+
end
50+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%=
2+
flex_layout(test_selector: "op-custom-fields--hierarchy-item") do |link_container|
3+
link_container.with_column(flex_shrink: 0) do
4+
render(Primer::Beta::Octicon.new(icon: :"op-file-doc", mr: 2))
5+
end
6+
7+
link_container.with_column(classes: "ellipsis") do
8+
render(Primer::Beta::Link.new(href: "#", scheme: :primary)) { page_title_service.read(link) }
9+
end
10+
end
11+
%>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module Wikis
32+
class PageLinkComponent < ApplicationComponent
33+
include ApplicationHelper
34+
include OpPrimer::ComponentHelpers
35+
36+
alias_method :link, :model
37+
38+
def page_title_service
39+
@page_title_service ||= PageTitleService.new
40+
end
41+
end
42+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<%=
2+
render(Primer::Beta::BorderBox.new) do |box|
3+
box.with_header do
4+
render(Primer::Beta::Text.new(font_weight: :bold)) { provider.name }
5+
end
6+
7+
box.with_row { render(Wikis::InlinePageLinksComponent.new(provider, work_package: @work_package)) }
8+
end
9+
%>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module Wikis
32+
class ProviderLinkGroupComponent < ApplicationComponent
33+
include ApplicationHelper
34+
include OpPrimer::ComponentHelpers
35+
36+
alias_method :provider, :model
37+
38+
def initialize(model = nil, work_package: nil, **)
39+
@work_package = work_package
40+
super(model, **)
41+
end
42+
end
43+
end

modules/wikis/app/components/wikis/work_package_wikis_tab_component.html.erb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ See COPYRIGHT and LICENSE files for more details.
3030
<%=
3131
content_tag("turbo-frame", id: "work-package-wikis-tab-content") do
3232
component_wrapper do
33-
render(Primer::Beta::Text.new) { "Hi 👋" }
33+
flex_layout(test_selector: "op-work-package-wikis-tab-container") do |flex|
34+
providers.each do |provider|
35+
flex.with_row do
36+
render(Wikis::ProviderLinkGroupComponent.new(provider, work_package:))
37+
end
38+
end
39+
end
3440
end
3541
end
3642
%>

modules/wikis/app/components/wikis/work_package_wikis_tab_component.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@ class WorkPackageWikisTabComponent < ApplicationComponent
3333
include ApplicationHelper
3434
include OpPrimer::ComponentHelpers
3535
include OpTurbo::Streamable
36+
37+
alias_method :work_package, :model
38+
39+
def providers
40+
Wikis::Provider.enabled
41+
end
3642
end
3743
end

modules/wikis/app/controllers/work_package_wikis_tab_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class WorkPackageWikisTabController < ApplicationController
3636
before_action :set_work_package
3737

3838
def index
39-
render(Wikis::WorkPackageWikisTabComponent.new, layout: false)
39+
render(Wikis::WorkPackageWikisTabComponent.new(@work_package), layout: false)
4040
end
4141

4242
private
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module Wikis
32+
class PageLinkService
33+
def count(linkable)
34+
# Incomplete implementation until connection to Wikis API is done to fetch relation wiki page links
35+
# from external providers.
36+
# TODO: Replace with complete implementation
37+
38+
Wikis::PageLink.joins(:provider)
39+
.merge(Wikis::Provider.enabled)
40+
.where(linkable:)
41+
.count
42+
end
43+
end
44+
end

0 commit comments

Comments
 (0)