All files / app/assets/javascripts/pipelines/components/pipelines_list pipelines_ci_templates.vue

100% Statements 11/11
100% Branches 0/0
100% Functions 4/4
100% Lines 11/11

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  3x 3x 3x 3x 3x                                                                   12x 12x 24x               12x                   2x             79x                                                                                                                                                              
<script>
import { GlAvatar, GlButton, GlCard, GlSprintf } from '@gitlab/ui';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import { s__, sprintf } from '~/locale';
import { STARTER_TEMPLATE_NAME } from '~/pipeline_editor/constants';
import Tracking from '~/tracking';
 
export default {
  components: {
    GlAvatar,
    GlButton,
    GlCard,
    GlSprintf,
  },
  mixins: [Tracking.mixin()],
  STARTER_TEMPLATE_NAME,
  i18n: {
    cta: s__('Pipelines|Use template'),
    testTemplates: {
      title: s__('Pipelines|Use a sample CI/CD template'),
      subtitle: s__(
        'Pipelines|Use a sample %{codeStart}.gitlab-ci.yml%{codeEnd} template file to explore how CI/CD works.',
      ),
      gettingStarted: {
        title: s__('Pipelines|Get started with GitLab CI/CD'),
        description: s__(
          'Pipelines|Get familiar with GitLab CI/CD syntax by starting with a basic 3 stage CI/CD pipeline.',
        ),
      },
    },
    templates: {
      title: s__('Pipelines|Use a CI/CD template'),
      subtitle: s__(
        "Pipelines|Use a template based on your project's language or framework to get started with GitLab CI/CD.",
      ),
      description: s__('Pipelines|CI/CD template to test and deploy your %{name} project.'),
    },
  },
  inject: ['pipelineEditorPath', 'suggestedCiTemplates'],
  data() {
    const templates = this.suggestedCiTemplates.map(({ name, logo }) => {
      return {
        name,
        logo,
        link: mergeUrlParams({ template: name }, this.pipelineEditorPath),
        description: sprintf(this.$options.i18n.templates.description, { name }),
      };
    });
 
    return {
      templates,
      gettingStartedTemplateUrl: mergeUrlParams(
        { template: STARTER_TEMPLATE_NAME },
        this.pipelineEditorPath,
      ),
    };
  },
  methods: {
    trackEvent(template) {
      this.track('template_clicked', {
        label: template,
      });
    },
  },
};
</script>
<template>
  <div>
    <h2 class="gl-font-size-h2 gl-text-gray-900">{{ $options.i18n.testTemplates.title }}</h2>
    <p class="gl-text-gray-800 gl-mb-6">
      <gl-sprintf :message="$options.i18n.testTemplates.subtitle">
        <template #code="{ content }">
          <code>{{ content }}</code>
        </template>
      </gl-sprintf>
    </p>
 
    <div class="row gl-mb-8">
      <div class="col-12">
        <gl-card>
          <div class="gl-flex-direction-row">
            <div class="gl-py-5"><gl-emoji class="gl-font-size-h2-xl" data-name="wave" /></div>
            <div class="gl-mb-3">
              <strong class="gl-text-gray-800 gl-mb-2">{{
                $options.i18n.testTemplates.gettingStarted.title
              }}</strong>
            </div>
            <p class="gl-font-sm">{{ $options.i18n.testTemplates.gettingStarted.description }}</p>
          </div>
 
          <gl-button
            category="primary"
            variant="confirm"
            :href="gettingStartedTemplateUrl"
            data-testid="test-template-link"
            @click="trackEvent($options.STARTER_TEMPLATE_NAME)"
          >
            {{ $options.i18n.cta }}
          </gl-button>
        </gl-card>
      </div>
    </div>
 
    <h2 class="gl-font-size-h2 gl-text-gray-900">{{ $options.i18n.templates.title }}</h2>
    <p class="gl-text-gray-800 gl-mb-6">{{ $options.i18n.templates.subtitle }}</p>
 
    <ul class="gl-list-style-none gl-pl-0">
      <li v-for="template in templates" :key="template.name">
        <div
          class="gl-display-flex gl-align-items-center gl-justify-content-space-between gl-border-b-solid gl-border-b-1 gl-border-b-gray-100 gl-pb-3 gl-pt-3"
        >
          <div class="gl-display-flex gl-flex-direction-row gl-align-items-center">
            <gl-avatar
              :src="template.logo"
              :size="64"
              class="gl-mr-6 gl-bg-white dark-mode-override"
              shape="rect"
              :alt="template.name"
              data-testid="template-logo"
            />
            <div class="gl-flex-direction-row">
              <div class="gl-mb-3">
                <strong class="gl-text-gray-800" data-testid="template-name">{{
                  template.name
                }}</strong>
              </div>
              <p class="gl-mb-0 gl-font-sm" data-testid="template-description">
                {{ template.description }}
              </p>
            </div>
          </div>
          <gl-button
            category="primary"
            variant="confirm"
            :href="template.link"
            data-testid="template-link"
            @click="trackEvent(template.name)"
          >
            {{ $options.i18n.cta }}
          </gl-button>
        </div>
      </li>
    </ul>
  </div>
</template>