summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/pipelines_list/empty_state/pipelines_ci_templates.vue
blob: be46a7f5cec6c359320457899e1016d17cd467fe (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
168
169
170
171
172
173
<script>
import { GlButton, GlCard, GlSprintf, GlIcon, GlLink } from '@gitlab/ui';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import {
  STARTER_TEMPLATE_NAME,
  RUNNERS_AVAILABILITY_SECTION_EXPERIMENT_NAME,
  RUNNERS_SETTINGS_LINK_CLICKED_EVENT,
  RUNNERS_DOCUMENTATION_LINK_CLICKED_EVENT,
  RUNNERS_SETTINGS_BUTTON_CLICKED_EVENT,
  I18N,
} from '~/pipeline_editor/constants';
import Tracking from '~/tracking';
import { helpPagePath } from '~/helpers/help_page_helper';
import { isExperimentVariant } from '~/experimentation/utils';
import GitlabExperiment from '~/experimentation/components/gitlab_experiment.vue';
import ExperimentTracking from '~/experimentation/experiment_tracking';
import CiTemplates from './ci_templates.vue';

export default {
  components: {
    GlButton,
    GlCard,
    GlSprintf,
    GlIcon,
    GlLink,
    GitlabExperiment,
    CiTemplates,
  },
  mixins: [Tracking.mixin()],
  STARTER_TEMPLATE_NAME,
  RUNNERS_AVAILABILITY_SECTION_EXPERIMENT_NAME,
  RUNNERS_SETTINGS_LINK_CLICKED_EVENT,
  RUNNERS_DOCUMENTATION_LINK_CLICKED_EVENT,
  RUNNERS_SETTINGS_BUTTON_CLICKED_EVENT,
  I18N,
  inject: ['pipelineEditorPath'],
  props: {
    ciRunnerSettingsPath: {
      type: String,
      required: false,
      default: null,
    },
    anyRunnersAvailable: {
      type: Boolean,
      required: false,
      default: true,
    },
  },
  data() {
    return {
      gettingStartedTemplateUrl: mergeUrlParams(
        { template: STARTER_TEMPLATE_NAME },
        this.pipelineEditorPath,
      ),
      tracker: null,
    };
  },
  computed: {
    sharedRunnersHelpPagePath() {
      return helpPagePath('ci/runners/runners_scope', { anchor: 'shared-runners' });
    },
    runnersAvailabilitySectionExperimentEnabled() {
      return isExperimentVariant(RUNNERS_AVAILABILITY_SECTION_EXPERIMENT_NAME);
    },
  },
  created() {
    this.tracker = new ExperimentTracking(RUNNERS_AVAILABILITY_SECTION_EXPERIMENT_NAME);
  },
  methods: {
    trackEvent(template) {
      this.track('template_clicked', {
        label: template,
      });
    },
    trackExperimentEvent(action) {
      this.tracker.event(action);
    },
  },
};
</script>
<template>
  <div>
    <h2 class="gl-font-size-h2 gl-text-gray-900">{{ $options.I18N.title }}</h2>

    <gitlab-experiment :name="$options.RUNNERS_AVAILABILITY_SECTION_EXPERIMENT_NAME">
      <template #candidate>
        <div v-if="anyRunnersAvailable">
          <h2 class="gl-font-base gl-text-gray-900">
            <gl-icon name="check-circle-filled" class="gl-text-green-500 gl-mr-2" :size="12" />
            {{ $options.I18N.runners.title }}
          </h2>
          <p class="gl-text-gray-800 gl-mb-6">
            <gl-sprintf :message="$options.I18N.runners.subtitle">
              <template #settingsLink="{ content }">
                <gl-link
                  data-testid="settings-link"
                  :href="ciRunnerSettingsPath"
                  @click="trackExperimentEvent($options.RUNNERS_SETTINGS_LINK_CLICKED_EVENT)"
                  >{{ content }}</gl-link
                >
              </template>
              <template #docsLink="{ content }">
                <gl-link
                  data-testid="documentation-link"
                  :href="sharedRunnersHelpPagePath"
                  @click="trackExperimentEvent($options.RUNNERS_DOCUMENTATION_LINK_CLICKED_EVENT)"
                  >{{ content }}</gl-link
                >
              </template>
            </gl-sprintf>
          </p>
        </div>

        <div v-else>
          <h2 class="gl-font-base gl-text-gray-900">
            <gl-icon name="warning-solid" class="gl-text-red-600 gl-mr-2" :size="14" />
            {{ $options.I18N.noRunners.title }}
          </h2>
          <p class="gl-text-gray-800 gl-mb-6">{{ $options.I18N.noRunners.subtitle }}</p>
          <gl-button
            data-testid="settings-button"
            category="primary"
            variant="confirm"
            :href="ciRunnerSettingsPath"
            @click="trackExperimentEvent($options.RUNNERS_SETTINGS_BUTTON_CLICKED_EVENT)"
          >
            {{ $options.I18N.noRunners.cta }}
          </gl-button>
        </div>
      </template>
    </gitlab-experiment>

    <template v-if="!runnersAvailabilitySectionExperimentEnabled || anyRunnersAvailable">
      <h2 class="gl-font-lg gl-text-gray-900">{{ $options.I18N.learnBasics.title }}</h2>
      <p class="gl-text-gray-800 gl-mb-6">
        <gl-sprintf :message="$options.I18N.learnBasics.subtitle">
          <template #code="{ content }">
            <code>{{ content }}</code>
          </template>
        </gl-sprintf>
      </p>

      <div class="gl-lg-w-25p gl-lg-pr-5 gl-mb-8">
        <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.learnBasics.gettingStarted.title }}
              </strong>
            </div>
            <p class="gl-font-sm">{{ $options.I18N.learnBasics.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.learnBasics.gettingStarted.cta }}
          </gl-button>
        </gl-card>
      </div>

      <h2 class="gl-font-lg gl-text-gray-900">{{ $options.I18N.templates.title }}</h2>
      <p class="gl-text-gray-800 gl-mb-6">{{ $options.I18N.templates.subtitle }}</p>

      <ci-templates />
    </template>
  </div>
</template>