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

gitlab_version_check_badge.vue « components « gitlab_version_check « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1536a9a525b72abfec94b9b62dd539daf7058f00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<script>
import { GlBadge } from '@gitlab/ui';
import { s__ } from '~/locale';
import Tracking from '~/tracking';
import { STATUS_TYPES, UPGRADE_DOCS_URL } from '../constants';

export default {
  name: 'GitlabVersionCheckBadge',
  components: {
    GlBadge,
  },
  mixins: [Tracking.mixin()],
  props: {
    size: {
      type: String,
      required: false,
      default: 'md',
    },
    actionable: {
      type: Boolean,
      required: false,
      default: false,
    },
    status: {
      type: String,
      required: true,
    },
  },
  computed: {
    title() {
      if (this.status === STATUS_TYPES.SUCCESS) {
        return s__('VersionCheck|Up to date');
      } else if (this.status === STATUS_TYPES.WARNING) {
        return s__('VersionCheck|Update available');
      } else if (this.status === STATUS_TYPES.DANGER) {
        return s__('VersionCheck|Update ASAP');
      }

      return null;
    },
    badgeUrl() {
      return this.actionable ? UPGRADE_DOCS_URL : null;
    },
  },
  mounted() {
    this.track('render', {
      label: 'version_badge',
      property: this.title,
    });
  },
  methods: {
    onClick() {
      if (!this.actionable) return;

      this.track('click_link', {
        label: 'version_badge',
        property: this.title,
      });
    },
  },
  UPGRADE_DOCS_URL,
};
</script>

<template>
  <!-- TODO: remove the span element once bootstrap-vue is updated to version 2.21.1 -->
  <!-- TODO: https://github.com/bootstrap-vue/bootstrap-vue/issues/6219 -->
  <span data-testid="badge-click-wrapper" @click="onClick">
    <gl-badge :href="badgeUrl" class="version-check-badge" :variant="status" :size="size">{{
      title
    }}</gl-badge>
  </span>
</template>