summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipeline_editor/components/popovers/file_tree_popover.vue
blob: efa6a54c6383b5712db39fd12c4cffc833d2d01b (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
<script>
import { GlLink, GlPopover, GlOutsideDirective as Outside, GlSprintf } from '@gitlab/ui';
import { s__ } from '~/locale';
import { FILE_TREE_POPOVER_DISMISSED_KEY } from '../../constants';

export default {
  name: 'PipelineEditorFileTreePopover',
  directives: { Outside },
  i18n: {
    description: s__(
      'pipelineEditorWalkthrough|You can use the file tree to view your pipeline configuration files. %{linkStart}Learn more%{linkEnd}',
    ),
  },
  components: {
    GlLink,
    GlPopover,
    GlSprintf,
  },
  inject: ['includesHelpPagePath'],
  data() {
    return {
      showPopover: false,
    };
  },
  mounted() {
    this.showPopover = localStorage.getItem(FILE_TREE_POPOVER_DISMISSED_KEY) !== 'true';
  },
  methods: {
    dismissPermanently() {
      this.showPopover = false;
      localStorage.setItem(FILE_TREE_POPOVER_DISMISSED_KEY, 'true');
    },
  },
};
</script>

<template>
  <gl-popover
    v-if="showPopover"
    show
    show-close-button
    target="file-tree-toggle"
    triggers="manual"
    placement="right"
    data-qa-selector="file_tree_popover"
    @close-button-clicked="dismissPermanently"
  >
    <div v-outside="dismissPermanently" class="gl-font-base gl-mb-3">
      <gl-sprintf :message="$options.i18n.description">
        <template #link="{ content }">
          <gl-link :href="includesHelpPagePath" target="_blank">{{ content }}</gl-link>
        </template>
      </gl-sprintf>
    </div>
  </gl-popover>
</template>