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

//# sourceMappingURL=GlobalConfig.691af6fe2c3eb4fdd0da.js.map