debian-mirror-gitlab/app/assets/javascripts/groups/components/invite_members_banner.vue

73 lines
1.9 KiB
Vue
Raw Normal View History

2020-11-24 15:15:51 +05:30
<script>
import { GlBanner } from '@gitlab/ui';
2021-06-08 01:23:25 +05:30
import eventHub from '~/invite_members/event_hub';
2020-11-24 15:15:51 +05:30
import { parseBoolean, setCookie, getCookie } from '~/lib/utils/common_utils';
2021-03-11 19:13:27 +05:30
import { s__ } from '~/locale';
2020-11-24 15:15:51 +05:30
import Tracking from '~/tracking';
const trackingMixin = Tracking.mixin();
export default {
components: {
GlBanner,
},
mixins: [trackingMixin],
2021-06-08 01:23:25 +05:30
inject: ['svgPath', 'isDismissedKey', 'trackLabel'],
2020-11-24 15:15:51 +05:30
data() {
return {
isDismissed: parseBoolean(getCookie(this.isDismissedKey)),
tracking: {
label: this.trackLabel,
},
};
},
mounted() {
this.trackOnShow();
},
methods: {
handleClose() {
setCookie(this.isDismissedKey, true);
this.isDismissed = true;
this.track(this.$options.dismissEvent);
},
trackOnShow() {
2021-04-17 20:07:23 +05:30
this.$nextTick(() => {
if (!this.isDismissed) this.track(this.$options.displayEvent);
});
2020-11-24 15:15:51 +05:30
},
2021-06-08 01:23:25 +05:30
openModal() {
eventHub.$emit('openModal', {
inviteeType: 'members',
source: this.$options.openModalSource,
});
this.track(this.$options.buttonClickEvent);
2020-11-24 15:15:51 +05:30
},
},
i18n: {
title: s__('InviteMembersBanner|Collaborate with your team'),
body: s__(
"InviteMembersBanner|We noticed that you haven't invited anyone to this group. Invite your colleagues so you can discuss issues, collaborate on merge requests, and share your knowledge.",
),
button_text: s__('InviteMembersBanner|Invite your colleagues'),
},
displayEvent: 'invite_members_banner_displayed',
buttonClickEvent: 'invite_members_banner_button_clicked',
2021-06-08 01:23:25 +05:30
openModalSource: 'invite_members_banner',
2020-11-24 15:15:51 +05:30
dismissEvent: 'invite_members_banner_dismissed',
};
</script>
<template>
<gl-banner
v-if="!isDismissed"
ref="banner"
:title="$options.i18n.title"
:button-text="$options.i18n.button_text"
:svg-path="svgPath"
@close="handleClose"
2021-06-08 01:23:25 +05:30
@primary="openModal"
2020-11-24 15:15:51 +05:30
>
<p>{{ $options.i18n.body }}</p>
</gl-banner>
</template>