Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%#-- 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.

++#%>

<%= content_tag("turbo-frame", id: frame_id, src: frame_src, data: { provider_id:, page_identifier: identifier, type: "wiki-page-link" }) do %>
<%= render(OpPrimer::InlineMacroComponent.new) do |component| %>
<% component.with_leading_visual_icon(icon: :"op-file-doc") %>

<%= render Primer::Beta::Spinner.new(size: :small, display: :flex, mr: 2) %>
<%= render(Primer::Beta::Text.new(color: :muted)) { t(".loading") } %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 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 DeferredInlinePageLinkMacroComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers

attr_reader :identifier, :provider_id

def initialize(identifier:, provider_id:, **)
super(nil, **)

@identifier = identifier
@provider_id = provider_id
end

def frame_id
@frame_id ||= SecureRandom.uuid
end

def frame_src
url_helpers.load_wiki_page_link_macro_path(
provider_id:,
page_identifier: identifier,
turbo_frame_id: frame_id
)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def process_match(match, _matched_string, _context)
end
end

attr_reader :provider_id, :identifier

def initialize(provider_id:, identifier:)
super()

Expand All @@ -60,23 +62,9 @@ def initialize(provider_id:, identifier:)
end

def process
provider = Provider.find_by(id: @provider_id)
view_context = ApplicationController.new.view_context
page_info_result = resolve_page(provider, @identifier)

InlinePageLinkMacroComponent.new(page_info_result).render_in(view_context)
end

private

def resolve_page(provider, identifier)
return Failure() if provider.nil?

Adapters::Input::PageInfo.build(identifier:).bind do |input_data|
provider.auth_strategy_for(User.current).bind do |auth_strategy|
provider.resolve("queries.page_info").call(input_data:, auth_strategy:)
end
end
DeferredInlinePageLinkMacroComponent.new(provider_id:, identifier:).render_in(view_context)
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions modules/wikis/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ en:
wiki_page: Wiki page
create_new_wiki_page_dialog:
title: Create new wiki page
deferred_inline_page_link_macro_component:
loading: Loading…
delete_relation_page_link_confirmation_dialog:
heading: Delete related wiki page link?
title: Delete related wiki page link
Expand Down
Loading