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

//# sourceMappingURL=GlobalConfig-react19.f6acb2c858d77583ff4c.js.map