Skip to content

Commit

Permalink
Merge pull request #13454 from eduardoj/fix_13443
Browse files Browse the repository at this point in the history
Bring back AJAX calls to request changes in beta
  • Loading branch information
danidoni committed Nov 30, 2022
2 parents 9f7eaa5 + a6c9bc1 commit 8a4213a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/api/app/assets/javascripts/webui/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,15 @@ function loadDiffs(element){
}
});
}

function loadChanges() { // jshint ignore:line
$('.loading-diff').removeClass('invisible');
var element = $('#changes-tab');
var url = '/request/' + element.data('request-number') + '/request_action/' + element.data('request-action-id') + '/changes';
$.ajax({
url: url,
success: function() {
$('.loading-diff').addClass('invisible');
}
});
}
30 changes: 27 additions & 3 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class Webui::RequestController < Webui::WebuiController
helper 'webui/package'

before_action :require_login, except: [:show, :sourcediff, :diff, :request_action]
before_action :require_login, except: [:show, :sourcediff, :diff, :request_action, :request_action_changes]
# requests do not really add much value for our page rank :)
before_action :lockout_spiders
before_action :require_request, only: [:changerequest, :show, :request_action]
before_action :set_superseded_request, only: [:show, :request_action]
before_action :require_request, only: [:changerequest, :show, :request_action, :request_action_changes]
before_action :set_superseded_request, only: [:show, :request_action, :request_action_changes]
before_action :check_ajax, only: :sourcediff

after_action :verify_authorized, only: [:create]
Expand Down Expand Up @@ -212,6 +212,30 @@ def request_action
end
end

def request_action_changes
# TODO: Change @diff_limit to a local variable
@diff_limit = params[:full_diff] ? 0 : nil
# TODO: Change @actions to a local variable
@actions = @bs_request.webui_actions(filelimit: @diff_limit, tarlimit: @diff_limit, diff_to_superseded: @diff_to_superseded, diffs: true,
action_id: params['id'].to_i, cacheonly: 1)
@action = @actions.find { |action| action[:id] == params['id'].to_i }
# TODO: Check if @not_full_diff is really needed
@not_full_diff = BsRequest.truncated_diffs?(@actions)
# TODO: Check if @diff_to_superseded_id is really needed
@diff_to_superseded_id = params[:diff_to_superseded]
@refresh = @action[:diff_not_cached]

if @refresh
bs_request_action = BsRequestAction.find(@action[:id])
job = Delayed::Job.where("handler LIKE '%job_class: BsRequestActionWebuiInfosJob%#{bs_request_action.to_global_id.uri}%'").count
BsRequestActionWebuiInfosJob.perform_later(bs_request_action) if job.zero?
end

respond_to do |format|
format.js
end
end

def sourcediff
render partial: 'webui/shared/editor', locals: { text: params[:text],
mode: 'diff', style: { read_only: true },
Expand Down
13 changes: 7 additions & 6 deletions src/api/app/views/webui/request/beta_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,23 @@
.border-bottom
%ul.nav.nav-tabs.scrollable-tabs.border-0#request-tabs{ role: 'tablist' }
%li.nav-item.scrollable-tab-link{ role: 'presentation' }
= link_to('Conversation', '#conversation', class: 'nav-link text-nowrap', 'aria-controls': 'conversation',
= link_to('Conversation', '#conversation', id: 'conversation-tab', class: 'nav-link text-nowrap', 'aria-controls': 'conversation',
'aria-selected': 'false', 'data-toggle': 'tab', role: 'tab')
- if @action[:sprj] || @action[:spkg]
%li.nav-item.scrollable-tab-link{ role: 'presentation' }
= link_to('Build Results', '#build-results', class: 'nav-link text-nowrap', 'aria-controls': 'build-results',
= link_to('Build Results', '#build-results', id: 'build-results-tab', class: 'nav-link text-nowrap', 'aria-controls': 'build-results',
'aria-selected': 'false', 'data-toggle': 'tab', role: 'tab')
%li.nav-item.scrollable-tab-link{ role: 'presentation' }
= link_to('RPM Lint', '#rpm-lint', class: 'nav-link text-nowrap', 'aria-controls': 'rpm-lint',
= link_to('RPM Lint', '#rpm-lint', id: 'rpm-lint-tab', class: 'nav-link text-nowrap', 'aria-controls': 'rpm-lint',
'aria-selected': 'false', 'data-toggle': 'tab', role: 'tab')
- if @action[:type].in?(actions_for_diff)
%li.nav-item.scrollable-tab-link{ role: 'presentation', 'data-request-number': @bs_request.number, 'data-request-action-id': @action[:id] }
= link_to('Changes', '#changes', class: 'nav-link text-nowrap', 'aria-controls': 'changes',
%li.nav-item.scrollable-tab-link{ role: 'presentation' }
= link_to('Changes', '#changes', id: 'changes-tab', class: 'nav-link text-nowrap', 'aria-controls': 'changes',
'data-request-number': @bs_request.number, 'data-request-action-id': @action[:id],
'aria-selected': 'false', 'data-toggle': 'tab', role: 'tab')
- if @action[:type].in?(actions_for_diff)
%li.nav-item.scrollable-tab-link{ role: 'presentation' }
= link_to('#mentioned-issues', class: 'nav-link text-nowrap', 'aria-controls': 'mentioned-issues',
= link_to('#mentioned-issues', id: 'mentioned-issues-tab', class: 'nav-link text-nowrap', 'aria-controls': 'mentioned-issues',
'aria-selected': 'false', 'data-toggle': 'tab', role: 'tab') do
Mentioned Issues
%span.badge.badge-primary.align-text-top= @issues.size
Expand Down
1 change: 1 addition & 0 deletions src/api/config/routes/webui_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
get 'request/list_small' => :list_small, as: 'request_list_small'
post 'request/set_bugowner_request' => :set_bugowner_request
get 'request/:number/request_action/:id' => :request_action, as: 'request_action'
get 'request/:number/request_action/:id/changes' => :request_action_changes, as: 'request_action_changes'
end

resources :requests, only: [], param: :number, controller: 'webui/bs_requests' do
Expand Down

0 comments on commit 8a4213a

Please sign in to comment.