From bac53b8d52ba8e5b0a897dd9eb04e7eb06f92c45 Mon Sep 17 00:00:00 2001 From: Lukas Krause Date: Wed, 27 Sep 2023 20:21:29 +0200 Subject: [PATCH] Fix javascript and remove render condition from report modal We cannot authorize inside the render condition in this case. We render the modal on the package, project and request views, then set the attributes on the form inside the model via javascript. When for example we cannot report on the package itself but on the comment that is on the package view, the component is not rendered. We already have authorization on the controller code and the report links. There is no need to do this on the modal. --- src/api/app/assets/javascripts/webui/report.js | 2 +- src/api/app/components/report_component.rb | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/api/app/assets/javascripts/webui/report.js b/src/api/app/assets/javascripts/webui/report.js index a286ddb7173..c36602ec29c 100644 --- a/src/api/app/assets/javascripts/webui/report.js +++ b/src/api/app/assets/javascripts/webui/report.js @@ -28,7 +28,7 @@ function setValuesOnReportDialog(modalId) { if (typeof(link.data('reportable-type')) !== 'undefined') { modal.find('#report_reportable_type').val(link.data('reportable-type')); - modal.find('.report_type').text(link.data('reportable-type')); + modal.find('.reportable_type').text(link.data('reportable-type')); } modal.find('#link_id').val(link.attr('id')); diff --git a/src/api/app/components/report_component.rb b/src/api/app/components/report_component.rb index ef6bcf01533..dd772e58d43 100644 --- a/src/api/app/components/report_component.rb +++ b/src/api/app/components/report_component.rb @@ -7,9 +7,5 @@ def initialize(reportable:) @reportable = reportable end - - def render? - policy(Report.new(reportable: @reportable)).create? - end end # rubocop:enable ViewComponent/MissingPreviewFile