summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue
blob: fa3c19921df05f5f1bb97fb434b86497ffce5b7d (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
<script>
import { GlPopover, GlSprintf, GlButton, GlIcon } from '@gitlab/ui';
import Cookies from 'js-cookie';
import { parseBoolean } from '~/lib/utils/common_utils';
import { s__ } from '~/locale';
import { glEmojiTag } from '~/emoji';

export default {
  components: {
    GlPopover,
    GlSprintf,
    GlIcon,
    GlButton,
  },
  props: {
    target: {
      type: String,
      required: true,
    },
    cssClass: {
      type: String,
      required: true,
    },
    dismissKey: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      popoverDismissed: parseBoolean(Cookies.get(this.dismissKey)),
    };
  },
  computed: {
    suggestTitle() {
      return s__(`suggestPipeline|1/2: Choose a template`);
    },
    suggestContent() {
      return s__(
        `suggestPipeline|We recommend the %{boldStart}Code Quality%{boldEnd} template, which will add a report widget to your Merge Requests. This way you’ll learn about code quality degradations much sooner. %{footerStart} Goodbye technical debt! %{footerEnd}`,
      );
    },
    emoji() {
      return glEmojiTag('wave');
    },
  },
  methods: {
    onDismiss() {
      this.popoverDismissed = true;
      Cookies.set(this.dismissKey, this.popoverDismissed, { expires: 365 });
    },
  },
};
</script>

<template>
  <gl-popover
    v-if="!popoverDismissed"
    show
    :target="target"
    placement="rightbottom"
    trigger="manual"
    container="viewport"
    :css-classes="[cssClass]"
  >
    <template #title>
      <gl-button :aria-label="__('Close')" class="btn-blank float-right" @click="onDismiss">
        <gl-icon name="close" aria-hidden="true" />
      </gl-button>
      {{ suggestTitle }}
    </template>

    <gl-sprintf :message="suggestContent">
      <template #bold="{content}">
        <strong> {{ content }} </strong>
      </template>
      <template #footer="{content}">
        <div class="mt-3">
          {{ content }}
          <span v-html="emoji"></span>
        </div>
      </template>
    </gl-sprintf>
  </gl-popover>
</template>