summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/runner/components/runner_manual_setup_help.vue
blob: 475d362bb5225cc30ef788f516a11d9d3b456d24 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<script>
import { GlLink, GlSprintf, GlTooltipDirective } from '@gitlab/ui';
import { s__ } from '~/locale';
import MaskedValue from '~/runner/components/helpers/masked_value.vue';
import RunnerRegistrationTokenReset from '~/runner/components/runner_registration_token_reset.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import RunnerInstructions from '~/vue_shared/components/runner_instructions/runner_instructions.vue';
import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE } from '../constants';

export default {
  components: {
    GlLink,
    GlSprintf,
    ClipboardButton,
    MaskedValue,
    RunnerInstructions,
    RunnerRegistrationTokenReset,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  inject: {
    runnerInstallHelpPage: {
      default: null,
    },
  },
  props: {
    registrationToken: {
      type: String,
      required: true,
    },
    type: {
      type: String,
      required: true,
      validator(type) {
        return [INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE].includes(type);
      },
    },
  },
  data() {
    return {
      currentRegistrationToken: this.registrationToken,
    };
  },
  computed: {
    rootUrl() {
      return gon.gitlab_url || '';
    },
    typeName() {
      switch (this.type) {
        case INSTANCE_TYPE:
          return s__('Runners|shared');
        case GROUP_TYPE:
          return s__('Runners|group');
        case PROJECT_TYPE:
          return s__('Runners|specific');
        default:
          return '';
      }
    },
  },
  methods: {
    onTokenReset(token) {
      this.currentRegistrationToken = token;
    },
  },
};
</script>

<template>
  <div class="bs-callout">
    <h5 data-testid="runner-help-title">
      <gl-sprintf :message="__('Set up a %{type} runner manually')">
        <template #type>
          {{ typeName }}
        </template>
      </gl-sprintf>
    </h5>

    <ol>
      <li>
        <gl-link :href="runnerInstallHelpPage" data-testid="runner-help-link" target="_blank">
          {{ __("Install GitLab Runner and ensure it's running.") }}
        </gl-link>
      </li>
      <li>
        {{ __('Register the runner with this URL:') }}
        <br />

        <code data-testid="coordinator-url">{{ rootUrl }}</code>
        <clipboard-button :title="__('Copy URL')" :text="rootUrl" />
      </li>
      <li>
        {{ __('And this registration token:') }}
        <br />

        <code data-testid="registration-token"
          ><masked-value :value="currentRegistrationToken"
        /></code>
        <clipboard-button :title="__('Copy token')" :text="currentRegistrationToken" />
      </li>
    </ol>

    <runner-registration-token-reset :type="type" @tokenReset="onTokenReset" />

    <runner-instructions />
  </div>
</template>