summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci/runner/components/registration/platforms_drawer.vue
blob: a56302898ca8ed7042b946276544f5ad344a44e7 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<script>
import { GlDrawer, GlFormGroup, GlFormSelect, GlLink, GlSprintf } from '@gitlab/ui';
import { getContentWrapperHeight } from '~/lib/utils/dom_utils';
import { DRAWER_Z_INDEX } from '~/lib/utils/constants';

import {
  DEFAULT_PLATFORM,
  MACOS_PLATFORM,
  LINUX_PLATFORM,
  WINDOWS_PLATFORM,
  INSTALL_HELP_URL,
} from '../../constants';
import { installScript, platformArchitectures } from './utils';

import CliCommand from './cli_command.vue';

export default {
  components: {
    GlDrawer,
    GlFormGroup,
    GlFormSelect,
    GlLink,
    GlSprintf,
    CliCommand,
  },
  props: {
    open: {
      type: Boolean,
      required: true,
    },
    platform: {
      type: String,
      required: false,
      default: DEFAULT_PLATFORM,
    },
  },
  data() {
    return {
      selectedPlatform: this.platform,
      selectedArchitecture: null,
    };
  },
  computed: {
    drawerHeightOffset() {
      return getContentWrapperHeight('.content-wrapper');
    },
    architectureOptions() {
      return platformArchitectures({ platform: this.selectedPlatform });
    },
    script() {
      return installScript({
        platform: this.selectedPlatform,
        architecture: this.selectedArchitecture,
      });
    },
  },
  watch: {
    selectedPlatform() {
      this.selectedArchitecture =
        this.architectureOptions.find((value) => value === this.selectedArchitecture) ||
        this.architectureOptions[0];

      this.$emit('selectPlatform', this.selectedPlatform);
    },
  },
  created() {
    [this.selectedArchitecture] = this.architectureOptions;
  },
  methods: {
    onClose() {
      this.$emit('close');
    },
  },
  platformOptions: [
    /* eslint-disable @gitlab/require-i18n-strings */
    { value: LINUX_PLATFORM, text: 'Linux' },
    { value: MACOS_PLATFORM, text: 'macOS' },
    { value: WINDOWS_PLATFORM, text: 'Windows' },
    /* eslint-enable @gitlab/require-i18n-strings */
  ],
  INSTALL_HELP_URL,
  DRAWER_Z_INDEX,
};
</script>
<template>
  <gl-drawer
    :open="open"
    :header-height="drawerHeightOffset"
    :z-index="$options.DRAWER_Z_INDEX"
    @close="onClose"
  >
    <template #title>
      <h2 class="gl-my-0 gl-font-size-h2 gl-line-height-24">
        {{ s__('Runners|Install GitLab Runner') }}
      </h2>
    </template>
    <div>
      <p>{{ s__('Runners|Select platform specifications to install GitLab Runner.') }}</p>

      <gl-form-group :label="s__('Runners|Environment')" label-for="runner-environment-select">
        <gl-form-select
          id="runner-environment-select"
          v-model="selectedPlatform"
          :options="$options.platformOptions"
        />
      </gl-form-group>

      <gl-form-group :label="s__('Runners|Architecture')" label-for="runner-architecture-select">
        <gl-form-select
          id="runner-architecture-select"
          v-model="selectedArchitecture"
          :options="architectureOptions"
        />
      </gl-form-group>

      <cli-command :command="script" />

      <p>
        <gl-sprintf
          :message="
            s__('Runners|See more %{linkStart}installation methods and architectures%{linkEnd}.')
          "
        >
          <template #link="{ content }">
            <gl-link :href="$options.INSTALL_HELP_URL">{{ content }}</gl-link>
          </template>
        </gl-sprintf>
      </p>
    </div>
  </gl-drawer>
</template>