Skip to content

Commit

Permalink
Set diff_to_superseded_id for multiple occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Mar 28, 2024
1 parent f576e51 commit b0ce25b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/api/app/components/sourcediff_component.html.haml
Expand Up @@ -2,7 +2,8 @@
.col
- if @action.diff_not_cached
.clearfix.mb-2.text-center
.btn.btn-outline-primary.cache-refresh{ title: 'Refresh results', onclick: "loadChanges(#{@bs_request.number}, #{@action.id}, #{@diff_to_superseded&.number});" }
.btn.btn-outline-primary.cache-refresh{ title: 'Refresh results',
onclick: "loadChanges(#{@bs_request.number}, #{@action.id}, #{@diff_to_superseded_id});" }
Crunching the latest data. Refresh again in a few seconds
%i.fas.fa-sync-alt{ id: "cache#0-reload" }
.text-center.p-4.loading.invisible
Expand Down
14 changes: 8 additions & 6 deletions src/api/app/controllers/webui/request_controller.rb
Expand Up @@ -16,6 +16,7 @@ class Webui::RequestController < Webui::WebuiController
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_influxdb_data_request_actions, only: %i[show build_results rpm_lint changes mentioned_issues],
if: -> { Flipper.enabled?(:request_show_redesign, User.session) }
before_action :set_diff_to_superseded_id, only: %i[show request_action request_action_changes build_results rpm_lint changes mentioned_issues]
before_action :set_superseded_request, only: %i[show request_action request_action_changes build_results rpm_lint changes mentioned_issues]
before_action :check_ajax, only: :sourcediff
before_action :prepare_request_data, only: %i[show build_results rpm_lint changes mentioned_issues],
Expand All @@ -34,7 +35,6 @@ def show
render :beta_show
else
@diff_limit = params[:full_diff] ? 0 : nil
@diff_to_superseded_id = params[:diff_to_superseded]
@is_author = @bs_request.creator == User.possibly_nobody.login

@is_target_maintainer = @bs_request.is_target_maintainer?(User.session)
Expand Down Expand Up @@ -354,13 +354,17 @@ def new_state
end
end

def set_diff_to_superseded_id
@diff_to_superseded_id = params[:diff_to_superseded]
end

def set_superseded_request
return unless params[:diff_to_superseded]
return unless @diff_to_superseded_id

@diff_to_superseded = @bs_request.superseding.find_by(number: params[:diff_to_superseded])
@diff_to_superseded = @bs_request.superseding.find_by(number: @diff_to_superseded_id)
return if @diff_to_superseded

flash[:error] = "Request #{params[:diff_to_superseded]} does not exist or is not superseded by request #{@bs_request.number}."
flash[:error] = "Request #{@diff_to_superseded_id} does not exist or is not superseded by request #{@bs_request.number}."
nil
end

Expand Down Expand Up @@ -517,8 +521,6 @@ def prepare_request_data
@is_target_maintainer = @bs_request.is_target_maintainer?(User.session)
@my_open_reviews = ReviewsFinder.new(@bs_request.reviews).open_reviews_for_user(User.session).reject(&:staging_project?)

@diff_to_superseded_id = params[:diff_to_superseded]

# Handling request actions
@action ||= @actions.first
action_index = @actions.index(@action)
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/views/webui/request/_changes_content.html.haml
@@ -1,6 +1,6 @@
- if diff_to_superseded
- if diff_to_superseded_id
You're reviewing changes from
= link_to("superseded request ##{diff_to_superseded.number}.", request_show_path(number: diff_to_superseded))
= link_to("superseded request ##{diff_to_superseded_id}.", request_show_path(number: diff_to_superseded_id))
This only represents a small part of changes which are included in this request.
= surround('(', ')') do
= link_to('See the full changes for request', request_changes_path(number: bs_request.number))
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/changes.html.haml
Expand Up @@ -21,7 +21,7 @@
%i.fas.fa-spinner.fa-spin.me-1
Loading changes...
:javascript
loadChanges('#{@bs_request.number}', '#{@action.id}', '#{@diff_to_superseded&.number}');
loadChanges('#{@bs_request.number}', '#{@action.id}', '#{@diff_to_superseded_id}');
= render DeleteConfirmationDialogComponent.new(modal_id: 'delete-comment-modal',
method: :delete,
options: { modal_title: 'Delete comment?', remote: true })
@@ -1 +1 @@
$('.tab-content.sourcediff').html("<%= escape_javascript(render(partial: 'webui/request/changes_content', locals: { bs_request: @bs_request, action: @action, diff_to_superseded: @diff_to_superseded })) %>");
$('.tab-content.sourcediff').html("<%= escape_javascript(render(partial: 'webui/request/changes_content', locals: { bs_request: @bs_request, action: @action, diff_to_superseded_id: @diff_to_superseded_id })) %>");

0 comments on commit b0ce25b

Please sign in to comment.