Skip to content

Commit

Permalink
Hit the single file_diff async route
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Mar 29, 2024
1 parent 436329a commit 3d9df23
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/api/app/components/diff_list_component.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,39 @@
aria: { expanded: 'true', controls: "diff-item-#{name.parameterize}" },
class: expanded ? '' : 'collapsed' }
= render(DiffSubjectComponent.new(state:, old_filename:, new_filename: name))
.accordion-collapse.collapse{ class: expanded ? 'show' : '', id: "diff-item-#{name.parameterize}", 'data-object': view_id }
= render(DiffComponent.new(diff: file_info.dig('diff', '_content'), file_index:, commentable:, commented_lines:,
source_file: source_file(old_filename), target_file: target_file(name)))
.accordion-collapse.collapse{ class: expanded ? 'show' : '',
id: "diff-item-#{name.parameterize}",
'data-object': view_id,
data: {
url: request_action_file_changes_path(@bs_request_number, @action_id, name),
diff_to_superseded_id: @diff_to_superseded_id,
file_index: file_index, commentable: commentable, commented_lines: commented_lines,
source_file: source_file(old_filename), target_file: target_file(name)
}
}
= render partial: 'webui/shared/loading', locals: { text: 'Loading file changes...' }

:javascript
var parent = $('#diff-item-#{name.parameterize}');
// Take the parameters from the container data
var url = parent.data('url');
var diffToSupersededId = parent.data('diff-to-superseded-id');
var fileIndex = parent.data('file-index');
var commentable = parent.data('commentable');
var commentedLines = parent.data('commented-lines');
var sourceFile = parent.data('source-file');
var targetFile = parent.data('target-file');
var queryString = 'file_index=' + fileIndex;
queryString += commentable ? '&commentable=' + commentable : '';
queryString += commentedLines ? '&commented_lines=' + commentedLines : '';
queryString += sourceFile ? '&source_file=' + sourceFile : '';
queryString += targetFile ? '&target_file=' + targetFile : '';
queryString += diffToSupersededId ? '&diff_to_superseded=' + diffToSupersededId : '';

$.ajax({
url: url + '?' + queryString,
success: function() {},
error: function() {
$('#diff-item-#{name.parameterize} .result').text('Something went wrong while loading file changes.');
}
});

0 comments on commit 3d9df23

Please sign in to comment.