"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9199,1488],{40715:(v,s,e)=>{e.d(s,{o:()=>c});var t=e(96540),o=e(80348),i=e(97007);function c(a){const g=(0,o.useDispatch)(),f=(0,t.useRef)(a);f.current=a,(0,t.useEffect)(()=>()=>{g((0,i.N)({cleanupAction:f.current}))},[g])}},99199:(v,s,e)=>{e.r(s),e.d(s,{default:()=>R});var t=e(96540),o=e(42418),i=e(51488),c=e(70383),a=e(49785),g=e(66864),f=e(55852),p=e(40715),h=e(80348),O=e(61410),M=e(23770),P=e(21607),D=e(57220),E=e(56361),L=e(72399),S=e(88467),F=e(71854);const C={smtp_require_tls:!0},N=({config:l,alertManagerSourceName:r})=>{const d=(0,h.useDispatch)();(0,p.o)(n=>n.unifiedAlerting.saveAMConfig=S.jA);const{loading:m,error:u}=(0,O.$)(n=>n.saveAMConfig),A=(0,D.AL)(r),y=(0,a.mN)({defaultValues:JSON.parse(JSON.stringify({...C,...l.alertmanager_config.global??{}}))}),{handleSubmit:U,formState:{errors:I}}=y,T=n=>{d((0,M.RW)({newConfig:{...l,alertmanager_config:{...l.alertmanager_config,global:(0,L.FN)(n)}},oldConfig:l,alertManagerSourceName:r,successMessage:"Global config updated.",redirectPath:(0,E.nL)("/alerting/notifications",r)}))};return t.createElement(a.Op,{...y},t.createElement("form",{onSubmit:U(T)},u&&t.createElement(o.F,{severity:"error",title:"Error saving receiver"},u.message||String(u)),P.U.map(n=>t.createElement(F.e,{readOnly:A,defaultValue:C[n.propertyName],key:n.propertyName,option:n,error:I[n.propertyName],pathPrefix:""})),t.createElement("div",null,t.createElement(g.Gy,null,!A&&t.createElement(t.Fragment,null,m&&t.createElement(f.$n,{disabled:!0,icon:"spinner",variant:"primary"},"Saving..."),!m&&t.createElement(f.$n,{type:"submit"},"Save global config")),t.createElement(f.z9,{disabled:m,fill:"outline",variant:"secondary",href:(0,E.nL)("alerting/notifications",r)},"Cancel")))))},R=()=>{const{selectedAlertmanager:l}=(0,c.VI)(),{data:r,isLoading:d,error:m}=(0,i.f)(l);return d&&!r?"loading...":m?t.createElement(o.F,{severity:"error",title:"Failed to fetch notification template"},String(m)):r?t.createElement(N,{config:r,alertManagerSourceName:l}):null}},51488:(v,s,e)=>{e.d(s,{f:()=>o});var t=e(82843);function o(i,c){const a=t.m.endpoints.getAlertmanagerConfiguration.useQuery(i??"",{...c,skip:!i});return{...a,error:a.error}}}}]);

//# sourceMappingURL=9199.9897e268d6d13e834d4c.js.map