Welcome to mirror list, hosted at ThFree Co, Russian Federation.

notification.js « utils « whats_new « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1621c4d5f275853d37544862673e0e5bc277e879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export const STORAGE_KEY = 'display-whats-new-notification';

export const getVersionDigest = (appEl) => appEl.dataset.versionDigest;

export const setNotification = (appEl) => {
  const versionDigest = getVersionDigest(appEl);
  const notificationEl = document.querySelector('.header-help');
  if (!notificationEl) return;

  let notificationCountEl = notificationEl.querySelector('.js-whats-new-notification-count');

  if (localStorage.getItem(STORAGE_KEY) === versionDigest || versionDigest === undefined) {
    notificationEl.classList.remove('with-notifications');
    if (notificationCountEl) {
      notificationCountEl.parentElement.removeChild(notificationCountEl);
      notificationCountEl = null;
    }
  } else {
    notificationEl.classList.add('with-notifications');
  }
};