1import{w as O,r as V,j as e,aN as q,a as C,cX as y,R as k}from"./react-DwuEVfNv.js";import{fP as K,_ as Y,$ as G,fQ as Q,co as W,cp as I,gR as X,c4 as J,a8 as L,bV as Z,cL as N,aa as g,c_ as ee,c5 as te,gt as ne,f3 as ae,g5 as U,dm as ie,an as B,dc as r,q as v,dw as w,dx as _,dy as $,dz as R,dA as x,b5 as se,b7 as oe,c as le,dd as P,bh as ce,bi as re,bj as de,bk as ue,bl as he,bm as fe,ba as A,bc as T,bd as E,be as F,k as M}from"./index-DQzPtNsy.js";import"./d3-q0zOtUjj.js";const S=()=>Math.random().toString(36).substring(2),me={email:X,slack:()=>`https://example.com/slack/${S()}`,pagerduty:S},p=Q(`${I}/notification-methods`,{bodyKey:"notificationMethod",preserveSnake:!0,fuzzer:n=>{const i=me[n.service]||S;return{...n,value:i()}}});p.list;p.create;p.update;p.remove;const{useList:xe,useCreateMutation:je,useUpdateMutation:H,useDeleteMutation:ge}=K("notification_channel",p),pe=(n={})=>{const i=Y()??"",l=G();return O({...n,mutationFn:a=>W(`${I}/notification-methods/${a}/test`,{},{organization:i,environment:l})})},Ce=({alertingV2:n,onUpdateNotificationMethod:i})=>{const l=J(),a=L(),{mutate:s}=H({onSuccess:t=>{a({id:"notification_channel_toggled",type:"Success",title:"Notification Channel updated",description:`The ${t.service} notification channel "${t.value}" was ${t.enabled?"enabled":"disabled"} successfully.`})}}),{data:d,isLoading:j}=xe({}),u=d?.data??[],{mutate:m}=ge({onSuccess:()=>{a({id:"notification_channel_deleted",type:"Success",title:"Notification Channel deleted",description:"Successfully deleted the notification channel"})}}),{mutate:c,isLoading:o}=pe({meta:{ignoreGlobalErrorHandling:!0},onSuccess:()=>{a({id:"notification_channel_tested",type:"Success",title:"Test notification sent",description:"A test notification was sent successfully. Check your integration to confirm it was received."})},onError:()=>{a({id:"notification_channel_test_failed",type:"Error",title:"Test notification failed",description:"Failed to send a test notification. Please check your integration settings."})}}),h=V.useMemo(()=>[{title:"Active",render:t=>e.jsx(Z,{variant:"success",checked:t.enabled,onChange:()=>s({id:t.id,changes:{enabled:!t.enabled}})}),layout:{width:80,align:"left"}},{title:"Service",field:"service",layout:{width:120,align:"left"},render:t=>{switch(t){case"pagerduty":return"PagerDuty";default:return N(t)}}},{title:"Details",field:"value",layout:{align:"left"}},...n?[{title:"Alerts",field:"alert_types",render:t=>e.jsx(e.Fragment,{children:N(t.length>1?"all":t[0])}),layout:{width:150,align:"left"}},{title:"Edit",render:t=>e.jsx(g,{variant:"muted",onClick:()=>i(t),children:e.jsx(ee,{})}),layout:{width:60}}]:[{title:"Created",field:"createdAt",render:t=>l(new Date(t),te.date),layout:{width:150}}],{title:"Test",render:t=>e.jsx(g,{variant:"muted",disabled:o,onClick:()=>c(t.id),children:e.jsx(ne,{})}),layout:{width:60}},{title:"Delete",field:"id",render:t=>e.jsx(g,{variant:"muted",onClick:()=>m(t),children:e.jsx(ae,{})}),layout:{width:60}}],[n,s,i,c,o,m,l]);return e.jsx(U,{children:e.jsx(ie,{isLoading:j,columns:h,data:u})})},ye=C(U)(["padding:0px;background:",";"],le.white),b=C(P)(["margin-bottom:20px;"]),ve=C(P)(["margin-bottom:0;"]),be=C.a(["text-decoration:underline;cursor:pointer;color:inherit;"]),z={service:"email",value:"",alert_types:["threshold","anomaly"]},D=({value:n,loading:i,onSubmit:l,onCancel:a})=>{const s=B("alertingV2")??!1;s||(z.alert_types=["anomaly"]);const{register:d,watch:j,control:u,handleSubmit:m}=q({defaultValues:{...z,...n}}),c=j("service");return e.jsx("form",{action:"javascript:void(0)",onSubmit:m(l),children:e.jsxs(ye,{children:[e.jsxs(b,{children:[e.jsx(r,{sm:12,children:e.jsx(v,{children:"Service"})}),e.jsx(r,{md:4,children:e.jsx(y,{control:u,name:"service",render:({field:{value:o,onChange:h}})=>e.jsxs(w,{value:o,onValueChange:h,children:[e.jsx(_,{children:e.jsx($,{})}),e.jsxs(R,{children:[e.jsx(x,{value:"email",children:"Email"}),e.jsx(x,{value:"slack",children:"Slack"}),e.jsx(x,{value:"pagerduty",children:"PagerDuty"})]})]})})})]}),e.jsx(b,{children:e.jsxs(r,{children:[e.jsx(v,{children:{email:"Email",slack:"Webhook URL",pagerduty:"Service or Ruleset Integration Key"}[c]}),e.jsx(se,{children:e.jsx(oe,{required:!0,...d("value"),type:c==="email"?"email":"text",placeholder:{email:"[email protected]",slack:"https://hooks.slack.com/...",pagerduty:"Integration key"}[c]})})]})}),s?e.jsxs(b,{children:[e.jsx(r,{sm:12,children:e.jsx(v,{children:"Enable for alert types:"})}),e.jsx(r,{md:4,children:e.jsx(y,{control:u,name:"alert_types",render:({field:{value:o,onChange:h}})=>e.jsxs(w,{value:o.length===1?o[0]:"all",onValueChange:t=>h(t==="all"?["anomaly","threshold"]:[t]),children:[e.jsx(_,{children:e.jsx($,{})}),e.jsxs(R,{children:[e.jsx(x,{value:"all",children:"All"}),e.jsx(x,{value:"anomaly",children:"Anomaly"}),e.jsx(x,{value:"threshold",children:"Threshold"})]})]})})})]}):e.jsx(y,{control:u,name:"alert_types",render:()=>e.jsx(e.Fragment,{})}
1),e.jsxs(ve,{align:"center",children:[e.jsx(r,{}),e.jsx(r,{auto:!0,children:e.jsx(be,{onClick:a,children:"Cancel"})}),e.jsx(r,{auto:!0,children:e.jsx(g,{type:"submit",variant:"access",loading:i,children:n?"Update Channel":"Add Channel"})})]})]})})};function we(){const n=L(),i=B("alertingV2",!1),[l,a]=k.useState(!1),[s,d]=V.useState();ce("Notification Channels | Alerts");const{mutate:j,status:u}=je({onSuccess:f=>{a(!1),n({id:"notification_channel_created",type:"Success",title:"Notification Channel created",description:`The ${f.service} notification channel "${f.value}" was created successfully.`})}}),{mutate:m,status:c}=H({onSuccess:f=>{d(void 0),n({id:"notification_channel_updated",type:"Success",title:"Notification Channel updated",description:`The ${f.service} notification channel "${f.value}" was updated successfully.`})}}),o=f=>{s&&m({changes:f,id:s.id})},h=k.useCallback(()=>{a(!0)},[]),t=()=>{a(!1),d(void 0)};return e.jsxs(re,{children:[e.jsxs(de,{children:[e.jsx(ue,{children:"Notifications"}),e.jsx(he,{children:e.jsx(g,{variant:"access",onClick:h,children:"Add Channel"})})]}),e.jsxs(fe,{children:[e.jsx(Ce,{alertingV2:i,onUpdateNotificationMethod:d}),l&&e.jsx(A,{open:!0,onOpenChange:t,children:e.jsxs(T,{children:[e.jsx(E,{children:e.jsx(F,{children:"Add Channel"})}),e.jsx(M,{gutterY:4,children:e.jsx(D,{loading:u==="loading",onSubmit:j,onCancel:t})})]})}),s&&e.jsx(A,{open:!0,onOpenChange:t,children:e.jsxs(T,{children:[e.jsx(E,{children:e.jsx(F,{children:"Update Channel"})}),e.jsx(M,{gutterY:4,children:e.jsx(D,{value:s,loading:c==="loading",onSubmit:o,onCancel:t})})]})})]})]})}export{we as default}; 2//# sourceMappingURL=NotificationChannelsRoute-_fuEKZ9k.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.