Skip to content
Draft
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
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ volumes:
tmp:
opdata:
bundle:
npm:
pgdata-test:
tmp-test:
fedata-test:
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/app/core/path-helper/path-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,11 @@ export class PathHelperService {
public externalRedirectPath(url:string) {
return `${this.staticBase}/external_redirect?url=${encodeURIComponent(url)}`;
}

public wikiPageLinkMacro(providerId:string, pageIdentifier:string, turboFrameId:string) {
const providerIdQuery = `provider_id=${encodeURIComponent(providerId)}`;
const pageIdentifierQuery = `page_identifier=${encodeURIComponent(pageIdentifier)}`;
const frameIdQuery = `turbo_frame_id=${encodeURIComponent(turboFrameId)}`;
return `${this.staticBase}/wiki_page_link_macro/load?${providerIdQuery}&${pageIdentifierQuery}&${frameIdQuery}`;
}
}
2 changes: 1 addition & 1 deletion frontend/src/vendor/ckeditor/ckeditor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/vendor/ckeditor/ckeditor.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%#-- 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(Primer::OpenProject::DangerDialog.new(title: t(".title"), form_arguments:)) do |dialog|
dialog.with_confirmation_message do |message|
message.with_heading(tag: :h2) { t(".heading") }
end
end
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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 DeletePageLinkConfirmationDialogComponent < ApplicationComponent
include OpTurbo::Streamable

def initialize(page_link:)
super
@page_link = page_link
end

def form_arguments
{
action: page_link_url,
method: :delete
}
end

private

def page_link_url
url_helpers.project_work_package_relation_wiki_page_link_path(@page_link, work_package_id:, project_id:)
end

def work_package_id
@page_link.linkable_id
end

def project_id
@page_link.linkable.project_id
end
end
end
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
Expand Up @@ -40,12 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
if show_action_menu?
render(Primer::Alpha::ActionMenu.new) do |menu|
menu.with_show_button(icon: :"kebab-horizontal", "aria-label": t(:label_more), scheme: :invisible)

if actions.include?(:remove)
menu.with_item(label: t(".remove"), scheme: :danger) do |item|
item.with_leading_visual_icon(icon: :trash)
end
end
menu_items(menu)
end
end
%>
Expand Down
32 changes: 31 additions & 1 deletion modules/wikis/app/components/wikis/page_link_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,37 @@ def page_href
end

def show_action_menu?
actions.any?
page_info_result.success? && actions.any?
end

def menu_items(menu)
if actions.include?(:remove)
deletion_action_item(menu)
end
end

private

def page_link
page_info_result.value!.page_link
end

def work_package_id = page_link.linkable_id

def project_id = page_link.linkable.project_id

def deletion_action_item(menu)
href = url_helpers.confirm_delete_project_work_package_relation_wiki_page_link_path(page_link,
work_package_id:,
project_id:)

menu.with_item(label: t(".remove"),
scheme: :danger,
tag: :a,
href:,
content_arguments: { data: { controller: "async-dialog" } }) do |item|
item.with_leading_visual_icon(icon: :trash)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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 InlinePageLinkMacroController < ApplicationController
include Dry::Monads[:result]

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_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 find_provider
@provider = Provider.find_by(id: params[:provider_id])
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,54 @@
# 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 RelationPageLinkController < ApplicationController
include OpTurbo::ComponentStream

before_action :find_page_link
before_action :authorize, except: %i[confirm_delete]

no_authorization_required! :confirm_delete

def destroy
# TODO: implement delete service
end

def confirm_delete
respond_with_dialog(DeletePageLinkConfirmationDialogComponent.new(page_link: @page_link))
end

private

def find_page_link
@page_link = RelationPageLink.find(params[:id])
end
end
end
6 changes: 5 additions & 1 deletion modules/wikis/app/models/wikis/adapters/results/page_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@
#++

module Wikis::Adapters::Results
PageInfo = Data.define(:identifier, :provider, :title, :href)
PageInfo = Data.define(:identifier, :provider, :title, :href, :page_link) do
def initialize(identifier:, provider:, title:, href:, page_link: nil)
super
end
end
end
Loading
Loading