Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,12 @@ en:
index:
no_results_content_text: Add a new wiki page

wikis:
Comment thread
NobodysNightmare marked this conversation as resolved.
Outdated
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"

workflows:
form:
matrix_caption: "Workflow matrix"
Expand Down
Original file line number Diff line number Diff line change
@@ -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 |empty_placeholder|
Comment thread
NobodysNightmare marked this conversation as resolved.
Outdated
empty_placeholder.with_heading(tag: :h2).with_content(t(".empty_heading"))
empty_placeholder.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
%>
50 changes: 50 additions & 0 deletions modules/wikis/app/components/wikis/inline_page_links_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.
#++

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)
Comment thread
NobodysNightmare marked this conversation as resolved.
.order(created_at: :desc)
end
end
end
11 changes: 11 additions & 0 deletions modules/wikis/app/components/wikis/page_link_component.html.erb
Original file line number Diff line number Diff line change
@@ -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
%>
42 changes: 42 additions & 0 deletions modules/wikis/app/components/wikis/page_link_component.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
%>
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
NobodysNightmare marked this conversation as resolved.
render(Wikis::ProviderLinkGroupComponent.new(provider, work_package:))
end
end
end
end
end
%>
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ class WorkPackageWikisTabComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable

alias_method :work_package, :model

def providers
Wikis::Provider.enabled
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions modules/wikis/app/services/wikis/page_title_service.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions modules/wikis/lib/open_project/wikis/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class Engine < ::Rails::Engine
{ tab: :wikis },
skip_permissions_check: true,
after: :relations,
badge: ->(work_package:, **) {
Wikis::PageLink.joins(:provider)
.merge(Wikis::Provider.enabled)
.where(linkable: work_package)
Comment thread
NobodysNightmare marked this conversation as resolved.
Outdated
.count
},
if: ->(_project) {
Wikis::Provider.enabled.exists? &&
OpenProject::FeatureDecisions.wiki_enhancements_active?
Expand Down
Loading
Loading