Improve async/await usage, and sort init calls in `index.js` (#17386)
* clean up async/await, and sort init calls in `index.js * use `const _promise` to indicate that we do not need await an async functiontokarchuk/v1.17
parent
3a693bd18c
commit
bb71ceeeb2
@ -1,24 +0,0 @@ |
|||||||
export function initDiffShowMore() { |
|
||||||
$('#diff-files, #diff-file-boxes').on('click', '#diff-show-more-files, #diff-show-more-files-stats', (e) => { |
|
||||||
e.preventDefault(); |
|
||||||
|
|
||||||
if ($(e.target).hasClass('disabled')) { |
|
||||||
return; |
|
||||||
} |
|
||||||
$('#diff-show-more-files, #diff-show-more-files-stats').addClass('disabled'); |
|
||||||
|
|
||||||
const url = $('#diff-show-more-files, #diff-show-more-files-stats').data('href'); |
|
||||||
$.ajax({ |
|
||||||
type: 'GET', |
|
||||||
url, |
|
||||||
}).done((resp) => { |
|
||||||
if (!resp || resp.html === '' || resp.empty) { |
|
||||||
$('#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()); |
|
||||||
}); |
|
||||||
}); |
|
||||||
} |
|
@ -1,40 +0,0 @@ |
|||||||
const {csrfToken} = window.config; |
|
||||||
|
|
||||||
export async function initLastCommitLoader() { |
|
||||||
const entryMap = {}; |
|
||||||
|
|
||||||
const entries = $('table#repo-files-table tr.notready') |
|
||||||
.map((_, v) => { |
|
||||||
entryMap[$(v).attr('data-entryname')] = $(v); |
|
||||||
return $(v).attr('data-entryname'); |
|
||||||
}) |
|
||||||
.get(); |
|
||||||
|
|
||||||
if (entries.length === 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
const lastCommitLoaderURL = $('table#repo-files-table').data('lastCommitLoaderUrl'); |
|
||||||
|
|
||||||
if (entries.length > 200) { |
|
||||||
$.post(lastCommitLoaderURL, { |
|
||||||
_csrf: csrfToken, |
|
||||||
}, (data) => { |
|
||||||
$('table#repo-files-table').replaceWith(data); |
|
||||||
}); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
$.post(lastCommitLoaderURL, { |
|
||||||
_csrf: csrfToken, |
|
||||||
'f': entries, |
|
||||||
}, (data) => { |
|
||||||
$(data).find('tr').each((_, row) => { |
|
||||||
if (row.className === 'commit-list') { |
|
||||||
$('table#repo-files-table .commit-list').replaceWith(row); |
|
||||||
return; |
|
||||||
} |
|
||||||
entryMap[$(row).attr('data-entryname')].replaceWith(row); |
|
||||||
}); |
|
||||||
}); |
|
||||||
} |
|
@ -1,6 +1,47 @@ |
|||||||
|
const {csrfToken} = window.config; |
||||||
|
|
||||||
export function initRepoCommitButton() { |
export function initRepoCommitButton() { |
||||||
$('.commit-button').on('click', function (e) { |
$('.commit-button').on('click', function (e) { |
||||||
e.preventDefault(); |
e.preventDefault(); |
||||||
$(this).parent().find('.commit-body').toggle(); |
$(this).parent().find('.commit-body').toggle(); |
||||||
}); |
}); |
||||||
} |
} |
||||||
|
|
||||||
|
export function initRepoCommitLastCommitLoader() { |
||||||
|
const entryMap = {}; |
||||||
|
|
||||||
|
const entries = $('table#repo-files-table tr.notready') |
||||||
|
.map((_, v) => { |
||||||
|
entryMap[$(v).attr('data-entryname')] = $(v); |
||||||
|
return $(v).attr('data-entryname'); |
||||||
|
}) |
||||||
|
.get(); |
||||||
|
|
||||||
|
if (entries.length === 0) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const lastCommitLoaderURL = $('table#repo-files-table').data('lastCommitLoaderUrl'); |
||||||
|
|
||||||
|
if (entries.length > 200) { |
||||||
|
$.post(lastCommitLoaderURL, { |
||||||
|
_csrf: csrfToken, |
||||||
|
}, (data) => { |
||||||
|
$('table#repo-files-table').replaceWith(data); |
||||||
|
}); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
$.post(lastCommitLoaderURL, { |
||||||
|
_csrf: csrfToken, |
||||||
|
'f': entries, |
||||||
|
}, (data) => { |
||||||
|
$(data).find('tr').each((_, row) => { |
||||||
|
if (row.className === 'commit-list') { |
||||||
|
$('table#repo-files-table .commit-list').replaceWith(row); |
||||||
|
return; |
||||||
|
} |
||||||
|
entryMap[$(row).attr('data-entryname')].replaceWith(row); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
@ -1,4 +1,4 @@ |
|||||||
export default async function initGitGraph() { |
export default function initRepoGraphGit() { |
||||||
const graphContainer = document.getElementById('git-graph-container'); |
const graphContainer = document.getElementById('git-graph-container'); |
||||||
if (!graphContainer) return; |
if (!graphContainer) return; |
||||||
|
|
Loading…
Reference in new issue