2020-04-08 14:13:33 +05:30
< script >
2020-11-24 15:15:51 +05:30
import { GlModal , GlSprintf , GlLink , GlButton } from '@gitlab/ui' ;
2020-04-08 14:13:33 +05:30
import Cookies from 'js-cookie' ;
2020-10-24 23:57:45 +05:30
import { sprintf , s _ _ , _ _ } from '~/locale' ;
2020-04-08 14:13:33 +05:30
import { glEmojiTag } from '~/emoji' ;
2020-04-22 19:07:51 +05:30
import Tracking from '~/tracking' ;
const trackingMixin = Tracking . mixin ( ) ;
2020-04-08 14:13:33 +05:30
export default {
beginnerLink :
'https://about.gitlab.com/blog/2018/01/22/a-beginners-guide-to-continuous-integration/' ,
exampleLink : 'https://docs.gitlab.com/ee/ci/examples/' ,
2020-10-24 23:57:45 +05:30
codeQualityLink : 'https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html' ,
2020-04-08 14:13:33 +05:30
bodyMessage : s _ _ (
2020-10-24 23:57:45 +05:30
` MR widget|The pipeline will test your code on every commit. A %{codeQualityLinkStart}code quality report%{codeQualityLinkEnd} will appear in your merge requests to warn you about potential code degradations. ` ,
) ,
helpMessage : s _ _ (
` MR widget|Take a look at our %{beginnerLinkStart}Beginner's Guide to Continuous Integration%{beginnerLinkEnd} and our %{exampleLinkStart}examples of GitLab CI/CD%{exampleLinkEnd} to learn more. ` ,
2020-04-08 14:13:33 +05:30
) ,
2020-11-24 15:15:51 +05:30
pipelinesButton : s _ _ ( 'MR widget|See your pipeline in action' ) ,
mergeRequestButton : s _ _ ( 'MR widget|Back to the Merge request' ) ,
2020-04-08 14:13:33 +05:30
modalTitle : sprintf (
_ _ ( "That's it, well done!%{celebrate}" ) ,
{
celebrate : glEmojiTag ( 'tada' ) ,
} ,
false ,
) ,
2020-11-24 15:15:51 +05:30
goToTrackValuePipelines : 10 ,
goToTrackValueMergeRequest : 20 ,
2020-04-22 19:07:51 +05:30
trackEvent : 'click_button' ,
2020-04-08 14:13:33 +05:30
components : {
GlModal ,
GlSprintf ,
2020-11-24 15:15:51 +05:30
GlButton ,
2020-04-08 14:13:33 +05:30
GlLink ,
} ,
2020-04-22 19:07:51 +05:30
mixins : [ trackingMixin ] ,
2020-04-08 14:13:33 +05:30
props : {
goToPipelinesPath : {
type : String ,
required : true ,
} ,
2020-11-24 15:15:51 +05:30
projectMergeRequestsPath : {
type : String ,
required : false ,
default : '' ,
} ,
2020-04-08 14:13:33 +05:30
commitCookie : {
type : String ,
required : true ,
} ,
2020-04-22 19:07:51 +05:30
humanAccess : {
type : String ,
required : true ,
} ,
} ,
data ( ) {
return {
trackLabel : 'congratulate_first_pipeline' ,
} ;
} ,
computed : {
tracking ( ) {
return {
label : this . trackLabel ,
property : this . humanAccess ,
} ;
} ,
2020-11-24 15:15:51 +05:30
goToMergeRequestPath ( ) {
return this . commitCookiePath || this . projectMergeRequestsPath ;
} ,
commitCookiePath ( ) {
const cookieVal = Cookies . get ( this . commitCookie ) ;
if ( cookieVal !== 'true' ) return cookieVal ;
return '' ;
} ,
2020-04-08 14:13:33 +05:30
} ,
mounted ( ) {
2020-04-22 19:07:51 +05:30
this . track ( ) ;
2020-04-08 14:13:33 +05:30
this . disableModalFromRenderingAgain ( ) ;
} ,
methods : {
disableModalFromRenderingAgain ( ) {
Cookies . remove ( this . commitCookie ) ;
} ,
} ,
} ;
< / script >
< template >
< gl-modal
visible
size = "sm"
: title = "$options.modalTitle"
modal - id = "success-pipeline-modal-id-not-used"
>
< p >
2020-10-24 23:57:45 +05:30
< gl-sprintf :message = "$options.bodyMessage" >
< template # codeQualityLink = "{content}" >
< gl-link :href = "$options.codeQualityLink" target = "_blank" class = "font-size-inherit" > { {
content
} } < / gl-link >
< / template >
< / gl-sprintf >
2020-04-08 14:13:33 +05:30
< / p >
2020-10-24 23:57:45 +05:30
< gl-sprintf :message = "$options.helpMessage" >
2020-04-08 14:13:33 +05:30
< template # beginnerLink = "{content}" >
< gl-link :href = "$options.beginnerLink" target = "_blank" >
{ { content } }
< / gl-link >
< / template >
< template # exampleLink = "{content}" >
< gl-link :href = "$options.exampleLink" target = "_blank" >
{ { content } }
< / gl-link >
< / template >
< / gl-sprintf >
< template # modal -footer >
2020-11-24 15:15:51 +05:30
< gl-button
v - if = "projectMergeRequestsPath"
ref = "goToMergeRequest"
: href = "goToMergeRequestPath"
: data - track - property = "humanAccess"
: data - track - value = "$options.goToTrackValueMergeRequest"
: data - track - event = "$options.trackEvent"
: data - track - label = "trackLabel"
>
{ { $options . mergeRequestButton } }
< / gl-button >
< gl-button
ref = "goToPipelines"
2020-04-22 19:07:51 +05:30
: href = "goToPipelinesPath"
2020-11-24 15:15:51 +05:30
variant = "success"
2020-04-22 19:07:51 +05:30
: data - track - property = "humanAccess"
2020-11-24 15:15:51 +05:30
: data - track - value = "$options.goToTrackValuePipelines"
2020-04-22 19:07:51 +05:30
: data - track - event = "$options.trackEvent"
: data - track - label = "trackLabel"
>
2020-11-24 15:15:51 +05:30
{ { $options . pipelinesButton } }
< / gl-button >
2020-04-08 14:13:33 +05:30
< / template >
< / gl-modal >
< / template >