2020-04-22 19:07:51 +05:30
< script >
2021-11-18 22:05:49 +05:30
import {
GlButton ,
GlFormGroup ,
GlFormInput ,
GlModal ,
GlModalDirective ,
GlSprintf ,
GlLink ,
} from '@gitlab/ui' ;
2021-09-04 01:27:46 +05:30
import createFlash from '~/flash' ;
2020-04-22 19:07:51 +05:30
import axios from '~/lib/utils/axios_utils' ;
2021-11-18 22:05:49 +05:30
import { _ _ } from '~/locale' ;
2021-03-11 19:13:27 +05:30
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue' ;
2020-04-22 19:07:51 +05:30
export default {
copyToClipboard : _ _ ( 'Copy' ) ,
components : {
2020-10-24 23:57:45 +05:30
GlButton ,
2020-04-22 19:07:51 +05:30
GlFormGroup ,
GlFormInput ,
GlModal ,
ClipboardButton ,
2021-11-18 22:05:49 +05:30
GlSprintf ,
GlLink ,
2020-04-22 19:07:51 +05:30
} ,
directives : {
'gl-modal' : GlModalDirective ,
} ,
props : {
initialAuthorizationKey : {
type : String ,
required : false ,
default : '' ,
} ,
changeKeyUrl : {
type : String ,
required : true ,
} ,
notifyUrl : {
type : String ,
required : true ,
} ,
learnMoreUrl : {
type : String ,
required : true ,
} ,
2020-07-28 23:09:34 +05:30
disabled : {
type : Boolean ,
required : false ,
default : false ,
} ,
2020-04-22 19:07:51 +05:30
} ,
data ( ) {
return {
authorizationKey : this . initialAuthorizationKey ,
} ;
} ,
methods : {
resetKey ( ) {
axios
. post ( this . changeKeyUrl )
2021-03-08 18:12:59 +05:30
. then ( ( res ) => {
2020-04-22 19:07:51 +05:30
this . authorizationKey = res . data . token ;
} )
. catch ( ( ) => {
2021-09-04 01:27:46 +05:30
createFlash ( {
message : _ _ ( 'Failed to reset key. Please try again.' ) ,
} ) ;
2020-04-22 19:07:51 +05:30
} ) ;
} ,
} ,
} ;
< / script >
< template >
< div class = "row py-4 border-top js-prometheus-alerts" >
< div class = "col-lg-3" >
< h4 class = "mt-0" >
{ { _ _ ( 'Alerts' ) } }
< / h4 >
< p >
{ { _ _ ( 'Receive alerts from manually configured Prometheus servers.' ) } }
< / p >
< / div >
< div class = "col-lg-9" >
2021-11-18 22:05:49 +05:30
< gl-sprintf
: message = "
_ _ (
'To receive alerts from manually configured Prometheus services, add the following URL and Authorization key to your Prometheus webhook config file. Learn more about %{linkStart}configuring Prometheus%{linkEnd} to send alerts to GitLab.' ,
)
"
>
< template # link = "{ content }" >
< gl-link :href = "learnMoreUrl" target = "_blank" > { { content } } < / gl-link >
< / template >
< / gl-sprintf >
2020-04-22 19:07:51 +05:30
< gl-form-group :label = "__('URL')" label -for = " notify -url " label -class = " label -bold " >
< div class = "input-group" >
< gl-form-input id = "notify-url" :readonly = "true" :value = "notifyUrl" / >
< span class = "input-group-append" >
2020-07-28 23:09:34 +05:30
< clipboard-button
: text = "notifyUrl"
: title = "$options.copyToClipboard"
: disabled = "disabled"
/ >
2020-04-22 19:07:51 +05:30
< / span >
< / div >
< / gl-form-group >
< gl-form-group
: label = "__('Authorization key')"
label - for = "authorization-key"
label - class = "label-bold"
>
< div class = "input-group" >
< gl-form-input id = "authorization-key" :readonly = "true" :value = "authorizationKey" / >
< span class = "input-group-append" >
2020-07-28 23:09:34 +05:30
< clipboard-button
: text = "authorizationKey"
: title = "$options.copyToClipboard"
: disabled = "disabled"
/ >
2020-04-22 19:07:51 +05:30
< / span >
< / div >
< / gl-form-group >
< template v-if = "authorizationKey.length > 0" >
< gl-modal
modal - id = "authKeyModal"
: title = "__('Reset authorization key?')"
: ok - title = "__('Reset authorization key')"
ok - variant = "danger"
@ ok = "resetKey"
>
{ {
_ _ (
'Resetting the authorization key will invalidate the previous key. Existing alert configurations will need to be updated with the new key.' ,
)
} }
< / gl-modal >
2020-10-24 23:57:45 +05:30
< gl-button v -gl -modal .authKeyModal class = "js-reset-auth-key" :disabled = "disabled" > { {
_ _ ( 'Reset key' )
} } < / gl-button >
2020-04-22 19:07:51 +05:30
< / template >
2020-10-24 23:57:45 +05:30
< gl-button v -else :disabled = "disabled" class = "js-reset-auth-key" @click ="resetKey" > {{
_ _ ( 'Generate key' )
} } < / gl-button >
2020-04-22 19:07:51 +05:30
< / div >
< / div >
< / template >