"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8504],{6405:(j,s,n)=>{n.r(s),n.d(s,{default:()=>D});var t=n(74848),o=n(37e3),l=n(17618),g=n(13005),d=n(37104),y=n(32174),m=n(49785),A=n(48583),f=n(54594),S=n(43269),O=n(11817),p=n(61491),P=n(9912),F=n(48542),E=n(2473),G=n(88214),u=n(85651),L=n(72897),B=n(4013),I=n(77207);const h={smtp_require_tls:!0},M=({config:e,alertManagerSourceName:a})=>{const c=(0,p.useDispatch)();(0,S.o)(r=>r.unifiedAlerting.saveAMConfig=B.jA);const{loading:i,error:v}=(0,P.$)(r=>r.saveAMConfig),x=(0,G.AL)(a),C=(0,m.mN)({defaultValues:JSON.parse(JSON.stringify({...h,...e.alertmanager_config.global??{}}))}),{handleSubmit:U,formState:{errors:W}}=C,$=r=>{c((0,F.RW)({newConfig:{...e,alertmanager_config:{...e.alertmanager_config,global:(0,L.FN)(r)}},oldConfig:e,alertManagerSourceName:a,successMessage:"Global config updated.",redirectPath:(0,u.nL)("/alerting/notifications",a)}))};return(0,t.jsx)(m.Op,{...C,children:(0,t.jsxs)("form",{onSubmit:U($),children:[v&&(0,t.jsx)(o.F,{severity:"error",title:"Error saving receiver",children:v.message||String(v)}),E.U.map(r=>(0,t.jsx)(I.e,{readOnly:x,defaultValue:h[r.propertyName],option:r,error:W[r.propertyName],pathPrefix:""},r.propertyName)),(0,t.jsx)("div",{children:(0,t.jsxs)(A.B,{children:[!x&&(0,t.jsxs)(t.Fragment,{children:[i&&(0,t.jsx)(f.$n,{disabled:!0,icon:"spinner",variant:"primary",children:"Saving..."}),!i&&(0,t.jsx)(f.$n,{type:"submit",children:"Save global config"})]}),(0,t.jsx)(f.z9,{disabled:i,fill:"outline",variant:"secondary",href:(0,u.nL)("alerting/notifications",a),children:(0,t.jsx)(O.x6,{i18nKey:"alerting.common.cancel",children:"Cancel"})})]})})]})})},N=()=>{const{selectedAlertmanager:e}=(0,g.VI)(),{data:a,isLoading:c,error:i}=(0,l.f)(e);return c&&!a?"loading...":i?(0,t.jsx)(o.F,{severity:"error",title:"Failed to fetch notification template",children:String(i)}):a?(0,t.jsx)(M,{config:a,alertManagerSourceName:e}):null};function V(){return(0,t.jsx)(y.y,{navId:"receivers",accessType:"notification",children:(0,t.jsx)(N,{})})}const D=(0,d.S)(V)},17618:(j,s,n)=>{n.d(s,{f:()=>o});var t=n(9365);function o(l,g){const d=t.m.endpoints.getAlertmanagerConfiguration.useQuery(l??"",{refetchOnMountOrArgChange:!0,...g,skip:!l});return{...d,error:d.error}}}}]);

//# sourceMappingURL=GlobalConfig.e176788ed5e8a1ce7ec6.js.map