2020-11-24 15:15:51 +05:30
< script >
import { GlBanner } from '@gitlab/ui' ;
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 ] ,
inject : [ 'svgPath' , 'inviteMembersPath' , 'isDismissedKey' , 'trackLabel' ] ,
data ( ) {
return {
isDismissed : parseBoolean ( getCookie ( this . isDismissedKey ) ) ,
tracking : {
label : this . trackLabel ,
} ,
} ;
} ,
created ( ) {
this . $nextTick ( ( ) => {
this . addTrackingAttributesToButton ( ) ;
} ) ;
} ,
mounted ( ) {
this . trackOnShow ( ) ;
} ,
methods : {
handleClose ( ) {
setCookie ( this . isDismissedKey , true ) ;
this . isDismissed = true ;
this . track ( this . $options . dismissEvent ) ;
} ,
trackOnShow ( ) {
if ( ! this . isDismissed ) this . track ( this . $options . displayEvent ) ;
} ,
addTrackingAttributesToButton ( ) {
if ( this . $refs . banner === undefined ) return ;
const button = this . $refs . banner . $el . querySelector ( ` [href=' ${ this . inviteMembersPath } '] ` ) ;
if ( button ) {
button . setAttribute ( 'data-track-event' , this . $options . buttonClickEvent ) ;
button . setAttribute ( 'data-track-label' , this . trackLabel ) ;
}
} ,
} ,
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' ,
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"
: button - link = "inviteMembersPath"
@ close = "handleClose"
>
< p > { { $options . i18n . body } } < / p >
< / gl-banner >
< / template >