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
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 %>
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,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
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
36 changes: 34 additions & 2 deletions modules/wikis/app/components/wikis/page_link_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
return unless user_allowed_to_delete?

href = url_helpers.confirm_delete_dialog_relation_wiki_page_link_path(@page_link)

menu.with_item(label: t(".remove"),
scheme: :danger,
tag: :a,
href:,
content_arguments: { data: { controller: "async-dialog" } }) do |item|
Comment thread
NobodysNightmare marked this conversation as resolved.
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
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -52,29 +52,30 @@ 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|
blankslate.with_heading(tag: :h2).with_content(t(".empty_heading"))
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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

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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading