debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/help_popover.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.2 KiB
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
2023-03-04 22:38:38 +05:30
import { GlButton, GlPopover } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
2018-11-18 11:00:15 +05:30
/**
* Render a button with a question mark icon
* On hover shows a popover. The popover will be dismissed on mouseleave
*/
export default {
name: 'HelpPopover',
components: {
2021-02-22 17:27:13 +05:30
GlButton,
2021-03-11 19:13:27 +05:30
GlPopover,
2018-11-18 11:00:15 +05:30
},
2021-04-29 21:17:54 +05:30
directives: {
2023-03-04 22:38:38 +05:30
SafeHtml,
2021-04-29 21:17:54 +05:30
},
2018-11-18 11:00:15 +05:30
props: {
options: {
type: Object,
required: false,
default: () => ({}),
},
2023-01-13 00:05:48 +05:30
icon: {
type: String,
required: false,
default: 'question-o',
},
2018-11-18 11:00:15 +05:30
},
2022-06-21 17:19:12 +05:30
methods: {
targetFn() {
return this.$refs.popoverTrigger?.$el;
},
},
2018-11-18 11:00:15 +05:30
};
</script>
<template>
2021-03-11 19:13:27 +05:30
<span>
2023-01-13 00:05:48 +05:30
<gl-button ref="popoverTrigger" variant="link" :icon="icon" :aria-label="__('Help')" />
2022-06-21 17:19:12 +05:30
<gl-popover :target="targetFn" v-bind="options">
2021-04-29 21:17:54 +05:30
<template v-if="options.title" #title>
<span v-safe-html="options.title"></span>
2021-03-11 19:13:27 +05:30
</template>
<template #default>
2021-04-29 21:17:54 +05:30
<div v-safe-html="options.content"></div>
2021-03-11 19:13:27 +05:30
</template>
2022-08-13 15:12:31 +05:30
<!-- eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots -->
2022-04-04 11:22:00 +05:30
<template v-for="slot in Object.keys($slots)" #[slot]>
<slot :name="slot"></slot>
</template>
2021-03-11 19:13:27 +05:30
</gl-popover>
</span>
2018-11-18 11:00:15 +05:30
</template>