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' ;
2021-11-11 11:23:49 +05:30
import axios from '~/lib/utils/axios_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-11-11 11:23:49 +05:30
inject : [ 'svgPath' , 'trackLabel' , 'calloutsPath' , 'calloutsFeatureId' , 'groupId' ] ,
2020-11-24 15:15:51 +05:30
data ( ) {
return {
2021-11-11 11:23:49 +05:30
isDismissed : false ,
2020-11-24 15:15:51 +05:30
tracking : {
label : this . trackLabel ,
} ,
} ;
} ,
mounted ( ) {
this . trackOnShow ( ) ;
} ,
methods : {
handleClose ( ) {
2021-11-11 11:23:49 +05:30
axios
. post ( this . calloutsPath , {
feature _name : this . calloutsFeatureId ,
group _id : this . groupId ,
} )
. catch ( ( e ) => {
// eslint-disable-next-line @gitlab/require-i18n-strings, no-console
console . error ( 'Failed to dismiss banner.' , e ) ;
} ) ;
2020-11-24 15:15:51 +05:30
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 ( ) {
2023-05-27 22:25:52 +05:30
eventHub . $emit ( 'openModal' , { source : this . $options . openModalSource } ) ;
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' ,
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"
2021-11-11 11:23:49 +05:30
data - testid = "invite-members-banner"
2020-11-24 15:15:51 +05:30
: 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 >