mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 19:11:58 +01:00
Restore function to "Show more" buttons (#22399)
There was a serious regression in #21012 which broke the Show More button on the diff page, and the show more button was also broken on the file tree too. This PR fixes this by resetting the pageData.diffFiles as the vue watched value and reattachs a function to the show more button outside of the file tree view. Fix #22380 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
99cf0d394e
commit
c0da3638e7
4 changed files with 30 additions and 3 deletions
|
@ -143,7 +143,7 @@
|
||||||
{{$.locale.Tr "repo.diff.file_suppressed_line_too_long"}}
|
{{$.locale.Tr "repo.diff.file_suppressed_line_too_long"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$.locale.Tr "repo.diff.file_suppressed"}}
|
{{$.locale.Tr "repo.diff.file_suppressed"}}
|
||||||
<a class="ui basic tiny button diff-show-more-button" data-href="{{$.Link}}?file-only=true&files={{$file.Name}}&files={{$file.OldName}}">{{$.locale.Tr "repo.diff.load"}}</a>
|
<a class="ui basic tiny button diff-load-button" data-href="{{$.Link}}?file-only=true&files={{$file.Name}}&files={{$file.OldName}}">{{$.locale.Tr "repo.diff.load"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$.locale.Tr "repo.diff.bin_not_shown"}}
|
{{$.locale.Tr "repo.diff.bin_not_shown"}}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item" />
|
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isIncomplete" id="diff-too-many-files-stats" class="pt-2">
|
<div v-if="isIncomplete" id="diff-too-many-files-stats" class="pt-2">
|
||||||
<span>{{ tooManyFilesMessage }}</span><a :class="['ui', 'basic', 'tiny', 'button', isLoadingNewData === true ? 'disabled' : '']" id="diff-show-more-files-stats" @click.stop="loadMoreData">{{ showMoreMessage }}</a>
|
<span class="mr-2">{{ tooManyFilesMessage }}</span><a :class="['ui', 'basic', 'tiny', 'button', isLoadingNewData === true ? 'disabled' : '']" id="diff-show-more-files-stats" @click.stop="loadMoreData">{{ showMoreMessage }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -94,6 +94,9 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
// ensure correct buttons when we are mounted to the dom
|
// ensure correct buttons when we are mounted to the dom
|
||||||
this.adjustToggleButton(this.fileTreeIsVisible);
|
this.adjustToggleButton(this.fileTreeIsVisible);
|
||||||
|
// replace the pageData.diffFileInfo.files with our watched data so we get updates
|
||||||
|
pageData.diffFileInfo.files = this.files;
|
||||||
|
|
||||||
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
|
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
|
|
|
@ -119,26 +119,47 @@ function onShowMoreFiles() {
|
||||||
|
|
||||||
export function doLoadMoreFiles(link, diffEnd, callback) {
|
export function doLoadMoreFiles(link, diffEnd, callback) {
|
||||||
const url = `${link}?skip-to=${diffEnd}&file-only=true`;
|
const url = `${link}?skip-to=${diffEnd}&file-only=true`;
|
||||||
|
loadMoreFiles(url, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadMoreFiles(url, callback) {
|
||||||
|
const $target = $('a#diff-show-more-files');
|
||||||
|
if ($target.hasClass('disabled')) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$target.addClass('disabled');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url,
|
url,
|
||||||
}).done((resp) => {
|
}).done((resp) => {
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
|
$target.removeClass('disabled');
|
||||||
callback(resp);
|
callback(resp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children());
|
||||||
// By simply rerunning the script we add the new data to our existing
|
// By simply rerunning the script we add the new data to our existing
|
||||||
// pagedata object. this triggers vue and the filetree and filelist will
|
// pagedata object. this triggers vue and the filetree and filelist will
|
||||||
// render the new elements.
|
// render the new elements.
|
||||||
$('body').append($(resp).find('script#diff-data-script'));
|
$('body').append($(resp).find('script#diff-data-script'));
|
||||||
|
onShowMoreFiles();
|
||||||
callback(resp);
|
callback(resp);
|
||||||
}).fail(() => {
|
}).fail(() => {
|
||||||
|
$target.removeClass('disabled');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initRepoDiffShowMore() {
|
export function initRepoDiffShowMore() {
|
||||||
$(document).on('click', 'a.diff-show-more-button', (e) => {
|
$(document).on('click', 'a#diff-show-more-files', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const $target = $(e.target);
|
||||||
|
loadMoreFiles($target.data('href'), () => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', 'a.diff-load-button', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const $target = $(e.target);
|
const $target = $(e.target);
|
||||||
|
|
||||||
|
|
|
@ -1667,6 +1667,9 @@
|
||||||
background-color: var(--color-teal);
|
background-color: var(--color-teal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.button {
|
||||||
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-box .header:not(.resolved-placeholder) {
|
.diff-box .header:not(.resolved-placeholder) {
|
||||||
|
|
Loading…
Reference in a new issue