diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-22 00:09:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-22 00:09:30 +0300 |
commit | 664db1da1cd5951f09c0f54ff5e9dae16bcf1a92 (patch) | |
tree | 5e62895748848a94ed9775ffa5f017da4e83d25e /app/assets/javascripts/gitlab_version_check | |
parent | c0b718a0dbd99e6c0d30e5bc55bdcf4a12946375 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/gitlab_version_check')
-rw-r--r-- | app/assets/javascripts/gitlab_version_check/index.js | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/app/assets/javascripts/gitlab_version_check/index.js b/app/assets/javascripts/gitlab_version_check/index.js index 203ce10ef57..8d778ecc792 100644 --- a/app/assets/javascripts/gitlab_version_check/index.js +++ b/app/assets/javascripts/gitlab_version_check/index.js @@ -1,50 +1,38 @@ import Vue from 'vue'; -import * as Sentry from '@sentry/browser'; import { parseBoolean } from '~/lib/utils/common_utils'; -import axios from '~/lib/utils/axios_utils'; -import { joinPaths } from '~/lib/utils/url_utility'; import GitlabVersionCheckBadge from './components/gitlab_version_check_badge.vue'; -const mountGitlabVersionCheckBadge = ({ el, status }) => { - const { size } = el.dataset; +const mountGitlabVersionCheckBadge = (el) => { + const { size, version } = el.dataset; const actionable = parseBoolean(el.dataset.actionable); - return new Vue({ - el, - render(createElement) { - return createElement(GitlabVersionCheckBadge, { - props: { - size, - actionable, - status, - }, - }); - }, - }); -}; + try { + const { severity } = JSON.parse(version); -export default async () => { - const versionCheckBadges = [...document.querySelectorAll('.js-gitlab-version-check-badge')]; + // If no severity (status) data don't worry about rendering + if (!severity) { + return null; + } - // If there are no version check elements, exit out - if (versionCheckBadges?.length <= 0) { + return new Vue({ + el, + render(createElement) { + return createElement(GitlabVersionCheckBadge, { + props: { + size, + actionable, + status: severity, + }, + }); + }, + }); + } catch { return null; } +}; - const status = await axios - .get(joinPaths('/', gon.relative_url_root, '/admin/version_check.json')) - .then((res) => { - return res.data?.severity; - }) - .catch((e) => { - Sentry.captureException(e); - return null; - }); - - // If we don't have a status there is nothing to render - if (status) { - return versionCheckBadges.map((el) => mountGitlabVersionCheckBadge({ el, status })); - } +export default () => { + const versionCheckBadges = [...document.querySelectorAll('.js-gitlab-version-check-badge')]; - return null; + return versionCheckBadges.map((el) => mountGitlabVersionCheckBadge(el)); }; |