-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[#74710] show inline page link macros in editing mode #23142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c3d5001
e523833
73ccbc8
925b5a5
82e0436
37e64d6
2ea8949
1c76aaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ volumes: | |
| tmp: | ||
| opdata: | ||
| bundle: | ||
| npm: | ||
| pgdata-test: | ||
| tmp-test: | ||
| fedata-test: | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # 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 | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # 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 | ||
| include Dry::Monads[:result] | ||
|
|
||
| # The view component shown in `load` will be rendered regardless of the current user's authorization status. | ||
| # The component itself handles the states of "unauthorized", "forbidden", and "not_found". | ||
| authorization_checked! :load | ||
|
|
||
| def load | ||
| provider = Provider.visible.find_by(id: params[:provider_id]) | ||
| @page_info_result = page_info_result(provider) | ||
| @turbo_frame_id = turbo_frame_id | ||
|
|
||
| render layout: false | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def page_info_result(provider) | ||
| 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 | ||
| end | ||
|
|
||
| def identifier | ||
| params[:page_identifier] | ||
| end | ||
|
|
||
| def turbo_frame_id | ||
| params[:turbo_frame_id] | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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)) %> | ||
| </turbo-frame> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,11 @@ | |
| end | ||
| end | ||
| end | ||
|
|
||
| resource :wiki_page_link_macro, controller: "wikis/page_link" do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟢 Last thing that I noticed so late, that it feels weird to bring this up now: I saw that the controller was called Seeing that the route is already called
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The controller was renamed in the follow up PR - #23193 - to be better distinguished to the other page link related controllers.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this was a flaw I also detected when working on the next iteration, the PR #23193 has some changes here, changing the route definition to resource :wiki_page_link_macro, controller: "wikis/inline_page_link_macro", only: [] do
get :load
end |
||
| get :load | ||
| end | ||
|
|
||
| resources :projects, only: %i[] do | ||
| resources :work_packages, only: %i[] do | ||
| resources :wikis, only: %i[] do | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.