summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/clusters_list/components/agent_token.vue
blob: 93c37226a09164a66027409f587765f73f4430ff (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
<script>
import { GlAlert, GlFormInputGroup, GlLink, GlSprintf, GlIcon } from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
import CodeBlock from '~/vue_shared/components/code_block.vue';
import { generateAgentRegistrationCommand } from '../clusters_util';
import { I18N_AGENT_TOKEN, HELM_VERSION_POLICY_URL } from '../constants';

export default {
  i18n: I18N_AGENT_TOKEN,
  advancedInstallPath: helpPagePath('user/clusters/agent/install/index', {
    anchor: 'advanced-installation-method',
  }),
  HELM_VERSION_POLICY_URL,
  components: {
    GlAlert,
    CodeBlock,
    GlFormInputGroup,
    GlLink,
    GlSprintf,
    GlIcon,
    ModalCopyButton,
  },
  inject: ['kasAddress', 'kasVersion'],
  props: {
    agentName: {
      required: true,
      type: String,
    },
    agentToken: {
      required: true,
      type: String,
    },
    modalId: {
      required: true,
      type: String,
    },
  },
  computed: {
    agentRegistrationCommand() {
      return generateAgentRegistrationCommand({
        name: this.agentName,
        token: this.agentToken,
        version: this.kasVersion,
        address: this.kasAddress,
      });
    },
  },
};
</script>

<template>
  <div>
    <p class="gl-mb-3">{{ $options.i18n.tokenLabel }}</p>

    <p>
      <gl-form-input-group readonly :value="agentToken" :select-on-click="true">
        <template #append>
          <modal-copy-button
            :text="agentToken"
            :title="$options.i18n.copyToken"
            :modal-id="modalId"
          />
        </template>
      </gl-form-input-group>
    </p>

    <p>
      {{ $options.i18n.tokenSubtitle }}
    </p>

    <gl-alert :dismissible="false" variant="warning" class="gl-mb-5">
      {{ $options.i18n.tokenSingleUseWarningTitle }}
    </gl-alert>

    <p>
      <strong>{{ $options.i18n.basicInstallTitle }}</strong>
    </p>

    <p>
      {{ $options.i18n.basicInstallBody }}
      <gl-sprintf :message="$options.i18n.helmVersionText">
        <template #link="{ content }"
          ><gl-link :href="$options.HELM_VERSION_POLICY_URL" target="_blank"
            >{{ content }} <gl-icon name="external-link" :size="12" /></gl-link></template
      ></gl-sprintf>
    </p>

    <p class="gl-display-flex gl-align-items-flex-start">
      <code-block class="gl-w-full" :code="agentRegistrationCommand" />
      <modal-copy-button
        :title="$options.i18n.copyCommand"
        :text="agentRegistrationCommand"
        :modal-id="modalId"
      />
    </p>

    <p>
      <strong>{{ $options.i18n.advancedInstallTitle }}</strong>
    </p>

    <p>
      <gl-sprintf :message="$options.i18n.advancedInstallBody">
        <template #link="{ content }">
          <gl-link :href="$options.advancedInstallPath" target="_blank"> {{ content }}</gl-link>
        </template>
      </gl-sprintf>
    </p>
  </div>
</template>