"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9224],{51866:(A,p,e)=>{e.r(p),e.d(p,{default:()=>R});var t=e(74848),o=e(54148),d=e(81876),s=e(37e3),n=e(22961),a=e(11817),L=e(75764),g=e(13005),M=e(36826),C=e(85651),D=e(5900),u=e(35874),f=e(37104),x=e(32174),T=e(38979),v=e(6353),j=e(50292);const E=(0,t.jsx)(n.L,{entity:"Notification template"}),F=()=>{const{selectedAlertmanager:i}=(0,g.VI)(),{name:r}=(0,o.g)(),c=r?decodeURIComponent(r):void 0,{currentData:l,isLoading:N,error:m}=(0,j.J2)({alertmanager:i??"",uid:c??""}),{currentData:y,isLoading:Z,error:W}=(0,j.cC)({alertmanager:i??""}),H=N||Z,h=m||W;if(!i)return(0,t.jsx)(n.L,{entity:"Alertmanager"});if(!c)return(0,t.jsx)(n.L,{entity:"Notification template"});if(H)return(0,t.jsx)(d._,{text:"Loading notification template"});if(h)return(0,L.E)(h)?E:(0,t.jsx)(s.F,{title:"Error loading notification template",severity:"error",children:(0,C.JZ)(h)});if(!l)return E;const K=(0,M.V)(l.title,y?.map(O=>O.title)??[]);return(0,t.jsx)(T.By,{alertmanager:i,prefill:{title:K,content:(0,D.a)(l.content)}})};function V(){return(0,t.jsx)(x.y,{navId:"receivers",accessType:"notification",pageNav:{id:"templates",text:(0,a.t)("alerting.notification-templates.duplicate.title","Duplicate notification template group"),subTitle:(0,a.t)("alerting.notification-templates.duplicate.subTitle","Duplicate a group of notification templates"),parentItem:{text:(0,a.t)("alerting.common.titles.notification-templates","Notification Templates"),url:(0,u.G)("/alerting/notifications",{tab:v.ActiveTab.NotificationTemplates})}},children:(0,t.jsx)(F,{})})}const B=(0,f.S)(V),I=(0,t.jsx)(n.L,{entity:"Notification template"}),P=()=>{const{name:i}=(0,o.g)(),r=i?decodeURIComponent(i):void 0,{selectedAlertmanager:c}=(0,g.VI)(),{currentData:l,isLoading:N,error:m,isUninitialized:y}=(0,j.J2)({alertmanager:c??"",uid:r??""});return r?N||y?(0,t.jsx)(d._,{text:"Loading template..."}):m?(0,L.E)(m)?I:(0,t.jsx)(s.F,{severity:"error",title:"Failed to fetch notification template",children:(0,C.JZ)(m)}):l?(0,t.jsx)(T.By,{alertmanager:c??"",originalTemplate:l}):I:(0,t.jsx)(n.L,{entity:"Notification template"})};function U(){return(0,t.jsx)(x.y,{navId:"receivers",accessType:"notification",pageNav:{id:"templates",text:(0,a.t)("alerting.notification-templates.edit.title","Edit notification template group"),subTitle:(0,a.t)("alerting.notification-templates.edit.subTitle","Edit a group of notification templates"),parentItem:{text:(0,a.t)("alerting.common.titles.notification-templates","Notification Templates"),url:(0,u.G)("/alerting/notifications",{tab:v.ActiveTab.NotificationTemplates})}},children:(0,t.jsx)(P,{})})}const J=(0,f.S)(U);function S(){return(0,t.jsx)(x.y,{navId:"receivers",accessType:"notification",pageNav:{id:"templates",text:(0,a.t)("alerting.notification-templates.new.title","New notification template group"),subTitle:(0,a.t)("alerting.notification-templates.new.subTitle","Create a new group of notification templates"),parentItem:{text:(0,a.t)("alerting.common.titles.notification-templates","Notification Templates"),url:(0,u.G)("/alerting/notifications",{tab:v.ActiveTab.NotificationTemplates})}},children:(0,t.jsx)($,{})})}function $(){const{selectedAlertmanager:i}=(0,g.VI)();return(0,t.jsx)(T.By,{alertmanager:i??""})}const G=(0,f.S)(S);function z(){return(0,t.jsxs)(o.BV,{children:[(0,t.jsx)(o.qh,{path:"new",element:(0,t.jsx)(G,{})}),(0,t.jsx)(o.qh,{path:":name/edit",element:(0,t.jsx)(J,{})}),(0,t.jsx)(o.qh,{path:":name/duplicate",element:(0,t.jsx)(B,{})})]})}const R=(0,f.S)(z)},36826:(A,p,e)=>{e.d(p,{V:()=>t});function t(o,d){const s=o.replace(/\(copy( [0-9]+)?\)$/,"").trim();let n=`${s} (copy)`;for(let a=2;d.includes(n);a++)n=`${s} (copy ${a})`;return n}}}]);

//# sourceMappingURL=Templates.411006252b7a92d57ff2.js.map