"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5799,335],{95500:(v,s,e)=>{e.d(s,{x:()=>c});var t=e(85960),o=e(95162),i=e(1992);function c(a){const m=(0,o.useDispatch)(),f=(0,t.useRef)(a);f.current=a,(0,t.useEffect)(()=>()=>{m((0,i.e)({cleanupAction:f.current}))},[m])}},95799:(v,s,e)=>{e.r(s),e.d(s,{default:()=>I});var t=e(85960),o=e(49199),i=e(70335),c=e(84954),a=e(53285),m=e(74042),f=e(29165),h=e(95500),p=e(95162),M=e(92746),O=e(5970),P=e(8764),D=e(76679),E=e(77294),R=e(2232),S=e(30422),x=e(8506);const C={smtp_require_tls:!0},L=({config:l,alertManagerSourceName:r})=>{const d=(0,p.useDispatch)();(0,h.x)(n=>n.unifiedAlerting.saveAMConfig=S.oq);const{loading:g,error:u}=(0,M._)(n=>n.saveAMConfig),A=(0,D.RY)(r),y=(0,a.cI)({defaultValues:JSON.parse(JSON.stringify({...C,...l.alertmanager_config.global??{}}))}),{handleSubmit:T,formState:{errors:U}}=y,W=n=>{d((0,O.mM)({newConfig:{...l,alertmanager_config:{...l.alertmanager_config,global:(0,R.oP)(n)}},oldConfig:l,alertManagerSourceName:r,successMessage:"Global config updated.",redirectPath:(0,E.eQ)("/alerting/notifications",r)}))};return t.createElement(a.RV,{...y},t.createElement("form",{onSubmit:T(W)},u&&t.createElement(o.b,{severity:"error",title:"Error saving receiver"},u.message||String(u)),P.g.map(n=>t.createElement(x.t,{readOnly:A,defaultValue:C[n.propertyName],key:n.propertyName,option:n,error:U[n.propertyName],pathPrefix:""})),t.createElement("div",null,t.createElement(m.Lh,null,!A&&t.createElement(t.Fragment,null,g&&t.createElement(f.zx,{disabled:!0,icon:"spinner",variant:"primary"},"Saving..."),!g&&t.createElement(f.zx,{type:"submit"},"Save global config")),t.createElement(f.Qj,{disabled:g,fill:"outline",variant:"secondary",href:(0,E.eQ)("alerting/notifications",r)},"Cancel")))))},I=()=>{const{selectedAlertmanager:l}=(0,c.ZA)(),{data:r,isLoading:d,error:g}=(0,i.W)(l);return d&&!r?"loading...":g?t.createElement(o.b,{severity:"error",title:"Failed to fetch notification template"},String(g)):r?t.createElement(L,{config:r,alertManagerSourceName:l}):null}},70335:(v,s,e)=>{e.d(s,{W:()=>o});var t=e(81828);function o(i,c){const a=t.alertmanagerApi.endpoints.getAlertmanagerConfiguration.useQuery(i??"",{...c,skip:!i});return{...a,error:a.error}}}}]);

//# sourceMappingURL=5799.5e34d11e6825c901a3f6.js.map