D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
share
/
grafana
/
public
/
build
/
Filename :
AlertAmRoutes.5bc797eea65ebe2d8ff4.js
back
Copy
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8648],{75429:(J,M,t)=>{t.d(M,{x:()=>h});var r=t(27702),l=t(18771),e=t(92071);function h(d){const p=(0,l.useDispatch)(),v=(0,r.useRef)(d);v.current=d,(0,r.useEffect)(()=>()=>{p((0,e.e)({cleanupAction:v.current}))},[p])}},18555:(J,M,t)=>{t.d(M,{Z:()=>e});var r=t(27702);const e=({shouldWrap:h,children:d,wrap:p})=>h?r.cloneElement(p(d)):d},90402:(J,M,t)=>{t.r(M),t.d(M,{default:()=>Mn,findRoutesMatchingFilters:()=>Ct});var r=t(42844),l=t(89949),e=t(27702),h=t(26811),d=t(23852),p=t(66310),v=t(15372),B=t(54281),A=t(4432),S=t(52419),W=t(63439),w=t(37647),V=t(89033),D=t(18771),$=t(75429),j=t(52646),Y=t(98164),ie=t(81324),ye=t(80118),N=t(66670),he=t(3613),ce=t(9848),oe=t(67437),be=t(91368),b=t(29891),Z=t(89439),K=t(97529),ne=t(47702),_=t(2082),R=t(39036),se=t(45986);const ze=({children:n})=>{const a=(0,p.wW)(Ot);return e.createElement("div",{className:a.container},n)},Ot=n=>({container:(0,r.css)` background-color: ${n.colors.background.secondary}; color: ${n.colors.text.secondary}; padding: ${n.spacing(4)}; text-align: center; `}),lt=({buttonIcon:n,buttonLabel:a,buttonSize:o="lg",buttonVariant:i="primary",onButtonClick:u,text:c,href:s,showButton:E=!0})=>{const m=(0,p.wW)(Tt),f={className:m.button,icon:n,size:o,variant:i};return e.createElement(ze,null,e.createElement(e.Fragment,null,e.createElement("p",{className:m.text},c),E&&(s?e.createElement(N.Qj,{href:s,type:"button",...f},a):e.createElement(N.zx,{onClick:u,type:"button",...f},a))))},Tt=n=>({container:(0,r.css)` background-color: ${n.colors.background.secondary}; color: ${n.colors.text.secondary}; padding: ${n.spacing(4)}; text-align: center; `,text:(0,r.css)` margin-bottom: ${n.spacing(2)}; `,button:(0,r.css)` margin: ${n.spacing(2,0,1)}; `});var ot=t(18629),st=t(67045),Dt=t(86342);const It=({alertManagerSourceName:n,muteTimingNames:a,hideActions:o})=>{const i=(0,p.wW)(St),u=(0,b.I0)(),c=(0,_.Ko)(n),{currentData:s}=(0,K.W)(n,{refetchOnFocus:!0,refetchOnReconnect:!0}),E=s?.alertmanager_config,[m,f]=(0,e.useState)(""),P=(0,e.useMemo)(()=>{const z=E?.mute_time_intervals??[],F=E?.muteTimeProvenances??{};return z.filter(({name:I})=>a?a.includes(I):!0).map(I=>({id:I.name,data:{...I,provenance:F[I.name]}}))},[E?.mute_time_intervals,E?.muteTimeProvenances,a]),y=xt(n,o,f);return e.createElement("div",{className:i.container},e.createElement(d.K,{direction:"row",alignItems:"center"},e.createElement("span",null,"Enter specific time intervals when not to send notifications or freeze notifications for recurring periods of time."),e.createElement(st.L,null),!o&&P.length>0&&e.createElement(Z.q,{actions:[c.create]},e.createElement(N.Qj,{className:i.addMuteButton,icon:"plus",variant:"primary",href:(0,R.eQ)("alerting/routes/mute-timing/new",n)},"Add mute timing"))),P.length>0?e.createElement(se.t,{items:P,cols:y}):o?e.createElement(lt,{text:"No mute timings configured",buttonLabel:"",showButton:!1}):e.createElement(lt,{text:"You haven't created any mute timings yet",buttonLabel:"Add mute timing",buttonIcon:"plus",buttonSize:"lg",href:(0,R.eQ)("alerting/routes/mute-timing/new",n),showButton:be.contextSrv.hasPermission(c.create)}),!o&&e.createElement(he.s,{isOpen:!!m,title:"Delete mute timing",body:`Are you sure you would like to delete "${m}"`,confirmText:"Delete",onConfirm:()=>{u((0,ne.r0)(n,m)),f("")},onDismiss:()=>f("")}))};function xt(n,a=!1,o){const i=(0,_.Ko)(n),u=be.contextSrv.hasPermission(i.update),c=be.contextSrv.hasPermission(i.delete),s=!a&&(u||c);return(0,e.useMemo)(()=>{const E=[{id:"name",label:"Name",renderCell:function({data:f}){return e.createElement(e.Fragment,null,f.name," ",f.provenance&&e.createElement(ot.C0,null))},size:"250px"},{id:"timeRange",label:"Time range",renderCell:({data:m})=>(0,Dt.Nx)(m)}];return s&&E.push({id:"actions",label:"Actions",renderCell:function({data:f}){return f.provenance?e.createElement("div",null,e.createElement(ce.r,{href:(0,R.eQ)("/alerting/routes/mute-timing/edit",n,{muteName:f.name})},e.createElement(oe.h,{name:"file-alt",tooltip:"View mute timing"}))):e.createElement("div",null,e.createElement(Z.q,{actions:[i.update]},e.createElement(ce.r,{href:(0,R.eQ)("/alerting/routes/mute-timing/edit",n,{muteName:f.name})},e.createElement(oe.h,{name:"edit",tooltip:"Edit mute timing"}))),e.createElement(Z.q,{actions:[i.delete]},e.createElement(oe.h,{name:"trash-alt",tooltip:"Delete mute timing",onClick:()=>o(f.name)})))},size:"100px"}),E},[n,o,s,i])}const St=n=>({container:(0,r.css)` display: flex; flex-flow: column nowrap; `,addMuteButton:(0,r.css)` margin-bottom: ${n.spacing(2)}; align-self: flex-end; `});var L=t(22209),Rt=t(79978),pe=t(80011),Ee=t(73453),Se=t(1128),me=t(28580),Wt=t(79003),Ce=t(76658);const Gt=({receivers:n,onChangeReceiver:a,onChangeMatchers:o})=>{const[i,u]=(0,Wt.j)(),c=(0,e.useRef)(null),{queryString:s,contactPoint:E}=$t(i),m=(0,p.wW)(Nt),f=(0,e.useCallback)(()=>(0,l.debounce)(o,500),[o]);(0,e.useEffect)(()=>{a(E)},[E,a]),(0,e.useEffect)(()=>{const g=(0,Ce.Zh)(s??"").map(Ce.xz);f()(g)},[f,s]);const P=(0,e.useCallback)(()=>{c.current&&(c.current.value=""),u({contactPoint:void 0,queryString:void 0})},[u]),y=n.map(Bt),z=y.find(g=>g.value===E)??null,F=s||E,I=s&&s.length>3?(0,Ce.Zh)(s).length===0:!1;return e.createElement(d.K,{direction:"row",alignItems:"flex-start",gap:.5},e.createElement(L.g,{className:m.noBottom,label:e.createElement(Rt._,null,e.createElement(d.K,{gap:.5},e.createElement("span",null,"Search by matchers"),e.createElement(pe.u,{content:e.createElement("div",null,"Filter silences by matchers using a comma separated list of matchers, ie:",e.createElement("pre",null,"severity=critical, instance=~cluster-us-.+"))},e.createElement(Ee.J,{name:"info-circle",size:"sm"})))),invalid:I,error:I?"Query must use valid matcher syntax":null},e.createElement(Se.I,{ref:c,"data-testid":"search-query-input",placeholder:"Search",width:46,prefix:e.createElement(Ee.J,{name:"search"}),onChange:g=>{u({queryString:g.currentTarget.value})},defaultValue:s})),e.createElement(L.g,{label:"Search by contact point",style:{marginBottom:0}},e.createElement(me.Ph,{id:"receiver","aria-label":"Search by contact point",value:z,options:y,onChange:g=>{u({contactPoint:g?.value})},width:28,isClearable:!0})),F&&e.createElement(N.zx,{variant:"secondary",icon:"times",onClick:P,style:{marginTop:19}},"Clear filters"))};function it(n,a){const o=[];function i(u){a(u)&&o.push(u),u.routes?.forEach(i)}return i(n),o}const Bt=n=>({label:n.name,value:n.name}),$t=n=>({queryString:n.get("queryString")??void 0,contactPoint:n.get("contactPoint")??void 0}),Nt=()=>({noBottom:(0,r.css)` margin-bottom: 0; `});var ee=t(13741),Ft=t(62108),Re=t(62862),Lt=t(9853),ct=t(74023),Ut=t(6772),We=t.n(Ut),Ae=t(25357);const wt=({active:n=0,suppressed:a=0,unprocessed:o=0})=>{const i=[],u=n+a+o;return n&&i.push(e.createElement(Ae.C,{color:"red",key:"firing",text:`${n} firing`})),a&&i.push(e.createElement(Ae.C,{color:"blue",key:"suppressed",text:`${a} suppressed`})),o&&i.push(e.createElement(Ae.C,{color:"orange",key:"unprocessed",text:`${o} unprocessed`})),i.length>1&&i.unshift(e.createElement(e.Fragment,{key:"total"},u," ",We()("instance",u))),!!i.length?e.createElement(d.K,{gap:.5},i):null};var mt=t(23839),ve=t(16310),Kt=t(41640),G=t(26630),Ge=t(51453),Pe=t(42439);function zt(){const n=(0,p.wW)(ut);return e.createElement("div",null,"Prometheus duration format consist of a number followed by a time unit.",e.createElement("br",null),"Different units can be combined for more granularity.",e.createElement("hr",null),e.createElement("div",{className:n.list},e.createElement("div",{className:n.header},e.createElement("div",null,"Symbol"),e.createElement("div",null,"Time unit"),e.createElement("div",null,"Example")),e.createElement(Me,{unit:Pe.t.seconds,name:"seconds",example:"20s"}),e.createElement(Me,{unit:Pe.t.minutes,name:"minutes",example:"10m"}),e.createElement(Me,{unit:Pe.t.hours,name:"hours",example:"4h"}),e.createElement(Me,{unit:Pe.t.days,name:"days",example:"3d"}),e.createElement(Me,{unit:Pe.t.weeks,name:"weeks",example:"2w"}),e.createElement("div",{className:n.examples},e.createElement("div",null,"Multiple units combined"),e.createElement("code",null,"1m30s, 2h30m20s, 1w2d"))))}function Me({unit:n,name:a,example:o}){const i=(0,p.wW)(ut);return e.createElement(e.Fragment,null,e.createElement("div",{className:i.unit},n),e.createElement("div",null,a),e.createElement("code",null,o))}const ut=n=>({unit:(0,r.css)` font-weight: ${n.typography.fontWeightBold}; `,list:(0,r.css)` display: grid; grid-template-columns: max-content 1fr 2fr; gap: ${n.spacing(1,3)}; `,header:(0,r.css)` display: contents; font-weight: ${n.typography.fontWeightBold}; `,examples:(0,r.css)` display: contents; & > div { grid-column: 1 / span 2; } `}),ue=e.forwardRef((n,a)=>e.createElement(Se.I,{suffix:e.createElement(Ge.z,{content:e.createElement(zt,null),disabled:!1},e.createElement(Ee.J,{name:"info-circle",size:"lg"})),...n,ref:a}));ue.displayName="PromDurationInput";const dt=n=>({container:(0,r.css)` align-items: center; display: flex; flex-flow: row nowrap; & > * + * { margin-left: ${n.spacing(1)}; } `,input:(0,r.css)` flex: 1; `,promDurationInput:(0,r.css)` max-width: ${n.spacing(32)}; `,timingFormContainer:(0,r.css)` padding: ${n.spacing(1)}; `,linkText:(0,r.css)` text-decoration: underline; `,collapse:(0,r.css)` border: none; background: none; color: ${n.colors.text.primary}; `}),Be={group_wait:"30s",group_interval:"5m",repeat_interval:"4h"},Vt=({actionButtons:n,alertManagerSourceName:a,onSubmit:o,receivers:i,route:u})=>{const c=(0,p.wW)(dt),[s,E]=(0,e.useState)(!1),[m,f]=(0,e.useState)((0,G.eh)(u.group_by)),P=(0,G.ZS)(u);return e.createElement(mt.l,{defaultValues:{...P,overrideTimings:!0,overrideGrouping:!0},onSubmit:o},({register:y,control:z,errors:F,setValue:I,getValues:g})=>e.createElement(e.Fragment,null,e.createElement(L.g,{label:"Default contact point",invalid:!!F.receiver,error:F.receiver?.message},e.createElement(e.Fragment,null,e.createElement("div",{className:c.container,"data-testid":"am-receiver-select"},e.createElement(ve.g,{render:({field:{onChange:O,ref:U,...X}})=>e.createElement(me.Ph,{"aria-label":"Default contact point",...X,className:c.input,onChange:H=>O((0,G.mJ)(H)),options:i}),control:z,name:"receiver",rules:{required:{value:!0,message:"Required."}}}),e.createElement("span",null,"or"),e.createElement(ce.r,{className:c.linkText,href:(0,R.eQ)("/alerting/notifications/receivers/new",a)},"Create a contact point")))),e.createElement(L.g,{label:"Group by",description:"Group alerts when you receive a notification based on labels.","data-testid":"am-group-select"},e.createElement(ve.g,{render:({field:{onChange:O,ref:U,...X}})=>e.createElement(me.NU,{"aria-label":"Group by",...X,allowCustomValue:!0,className:c.input,onCreateOption:H=>{f(x=>[...x,(0,G.T0)(H)]),I("groupBy",[...X.value,H])},onChange:H=>O((0,G.bi)(H)),options:[...G.dO,...m]}),control:z,name:"groupBy"})),e.createElement(Kt.U,{collapsible:!0,className:c.collapse,isOpen:s,label:"Timing options",onToggle:E},e.createElement("div",{className:c.timingFormContainer},e.createElement(L.g,{label:"Group wait",description:"The waiting time until the initial notification is sent for a new group created by an incoming alert. Default 30 seconds.",invalid:!!F.groupWaitValue,error:F.groupWaitValue?.message,"data-testid":"am-group-wait"},e.createElement(ue,{...y("groupWaitValue",{validate:G.Oy}),placeholder:Be.group_wait,className:c.promDurationInput,"aria-label":"Group wait"})),e.createElement(L.g,{label:"Group interval",description:"The waiting time to send a batch of new alerts for that group after the first notification was sent. Default 5 minutes.",invalid:!!F.groupIntervalValue,error:F.groupIntervalValue?.message,"data-testid":"am-group-interval"},e.createElement(ue,{...y("groupIntervalValue",{validate:G.Oy}),placeholder:Be.group_interval,className:c.promDurationInput,"aria-label":"Group interval"})),e.createElement(L.g,{label:"Repeat interval",description:"The waiting time to resend an alert after they have successfully been sent. Default 4 hours.",invalid:!!F.repeatIntervalValue,error:F.repeatIntervalValue?.message,"data-testid":"am-repeat-interval"},e.createElement(ue,{...y("repeatIntervalValue",{validate:O=>{const U=g("groupIntervalValue");return(0,G.eP)(O,U)}}),placeholder:Be.repeat_interval,className:c.promDurationInput,"aria-label":"Repeat interval"})))),e.createElement("div",{className:c.container},n)))};var jt=t(56948),Ve=t(42074),Zt=t(59904),gt=t(1469);function Qt(){const{selectedAlertmanager:n}=(0,gt.Z)(),{currentData:a}=(0,K.W)(n),o=a?.alertmanager_config;return(0,e.useMemo)(()=>o?.mute_time_intervals?.map(u=>({value:u.name,label:u.name,description:u.time_intervals.map(c=>(0,Ce.uK)(c)).join(", AND ")}))??[],[o])}var Ht=t(62401);const pt=({actionButtons:n,receivers:a,route:o,onSubmit:i,defaults:u})=>{const c=(0,p.wW)(Yt),s=(0,p.wW)(dt),[E,m]=(0,e.useState)((0,G.eh)(o?.group_by)),f=Qt(),P=[{name:"",operator:Re._M.equal,value:""}],y=a.sort(Jt),z={...(0,G.ZS)(o),...u},F={...z,object_matchers:o?z.object_matchers:P};return e.createElement(mt.l,{defaultValues:F,onSubmit:i,maxWidth:"none"},({control:I,register:g,errors:O,setValue:U,watch:X,getValues:H})=>e.createElement(e.Fragment,null,e.createElement("input",{type:"hidden",...g("id")}),e.createElement(jt.F,{name:"object_matchers",control:I},({fields:x,append:Q,remove:k})=>e.createElement(e.Fragment,null,e.createElement(d.K,{direction:"column",alignItems:"flex-start"},e.createElement("div",null,"Matching labels"),x.length===0&&e.createElement(Ae.C,{color:"orange",className:c.noMatchersWarning,icon:"exclamation-triangle",text:"If no matchers are specified, this notification policy will handle all alert instances."}),x.length>0&&e.createElement("div",{className:c.matchersContainer},x.map((T,C)=>e.createElement(d.K,{direction:"row",key:T.id,alignItems:"center"},e.createElement(L.g,{label:"Label",invalid:!!O.object_matchers?.[C]?.name,error:O.object_matchers?.[C]?.name?.message},e.createElement(Se.I,{...g(`object_matchers.${C}.name`,{required:"Field is required"}),defaultValue:T.name,placeholder:"label",autoFocus:!0})),e.createElement(L.g,{label:"Operator"},e.createElement(ve.g,{render:({field:{onChange:re,ref:de,...ge}})=>e.createElement(me.Ph,{...ge,className:c.matchersOperator,onChange:Te=>re(Te?.value),options:Ce.tA,"aria-label":"Operator"}),defaultValue:T.operator,control:I,name:`object_matchers.${C}.operator`,rules:{required:{value:!0,message:"Required."}}})),e.createElement(L.g,{label:"Value",invalid:!!O.object_matchers?.[C]?.value,error:O.object_matchers?.[C]?.value?.message},e.createElement(Se.I,{...g(`object_matchers.${C}.value`,{required:"Field is required"}),defaultValue:T.value,placeholder:"value"})),e.createElement(oe.h,{tooltip:"Remove matcher",name:"trash-alt",onClick:()=>k(C)},"Remove")))),e.createElement(N.zx,{className:c.addMatcherBtn,icon:"plus",onClick:()=>Q(G.fx),variant:"secondary",type:"button"},"Add matcher")))),e.createElement(L.g,{label:"Contact point"},e.createElement(ve.g,{render:({field:{onChange:x,ref:Q,...k}})=>e.createElement(me.Ph,{"aria-label":"Contact point",...k,className:s.input,onChange:T=>x((0,G.mJ)(T)),options:y,isClearable:!0}),control:I,name:"receiver"})),e.createElement(L.g,{label:"Continue matching subsequent sibling nodes"},e.createElement(Ve.r,{id:"continue-toggle",...g("continue")})),e.createElement(L.g,{label:"Override grouping"},e.createElement(Ve.r,{id:"override-grouping-toggle",...g("overrideGrouping")})),X().overrideGrouping&&e.createElement(L.g,{label:"Group by",description:"Group alerts when you receive a notification based on labels. If empty it will be inherited from the parent policy."},e.createElement(ve.g,{rules:{validate:x=>!x||x.length===0?"At least one group by option is required.":!0},render:({field:{onChange:x,ref:Q,...k},fieldState:{error:T}})=>e.createElement(e.Fragment,null,e.createElement(me.NU,{"aria-label":"Group by",...k,invalid:!!T,allowCustomValue:!0,className:s.input,onCreateOption:C=>{m(re=>[...re,(0,G.T0)(C)]),U("groupBy",[...k.value,C])},onChange:C=>x((0,G.bi)(C)),options:[...G.dO,...E]}),T&&e.createElement(Zt.S,null,T.message)),control:I,name:"groupBy"})),e.createElement(L.g,{label:"Override general timings"},e.createElement(Ve.r,{id:"override-timings-toggle",...g("overrideTimings")})),X().overrideTimings&&e.createElement(e.Fragment,null,e.createElement(L.g,{label:"Group wait",description:"The waiting time until the initial notification is sent for a new group created by an incoming alert. If empty it will be inherited from the parent policy.",invalid:!!O.groupWaitValue,error:O.groupWaitValue?.message},e.createElement(ue,{...g("groupWaitValue",{validate:G.Oy}),"aria-label":"Group wait value",className:s.promDurationInput})),e.createElement(L.g,{label:"Group interval",description:"The waiting time to send a batch of new alerts for that group after the first notification was sent. If empty it will be inherited from the parent policy.",invalid:!!O.groupIntervalValue,error:O.groupIntervalValue?.message},e.createElement(ue,{...g("groupIntervalValue",{validate:G.Oy}),"aria-label":"Group interval value",className:s.promDurationInput})),e.createElement(L.g,{label:"Repeat interval",description:"The waiting time to resend an alert after they have successfully been sent.",invalid:!!O.repeatIntervalValue,error:O.repeatIntervalValue?.message},e.createElement(ue,{...g("repeatIntervalValue",{validate:x=>{const Q=H("groupIntervalValue");return(0,G.eP)(x,Q)}}),"aria-label":"Repeat interval value",className:s.promDurationInput}))),e.createElement(L.g,{label:"Mute timings","data-testid":"am-mute-timing-select",description:"Add mute timing to policy",invalid:!!O.muteTimeIntervals},e.createElement(ve.g,{render:({field:{onChange:x,ref:Q,...k}})=>e.createElement(me.NU,{"aria-label":"Mute timings",...k,className:s.input,onChange:T=>x((0,G.bi)(T)),options:f}),control:I,name:"muteTimeIntervals"})),n))};function Jt(n){return n.grafanaAppReceiverType===Ht.W.OnCall?-1:0}const Yt=n=>{const a=n.spacing(3.5);return{addMatcherBtn:(0,r.css)` margin-bottom: ${a}; `,matchersContainer:(0,r.css)` background-color: ${n.colors.background.secondary}; padding: ${n.spacing(1.5)} ${n.spacing(2)}; padding-bottom: 0; width: fit-content; `,matchersOperator:(0,r.css)` min-width: 120px; `,noMatchersWarning:(0,r.css)` padding: ${n.spacing(1)} ${n.spacing(2)}; `}};var Et=t(54915);const Xt=(n=[],a,o)=>{const[i,u]=(0,e.useState)(!1),[c,s]=(0,e.useState)(),E=(0,ct.Kt)(n),m=(0,e.useCallback)(()=>{s(void 0),u(!1)},[]),f=(0,e.useCallback)(y=>{s(y),u(!0)},[]);return[(0,e.useMemo)(()=>o?e.createElement(je,{isOpen:i}):e.createElement(ee.u,{isOpen:i,onDismiss:m,closeOnBackdropClick:!0,closeOnEscape:!0,title:"Add notification policy"},e.createElement(pt,{receivers:E,defaults:{groupBy:c?.group_by},onSubmit:y=>c&&a(y,c),actionButtons:e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:m,fill:"outline"},"Cancel"),e.createElement(N.zx,{type:"submit"},"Save policy"))})),[E,a,m,o,c,i]),f,m]},kt=(n,a,o,i)=>{const[u,c]=(0,e.useState)(!1),[s,E]=(0,e.useState)(!1),[m,f]=(0,e.useState)(),P=(0,ct.Kt)(a),y=(0,e.useCallback)(()=>{f(void 0),c(!1)},[]),z=(0,e.useCallback)((I,g)=>{E(g??!1),f(I),c(!0)},[]);return[(0,e.useMemo)(()=>i?e.createElement(je,{isOpen:u}):e.createElement(ee.u,{isOpen:u,onDismiss:y,closeOnBackdropClick:!0,closeOnEscape:!0,title:"Edit notification policy"},s&&m&&e.createElement(Vt,{alertManagerSourceName:n,onSubmit:o,receivers:P,route:m,actionButtons:e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:y,fill:"outline"},"Cancel"),e.createElement(N.zx,{type:"submit"},"Update default policy"))}),!s&&e.createElement(pt,{receivers:P,route:m,onSubmit:o,actionButtons:e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:y,fill:"outline"},"Cancel"),e.createElement(N.zx,{type:"submit"},"Update policy"))})),[P,n,y,o,s,i,m,u]),z,y]},qt=(n,a)=>{const[o,i]=(0,e.useState)(!1),[u,c]=(0,e.useState)(),s=(0,e.useCallback)(()=>{c(void 0),i(!1)},[c]),E=(0,e.useCallback)(P=>{c(P),i(!0)},[]),m=(0,e.useCallback)(()=>{u&&n(u)},[n,u]);return[(0,e.useMemo)(()=>a?e.createElement(je,{isOpen:o}):e.createElement(ee.u,{isOpen:o,onDismiss:s,closeOnBackdropClick:!0,closeOnEscape:!0,title:"Delete notification policy"},e.createElement("p",null,"Deleting this notification policy will permanently remove it."),e.createElement("p",null,"Are you sure you want to delete this policy?"),e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"destructive",onClick:m},"Yes, delete policy"),e.createElement(N.zx,{type:"button",variant:"secondary",onClick:s},"Cancel"))),[s,m,a,o]),E,s]},_t=()=>{const[n,a]=(0,e.useState)(!1),[o,i]=(0,e.useState)([]),[u,c]=(0,e.useState)([]),s=(0,e.useCallback)(()=>{a(!1),i([]),c([])},[]),E=(0,e.useCallback)((P,y)=>{i(P),y&&c(y),a(!0)},[]),m=(0,e.useMemo)(()=>{const P=o.flatMap(y=>y.alerts);return(0,l.groupBy)(P,y=>y.status.state)},[o]);return[(0,e.useMemo)(()=>e.createElement(ee.u,{isOpen:n,onDismiss:s,closeOnBackdropClick:!0,closeOnEscape:!0,title:e.createElement(d.K,{direction:"row",alignItems:"center",gap:1,flexGrow:1},e.createElement(d.K,{direction:"row",alignItems:"center",gap:.5},e.createElement(Ee.J,{name:"x"})," Matchers"),e.createElement(Et.g,{matchers:u}))},e.createElement(d.K,{direction:"column"},e.createElement(wt,{active:m[Re.Z9.Active]?.length,suppressed:m[Re.Z9.Suppressed]?.length,unprocessed:m[Re.Z9.Unprocessed]?.length}),e.createElement("div",null,o.map((P,y)=>e.createElement(Lt.y,{key:y,alertManagerSourceName:"",group:P})))),e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:s},"Cancel"))),[o,s,m,u,n]),E,s]},je=({isOpen:n})=>e.createElement(ee.u,{isOpen:n,onDismiss:()=>{},closeOnBackdropClick:!1,closeOnEscape:!1,title:e.createElement(d.K,{direction:"row",alignItems:"center",gap:.5},"Updating... ",e.createElement(Ft.$,{inline:!0}))},"Please wait while we update your notification policies.");var $e=t(85014),en=t(80434),Oe=t(89746),tn=t(64714),vt=t(21323),Ze=t(66574),Qe=t(18555),nn=t(309),an=t(14917),ft=t(22513),yt=t(32925),ht=t(95984),rn=t(59597),He=t(79374),ae=t(218),q=t(92273);const bt=({receivers:n=[],contactPointsState:a,readOnly:o=!1,provisioned:i=!1,alertGroups:u=[],alertManagerSourceName:c,currentRoute:s,routeTree:E,inheritedProperties:m,routesMatchingFilters:f=[],matchingInstancesPreview:P={enabled:!1},onEditPolicy:y,onAddPolicy:z,onDeletePolicy:F,onShowAlertInstances:I})=>{const g=(0,p.wW)(Ne),O=s===E,U=(0,_.Ko)(c),X=Ze.Vt.hasPermission(U.update),H=Ze.Vt.hasPermission(U.delete),x=Ze.Vt.hasAccess(U.provisioning.read,(0,nn.RN)()),Q=s.receiver,k=s.continue??!1,T=s.group_by,C=s.mute_time_intervals??[],re={group_wait:s.group_wait,group_interval:s.group_interval,repeat_interval:s.repeat_interval},de=(0,yt.QO)(s),ge=!!(de&&de.length),Te=!!C.length,Xe=f.some(te=>te.id===s.id),De=[],ke=!ge&&!O&&!k,qe=Q??m?.receiver??"";(a?pn(qe,a):[]).forEach(te=>{De.push(te)});const Le=m&&Object.keys(m).length>0,_e=s.routes??[],et=Le&&m.group_by,Ue=(0,l.isArray)(T)&&T[0]==="...",tt=!Ue&&(0,l.isArray)(T)&&T.length>0,nt=O&&(0,l.isArray)(T)&&T.length===0,at=X,we=H&&!O,fe=P?.groupsMap?.get(s.id),Ke=fe?(0,l.sumBy)(fe,te=>te.alerts.length):void 0,Ie=c===ft.GC&&O&&x;return e.createElement(d.K,{direction:"column",gap:1.5},e.createElement("div",{className:g.policyWrapper(Xe),"data-testid":O?"am-root-route-container":"am-route-container"},k&&e.createElement(on,null),ke&&e.createElement(sn,null),e.createElement("div",{className:g.policyItemWrapper},e.createElement(d.K,{direction:"column",gap:1},e.createElement("div",null,e.createElement(d.K,{direction:"row",alignItems:"center",gap:1},O?e.createElement(cn,null):ge?e.createElement(Et.g,{matchers:de??[]}):e.createElement("span",{className:g.metadata},"No matchers"),e.createElement(st.L,null),De.length>0&&e.createElement(ln,{errors:De}),i&&e.createElement(ot.C0,null),o&&!Ie?null:e.createElement(d.K,{direction:"row",gap:.5},!o&&e.createElement(Qe.Z,{shouldWrap:i,wrap:Je},e.createElement(N.zx,{variant:"secondary",icon:"plus",size:"sm",onClick:()=>z(s),disabled:i,type:"button"},"New nested policy")),e.createElement(en.L,{overlay:e.createElement(Oe.v,null,!o&&e.createElement(Qe.Z,{shouldWrap:i,wrap:Je},e.createElement(Oe.v.Item,{icon:"edit",disabled:!at||i,label:"Edit",onClick:()=>y(s,O)})),Ie&&e.createElement(Oe.v.Item,{icon:"download-alt",label:"Export",url:(0,rn.u)("/api/v1/provisioning/policies/export",{download:"true",format:"yaml"}),target:"_blank"}),!o&&we&&e.createElement(e.Fragment,null,e.createElement(Oe.v.Divider,null),e.createElement(Qe.Z,{shouldWrap:i,wrap:Je},e.createElement(Oe.v.Item,{destructive:!0,icon:"trash-alt",disabled:!we||i,label:"Delete",onClick:()=>F(s)}))))},e.createElement(N.zx,{icon:"ellipsis-h",variant:"secondary",size:"sm",type:"button","aria-label":"more-actions","data-testid":"more-actions"}))))),e.createElement("div",{className:g.metadataRow},e.createElement(d.K,{direction:"row",alignItems:"center",gap:1},P.enabled&&e.createElement(ae.g,{icon:"layers-alt",onClick:()=>{fe&&I(fe,de)},"data-testid":"matching-instances"},e.createElement(q.c,null,Ke??"-"),e.createElement("span",null,We()("instance",Ke))),Q&&e.createElement(ae.g,{icon:"at","data-testid":"contact-point"},e.createElement("span",null,"Delivered to"),e.createElement(gn,{alertManagerSourceName:c,receivers:n,contactPoint:Q})),!et&&e.createElement(e.Fragment,null,tt&&e.createElement(ae.g,{icon:"layer-group","data-testid":"grouping"},e.createElement("span",null,"Grouped by"),e.createElement(q.c,null,T.join(", "))),nt&&e.createElement(ae.g,{icon:"layer-group"},e.createElement("span",null,"Single group")),Ue&&e.createElement(ae.g,{icon:"layer-group"},e.createElement("span",null,"Not grouping"))),Te&&e.createElement(ae.g,{icon:"calendar-slash","data-testid":"mute-timings"},e.createElement("span",null,"Muted when"),e.createElement(un,{timings:C,alertManagerSourceName:c})),re&&e.createElement(dn,{timingOptions:O?{...re,...Be}:re}),Le&&e.createElement(e.Fragment,null,e.createElement(ae.g,{icon:"corner-down-right-alt","data-testid":"inherited-properties"},e.createElement("span",null,"Inherited"),e.createElement(mn,{properties:m})))))))),e.createElement("div",{className:g.childPolicies},_e.map(te=>{const rt=(0,ht.$2)(s,te,m);return e.createElement(bt,{key:(0,l.uniqueId)(),routeTree:E,currentRoute:te,receivers:n,contactPointsState:a,readOnly:o||i,inheritedProperties:rt,onAddPolicy:z,onEditPolicy:y,onDeletePolicy:F,onShowAlertInstances:I,alertManagerSourceName:c,alertGroups:u,routesMatchingFilters:f,matchingInstancesPreview:P})})))},Je=n=>e.createElement(pe.u,{content:"Provisioned items cannot be edited in the UI",placement:"top"},e.createElement("span",null,n)),ln=({errors:n})=>e.createElement(Ge.z,{arrow:!0,placement:"top",content:e.createElement(d.K,{direction:"column",gap:.5},n.map(a=>e.createElement(e.Fragment,{key:(0,l.uniqueId)()},a)))},e.createElement("span",null,e.createElement(Ae.C,{icon:"exclamation-circle",color:"red",text:We()("error",n.length,!0)}))),on=()=>{const n=(0,p.wW)(Ne);return e.createElement(pe.u,{placement:"top",content:"This route will continue matching other policies"},e.createElement("div",{className:n.gutterIcon,"data-testid":"continue-matching"},e.createElement(Ee.J,{name:"arrow-down"})))},sn=()=>{const n=(0,p.wW)(Ne);return e.createElement(pe.u,{placement:"top",content:"This policy matches all labels"},e.createElement("div",{className:n.gutterIcon,"data-testid":"matches-all"},e.createElement(Ee.J,{name:"exclamation-triangle"})))},cn=()=>{const n=(0,p.wW)(Ne);return e.createElement(e.Fragment,null,e.createElement("strong",null,"Default policy"),e.createElement("span",{className:n.metadata},"All alert instances will be handled by the default policy if no other matching policies are found."))},mn=({properties:n})=>e.createElement(Ge.z,{arrow:!0,placement:"top",content:e.createElement(d.K,{direction:"row",gap:.5},Object.entries(n).map(([a,o])=>e.createElement(He._,{key:a,label:En(a),value:e.createElement(q.c,null,vn(a,o))})))},e.createElement("div",null,e.createElement(q.c,null,We()("property",Object.keys(n).length,!0)))),un=({timings:n,alertManagerSourceName:a})=>e.createElement("div",null,e.createElement(q.c,null,n.map(o=>e.createElement($e.Link,{key:o,to:(0,R.ET)(o,a)},o)))),dn=({timingOptions:n})=>{const a=n.group_wait,o=n.group_interval;return!a&&!o?null:e.createElement(ae.g,{icon:"hourglass","data-testid":"timing-options"},e.createElement("span",null,"Wait"),a&&e.createElement(pe.u,{placement:"top",content:"How long to initially wait to send a notification for a group of alert instances."},e.createElement("span",null,e.createElement(q.c,null,a)," ",e.createElement("span",null,"to group instances"),a&&o&&",")),o&&e.createElement(pe.u,{placement:"top",content:"How long to wait before sending a notification about new alerts that are added to a group of alerts for which an initial notification has already been sent."},e.createElement("span",null,e.createElement(q.c,null,o)," ",e.createElement("span",null,"before sending updates"))))},gn=({alertManagerSourceName:n,contactPoint:a,receivers:o})=>{const i=o.find(s=>s.name===a);if(!i)return e.createElement($e.Link,{to:(0,R.GV)(a,n)},e.createElement(q.c,null,a));if(!i.grafana_managed_receiver_configs)return e.createElement($e.Link,{to:(0,R.GV)(a,n)},e.createElement(q.c,null,a));const c=(0,l.groupBy)(i.grafana_managed_receiver_configs,s=>s.type);return e.createElement(Ge.z,{arrow:!0,placement:"top",header:e.createElement(ae.g,{icon:"at"},e.createElement("div",null,"Contact Point"),e.createElement(q.c,null,a)),key:(0,l.uniqueId)(),content:e.createElement(d.K,{direction:"row",gap:.5},Object.entries(c).map(([s,E])=>e.createElement(He._,{key:(0,l.uniqueId)(),label:E.length>1?E.length:void 0,icon:an.y[s],value:(0,l.upperFirst)(s)})))},e.createElement($e.Link,{to:(0,R.GV)(a,n)},e.createElement(q.c,null,a)))};function pn(n,a){return Object.entries(a[n]?.notifiers??[]).reduce((u=[],[c,s])=>{const E=s.filter(m=>m.lastNotifyAttemptError).map(m=>e.createElement(He._,{icon:"at",key:(0,l.uniqueId)(),label:`Contact Point \u203A ${m.name}`,value:m.lastNotifyAttemptError}));return u.concat(E)},[])}const En=n=>{switch(n){case"receiver":return"Contact Point";case"group_by":return"Group by";case"group_interval":return"Group interval";case"group_wait":return"Group wait";case"mute_time_intervals":return"Mute timings";case"repeat_interval":return"Repeat interval";default:return n}},vn=(n,a)=>{const o=n==="group_by"&&Array.isArray(a)&&a[0]==="...",i=n==="group_by"&&Array.isArray(a)&&a.length===0;return o?e.createElement(vt.x,{variant:"bodySmall",color:"secondary"},"Not grouping"):i?e.createElement(vt.x,{variant:"bodySmall",color:"secondary"},"Single group"):Array.isArray(a)?a.join(", "):a},Ne=n=>({matcher:a=>{const{color:o,borderColor:i}=(0,tn.Bx)(a);return{wrapper:(0,r.css)` color: #fff; background: ${o}; padding: ${n.spacing(.33)} ${n.spacing(.66)}; font-size: ${n.typography.bodySmall.fontSize}; border: solid 1px ${i}; border-radius: ${n.shape.borderRadius(1)}; `}},childPolicies:(0,r.css)` margin-left: ${n.spacing(4)}; position: relative; &:before { content: ''; position: absolute; height: calc(100% - 10px); border-left: solid 1px ${n.colors.border.weak}; margin-top: 0; margin-left: -20px; } `,policyItemWrapper:(0,r.css)` padding: ${n.spacing(1.5)}; `,metadataRow:(0,r.css)` background: ${n.colors.background.secondary}; border-bottom-left-radius: ${n.shape.borderRadius(2)}; border-bottom-right-radius: ${n.shape.borderRadius(2)}; `,policyWrapper:(a=!1)=>(0,r.css)` flex: 1; position: relative; background: ${n.colors.background.secondary}; border-radius: ${n.shape.borderRadius(1)}; border: solid 1px ${n.colors.border.weak}; ${a&&(0,r.css)` border-color: ${n.colors.primary.border}; `} `,metadata:(0,r.css)` color: ${n.colors.text.secondary}; font-size: ${n.typography.bodySmall.fontSize}; font-weight: ${n.typography.bodySmall.fontWeight}; `,break:(0,r.css)` width: 100%; height: 0; margin-bottom: ${n.spacing(2)}; `,gutterIcon:(0,r.css)` position: absolute; top: 0; transform: translateY(50%); left: -${n.spacing(4)}; color: ${n.colors.text.secondary}; background: ${n.colors.background.primary}; width: 25px; height: 25px; text-align: center; border: solid 1px ${n.colors.border.weak}; border-radius: ${n.shape.borderRadius(1)}; padding: 0; `});var fn=t(36546),yn=t(84369),Ye=t(68228),hn=(n=>(n.NotificationPolicies="notification_policies",n.MuteTimings="mute_timings",n))(hn||{});const bn=()=>{const n=(0,D.useDispatch)(),a=(0,p.wW)(Cn),{useGetAlertmanagerAlertGroupsQuery:o}=j.alertmanagerApi,[i,u]=(0,V.K)(),{tab:c}=An(i),[s,E]=(0,e.useState)(c),[m,f]=(0,e.useState)(!1),[P,y]=(0,e.useState)(),[z,F]=(0,e.useState)([]),{getRouteGroupsMap:I}=(0,fn.N)(),{selectedAlertmanager:g}=(0,gt.Z)(),O=(0,Y.V)(g??""),{currentData:U,isLoading:X,error:H}=(0,K.W)(g,{refetchOnFocus:!0,refetchOnReconnect:!0}),x=U?.alertmanager_config,{currentData:Q,refetch:k}=o({amSourceName:g??""},{skip:!g}),T=x?.receivers??[],C=(0,e.useMemo)(()=>{if(x?.route)return(0,G.br)(x.route)},[x?.route]),[{value:re,error:de},ge]=(0,h.Z)(I,[I]);(0,e.useEffect)(()=>{C&&Q&&ge(C,Q)},[C,Q,ge]);const Te=(0,e.useMemo)(()=>C?Ct(C,{contactPointFilter:P,labelMatchersFilter:z}):[],[P,z,C]),Xe=!!x?.route?.provenance;function De(le){if(!C)return;const xe=(0,Ye.SF)(g??"",le,C);Fe(xe)}function ke(le){if(!C)return;const xe=(0,Ye.wB)(le,C);Fe(xe)}function qe(le,xe){if(!C)return;const xn=(0,Ye._P)(g??"",le,xe,C);Fe(xn)}function Fe(le){U&&(f(!0),n((0,ne.mM)({newConfig:{...U,alertmanager_config:{...U.alertmanager_config,route:le}},oldConfig:U,alertManagerSourceName:g,successMessage:"Updated notification policies"})).unwrap().then(()=>{g&&k(),nt(),et(),fe()}).finally(()=>{f(!1)}))}const[Le,_e,et]=Xt(T,qe,m),[Ue,tt,nt]=kt(g??"",T,De,m),[at,we,fe]=qt(ke,m),[Ke,At]=_t();if((0,$.x)(le=>le.unifiedAlerting.saveAMConfig=yn.oq),!g)return null;const Ie=(0,ft.RY)(g),te=Ie,rt=Ie,On=U?.alertmanager_config.mute_time_intervals?.length??0,Tn=U&&!H&&!X,Dn=!U&&X,In=H&&!X,Pt=s==="mute_timings",Mt=s==="notification_policies";return e.createElement(e.Fragment,null,e.createElement(v.J,null,e.createElement(B.O,{label:"Notification Policies",active:Mt,onChangeTab:()=>{E("notification_policies"),u({tab:"notification_policies"})}}),e.createElement(B.O,{label:"Mute Timings",active:Pt,counter:On,onChangeTab:()=>{E("mute_timings"),u({tab:"mute_timings"})}})),e.createElement(A.I,{className:a.tabContent},Dn&&e.createElement(S.u,{text:"Loading Alertmanager config..."}),In&&e.createElement(W.b,{severity:"error",title:"Error loading Alertmanager config"},H.message||"Unknown error."),Tn&&e.createElement(e.Fragment,null,Mt&&e.createElement(e.Fragment,null,e.createElement(ye.u,{currentAlertmanager:g}),e.createElement(d.K,{direction:"column",gap:1},C&&e.createElement(Gt,{receivers:T,onChangeMatchers:F,onChangeReceiver:y}),C&&e.createElement(bt,{receivers:T,routeTree:C,currentRoute:C,alertGroups:Q??[],contactPointsState:O.receivers,readOnly:te,provisioned:Xe,alertManagerSourceName:g,onAddPolicy:_e,onEditPolicy:tt,onDeletePolicy:we,onShowAlertInstances:At,routesMatchingFilters:Te,matchingInstancesPreview:{groupsMap:re,enabled:!de}})),Le,Ue,at,Ke),Pt&&e.createElement(It,{alertManagerSourceName:g,hideActions:rt}))))},Ct=(n,a)=>{const{contactPointFilter:o,labelMatchersFilter:i=[]}=a;let u=[];const c=(0,ht.tK)(n),s=o?it(c,m=>m.receiver===o):void 0;s&&u.push(s);const E=i.length?it(c,m=>{const f=(0,yt.QO)(m);return i.every(P=>f.some(y=>(0,l.isEqual)(P,y)))}):void 0;return E&&u.push(E),(0,l.intersectionBy)(...u,"id")},Cn=n=>({tabContent:(0,r.css)` margin-top: ${n.spacing(2)}; `});function An(n){let a="notification_policies";return n.tab==="notification_policies"&&(a="notification_policies"),n.tab==="mute_timings"&&(a="mute_timings"),{tab:a}}const Pn=()=>e.createElement(ie.O,{pageId:"am-routes",accessType:"notification"},e.createElement(bn,null)),Mn=(0,w.Pf)(Pn,{style:"page"})},98164:(J,M,t)=>{t.d(M,{V:()=>d});var r=t(33555),l=t(16881),e=t(8014);const h=l.C.injectEndpoints({endpoints:p=>({contactPointsState:p.query({queryFn:async({amSourceName:v})=>{try{return{data:await(0,e.QE)(v)}}catch(B){return{error:B}}}})})}),d=p=>{const v={receivers:{},errorCount:0},{currentData:B}=h.useContactPointsStateQuery({amSourceName:p??""},{skip:!p,pollingInterval:r.m4});return B??v}},43491:(J,M,t)=>{t.d(M,{F:()=>d});var r=t(42844),l=t(27702),e=t(66310),h=t(45986);const d=({renderExpandedContent:v,...B})=>{const A=(0,e.wW)(p);return l.createElement(h.t,{renderExpandedContent:v?(S,W,w)=>l.createElement(l.Fragment,null,W!==w.length-1&&l.createElement("div",{className:(0,r.cx)(A.contentGuideline,A.guideline)}),v(S,W,w)):void 0,renderPrefixHeader:()=>l.createElement("div",{className:A.relative},l.createElement("div",{className:(0,r.cx)(A.headerGuideline,A.guideline)})),renderPrefixCell:(S,W,w)=>l.createElement("div",{className:A.relative},l.createElement("div",{className:(0,r.cx)(A.topGuideline,A.guideline)}),W!==w.length-1&&l.createElement("div",{className:(0,r.cx)(A.bottomGuideline,A.guideline)})),...B})},p=v=>({relative:(0,r.css)` position: relative; height: 100%; `,guideline:(0,r.css)` left: -19px; border-left: 1px solid ${v.colors.border.weak}; position: absolute; ${v.breakpoints.down("md")} { display: none; } `,topGuideline:(0,r.css)` width: 18px; border-bottom: 1px solid ${v.colors.border.medium}; top: 0; bottom: 50%; `,bottomGuideline:(0,r.css)` top: 50%; bottom: 0; `,contentGuideline:(0,r.css)` top: 0; bottom: 0; left: -49px !important; `,headerGuideline:(0,r.css)` top: -17px; bottom: 0; `})},80118:(J,M,t)=>{t.d(M,{u:()=>B});var r=t(42844),l=t(27702),e=t(66310),h=t(63439),d=t(62862),p=t(52646),v=t(22513);function B({currentAlertmanager:S}){const W=(0,e.wW)(A),{useGetAlertmanagerChoiceStatusQuery:w}=p.alertmanagerApi,{currentData:V}=w(),D=S===v.GC;if(!(V?.alertmanagersChoice&&[d.TE.External,d.TE.All].includes(V?.alertmanagersChoice))||!D)return null;const j=V.numExternalAlertmanagers>0;return V.alertmanagersChoice===d.TE.External?l.createElement(h.b,{title:"Grafana alerts are not delivered to Grafana Alertmanager"},"Grafana is configured to send alerts to external Alertmanagers only. Changing Grafana Alertmanager configuration will not affect delivery of your alerts.",l.createElement("div",{className:W.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):V.alertmanagersChoice===d.TE.All&&j?l.createElement(h.b,{title:"You have additional Alertmanagers to configure",severity:"warning"},"Ensure you make configuration changes in the correct Alertmanagers; both internal and external. Changing one will not affect the others.",l.createElement("div",{className:W.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):null}const A=S=>({adminHint:(0,r.css)` font-size: ${S.typography.bodySmall.fontSize}; font-weight: ${S.typography.bodySmall.fontWeight}; `})},18629:(J,M,t)=>{t.d(M,{C0:()=>p,Uv:()=>h,Xq:()=>d});var r=t(27702),l=t(63439),e=t(25357),h=(v=>(v.ContactPoint="contact point",v.Template="template",v.MuteTiming="mute timing",v.AlertRule="alert rule",v.RootNotificationPolicy="root notification policy",v))(h||{});const d=({resource:v})=>r.createElement(l.b,{title:`This ${v} cannot be edited through the UI`,severity:"info"},"This ",v," has been provisioned, that means it was created by config. Please contact your server admin to update this ",v,"."),p=()=>r.createElement(e.C,{text:"Provisioned",color:"purple"})},92273:(J,M,t)=>{t.d(M,{c:()=>e});var r=t(27702),l=t(66310);const e=({children:h})=>{const d=(0,l.l4)();return r.createElement("strong",{style:{color:d.colors.text.primary}},h)}},9853:(J,M,t)=>{t.d(M,{y:()=>oe});var r=t(42844),l=t(27702),e=t(66310),h=t(62862),d=t(8254),p=t(10759),v=t(32082),B=t(43491),A=t(22201),S=t(66670),W=t(91368),w=t(18771),V=t(2082),D=t(22513),$=t(39036),j=t(73104),Y=t(89439);const ie=({alert:b,alertManagerSourceName:Z})=>{const K=(0,e.wW)(ye),ne=(0,V.QX)(Z),R=(0,D.HY)(Z)?W.contextSrv.hasPermission(w.AccessControlAction.AlertingRuleRead):!0;return l.createElement(l.Fragment,null,l.createElement("div",{className:K.actionsRow},l.createElement(Y.q,{actions:[ne.update,ne.create],fallback:W.contextSrv.isEditor},b.status.state===h.Z9.Suppressed&&l.createElement(S.Qj,{href:`${(0,$.eQ)("/alerting/silences",Z)}&silenceIds=${b.status.silencedBy.join(",")}`,className:K.button,icon:"bell",size:"sm"},"Manage silences"),b.status.state===h.Z9.Active&&l.createElement(S.Qj,{href:(0,$.VN)(Z,b.labels),className:K.button,icon:"bell-slash",size:"sm"},"Silence")),R&&b.generatorURL&&l.createElement(S.Qj,{className:K.button,href:b.generatorURL,icon:"chart-line",size:"sm"},"See source")),Object.entries(b.annotations).map(([se,ze])=>l.createElement(j.a,{key:se,annotationKey:se,value:ze})),l.createElement("div",{className:K.receivers},"Receivers:"," ",b.receivers.map(({name:se})=>se).filter(se=>!!se).join(", ")))},ye=b=>({button:(0,r.css)` & + & { margin-left: ${b.spacing(1)}; } `,actionsRow:(0,r.css)` padding: ${b.spacing(2,0)} !important; border-bottom: 1px solid ${b.colors.border.medium}; `,receivers:(0,r.css)` padding: ${b.spacing(1,0)}; `}),N=({alerts:b,alertManagerSourceName:Z})=>{const K=(0,e.wW)(he),ne=(0,l.useMemo)(()=>[{id:"state",label:"State",renderCell:({data:R})=>l.createElement(l.Fragment,null,l.createElement(A.G,{state:R.status.state}),l.createElement("span",{className:K.duration},"for"," ",(0,v.vT)({start:new Date(R.startsAt),end:new Date(R.endsAt)}))),size:"220px"},{id:"labels",label:"Labels",renderCell:({data:{labels:R}})=>l.createElement(d.s,{labels:R,size:"sm"}),size:1}],[K]),_=(0,l.useMemo)(()=>b.map(R=>({id:R.fingerprint,data:R})),[b]);return l.createElement("div",{className:K.tableWrapper,"data-testid":"alert-group-table"},l.createElement(B.F,{cols:ne,items:_,isExpandable:!0,renderExpandedContent:({data:R})=>l.createElement(ie,{alert:R,alertManagerSourceName:Z})}))},he=b=>({tableWrapper:(0,r.css)` margin-top: ${b.spacing(3)}; ${b.breakpoints.up("md")} { margin-left: ${b.spacing(4.5)}; } `,duration:(0,r.css)` margin-left: ${b.spacing(1)}; font-size: ${b.typography.bodySmall.fontSize}; `});var ce=t(33273);const oe=({alertManagerSourceName:b,group:Z})=>{const[K,ne]=(0,l.useState)(!0),_=(0,e.wW)(be);return l.createElement("div",{className:_.wrapper},l.createElement("div",{className:_.header},l.createElement("div",{className:_.group,"data-testid":"alert-group"},l.createElement(p.U,{size:"sm",isCollapsed:K,onToggle:()=>ne(!K),"data-testid":"alert-group-collapse-toggle"}),Object.keys(Z.labels).length?l.createElement(d.s,{labels:Z.labels,size:"sm"}):l.createElement("span",null,"No grouping")),l.createElement(ce.Z,{group:Z})),!K&&l.createElement(N,{alertManagerSourceName:b,alerts:Z.alerts}))},be=b=>({wrapper:(0,r.css)` & + & { margin-top: ${b.spacing(2)}; } `,header:(0,r.css)` display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: ${b.spacing(1,1,1,0)}; background-color: ${b.colors.background.secondary}; width: 100%; `,group:(0,r.css)` display: flex; flex-direction: row; align-items: center; `,summary:(0,r.css)``,spanElement:(0,r.css)` margin-left: ${b.spacing(.5)}; `,[h.Z9.Active]:(0,r.css)` color: ${b.colors.error.main}; `,[h.Z9.Suppressed]:(0,r.css)` color: ${b.colors.primary.main}; `,[h.Z9.Unprocessed]:(0,r.css)` color: ${b.colors.secondary.main}; `})},86342:(J,M,t)=>{t.d(M,{Nx:()=>B,kO:()=>v,ot:()=>p});var r=t(79913),l=t.n(r),e=t(27702),h=t(76658);const d=/^((([01][0-9])|(2[0-3])):[0-5][0-9])$|(^24:00$)/,p=A=>A?d.test(A):!0,v=(A,S)=>{if(!A&&!S)return!0;if(!A&&S||A&&!S)return!1;const W="HH:mm",w=l()().startOf("day").add(A,W),V=l()().startOf("day").add(S,W);return!!(A&&S&&w.isBefore(V)||A&&S&&V.isAfter(w))};function B(A){return A.time_intervals.map((W,w)=>{const{times:V,weekdays:D,days_of_month:$,months:j,years:Y,location:ie}=W,ye=(0,h.u6)(V,ie),N=(0,h.v7)(D),he=(0,h.J8)($),ce=(0,h.m8)(j),oe=(0,h.qw)(Y);return e.createElement(e.Fragment,{key:JSON.stringify(W)+w},`${ye} ${N}`,e.createElement("br",null),[he,ce,oe].join(" | "),e.createElement("br",null))})}},74023:(J,M,t)=>{t.d(M,{Kt:()=>w,HU:()=>V});var r=t(78209),l=t(73289),e=t(16881);const h=e.C.injectEndpoints({endpoints:D=>({getOnCallIntegrations:D.query({queryFn:async()=>({data:await d()})})})});async function d(){try{return(await(0,r.n)((0,l.i)().fetch({url:"/api/plugin-proxy/grafana-oncall-app/api/internal/v1/alert_receive_channels/",showErrorAlert:!1,showSuccessAlert:!1}))).data.map($=>$.integration_url)}catch{return[]}}const{useGetOnCallIntegrationsQuery:p}=h;var v=t(76393),B=t(62401);const A=(D,$)=>$.includes(D),S=(D,$)=>{if(!D.grafana_managed_receiver_configs)return!1;const j=D.grafana_managed_receiver_configs.length===1,Y=A(D.grafana_managed_receiver_configs[0]?.settings?.url??"",$);return j&&Y},W=()=>{const{installed:D}=(0,v.n)(B.W.OnCall),{data:$}=p(void 0,{skip:!D});return Y=>{if(D&&S(Y,$??[]))return B.W.OnCall}},w=D=>{const $=W(),j=Y=>({label:Y.name,value:Y.name,grafanaAppReceiverType:$(Y)});return D.map(j)},V=D=>{const $=W();return D.map(j=>({...j,grafanaAppReceiverType:$(j)}))}},22201:(J,M,t)=>{t.d(M,{G:()=>d});var r=t(27702),l=t(62862),e=t(6949);const h={[l.Z9.Active]:"bad",[l.Z9.Unprocessed]:"neutral",[l.Z9.Suppressed]:"info"},d=({state:p})=>r.createElement(e.i,{state:h[p]},p)},79003:(J,M,t)=>{t.d(M,{j:()=>h});var r=t(27702),l=t(7662),e=t(26129);function h(){const{search:d}=(0,l.TH)(),p=(0,r.useMemo)(()=>new URLSearchParams(d),[d]),v=(0,r.useCallback)((B,A)=>{e.E1.partial(B,A)},[]);return[p,v]}},14917:(J,M,t)=>{t.d(M,{y:()=>r});const r={discord:"discord",email:"envelope",googlechat:"google-hangouts-alt",hipchat:"hipchat",line:"line",pagerduty:"pagerduty",slack:"slack",teams:"microsoft",telegram:"telegram-alt"}}}]); //# sourceMappingURL=AlertAmRoutes.5bc797eea65ebe2d8ff4.js.map