2020-09-03 23:08:22 -04:00
< script >
import { GlBanner } from '@gitlab/ui' ;
2021-05-10 14:10:41 -04:00
import eventHub from '~/invite_members/event_hub' ;
2020-09-10 08:08:54 -04:00
import { parseBoolean , setCookie , getCookie } from '~/lib/utils/common_utils' ;
2021-02-14 13:09:20 -05:00
import { s _ _ } from '~/locale' ;
2020-09-16 11:09:32 -04:00
import Tracking from '~/tracking' ;
const trackingMixin = Tracking . mixin ( ) ;
2020-09-03 23:08:22 -04:00
export default {
components : {
GlBanner ,
} ,
2020-09-16 11:09:32 -04:00
mixins : [ trackingMixin ] ,
2021-05-10 14:10:41 -04:00
inject : [ 'svgPath' , 'isDismissedKey' , 'trackLabel' ] ,
2020-09-03 23:08:22 -04:00
data ( ) {
return {
2020-09-10 08:08:54 -04:00
isDismissed : parseBoolean ( getCookie ( this . isDismissedKey ) ) ,
2020-09-16 11:09:32 -04:00
tracking : {
label : this . trackLabel ,
} ,
2020-09-03 23:08:22 -04:00
} ;
} ,
2020-09-16 11:09:32 -04:00
mounted ( ) {
this . trackOnShow ( ) ;
} ,
2020-09-03 23:08:22 -04:00
methods : {
handleClose ( ) {
2020-09-10 08:08:54 -04:00
setCookie ( this . isDismissedKey , true ) ;
this . isDismissed = true ;
2020-09-16 11:09:32 -04:00
this . track ( this . $options . dismissEvent ) ;
} ,
trackOnShow ( ) {
2021-02-18 07:09:34 -05:00
this . $nextTick ( ( ) => {
if ( ! this . isDismissed ) this . track ( this . $options . displayEvent ) ;
} ) ;
2020-09-16 11:09:32 -04:00
} ,
2021-05-10 14:10:41 -04:00
openModal ( ) {
eventHub . $emit ( 'openModal' , {
inviteeType : 'members' ,
source : this . $options . openModalSource ,
} ) ;
this . track ( this . $options . buttonClickEvent ) ;
2020-09-03 23:08:22 -04:00
} ,
} ,
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' ) ,
} ,
2020-09-16 11:09:32 -04:00
displayEvent : 'invite_members_banner_displayed' ,
buttonClickEvent : 'invite_members_banner_button_clicked' ,
2021-05-10 14:10:41 -04:00
openModalSource : 'invite_members_banner' ,
2020-09-16 11:09:32 -04:00
dismissEvent : 'invite_members_banner_dismissed' ,
2020-09-03 23:08:22 -04:00
} ;
< / script >
< template >
< gl-banner
2020-09-10 08:08:54 -04:00
v - if = "!isDismissed"
2020-09-03 23:08:22 -04:00
ref = "banner"
: title = "$options.i18n.title"
: button - text = "$options.i18n.button_text"
: svg - path = "svgPath"
@ close = "handleClose"
2021-05-10 14:10:41 -04:00
@ primary = "openModal"
2020-09-03 23:08:22 -04:00
>
< p > { { $options . i18n . body } } < / p >
< / gl-banner >
< / template >