Skip to content

Commit

Permalink
Fix javascript and remove render condition from report modal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
krauselukas committed Sep 27, 2023
1 parent ff30e4e commit bac53b8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/app/assets/javascripts/webui/report.js
Expand Up @@ -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'));
Expand Down
4 changes: 0 additions & 4 deletions src/api/app/components/report_component.rb
Expand Up @@ -7,9 +7,5 @@ def initialize(reportable:)

@reportable = reportable
end

def render?
policy(Report.new(reportable: @reportable)).create?
end
end
# rubocop:enable ViewComponent/MissingPreviewFile

0 comments on commit bac53b8

Please sign in to comment.