summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_pipeline_tour.vue
blob: f6bfb1784379604a14aa011dbbee080ea1512581 (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
<script>
import { GlPopover, GlDeprecatedButton } 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';

const trackingMixin = Tracking.mixin();

const cookieKey = 'suggest_pipeline_dismissed';

export default {
  name: 'MRWidgetPipelineTour',
  dismissTrackValue: 20,
  showTrackValue: 10,
  trackEvent: 'click_button',
  components: {
    GlPopover,
    GlDeprecatedButton,
    Icon,
  },
  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>
    <p>
      {{
        s__(
          'mrWidget|Detect issues before deployment with a CI pipeline that continuously tests your code. We created a quick guide that will show you how to create one. Make your code more secure and more robust in just a minute.',
        )
      }}
    </p>
    <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') }}
    </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, don't show this again") }}
    </gl-deprecated-button>
  </gl-popover>
</template>