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

runner_type_badge.vue « components « runner « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f568f914004d478dbada16ceda4bb31ae4a11bbe (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
<script>
import { GlBadge, GlTooltipDirective } from '@gitlab/ui';
import {
  INSTANCE_TYPE,
  GROUP_TYPE,
  PROJECT_TYPE,
  I18N_INSTANCE_TYPE,
  I18N_INSTANCE_RUNNER_DESCRIPTION,
  I18N_GROUP_TYPE,
  I18N_GROUP_RUNNER_DESCRIPTION,
  I18N_PROJECT_TYPE,
  I18N_PROJECT_RUNNER_DESCRIPTION,
} from '../constants';

const BADGE_DATA = {
  [INSTANCE_TYPE]: {
    icon: 'users',
    text: I18N_INSTANCE_TYPE,
    tooltip: I18N_INSTANCE_RUNNER_DESCRIPTION,
  },
  [GROUP_TYPE]: {
    icon: 'group',
    text: I18N_GROUP_TYPE,
    tooltip: I18N_GROUP_RUNNER_DESCRIPTION,
  },
  [PROJECT_TYPE]: {
    icon: 'project',
    text: I18N_PROJECT_TYPE,
    tooltip: I18N_PROJECT_RUNNER_DESCRIPTION,
  },
};

export default {
  components: {
    GlBadge,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    type: {
      type: String,
      required: false,
      default: null,
      validator(type) {
        return Boolean(BADGE_DATA[type]);
      },
    },
  },
  computed: {
    badge() {
      return BADGE_DATA[this.type];
    },
  },
};
</script>
<template>
  <gl-badge
    v-if="badge"
    v-gl-tooltip="badge.tooltip"
    variant="muted"
    :icon="badge.icon"
    v-bind="$attrs"
  >
    {{ badge.text }}
  </gl-badge>
</template>