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

registration_dropdown.vue « registration « components « runner « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 212ad5fa5a0d7401be9afca505a667bb5741b7c6 (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
<script>
import { GlDropdown, GlDropdownForm, GlDropdownItem, GlDropdownDivider } from '@gitlab/ui';
import { s__ } from '~/locale';
import RunnerInstructionsModal from '~/vue_shared/components/runner_instructions/runner_instructions_modal.vue';
import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE } from '../../constants';
import RegistrationToken from './registration_token.vue';
import RegistrationTokenResetDropdownItem from './registration_token_reset_dropdown_item.vue';

export default {
  i18n: {
    showInstallationInstructions: s__(
      'Runners|Show runner installation and registration instructions',
    ),
  },
  components: {
    GlDropdown,
    GlDropdownForm,
    GlDropdownItem,
    GlDropdownDivider,
    RegistrationToken,
    RunnerInstructionsModal,
    RegistrationTokenResetDropdownItem,
  },
  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: {
    dropdownText() {
      switch (this.type) {
        case INSTANCE_TYPE:
          return s__('Runners|Register an instance runner');
        case GROUP_TYPE:
          return s__('Runners|Register a group runner');
        case PROJECT_TYPE:
          return s__('Runners|Register a project runner');
        default:
          return s__('Runners|Register a runner');
      }
    },
  },
  methods: {
    onShowInstructionsClick() {
      this.$refs.runnerInstructionsModal.show();
    },
    onTokenReset(token) {
      this.currentRegistrationToken = token;

      this.$refs.runnerRegistrationDropdown.hide(true);
    },
  },
};
</script>

<template>
  <gl-dropdown
    ref="runnerRegistrationDropdown"
    menu-class="gl-w-auto!"
    :text="dropdownText"
    variant="confirm"
    v-bind="$attrs"
  >
    <gl-dropdown-item @click.capture.native.stop="onShowInstructionsClick">
      {{ $options.i18n.showInstallationInstructions }}
      <runner-instructions-modal
        ref="runnerInstructionsModal"
        :registration-token="currentRegistrationToken"
        data-testid="runner-instructions-modal"
      />
    </gl-dropdown-item>
    <gl-dropdown-divider />
    <gl-dropdown-form class="gl-p-4!">
      <registration-token input-id="token-value" :value="currentRegistrationToken" />
    </gl-dropdown-form>
    <gl-dropdown-divider />
    <registration-token-reset-dropdown-item :type="type" @tokenReset="onTokenReset" />
  </gl-dropdown>
</template>