[#74710] show inline page link macros in editing mode

- https://community.openproject.org/work_packages/74710
- show page link as turbo frame
- add route for loading the macro
- update ckeditor build
This commit is contained in:
Eric Schubert
2026-05-08 16:33:21 +02:00
parent 3ff2481ab2
commit c3d50019cb
9 changed files with 198 additions and 20 deletions
-1
View File
@@ -8,7 +8,6 @@ volumes:
tmp:
opdata:
bundle:
npm:
pgdata-test:
tmp-test:
fedata-test:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,43 @@
<%#-- 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.
++#%>
<%=
render(OpPrimer::InlineMacroComponent.new) do |inline_macro|
inline_macro.with_leading_visual_icon(icon: :"op-file-doc")
page_info_result.either(
->(page_info) do
render(Primer::Beta::Link.new(href: page_info.href)) { page_info.title }
end,
->(_error) do
render(Primer::Beta::Text.new(color: :muted)) { I18n.t("wikis.macro.page_not_found") }
end
)
end
%>
@@ -0,0 +1,46 @@
# 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 InlinePageLinkMacroComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
alias_method :page_info_result, :model
attr_reader :provider
def initialize(model = nil, provider:, **)
@provider = provider
super(model, **)
end
end
end
@@ -0,0 +1,66 @@
# 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 PageLinkController < ApplicationController
before_action :find_provider
authorization_checked! :load
def load
@page_info_result = page_info_result
@turbo_frame_id = turbo_frame_id
render layout: false
end
private
def page_info_result
return Failure() if @provider.nil?
Adapters::Input::PageInfo.build(identifier:).bind do |input|
@provider.resolve("queries.page_info").call(input)
end
end
def find_provider
@provider = Provider.find(params[:provider_id])
end
def identifier
params[:page_identifier]
end
def turbo_frame_id
params[:turbo_frame_id]
end
end
end
@@ -60,16 +60,11 @@ module Wikis
end
def process
provider = Wikis::Provider.find_by(id: @provider_id)
provider = Provider.find_by(id: @provider_id)
view_context = ApplicationController.new.view_context
OpPrimer::InlineMacroComponent.new.render_in(view_context) do |component|
component.with_leading_visual_icon(icon: :"op-file-doc")
page_info_result = resolve_page(provider, @identifier)
resolve_page(provider, @identifier).either(
->(page_info) { render_page_info_macro(view_context, page_info) },
->(error) { render_error_macro(view_context, error) }
)
end
InlinePageLinkMacroComponent.new(page_info_result, provider:).render_in(view_context)
end
private
@@ -77,18 +72,10 @@ module Wikis
def resolve_page(provider, identifier)
return Failure() if provider.nil?
Wikis::Adapters::Input::PageInfo.build(identifier:).bind do |input|
Adapters::Input::PageInfo.build(identifier:).bind do |input|
provider.resolve("queries.page_info").call(input)
end
end
def render_page_info_macro(view_context, page_info)
Primer::Beta::Link.new(href: page_info.href).render_in(view_context) { page_info.title }
end
def render_error_macro(view_context, _error)
Primer::Beta::Text.new(color: :muted).render_in(view_context) { I18n.t("wikis.macro.page_not_found") }
end
end
end
end
@@ -0,0 +1,32 @@
<%#-- 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.
++#%>
<turbo-frame id="<%= @turbo_frame_id %>">
<%= render(::Wikis::InlinePageLinkMacroComponent.new(@page_info_result, provider: @provider)) %>
</turbo-frame>
+5
View File
@@ -43,6 +43,11 @@ Rails.application.routes.draw do
end
end
end
resource :wiki_page_link_macro, controller: "wikis/page_link" do
get :load
end
resources :projects, only: %i[] do
resources :work_packages, only: %i[] do
resources :wikis, only: %i[] do