summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci/runner/components/registration/cli_command.vue
blob: 95b135c83a76764dc524b188c5a67667f32c8d0d (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
<script>
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';

export default {
  components: {
    ClipboardButton,
  },
  props: {
    prompt: {
      type: String,
      required: false,
      default: '',
    },
    command: {
      type: [Array, String],
      required: false,
      default: '',
    },
  },
  computed: {
    lines() {
      if (typeof this.command === 'string') {
        return [this.command];
      }
      return this.command;
    },
    clipboard() {
      return this.lines.join('');
    },
  },
};
</script>
<template>
  <div class="gl-display-flex gl-gap-3 gl-align-items-flex-start">
    <!-- eslint-disable vue/require-v-for-key-->
    <pre
      class="gl-w-full"
    ><span v-if="prompt" class="gl-user-select-none">{{ prompt }} </span><template v-for="line in lines">{{ line }}<br class="gl-user-select-none"/></template></pre>
    <!-- eslint-enable vue/require-v-for-key-->
    <clipboard-button :text="clipboard" :title="__('Copy')" />
  </div>
</template>