summaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-11-21 16:51:08 +0000
committerGitHub <noreply@github.com>2021-11-22 00:51:08 +0800
commit8511eec4d447499e37c1c3fbe3b1f9353ce36190 (patch)
tree2320539c50d2813906d0635b9dbe4b2ba19aadd8 /web_src/js/features
parentd710af6669654f27f02b69d7ef1ba563e7d58a90 (diff)
downloadgitea-8511eec4d447499e37c1c3fbe3b1f9353ce36190.tar.gz
gitea-8511eec4d447499e37c1c3fbe3b1f9353ce36190.zip
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 <art27@cantab.net>
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/repo-diff.js29
1 files changed, 28 insertions, 1 deletions
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');
});
});
}