diff --git a/modules/storages/app/views/storages/admin/health_status/show.html.erb b/modules/storages/app/views/storages/admin/health_status/show.html.erb index 1a464587fb7a..dec4201829e8 100644 --- a/modules/storages/app/views/storages/admin/health_status/show.html.erb +++ b/modules/storages/app/views/storages/admin/health_status/show.html.erb @@ -65,7 +65,7 @@ See COPYRIGHT and LICENSE files for more details. label: download_label, tag: :a, href: admin_settings_storage_health_status_report_path(@storage, format: :txt), - data: { turbo: true }, + data: { turbo: true } ) do download_label end @@ -76,7 +76,7 @@ See COPYRIGHT and LICENSE files for more details. label: button_label, tag: :a, href: admin_settings_storage_health_status_report_path(@storage), - data: { turbo_method: :post, turbo: true }, + data: { turbo_method: :post, turbo: true } ) do button_label end @@ -87,26 +87,27 @@ See COPYRIGHT and LICENSE files for more details. <%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |page| page.with_sidebar(col_placement: :end, row_placement: :end) - page.with_main do %> + page.with_main do + %> - <% if @report.present? %> - <%= render(HealthReports::ReportComponent.new(@report, i18n_scope: "storages.health.checks")) %> - <% else %> - <%= - render(Primer::Beta::Blankslate.new(border: true)) do |placeholder| - placeholder.with_visual_icon(icon: :meter) - placeholder.with_heading(tag: :h3) { I18n.t("storages.health.no_report") } - placeholder.with_description { I18n.t("storages.health.no_report_description") } - placeholder.with_primary_action( - href: admin_settings_storage_health_status_report_path(@storage), - data: { turbo_method: :post, turbo: true }, - aria: { label: I18n.t("storages.health.actions.run_checks") } - ) do - I18n.t("storages.health.actions.run_checks") - end + <% if @report.present? %> + <%= render(HealthReports::ReportComponent.new(@report, i18n_scope: "storages.health.checks")) %> + <% else %> + <%= + render(Primer::Beta::Blankslate.new(border: true)) do |placeholder| + placeholder.with_visual_icon(icon: :meter) + placeholder.with_heading(tag: :h3) { I18n.t("storages.health.no_report") } + placeholder.with_description { I18n.t("storages.health.no_report_description") } + placeholder.with_primary_action( + href: admin_settings_storage_health_status_report_path(@storage), + data: { turbo_method: :post, turbo: true }, + aria: { label: I18n.t("storages.health.actions.run_checks") } + ) do + I18n.t("storages.health.actions.run_checks") end - %> - <% end %> + end + %> <% end %> + <% end %> <% end %> <% end %> diff --git a/modules/wikis/app/components/wikis/delete_relation_page_link_confirmation_dialog.html.erb b/modules/wikis/app/components/wikis/delete_relation_page_link_confirmation_dialog.html.erb new file mode 100644 index 000000000000..53efb1fdde4d --- /dev/null +++ b/modules/wikis/app/components/wikis/delete_relation_page_link_confirmation_dialog.html.erb @@ -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 +%> diff --git a/modules/wikis/app/components/wikis/delete_relation_page_link_confirmation_dialog.rb b/modules/wikis/app/components/wikis/delete_relation_page_link_confirmation_dialog.rb new file mode 100644 index 000000000000..2f492c197ab7 --- /dev/null +++ b/modules/wikis/app/components/wikis/delete_relation_page_link_confirmation_dialog.rb @@ -0,0 +1,53 @@ +# 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 DeleteRelationPageLinkConfirmationDialog < 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.relation_wiki_page_link_path(@page_link) + end + end +end diff --git a/modules/wikis/app/components/wikis/page_link_component.html.erb b/modules/wikis/app/components/wikis/page_link_component.html.erb index df6d99bec5f2..9a77c4af97b0 100644 --- a/modules/wikis/app/components/wikis/page_link_component.html.erb +++ b/modules/wikis/app/components/wikis/page_link_component.html.erb @@ -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 %> diff --git a/modules/wikis/app/components/wikis/page_link_component.rb b/modules/wikis/app/components/wikis/page_link_component.rb index 521db5bf1ee4..17f5570ced68 100644 --- a/modules/wikis/app/components/wikis/page_link_component.rb +++ b/modules/wikis/app/components/wikis/page_link_component.rb @@ -37,8 +37,9 @@ class PageLinkComponent < ApplicationComponent attr_reader :actions - def initialize(model = nil, actions: [], **) + def initialize(model = nil, actions: [], page_link: nil, **) @actions = actions + @page_link = page_link super(model, **) end @@ -54,7 +55,38 @@ 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 project + @page_link&.linkable&.project + end + + def deletion_action_item(menu) + return if @page_link.nil? + + href = url_helpers.confirm_delete_dialog_relation_wiki_page_link_path(@page_link) + + menu.with_item(label: t(".remove"), + scheme: :danger, + tag: :a, + href:, + disabled: !user_allowed_to_delete?, + content_arguments: { data: { controller: "async-dialog" } }) do |item| + item.with_leading_visual_icon(icon: :trash) + end + end + + def user_allowed_to_delete? + helpers.current_user.allowed_in_project?(:manage_wiki_page_links, project) end end end diff --git a/modules/wikis/app/components/wikis/relation_page_links_component.html.erb b/modules/wikis/app/components/wikis/relation_page_links_component.html.erb index 183fbb6b45ce..60fb4d2480be 100644 --- a/modules/wikis/app/components/wikis/relation_page_links_component.html.erb +++ b/modules/wikis/app/components/wikis/relation_page_links_component.html.erb @@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details. flex_layout(align_items: :center, justify_content: :space_between) do |header| header.with_column do concat(render(Primer::Beta::Text.new(font_weight: :bold, mr: 2)) { provider.name }) - concat(render(Primer::Beta::Counter.new(count: page_link_infos.count, round: true, scheme: :primary))) + concat(render(Primer::Beta::Counter.new(count: page_links.count, round: true, scheme: :primary))) end header.with_column do render(Primer::Alpha::ActionMenu.new) do |menu| @@ -52,12 +52,9 @@ See COPYRIGHT and LICENSE files for more details. if !user_connected? box.with_row do - render(Wikis::OAuthLoginComponent.new( - provider, - return_url: work_package_url(@work_package, tab: :wikis) - )) + render(Wikis::OAuthLoginComponent.new(provider, return_url: work_package_url(@work_package, tab: :wikis))) end - elsif page_link_infos.empty? + elsif page_links.empty? box.with_row do if user_connected? render(Primer::Beta::Blankslate.new(border: false)) do |blankslate| @@ -65,16 +62,20 @@ See COPYRIGHT and LICENSE files for more details. blankslate.with_description { t(".empty_text") } end else - render(Wikis::OAuthLoginComponent.new( - provider, - return_url: work_package_url(@work_package, tab: :wikis) - ) - ) + render(Wikis::OAuthLoginComponent.new(provider, return_url: work_package_url(@work_package, tab: :wikis))) end end else - page_link_infos.each do |info| - box.with_row { render(Wikis::PageLinkComponent.new(info, actions: [:remove])) } + page_links.each do |page_link_aggregate| + box.with_row do + render( + Wikis::PageLinkComponent.new( + page_link_aggregate.page_info_result, + actions: [:remove], + page_link: page_link_aggregate.page_link + ) + ) + end end end end diff --git a/modules/wikis/app/components/wikis/relation_page_links_component.rb b/modules/wikis/app/components/wikis/relation_page_links_component.rb index 7baa2f950f4b..02686e724140 100644 --- a/modules/wikis/app/components/wikis/relation_page_links_component.rb +++ b/modules/wikis/app/components/wikis/relation_page_links_component.rb @@ -40,8 +40,8 @@ def initialize(model = nil, work_package: nil, **) super(model, **) end - def page_link_infos - @page_link_infos ||= page_link_service.relation_page_link_infos_for(provider:, linkable: @work_package) + def page_links + @page_links ||= page_link_service.relation_page_links_for(provider:, linkable: @work_package) end def user_connected? diff --git a/modules/wikis/app/controllers/wikis/page_link_controller.rb b/modules/wikis/app/controllers/wikis/page_link_macro_controller.rb similarity index 97% rename from modules/wikis/app/controllers/wikis/page_link_controller.rb rename to modules/wikis/app/controllers/wikis/page_link_macro_controller.rb index 4291bb00196b..35101548749e 100644 --- a/modules/wikis/app/controllers/wikis/page_link_controller.rb +++ b/modules/wikis/app/controllers/wikis/page_link_macro_controller.rb @@ -29,7 +29,7 @@ #++ module Wikis - class PageLinkController < ApplicationController + class PageLinkMacroController < ApplicationController include Dry::Monads[:result] # The view component shown in `load` will be rendered regardless of the current user's authorization status. diff --git a/modules/wikis/app/controllers/wikis/relation_page_links_controller.rb b/modules/wikis/app/controllers/wikis/relation_page_links_controller.rb new file mode 100644 index 000000000000..a3c2c9207bc8 --- /dev/null +++ b/modules/wikis/app/controllers/wikis/relation_page_links_controller.rb @@ -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 RelationPageLinksController < ApplicationController + include OpTurbo::ComponentStream + + before_action :find_page_link + before_action :authorize, except: %i[confirm_delete_dialog] + + no_authorization_required! :confirm_delete_dialog + + def destroy + # TODO: implement delete service + end + + def confirm_delete_dialog + respond_with_dialog(DeleteRelationPageLinkConfirmationDialog.new(page_link: @page_link)) + end + + private + + def find_page_link + @page_link = RelationPageLink.find(params.expect(:id)) + end + end +end diff --git a/modules/wikis/app/models/wikis/adapters/results/page_link_aggregate.rb b/modules/wikis/app/models/wikis/adapters/results/page_link_aggregate.rb new file mode 100644 index 000000000000..7cb17c2cf454 --- /dev/null +++ b/modules/wikis/app/models/wikis/adapters/results/page_link_aggregate.rb @@ -0,0 +1,33 @@ +# 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::Adapters::Results + PageLinkAggregate = Data.define(:page_info_result, :page_link) +end diff --git a/modules/wikis/app/services/wikis/adapters/providers/internal/queries/relation_page_links.rb b/modules/wikis/app/services/wikis/adapters/providers/internal/queries/relation_page_links.rb index c7deeaaf9b39..bce9ae211596 100644 --- a/modules/wikis/app/services/wikis/adapters/providers/internal/queries/relation_page_links.rb +++ b/modules/wikis/app/services/wikis/adapters/providers/internal/queries/relation_page_links.rb @@ -35,12 +35,15 @@ module Internal module Queries class RelationPageLinks < BaseQuery def call(input_data:, auth_strategy:) - page_link_infos = provider.page_links - .merge(RelationPageLink.all) - .where(linkable: input_data.linkable) - .map { |page_link| page_info(identifier: page_link.identifier, auth_strategy:) } + page_links = provider.page_links + .merge(RelationPageLink.all) + .where(linkable: input_data.linkable) + .map do |page_link| + page_info_result = page_info(identifier: page_link.identifier, auth_strategy:) + Results::PageLinkAggregate.new(page_info_result:, page_link:) + end - success(page_link_infos) + success(page_links) end end end diff --git a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/relation_page_links.rb b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/relation_page_links.rb index ba56bc9cf986..519bd537c886 100644 --- a/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/relation_page_links.rb +++ b/modules/wikis/app/services/wikis/adapters/providers/xwiki/queries/relation_page_links.rb @@ -34,24 +34,16 @@ module Providers module XWiki module Queries class RelationPageLinks < BaseQuery - def call(input_data:, **) # rubocop:disable Metrics/AbcSize - # TODO: use real API endpoints once available - - title = [ - "What makes XWiki special?", - "API documentation", - "A brief introduction on configuring your own XWiki instance and connect it to OpenProject." - ] - - results = [] - - if input_data.linkable.id % 2 == 1 - results << Success(Results::PageInfo.new(identifier: "1337", provider:, title: title.sample, href: "#")) - results << Success(Results::PageInfo.new(identifier: "1338", provider:, title: title.sample, href: "#")) - results << Success(Results::PageInfo.new(identifier: "1338", provider:, title: title.sample, href: "#")) + def call(input_data:, auth_strategy:) + page_links = provider.page_links + .merge(RelationPageLink.all) + .where(linkable: input_data.linkable) + .map do |page_link| + page_info_result = page_info(identifier: page_link.identifier, auth_strategy:) + Results::PageLinkAggregate.new(page_info_result:, page_link:) end - success(results) + success(page_links) end end end diff --git a/modules/wikis/app/services/wikis/page_link_service.rb b/modules/wikis/app/services/wikis/page_link_service.rb index d4616369fc79..e029f3b34d7c 100644 --- a/modules/wikis/app/services/wikis/page_link_service.rb +++ b/modules/wikis/app/services/wikis/page_link_service.rb @@ -33,20 +33,20 @@ class PageLinkService include Dry::Monads[:result] def count(linkable) - relation_page_links = Provider.enabled.sum { |provider| relation_page_link_infos_for(provider:, linkable:).size } + relation_page_links = Provider.enabled.sum { |provider| relation_page_links_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:) - Adapters::Input::RelationPageLinks.build(linkable:).bind do |input| + def relation_page_links_for(provider:, linkable:) + Adapters::Input::RelationPageLinks.build(linkable:).bind do |input_data| provider.auth_strategy_for(User.current).bind do |auth_strategy| provider.resolve("queries.relation_page_links") - .call(input_data: input, auth_strategy:) + .call(input_data:, auth_strategy:) .either( - ->(page_link_infos) { page_link_infos }, + ->(page_links) { page_links }, -> { [] } ) end diff --git a/modules/wikis/app/views/wikis/admin/health_status/show.html.erb b/modules/wikis/app/views/wikis/admin/health_status/show.html.erb index c1b726533a51..0d09452f2286 100644 --- a/modules/wikis/app/views/wikis/admin/health_status/show.html.erb +++ b/modules/wikis/app/views/wikis/admin/health_status/show.html.erb @@ -65,7 +65,7 @@ See COPYRIGHT and LICENSE files for more details. label: download_label, tag: :a, href: admin_settings_wiki_provider_health_status_report_path(@provider, format: :txt), - data: { turbo: true }, + data: { turbo: true } ) do download_label end @@ -76,7 +76,7 @@ See COPYRIGHT and LICENSE files for more details. label: rerun_label, tag: :a, href: admin_settings_wiki_provider_health_status_report_path(@provider), - data: { turbo_method: :post, turbo: true }, + data: { turbo_method: :post, turbo: true } ) do rerun_label end @@ -87,27 +87,27 @@ See COPYRIGHT and LICENSE files for more details. <%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |page| page.with_sidebar(col_placement: :end, row_placement: :end) - page.with_main do %> + page.with_main do + %> - <% if @report.present? %> - <%= render(HealthReports::ReportComponent.new(@report, i18n_scope: "wikis.health_checks")) %> - <% else %> - <%= - render(Primer::Beta::Blankslate.new(border: true)) do |placeholder| - placeholder.with_visual_icon(icon: :meter) - placeholder.with_heading(tag: :h3) { t(".no_health_report") } - placeholder.with_description { t(".no_health_report_description") } - placeholder.with_primary_action( - href: admin_settings_wiki_provider_health_status_report_path(@provider), - data: { turbo_method: :post, turbo: true }, - aria: { label: t(".actions.run_checks") } - ) do - t(".actions.run_checks") - end + <% if @report.present? %> + <%= render(HealthReports::ReportComponent.new(@report, i18n_scope: "wikis.health_checks")) %> + <% else %> + <%= + render(Primer::Beta::Blankslate.new(border: true)) do |placeholder| + placeholder.with_visual_icon(icon: :meter) + placeholder.with_heading(tag: :h3) { t(".no_health_report") } + placeholder.with_description { t(".no_health_report_description") } + placeholder.with_primary_action( + href: admin_settings_wiki_provider_health_status_report_path(@provider), + data: { turbo_method: :post, turbo: true }, + aria: { label: t(".actions.run_checks") } + ) do + t(".actions.run_checks") end - %> - <% end %> + end + %> <% end %> + <% end %> <% end %> <% end %> - diff --git a/modules/wikis/app/views/wikis/admin/wiki_providers/edit.html.erb b/modules/wikis/app/views/wikis/admin/wiki_providers/edit.html.erb index 7b0dfc73ae08..8c9a161588be 100644 --- a/modules/wikis/app/views/wikis/admin/wiki_providers/edit.html.erb +++ b/modules/wikis/app/views/wikis/admin/wiki_providers/edit.html.erb @@ -34,45 +34,53 @@ See COPYRIGHT and LICENSE files for more details. <%= render(Primer::OpenProject::PageHeader.new) do |header| %> <% header.with_title { page_title } %> - <% header.with_breadcrumbs([ - { href: admin_index_path, text: t(:label_administration) }, - { href: admin_settings_wiki_providers_path, text: t(:project_module_wiki_platforms) }, - page_title - ]) %> + <% + header.with_breadcrumbs( + [ + { href: admin_index_path, text: t(:label_administration) }, + { href: admin_settings_wiki_providers_path, text: t(:project_module_wiki_platforms) }, + page_title + ] + ) + %> <%# TODO: temp — move to a dedicated per-user connection status component once designed %> <% if current_user_xwiki_token_missing?(@wiki_provider) %> - <% header.with_action_button( + <% + header.with_action_button( + tag: :a, + scheme: :default, + mobile_icon: :plug, + mobile_label: t("wikis.buttons.connect_account", provider: @wiki_provider.name), + size: :medium, + href: oauth_clients_ensure_connection_url( + oauth_client_id: @wiki_provider.oauth_client.client_id, + integration_id: @wiki_provider.id, + destination_url: edit_admin_settings_wiki_provider_url(@wiki_provider) + ) + ) do |button| + button.with_trailing_visual_icon(icon: :"link-external") + t("wikis.buttons.connect_account", provider: @wiki_provider.name) + end + %> + <% end %> + + <% + header.with_action_button( tag: :a, - scheme: :default, - mobile_icon: :plug, - mobile_label: t("wikis.buttons.connect_account", provider: @wiki_provider.name), + scheme: :danger, + mobile_icon: :trash, + mobile_label: t(:button_delete), size: :medium, - href: oauth_clients_ensure_connection_url( - oauth_client_id: @wiki_provider.oauth_client.client_id, - integration_id: @wiki_provider.id, - destination_url: edit_admin_settings_wiki_provider_url(@wiki_provider) - ) + href: confirm_destroy_admin_settings_wiki_provider_path(@wiki_provider), + aria: { label: I18n.t(:button_delete) }, + title: I18n.t(:button_delete), + data: { "turbo-frame": "_top", controller: "async-dialog" } ) do |button| - button.with_trailing_visual_icon(icon: :"link-external") - t("wikis.buttons.connect_account", provider: @wiki_provider.name) - end %> - <% end %> - - <% header.with_action_button( - tag: :a, - scheme: :danger, - mobile_icon: :trash, - mobile_label: t(:button_delete), - size: :medium, - href: confirm_destroy_admin_settings_wiki_provider_path(@wiki_provider), - aria: { label: I18n.t(:button_delete) }, - title: I18n.t(:button_delete), - data: { "turbo-frame": "_top", controller: "async-dialog" } - ) do |button| - button.with_leading_visual_icon(icon: :trash) - t(:button_delete) - end %> + button.with_leading_visual_icon(icon: :trash) + t(:button_delete) + end + %> <% end %> <%= content_tag("turbo-frame", id: "wiki_provider_content") do %> diff --git a/modules/wikis/app/views/wikis/page_link/load.html.erb b/modules/wikis/app/views/wikis/inline_page_link_macro/load.html.erb similarity index 100% rename from modules/wikis/app/views/wikis/page_link/load.html.erb rename to modules/wikis/app/views/wikis/inline_page_link_macro/load.html.erb diff --git a/modules/wikis/config/locales/en.yml b/modules/wikis/config/locales/en.yml index 66b9bb872a4e..6584f37749b2 100644 --- a/modules/wikis/config/locales/en.yml +++ b/modules/wikis/config/locales/en.yml @@ -37,6 +37,9 @@ en: done_continue: Done, continue save_and_continue: Save and continue wiki_page: Wiki page + delete_relation_page_link_confirmation_dialog: + title: Delete related wiki page link + heading: Delete related wiki page link? health_checks: authentication: existing_token: User token diff --git a/modules/wikis/config/routes.rb b/modules/wikis/config/routes.rb index 0710d7d1a84f..4a8ac57407f4 100644 --- a/modules/wikis/config/routes.rb +++ b/modules/wikis/config/routes.rb @@ -49,10 +49,16 @@ end end - resource :wiki_page_link_macro, controller: "wikis/page_link" do + resource :wiki_page_link_macro, controller: "wikis/page_link_macro", only: [] do get :load end + resources :relation_wiki_page_links, only: %i[destroy], controller: "wikis/relation_page_links" do + member do + get :confirm_delete_dialog + end + end + resources :projects, only: %i[] do resources :work_packages, only: %i[] do resources :wikis, only: %i[] do diff --git a/modules/wikis/lib/open_project/wikis/engine.rb b/modules/wikis/lib/open_project/wikis/engine.rb index 858d51a38de8..ab1ebbab1e84 100644 --- a/modules/wikis/lib/open_project/wikis/engine.rb +++ b/modules/wikis/lib/open_project/wikis/engine.rb @@ -72,7 +72,7 @@ class Engine < ::Rails::Engine register "openproject-wikis", author_url: "https://openproject.org" do project_module :work_package_tracking do permission :manage_wiki_page_links, - {}, + { "wikis/relation_page_links": %i[destroy] }, permissible_on: :project, dependencies: %i[edit_work_packages], contract_actions: { wiki_page_links: %i[manage] } @@ -94,7 +94,7 @@ class Engine < ::Rails::Engine { controller: "/wikis/admin/wiki_providers", action: :index }, if: ->(_) { OpenProject::FeatureDecisions.wiki_enhancements_active? }, caption: :project_module_wiki_platforms, - icon: "book" + icon: :book end patch_with_namespace :WikiPages, :CreateService diff --git a/modules/wikis/spec/components/wikis/relation_page_links_component_spec.rb b/modules/wikis/spec/components/wikis/relation_page_links_component_spec.rb index 82afda088312..3fb0ce62e667 100644 --- a/modules/wikis/spec/components/wikis/relation_page_links_component_spec.rb +++ b/modules/wikis/spec/components/wikis/relation_page_links_component_spec.rb @@ -87,12 +87,14 @@ end context "when the user has a token and there are page links" do + let(:page_link) { create(:relation_wiki_page_link, linkable: work_package, provider:) } let(:page_info) do Wikis::Adapters::Results::PageInfo.new( identifier: "MyPage", provider:, title: "My Wiki Page", - href: "https://wiki.example.com/MyPage" + href: "https://wiki.example.com/MyPage", + page_link: ) end