Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mr_widget_pipeline_tour.vue « states « components « vue_merge_request_widget « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1a2d845fab97eb7c9f0873fa8cb2f8ad4c1aaec6 (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
<script>
import { GlPopover, GlDeprecatedButton, GlSprintf, GlLink } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import Cookies from 'js-cookie';
import { parseBoolean } from '~/lib/utils/common_utils';
import Tracking from '~/tracking';
import { s__ } from '~/locale';

const trackingMixin = Tracking.mixin();

const cookieKey = 'suggest_pipeline_dismissed';

export default {
  name: 'MRWidgetPipelineTour',
  dismissTrackValue: 20,
  showTrackValue: 10,
  trackEvent: 'click_button',
  helpContent: s__(
    `mrWidget|Use %{linkStart}CI pipelines to test your code%{linkEnd}, simply add a GitLab CI configuration file to your project. It only takes a minute to make your code more secure and robust.`,
  ),
  helpURL: 'https://about.gitlab.com/blog/2019/07/12/guide-to-ci-cd-pipelines/',
  components: {
    GlPopover,
    GlDeprecatedButton,
    Icon,
    GlSprintf,
    GlLink,
  },
  mixins: [trackingMixin],
  props: {
    pipelinePath: {
      type: String,
      required: true,
    },
    pipelineSvgPath: {
      type: String,
      required: true,
    },
    humanAccess: {
      type: String,
      required: true,
    },
    popoverTarget: {
      type: String,
      required: true,
    },
    popoverContainer: {
      type: String,
      required: true,
    },
    trackLabel: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      popoverDismissed: parseBoolean(Cookies.get(cookieKey)),
      tracking: {
        label: this.trackLabel,
        property: this.humanAccess,
      },
    };
  },
  mounted() {
    this.trackOnShow();
  },
  methods: {
    trackOnShow() {
      if (!this.popoverDismissed) {
        this.track();
      }
    },
    dismissPopover() {
      this.popoverDismissed = true;
      Cookies.set(cookieKey, this.popoverDismissed, { expires: 365 });
    },
  },
};
</script>
<template>
  <gl-popover
    v-if="!popoverDismissed"
    show
    :target="popoverTarget"
    :container="popoverContainer"
    placement="rightbottom"
  >
    <template #title>
      <button
        class="btn-blank float-right mt-1"
        type="button"
        :aria-label="__('Close')"
        :data-track-property="humanAccess"
        :data-track-value="$options.dismissTrackValue"
        :data-track-event="$options.trackEvent"
        :data-track-label="trackLabel"
        @click="dismissPopover"
      >
        <icon name="close" aria-hidden="true" />
      </button>
      {{ s__('mrWidget|Are you adding technical debt or code vulnerabilities?') }}
    </template>
    <div class="svg-content svg-150 pt-1">
      <img :src="pipelineSvgPath" />
    </div>
    <gl-sprintf :message="$options.helpContent">
      <template #link="{ content }">
        <gl-link :href="$options.helpURL" target="_blank" class="font-size-inherit">{{
          content
        }}</gl-link>
      </template>
    </gl-sprintf>
    <gl-deprecated-button
      ref="ok"
      category="primary"
      class="mt-2 mb-0"
      variant="info"
      block
      :href="pipelinePath"
      :data-track-property="humanAccess"
      :data-track-value="$options.showTrackValue"
      :data-track-event="$options.trackEvent"
      :data-track-label="trackLabel"
    >
      {{ __('Show me how to add a pipeline') }}
    </gl-deprecated-button>
    <gl-deprecated-button
      ref="no-thanks"
      category="secondary"
      class="mt-2 mb-0"
      variant="info"
      block
      :data-track-property="humanAccess"
      :data-track-value="$options.dismissTrackValue"
      :data-track-event="$options.trackEvent"
      :data-track-label="trackLabel"
      @click="dismissPopover"
    >
      {{ __('No thanks') }}
    </gl-deprecated-button>
  </gl-popover>
</template>