All files / app/assets/javascripts/clusters/forms/components integration_form.vue

0% Statements 0/5
0% Branches 0/3
0% Functions 0/3
0% Lines 0/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                                                                                                                                                                                                                             
<script>
import {
  GlFormGroup,
  GlFormInput,
  GlToggle,
  GlTooltipDirective,
  GlSprintf,
  GlLink,
  GlButton,
} from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
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: '',
    };
  },
  computed: {
    ...mapState(['enabled', 'editable', 'environmentScope', 'baseDomain']),
    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;
  },
};
</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"
            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]"
        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>
        <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="confirm"
        type="submit"
        :disabled="!canSubmit"
        :aria-disabled="!canSubmit"
        >{{ s__('ClusterIntegration|Save changes') }}</gl-button
      >
    </div>
  </div>
</template>