diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-04 18:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-04 18:09:26 +0300 |
commit | cad0cc33957b0ea82afb34836e42419bea5a99b9 (patch) | |
tree | 55f30a2cd2e8fde03e39c77b2fe4a4a3e2a1bb93 /app/assets/javascripts/pages | |
parent | 13f961dce9cbed0a684d694fb1cb9d85946e3be4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/pages')
-rw-r--r-- | app/assets/javascripts/pages/projects/commit/show/index.js | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/app/assets/javascripts/pages/projects/commit/show/index.js b/app/assets/javascripts/pages/projects/commit/show/index.js index bbd33ac2f07..eca3cf7ab13 100644 --- a/app/assets/javascripts/pages/projects/commit/show/index.js +++ b/app/assets/javascripts/pages/projects/commit/show/index.js @@ -27,8 +27,34 @@ initCommitBoxInfo(); initDeprecatedNotes(); +const loadDiffStats = () => { + const diffStatsElements = document.querySelectorAll('#js-diff-stats'); + + if (diffStatsElements.length) { + diffStatsElements.forEach((diffStatsEl) => { + const { addedLines, removedLines, oldSize, newSize, viewerName } = diffStatsEl.dataset; + + new Vue({ + el: diffStatsEl, + render(createElement) { + return createElement(DiffStats, { + props: { + diffFile: { + old_size: oldSize, + new_size: newSize, + viewer: { name: viewerName }, + }, + addedLines: Number(addedLines), + removedLines: Number(removedLines), + }, + }); + }, + }); + }); + } +}; + const filesContainer = $('.js-diffs-batch'); -const diffStatsElements = document.querySelectorAll('#js-diff-stats'); if (filesContainer.length) { const batchPath = filesContainer.data('diffFilesPath'); @@ -40,35 +66,14 @@ if (filesContainer.length) { syntaxHighlight(filesContainer); handleLocationHash(); new Diff(); + loadDiffStats(); }) .catch(() => { createFlash({ message: __('An error occurred while retrieving diff files') }); }); } else { new Diff(); -} - -if (diffStatsElements.length) { - diffStatsElements.forEach((diffStatsEl) => { - const { addedLines, removedLines, oldSize, newSize, viewerName } = diffStatsEl.dataset; - - new Vue({ - el: diffStatsEl, - render(createElement) { - return createElement(DiffStats, { - props: { - diffFile: { - old_size: oldSize, - new_size: newSize, - viewer: { name: viewerName }, - }, - addedLines: Number(addedLines), - removedLines: Number(removedLines), - }, - }); - }, - }); - }); + loadDiffStats(); } loadAwardsHandler(); |