OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#48266] Replace Webhooks cells by ViewComponent
Dombi Attila5c413df12521
diff --git a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/response/show.erb b/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.html.erbsimilarity index 100%rename from modules/webhooks/app/cells/webhooks/outgoing/deliveries/response/show.erbrename to modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.html.erbdiff --git a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/response_cell.rb b/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.rbsimilarity index 69%rename from modules/webhooks/app/cells/webhooks/outgoing/deliveries/response_cell.rbrename to modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.rbindex 97546358696..ed12c33b4f4 100644--- a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/response_cell.rb+++ b/modules/webhooks/app/components/webhooks/outgoing/deliveries/response_component.rb@@ -1,9 +1,7 @@module ::Webhooksmodule Outgoingmodule Deliveries- class ResponseCell < RailsCell- view_paths << ::OpenProject::Webhooks::Engine.root.join("app/cells")-+ class ResponseComponent < RailsComponentproperty :idproperty :response_headersproperty :response_bodydiff --git a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rb b/modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rbsimilarity index 64%rename from modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rbrename to modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rbindex 3652e8c687b..d3d9074f7cf 100644--- a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rb+++ b/modules/webhooks/app/components/webhooks/outgoing/deliveries/row_component.rb@@ -1,9 +1,11 @@module ::Webhooksmodule Outgoingmodule Deliveries- class RowCell < ::RowCell+ class RowComponent < ::RowComponentinclude ::IconsHelper+ property :id, :description, :event_name, :response_code+def logmodelend@@ -13,7 +15,7 @@ module ::Webhooksenddef response_body- cell(ResponseCell, log).()+ render ResponseComponent.new(log)endendenddiff --git a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rb b/modules/webhooks/app/components/webhooks/outgoing/deliveries/table_component.rbsimilarity index 94%rename from modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rbrename to modules/webhooks/app/components/webhooks/outgoing/deliveries/table_component.rbindex 2aa53211487..26a01092973 100644--- a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rb+++ b/modules/webhooks/app/components/webhooks/outgoing/deliveries/table_component.rb@@ -1,7 +1,7 @@module ::Webhooksmodule Outgoingmodule Deliveries- class TableCell < ::TableCell+ class TableComponent < ::TableComponentcolumns :id, :event_name, :time, :response_code, :response_bodydef sortable?diff --git a/modules/webhooks/app/cells/webhooks/outgoing/webhooks/row_cell.rb b/modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rbsimilarity index 96%rename from modules/webhooks/app/cells/webhooks/outgoing/webhooks/row_cell.rbrename to modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rbindex 393ed763870..aef519745ce 100644--- a/modules/webhooks/app/cells/webhooks/outgoing/webhooks/row_cell.rb+++ b/modules/webhooks/app/components/webhooks/outgoing/webhooks/row_component.rb@@ -1,9 +1,11 @@module ::Webhooksmodule Outgoingmodule Webhooks- class RowCell < ::RowCell+ class RowComponent < ::RowComponentinclude ::IconsHelper+ property :description+def webhookmodelenddiff --git a/modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rb b/modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rbsimilarity index 96%rename from modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rbrename to modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rbindex fc99ada650b..79269a23081 100644--- a/modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rb+++ b/modules/webhooks/app/components/webhooks/outgoing/webhooks/table_component.rb@@ -1,7 +1,7 @@module ::Webhooksmodule Outgoingmodule Webhooks- class TableCell < ::TableCell+ class TableComponent < ::TableComponentcolumns :name, :enabled, :selected_projects, :events, :descriptiondef initial_sortdiff --git a/modules/webhooks/app/views/webhooks/outgoing/admin/index.html.erb b/modules/webhooks/app/views/webhooks/outgoing/admin/index.html.erbindex fbf8564f500..7d3c2e4763f 100644--- a/modules/webhooks/app/views/webhooks/outgoing/admin/index.html.erb+++ b/modules/webhooks/app/views/webhooks/outgoing/admin/index.html.erb@@ -18,5 +18,5 @@link: link_to(t(:'webhooks.outgoing.explanation.link'), admin_settings_aggregation_path, target: '_blank')).html_safe %></p>-<%= rails_cell ::Webhooks::Outgoing::Webhooks::TableCell, @webhooks %>+<%= render ::Webhooks::Outgoing::Webhooks::TableComponent.new(rows: @webhooks) %>diff --git a/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb b/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erbindex 035f63bdc8c..58b1e800278 100644--- a/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb+++ b/modules/webhooks/app/views/webhooks/outgoing/admin/show.html.erb@@ -69,5 +69,5 @@<div class="account--section"><h2><%= t 'webhooks.outgoing.deliveries.title' %></h2>- <%= rails_cell ::Webhooks::Outgoing::Deliveries::TableCell, @webhook.deliveries.newest %>+ <%= render ::Webhooks::Outgoing::Deliveries::TableComponent.new(rows: @webhook.deliveries.newest) %></div>\ No newline at end of filediff --git a/modules/webhooks/spec/cells/webhooks/outgoing/deliveries/table_cell_spec.rb b/modules/webhooks/spec/components/webhooks/outgoing/deliveries/table_component_spec.rbsimilarity index 76%rename from modules/webhooks/spec/cells/webhooks/outgoing/deliveries/table_cell_spec.rbrename to modules/webhooks/spec/components/webhooks/outgoing/deliveries/table_component_spec.rbindex f52f994c8c7..3d61377f275 100644--- a/modules/webhooks/spec/cells/webhooks/outgoing/deliveries/table_cell_spec.rb+++ b/modules/webhooks/spec/components/webhooks/outgoing/deliveries/table_component_spec.rb@@ -27,27 +27,21 @@#++require 'spec_helper'-describe Webhooks::Outgoing::Deliveries::TableCell do- include Cell::Testing-- # used internally by Cell::Testing when calling #cell helper- let(:controller) { instance_double(ApplicationController, request: :dummy_request) }-+describe Webhooks::Outgoing::Deliveries::TableComponent, type: :component doit 'escapes response body html' dodelivery = create(:webhook_log, response_body: 'Hello <b>world<b/>!')- html = cell(described_class, [delivery]).()+ render_inline described_class.new(rows: [delivery])- response_body_node = Capybara.string(html).find('pre.webhooks--response-body')- expect(response_body_node.text).to eq(delivery.response_body)+ expect(page).to have_css("pre.webhooks--response-body", text: delivery.response_body)endit 'escapes response headers html' doheader_name = "x_header_<b>evil</b>_name"header_value = "header <b>evil</b> value"delivery = create(:webhook_log, response_headers: { header_name => header_value })- html = cell(described_class, [delivery]).()+ render_inline described_class.new(rows: [delivery])- response_headers_node = Capybara.string(html).find('pre.webhooks--response-headers')+ response_headers_node = page.find('pre.webhooks--response-headers')aggregate_failures doexpect(response_headers_node).not_to have_selector('b', text: 'evil')expect(response_headers_node.text).to include(header_name)