summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/clusters/forms/components/integration_form.vue
blob: a344f9578fdb4d28b2cf3866a578a2d24f7d53f2 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<script>
import {
  GlFormGroup,
  GlFormInput,
  GlToggle,
  GlTooltipDirective,
  GlSprintf,
  GlLink,
  GlButton,
} from '@gitlab/ui';
import { mapState } from 'vuex';
import { s__ } from '~/locale';

export default {
  i18n: {
    toggleLabel: s__(
      "ClusterIntegration|Enable or disable GitLab's connection to your Kubernetes cluster.",
    ),
  },
  components: {
    GlFormGroup,
    GlToggle,
    GlFormInput,
    GlSprintf,
    GlLink,
    GlButton,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  inject: {
    autoDevopsHelpPath: {
      default: '',
    },
    externalEndpointHelpPath: {
      default: '',
    },
  },
  data() {
    return {
      toggleEnabled: true,
      envScope: '*',
      baseDomainField: '',
      externalIp: '',
    };
  },
  computed: {
    ...mapState([
      'enabled',
      'editable',
      'environmentScope',
      'baseDomain',
      'applicationIngressExternalIp',
    ]),
    canSubmit() {
      return (
        this.enabled !== this.toggleEnabled ||
        this.environmentScope !== this.envScope ||
        this.baseDomain !== this.baseDomainField
      );
    },
  },
  mounted() {
    this.toggleEnabled = this.enabled;
    this.envScope = this.environmentScope;
    this.baseDomainField = this.baseDomain;
    this.externalIp = this.applicationIngressExternalIp;
  },
};
</script>

<template>
  <div class="d-flex gl-flex-direction-column">
    <gl-form-group>
      <div class="gl-display-flex gl-align-items-center">
        <h4 class="gl-pr-3 gl-m-0">{{ s__('ClusterIntegration|GitLab Integration') }}</h4>

        <div class="js-cluster-enable-toggle-area">
          <gl-toggle
            id="toggleCluster"
            v-model="toggleEnabled"
            v-gl-tooltip:tooltipcontainer
            name="cluster[enabled]"
            class="gl-mb-0 js-project-feature-toggle"
            data-qa-selector="integration_status_toggle"
            aria-describedby="toggleCluster"
            :disabled="!editable"
            :label="$options.i18n.toggleLabel"
            label-position="hidden"
            :title="$options.i18n.toggleLabel"
          />
        </div>
      </div>
    </gl-form-group>

    <gl-form-group
      :label="s__('ClusterIntegration|Environment scope')"
      label-size="sm"
      label-for="cluster_environment_scope"
      :description="
        s__('ClusterIntegration|Choose which of your environments will use this cluster.')
      "
    >
      <gl-form-input
        id="cluster_environment_scope"
        v-model="envScope"
        name="cluster[environment_scope]"
        class="col-md-6"
        type="text"
      />
    </gl-form-group>

    <gl-form-group
      :label="s__('ClusterIntegration|Base domain')"
      label-size="sm"
      label-for="cluster_base_domain"
    >
      <gl-form-input
        id="cluster_base_domain"
        v-model="baseDomainField"
        name="cluster[base_domain]"
        data-qa-selector="base_domain_field"
        class="col-md-6"
        type="text"
      />
      <div class="form-text text-muted inline">
        <gl-sprintf
          :message="
            s__(
              'ClusterIntegration|Specifying a domain will allow you to use Auto Review Apps and Auto Deploy stages for %{linkStart}Auto DevOps.%{linkEnd} The domain should have a wildcard DNS configured matching the domain. ',
            )
          "
        >
          <template #link="{ content }">
            <gl-link :href="autoDevopsHelpPath" target="_blank">{{ content }}</gl-link>
          </template>
        </gl-sprintf>
        <div v-if="applicationIngressExternalIp" class="js-ingress-domain-help-text inline">
          {{ s__('ClusterIntegration|Alternatively, ') }}
          <gl-sprintf :message="s__('ClusterIntegration|%{externalIp}.nip.io')">
            <template #externalIp>{{ externalIp }}</template>
          </gl-sprintf>
          {{ s__('ClusterIntegration|can be used instead of a custom domain. ') }}
        </div>
        <gl-sprintf
          class="inline"
          :message="s__('ClusterIntegration|%{linkStart}More information%{linkEnd}')"
        >
          <template #link="{ content }">
            <gl-link :href="externalEndpointHelpPath" target="_blank">{{ content }}</gl-link>
          </template>
        </gl-sprintf>
      </div>
    </gl-form-group>
    <div v-if="editable" class="form group gl-display-flex gl-justify-content-end">
      <gl-button
        category="primary"
        variant="success"
        type="submit"
        :disabled="!canSubmit"
        :aria-disabled="!canSubmit"
        data-qa-selector="save_changes_button"
        >{{ s__('ClusterIntegration|Save changes') }}</gl-button
      >
    </div>
  </div>
</template>