"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8504],{19644(W,f,n){n.r(f),n.d(f,{default:()=>$});var t=n(74848),e=n(92745),d=n(34999),u=n(47215),j=n(5358),y=n(88547),C=n(36826),c=n(49785),A=n(41654),o=n(45861),S=n(38396),F=n(52763),P=n(98127),G=n(11018),N=n(51740),O=n(52161),v=n(77256),L=n(22316),V=n(36200),p=n(28365);const m={smtp_require_tls:!0},B=({config:i,alertManagerSourceName:a})=>{const s=(0,F.wA)();(0,S.o)(r=>r.unifiedAlerting.saveAMConfig=V.jA);const{loading:l,error:g}=(0,P.$)(r=>r.saveAMConfig),h=(0,O.AL)(a),x=(0,c.mN)({defaultValues:JSON.parse(JSON.stringify({...m,...i.alertmanager_config.global??{}}))}),{handleSubmit:E,formState:{errors:J}}=x,U=r=>{s((0,G.RW)({newConfig:{...i,alertmanager_config:{...i.alertmanager_config,global:(0,L.FN)(r)}},oldConfig:i,alertManagerSourceName:a,successMessage:"Global config updated.",redirectPath:(0,v.nL)("/alerting/notifications",a)}))};return(0,t.jsx)(c.Op,{...x,children:(0,t.jsxs)("form",{onSubmit:E(U),children:[g&&(0,t.jsx)(d.F,{severity:"error",title:(0,e.t)("alerting.global-config-form.title-error-saving-receiver","Error saving receiver"),children:g.message||String(g)}),N.U.map(r=>(0,t.jsx)(p.e,{readOnly:h,defaultValue:m[r.propertyName],option:r,error:J[r.propertyName],pathPrefix:"",secureFields:{}},r.propertyName)),(0,t.jsx)("div",{children:(0,t.jsxs)(A.B,{children:[!h&&(0,t.jsxs)(t.Fragment,{children:[l&&(0,t.jsx)(o.$n,{disabled:!0,icon:"spinner",variant:"primary",children:(0,t.jsx)(e.x6,{i18nKey:"alerting.global-config-form.saving",children:"Saving..."})}),!l&&(0,t.jsx)(o.$n,{type:"submit",children:(0,t.jsx)(e.x6,{i18nKey:"alerting.global-config-form.save-global-config",children:"Save global config"})})]}),(0,t.jsx)(o.z9,{disabled:l,fill:"outline",variant:"secondary",href:(0,v.nL)("alerting/notifications",a),children:(0,t.jsx)(e.x6,{i18nKey:"alerting.common.cancel",children:"Cancel"})})]})})]})})},I=()=>{const{selectedAlertmanager:i}=(0,j.VI)(),{data:a,isLoading:s,error:l}=(0,u.f)(i);return s&&!a?"loading...":l?(0,t.jsx)(d.F,{severity:"error",title:(0,e.t)("alerting.global-config.title-failed-to-fetch-notification-template","Failed to fetch notification template"),children:String(l)}):a?(0,t.jsx)(B,{config:a,alertManagerSourceName:i}):null};function K(){return(0,t.jsx)(C.y,{navId:"receivers",accessType:"notification",children:(0,t.jsx)(I,{})})}const $=(0,y.S)(K)}}]);

//# sourceMappingURL=GlobalConfig.9602deed4216af51ccf1.js.map