mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
[#73909] removed wiki tab global blank slate
- resolved post merge conflict errors - improve counting of page links in tab
This commit is contained in:
@@ -31,30 +31,21 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
content_tag("turbo-frame", id: "work-package-wikis-tab-content") do
|
||||
component_wrapper do
|
||||
flex_layout(test_selector: "op-work-package-wikis-tab-container") do |container|
|
||||
if providers.empty?
|
||||
providers.each do |provider|
|
||||
container.with_row(mb: 3) do
|
||||
render(::Wikis::RelationPageLinksComponent.new(provider, work_package:))
|
||||
end
|
||||
end
|
||||
|
||||
if inline_page_links.any?
|
||||
container.with_row(mb: 3) do
|
||||
render(::Wikis::CollapsiblePageLinksComponent.new(inline_page_links, heading: t(".inline_page_links")))
|
||||
end
|
||||
end
|
||||
|
||||
if referencing_wiki_pages.any?
|
||||
container.with_row do
|
||||
render(Primer::Beta::Blankslate.new(border: false)) do |blankslate|
|
||||
blankslate.with_heading(tag: :h2).with_content(t(".blankslate.heading"))
|
||||
blankslate.with_description { t(".blankslate.description") }
|
||||
end
|
||||
end
|
||||
else
|
||||
providers.each do |provider|
|
||||
container.with_row(mb: 3) do
|
||||
render(::Wikis::RelationPageLinksComponent.new(provider, work_package:))
|
||||
end
|
||||
end
|
||||
|
||||
if inline_page_links.any?
|
||||
container.with_row(mb: 3) do
|
||||
render(::Wikis::CollapsiblePageLinksComponent.new(inline_page_links, heading: t(".inline_page_links")))
|
||||
end
|
||||
end
|
||||
|
||||
if referencing_wiki_pages.any?
|
||||
container.with_row do
|
||||
render(::Wikis::CollapsiblePageLinksComponent.new(referencing_wiki_pages, heading: t(".referencing_pages")))
|
||||
end
|
||||
render(::Wikis::CollapsiblePageLinksComponent.new(referencing_wiki_pages, heading: t(".referencing_pages")))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,15 +34,15 @@ module Wikis
|
||||
module Internal
|
||||
module Queries
|
||||
class PageInfo < BaseQuery
|
||||
def handle_query(identifier:)
|
||||
def call(input_data)
|
||||
# TODO: should we accept implicit User.current or do we want to pass in a user explicitly?
|
||||
wiki_page = WikiPage.visible.find_by(id: identifier)
|
||||
wiki_page = WikiPage.visible.find_by(id: input_data.identifier)
|
||||
return failure(code: :not_found) if wiki_page.nil?
|
||||
|
||||
success(
|
||||
Results::PageInfo.new(
|
||||
identifier:,
|
||||
provider: InternalProvider.first,
|
||||
identifier: input_data.identifier,
|
||||
provider:,
|
||||
title: wiki_page.title,
|
||||
href: url_for(only_path: true,
|
||||
controller: "/wiki",
|
||||
|
||||
@@ -34,7 +34,7 @@ module Wikis
|
||||
module XWiki
|
||||
module Queries
|
||||
class PageInfo < BaseQuery
|
||||
def handle_query(identifier:)
|
||||
def call(input_data)
|
||||
title = [
|
||||
"What makes XWiki special?",
|
||||
"API documentation",
|
||||
@@ -43,8 +43,8 @@ module Wikis
|
||||
|
||||
success(
|
||||
Results::PageInfo.new(
|
||||
identifier:,
|
||||
provider: XWikiProvider.first,
|
||||
identifier: input_data.identifier,
|
||||
provider:,
|
||||
title:,
|
||||
href: "#"
|
||||
)
|
||||
|
||||
@@ -41,6 +41,12 @@ module Wikis
|
||||
.merge(Provider.enabled)
|
||||
.where(linkable:)
|
||||
.count
|
||||
|
||||
relation_page_links = Provider.enabled.sum { |provider| relation_page_link_infos_for(provider:, linkable:).size }
|
||||
|
||||
relation_page_links +
|
||||
inline_page_link_infos_for(linkable:).size +
|
||||
referencing_wiki_page_infos_for(linkable:).size
|
||||
end
|
||||
|
||||
def relation_page_link_infos_for(provider:, linkable:)
|
||||
@@ -66,7 +72,7 @@ module Wikis
|
||||
if linkable.id % 2 == 0
|
||||
InternalProvider.enabled.each do |provider|
|
||||
random_wiki_page = WikiPage.order("RANDOM()").limit(1).first
|
||||
referenced_in << page_info(provider: , identifier: random_wiki_page.id.to_s)
|
||||
referenced_in << page_info(provider:, identifier: random_wiki_page.id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,11 +33,6 @@ en:
|
||||
work_package_wikis_tab_component:
|
||||
inline_page_links: Inline page links
|
||||
referencing_pages: Referenced in
|
||||
blankslate:
|
||||
heading: No wiki providers enabled
|
||||
description: >-
|
||||
There are no wiki providers configured and enabled. Wiki page links can only be added for enabled providers.
|
||||
To add wiki providers, visit Administration > Wikis.
|
||||
page_link_component:
|
||||
remove: Remove page link
|
||||
relation_page_links_component:
|
||||
|
||||
Reference in New Issue
Block a user