diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/assets/javascripts/commons | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/commons')
-rw-r--r-- | app/assets/javascripts/commons/bootstrap.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/commons/nav/user_merge_requests.js | 32 |
2 files changed, 25 insertions, 15 deletions
diff --git a/app/assets/javascripts/commons/bootstrap.js b/app/assets/javascripts/commons/bootstrap.js index 2a1244149ff..f750c62103e 100644 --- a/app/assets/javascripts/commons/bootstrap.js +++ b/app/assets/javascripts/commons/bootstrap.js @@ -13,14 +13,10 @@ import 'bootstrap/js/dist/tab'; // custom jQuery functions $.fn.extend({ disable() { - return $(this) - .prop('disabled', true) - .addClass('disabled'); + return $(this).prop('disabled', true).addClass('disabled'); }, enable() { - return $(this) - .prop('disabled', false) - .removeClass('disabled'); + return $(this).prop('disabled', false).removeClass('disabled'); }, }); diff --git a/app/assets/javascripts/commons/nav/user_merge_requests.js b/app/assets/javascripts/commons/nav/user_merge_requests.js index 8e694cca6a1..84ab728274f 100644 --- a/app/assets/javascripts/commons/nav/user_merge_requests.js +++ b/app/assets/javascripts/commons/nav/user_merge_requests.js @@ -1,4 +1,4 @@ -import Api from '~/api'; +import { getUserCounts } from '~/rest_api'; let channel; @@ -11,7 +11,17 @@ function broadcastCount(newCount) { } function updateUserMergeRequestCounts(newCount) { - const mergeRequestsCountEl = document.querySelector('.merge-requests-count'); + const mergeRequestsCountEl = document.querySelector('.js-assigned-mr-count'); + mergeRequestsCountEl.textContent = newCount.toLocaleString(); +} + +function updateReviewerMergeRequestCounts(newCount) { + const mergeRequestsCountEl = document.querySelector('.js-reviewer-mr-count'); + mergeRequestsCountEl.textContent = newCount.toLocaleString(); +} + +function updateMergeRequestCounts(newCount) { + const mergeRequestsCountEl = document.querySelector('.js-merge-requests-count'); mergeRequestsCountEl.textContent = newCount.toLocaleString(); mergeRequestsCountEl.classList.toggle('hidden', Number(newCount) === 0); } @@ -20,14 +30,18 @@ function updateUserMergeRequestCounts(newCount) { * Refresh user counts (and broadcast if open) */ export function refreshUserMergeRequestCounts() { - return Api.userCounts() + return getUserCounts() .then(({ data }) => { - const count = data.merge_requests; + const assignedMergeRequests = data.assigned_merge_requests; + const reviewerMergeRequests = data.review_requested_merge_requests; + const fullCount = assignedMergeRequests + reviewerMergeRequests; - updateUserMergeRequestCounts(count); - broadcastCount(count); + updateUserMergeRequestCounts(assignedMergeRequests); + updateReviewerMergeRequestCounts(reviewerMergeRequests); + updateMergeRequestCounts(fullCount); + broadcastCount(fullCount); }) - .catch(ex => { + .catch((ex) => { console.error(ex); // eslint-disable-line no-console }); } @@ -59,8 +73,8 @@ export function openUserCountsBroadcast() { const currentUserId = typeof gon !== 'undefined' && gon && gon.current_user_id; if (currentUserId) { channel = new BroadcastChannel(`mr_count_channel_${currentUserId}`); - channel.onmessage = ev => { - updateUserMergeRequestCounts(ev.data); + channel.onmessage = (ev) => { + updateMergeRequestCounts(ev.data); }; } } |