summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/feature_highlight/feature_highlight_popover.vue
blob: 24f7d567ea7ba91b5fa1e915e1ecb3e653cb52a6 (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
<script>
import clusterPopover from '@gitlab/svgs/dist/illustrations/cluster_popover.svg?raw';
import { GlPopover, GlSprintf, GlLink, GlButton } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
import { __ } from '~/locale';
import { POPOVER_TARGET_ID } from './constants';
import { dismiss } from './feature_highlight_helper';

export default {
  components: {
    GlPopover,
    GlSprintf,
    GlLink,
    GlButton,
  },
  directives: {
    SafeHtml,
  },
  props: {
    autoDevopsHelpPath: {
      type: String,
      required: true,
    },
    highlightId: {
      type: String,
      required: true,
    },
    dismissEndpoint: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      dismissed: false,
      triggerHidden: false,
    };
  },
  methods: {
    dismiss() {
      dismiss(this.dismissEndpoint, this.highlightId);
      this.$refs.popover.$emit('close');
      this.dismissed = true;
    },
    hideTrigger() {
      if (this.dismissed) {
        this.triggerHidden = true;
      }
    },
  },
  clusterPopover,
  targetId: POPOVER_TARGET_ID,
  i18n: {
    highlightMessage: __('Allows you to add and manage Kubernetes clusters.'),
    autoDevopsProTipMessage: __(
      'Protip: %{linkStart}Auto DevOps%{linkEnd} uses Kubernetes clusters to deploy your code!',
    ),
    dismissButtonLabel: __('Got it!'),
  },
};
</script>
<template>
  <div class="gl-ml-3">
    <span v-if="!triggerHidden" :id="$options.targetId" class="feature-highlight"></span>
    <gl-popover
      ref="popover"
      :target="$options.targetId"
      :css-classes="['feature-highlight-popover']"
      container="body"
      placement="right"
      boundary="viewport"
      @hidden="hideTrigger"
    >
      <span
        v-safe-html="$options.clusterPopover"
        class="feature-highlight-illustration gl-display-flex gl-justify-content-center gl-py-4 gl-w-full"
      ></span>
      <div class="gl-px-4 gl-py-5">
        <p>
          {{ $options.i18n.highlightMessage }}
        </p>
        <p>
          <gl-sprintf :message="$options.i18n.autoDevopsProTipMessage">
            <template #link="{ content }">
              <gl-link class="gl-font-sm" :href="autoDevopsHelpPath">{{ content }}</gl-link>
            </template>
          </gl-sprintf>
        </p>
        <gl-button size="small" icon="thumb-up" variant="confirm" @click="dismiss">
          {{ $options.i18n.dismissButtonLabel }}
        </gl-button>
      </div>
    </gl-popover>
  </div>
</template>