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

//# sourceMappingURL=GlobalConfig.2af19abb8f52521649e5.js.map