From 8511eec4d447499e37c1c3fbe3b1f9353ce36190 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 21 Nov 2021 16:51:08 +0000 Subject: Allow Loading of Diffs that are too large (#17739) * Allow Loading of Diffs that are too large This PR allows the loading of diffs that are suppressed because the file is too large. It does not handle diffs of files which have lines which are too long. Fix #17738 Signed-off-by: Andrew Thornton --- web_src/js/features/repo-diff.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'web_src') diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js index 9606e3baad..6741f277fb 100644 --- a/web_src/js/features/repo-diff.js +++ b/web_src/js/features/repo-diff.js @@ -94,13 +94,40 @@ export function initRepoDiffShowMore() { type: 'GET', url, }).done((resp) => { - if (!resp || resp.html === '' || resp.empty) { + if (!resp) { $('#diff-show-more-files, #diff-show-more-files-stats').removeClass('disabled'); return; } $('#diff-too-many-files-stats').remove(); $('#diff-files').append($(resp).find('#diff-files li')); $('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children()); + }).fail(() => { + $('#diff-show-more-files, #diff-show-more-files-stats').removeClass('disabled'); + }); + }); + $(document).on('click', 'a.diff-show-more-button', (e) => { + e.preventDefault(); + const $target = $(e.target); + + if ($target.hasClass('disabled')) { + return; + } + + $target.addClass('disabled'); + + const url = $target.data('href'); + $.ajax({ + type: 'GET', + url, + }).done((resp) => { + if (!resp) { + $target.removeClass('disabled'); + return; + } + + $target.parent().replaceWith($(resp).find('#diff-file-boxes .diff-file-body .file-body').children()); + }).fail(() => { + $target.removeClass('disabled'); }); }); } -- cgit v1.2.3