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 >