summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/runner/components/cells/runner_owner_cell.vue
blob: cb43760b2d6eaa3b7340656c6337f0843b1e760b (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
<script>
import { GlLink, GlTooltipDirective } from '@gitlab/ui';
import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE, I18N_ADMIN } from '../../constants';

export default {
  components: {
    GlLink,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    runner: {
      type: Object,
      required: true,
    },
  },
  computed: {
    cell() {
      switch (this.runner?.runnerType) {
        case INSTANCE_TYPE:
          return {
            text: I18N_ADMIN,
          };
        case GROUP_TYPE: {
          const { name, fullName, webUrl } = this.runner?.groups?.nodes[0] || {};

          return {
            text: name,
            href: webUrl,
            tooltip: fullName !== name ? fullName : '',
          };
        }
        case PROJECT_TYPE: {
          const { name, nameWithNamespace, webUrl } = this.runner?.ownerProject || {};

          return {
            text: name,
            href: webUrl,
            tooltip: nameWithNamespace !== name ? nameWithNamespace : '',
          };
        }
        default:
          return {};
      }
    },
  },
};
</script>

<template>
  <div>
    <gl-link
      v-if="cell.href"
      v-gl-tooltip="cell.tooltip"
      :href="cell.href"
      class="gl-text-body gl-text-decoration-underline"
    >
      {{ cell.text }}
    </gl-link>
    <span v-else>{{ cell.text }}</span>
  </div>
</template>