summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/profile/preferences/components/integration_view.vue
blob: c2952629a5d2430d11534fe7b76de46c563b4ad1 (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
<script>
import { GlFormText, GlIcon, GlLink } from '@gitlab/ui';
import IntegrationHelpText from '~/vue_shared/components/integrations_help_text.vue';

export default {
  name: 'IntegrationView',
  components: {
    GlFormText,
    GlIcon,
    GlLink,
    IntegrationHelpText,
  },
  inject: ['userFields'],
  props: {
    helpLink: {
      type: String,
      required: true,
    },
    message: {
      type: String,
      required: true,
    },
    messageUrl: {
      type: String,
      required: true,
    },
    config: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      isEnabled: this.userFields[this.config.formName],
    };
  },
  computed: {
    formName() {
      return `user[${this.config.formName}]`;
    },
    formId() {
      return `user_${this.config.formName}`;
    },
  },
};
</script>

<template>
  <div>
    <label class="label-bold">
      {{ config.title }}
    </label>
    <gl-link class="has-tooltip" title="More information" :href="helpLink">
      <gl-icon name="question-o" class="vertical-align-middle" />
    </gl-link>
    <div class="form-group form-check" data-testid="profile-preferences-integration-form-group">
      <!-- Necessary for Rails to receive the value when not checked -->
      <input
        :name="formName"
        type="hidden"
        value="0"
        data-testid="profile-preferences-integration-hidden-field"
      />
      <input
        :id="formId"
        v-model="isEnabled"
        type="checkbox"
        class="form-check-input"
        :name="formName"
        value="1"
        data-testid="profile-preferences-integration-checkbox"
      />
      <label class="form-check-label" :for="formId">
        {{ config.label }}
      </label>
      <gl-form-text tag="div">
        <integration-help-text :message="message" :message-url="messageUrl" />
      </gl-form-text>
    </div>
  </div>
</template>