You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo-commit.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const {csrfToken} = window.config;
  2. export function initRepoCommitButton() {
  3. $('.commit-button').on('click', function (e) {
  4. e.preventDefault();
  5. $(this).parent().find('.commit-body').toggle();
  6. });
  7. }
  8. export function initRepoCommitLastCommitLoader() {
  9. const entryMap = {};
  10. const entries = $('table#repo-files-table tr.notready')
  11. .map((_, v) => {
  12. entryMap[$(v).attr('data-entryname')] = $(v);
  13. return $(v).attr('data-entryname');
  14. })
  15. .get();
  16. if (entries.length === 0) {
  17. return;
  18. }
  19. const lastCommitLoaderURL = $('table#repo-files-table').data('lastCommitLoaderUrl');
  20. if (entries.length > 200) {
  21. $.post(lastCommitLoaderURL, {
  22. _csrf: csrfToken,
  23. }, (data) => {
  24. $('table#repo-files-table').replaceWith(data);
  25. });
  26. return;
  27. }
  28. $.post(lastCommitLoaderURL, {
  29. _csrf: csrfToken,
  30. 'f': entries,
  31. }, (data) => {
  32. $(data).find('tr').each((_, row) => {
  33. if (row.className === 'commit-list') {
  34. $('table#repo-files-table .commit-list').replaceWith(row);
  35. return;
  36. }
  37. entryMap[$(row).attr('data-entryname')].replaceWith(row);
  38. });
  39. });
  40. }