"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7680],{"./public/app/core/hooks/useQueryParams.ts":(e,r,t)=>{t.d(r,{K:()=>s});var n=t("./packages/grafana-runtime/src/index.ts"),a=t("./node_modules/react/index.js"),i=t("./node_modules/react-router/esm/react-router.js");function s(){const{search:e}=(0,i.TH)();return[(0,a.useMemo)((()=>(0,n.locationSearchToObject)(e||"")),[e]),(0,a.useCallback)(((e,r)=>setImmediate((()=>n.locationService.partial(e,r)))),[])]}},"./public/app/features/alerting/unified/Admin.tsx":(e,r,t)=>{t.r(r),t.d(r,{default:()=>m});var n,a=t("./node_modules/react/index.js"),i=t("./packages/grafana-ui/src/index.ts"),s=t("./public/app/features/alerting/unified/hooks/useAlertManagerSourceName.ts"),o=t("./public/app/features/alerting/unified/components/AlertingPageWrapper.tsx"),u=t("./public/app/features/alerting/unified/components/AlertManagerPicker.tsx"),l=t("./public/app/features/alerting/unified/utils/datasource.ts"),c=t("./node_modules/react-redux/es/index.js"),d=t("./public/app/features/alerting/unified/state/actions.ts"),g=t("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts"),p=t("./public/app/features/alerting/unified/utils/redux.ts"),f=t("./node_modules/react/jsx-runtime.js");function m(){var e;const r=(0,c.useDispatch)(),[t,m]=(0,s.k)(),[x,h]=(0,a.useState)(!1),{loading:b}=(0,g._)((e=>e.deleteAMConfig)),{loading:j}=(0,g._)((e=>e.saveAMConfig)),v=!!t&&(0,l.RY)(t),C=(0,g._)((e=>e.amConfigs)),{result:S,loading:k,error:A}=t&&C[t]||p.oq;(0,a.useEffect)((()=>{t&&r((0,d.Yh)(t))}),[t,r]);const y=()=>{t&&r((0,d.Nc)(t)),h(!1)},M=(0,a.useMemo)((()=>({configJSON:S?JSON.stringify(S,null,2):""})),[S]),N=b||k||j;return(0,f.jsxs)(o.J,{pageId:"alerting-admin",children:[(0,f.jsx)(u.P,{current:t,onChange:m}),A&&!N&&(0,f.jsx)(i.Alert,{severity:"error",title:"Error loading Alertmanager configuration",children:A.message||"Unknown error."}),b&&t!==l.GC&&(n||(n=(0,f.jsx)(i.Alert,{severity:"info",title:"Resetting Alertmanager configuration",children:"It might take a while..."}))),t&&S&&(0,f.jsx)(i.Form,{defaultValues:M,onSubmit:e=>{t&&r((0,d.mM)({newConfig:JSON.parse(e.configJSON),oldConfig:S,alertManagerSourceName:t,successMessage:"Alertmanager configuration updated.",refetch:!0}))},children:({register:r,errors:n})=>{var a;return(0,f.jsxs)(f.Fragment,{children:[!v&&(0,f.jsx)(i.Field,{disabled:N,label:"Configuration",invalid:!!n.configJSON,error:null===(a=n.configJSON)||void 0===a?void 0:a.message,children:(0,f.jsx)(i.TextArea,Object.assign({},r("configJSON",{required:{value:!0,message:"Required."},validate:e=>{try{return JSON.parse(e),!0}catch(e){return e.message}}}),{id:"configuration",rows:25}))}),v&&(0,f.jsx)(i.Field,{label:"Configuration",children:(0,f.jsx)("pre",{"data-testid":"readonly-config",children:M.configJSON})}),!v&&(0,f.jsxs)(i.HorizontalGroup,{children:[e||(e=(0,f.jsx)(i.Button,{type:"submit",variant:"primary",disabled:N,children:"Save"})),(0,f.jsx)(i.Button,{type:"button",disabled:N,variant:"destructive",onClick:()=>h(!0),children:"Reset configuration"})]}),!!x&&(0,f.jsx)(i.ConfirmModal,{isOpen:!0,title:"Reset Alertmanager configuration",body:`Are you sure you want to reset configuration ${t===l.GC?"for the Grafana Alertmanager":`for "${t}"`}? Contact points and notification policies will be reset to their defaults.`,confirmText:"Yes, reset configuration",onConfirm:y,onDismiss:()=>h(!1)})]})}},M.configJSON)]})}},"./public/app/features/alerting/unified/components/AlertingPageWrapper.tsx":(e,r,t)=>{t.d(r,{J:()=>o});t("./node_modules/react/index.js");var n=t("./public/app/core/components/Page/Page.tsx"),a=t("./public/app/core/selectors/navModel.ts"),i=t("./node_modules/react-redux/es/index.js"),s=t("./node_modules/react/jsx-runtime.js");const o=({children:e,pageId:r,isLoading:t})=>{const o=(0,a.h)((0,i.useSelector)((e=>e.navIndex)),r);return(0,s.jsx)(n.Z,{navModel:o,children:(0,s.jsx)(n.Z.Contents,{isLoading:t,children:e})})}},"./public/app/features/alerting/unified/hooks/useAlertManagerSourceName.ts":(e,r,t)=>{t.d(r,{k:()=>l});var n=t("./public/app/core/hooks/useQueryParams.ts"),a=t("./public/app/core/store.ts"),i=t("./node_modules/react/index.js"),s=t("./public/app/features/alerting/unified/utils/constants.ts"),o=t("./public/app/features/alerting/unified/utils/datasource.ts");function u(e){return e===o.GC||!!(0,o.aM)().find((r=>r.name===e))}function l(){const[e,r]=(0,n.K)(),t=(0,i.useCallback)((e=>{u(e)&&(e===o.GC?(a.Z.delete(s.de),r({[s.c4]:null})):(a.Z.set(s.de,e),r({[s.c4]:e})))}),[r]),l=e[s.c4];if(l&&"string"==typeof l)return u(l)?[l,t]:[void 0,t];const c=a.Z.get(s.de);return c&&"string"==typeof c&&u(c)?(t(c),[c,t]):[o.GC,t]}}}]);
//# sourceMappingURL=AlertingAdmin.8128b05ac04b15cbf98d.js.map