"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[152,4333],{85185(P,S,a){a.r(S),a.d(S,{BrowseFolderAlertingPage:()=>D,default:()=>ia});var t=a(14553),x=a(55501),B=a(54148),u=a(92745),b=a(34999),N=a(98970),R=a(13791),Z=a(66198),v=a(22803),E=a(2543),Y=a(40996),U=a(63142),C=a(41654),I=a(12737),W=a(54604),O=a(30703),p=a(8073),$=a(37658),G=a(34213),H=a(95943),y=a(1404),K=a(74048),z=a(20962),M=a(24610),T=a(52161),J=a(63895),Q=a(29442),V=(e=>(e.Ascending="alpha-asc",e.Descending="alpha-desc",e))(V||{});const X=[{label:"Alphabetically [A-Z]",value:"alpha-asc"},{label:"Alphabetically [Z-A]",value:"alpha-desc"}],w=({folder:e,rules:s})=>{const r=(0,U.of)(ea),g=c=>{const L=(0,M.EU)(o,c);i(L)},{nameFilter:n,labelFilter:o,sortOrder:l,setNameFilter:h,setLabelFilter:i,setSortOrder:m}=q(),j=_(s,n,o,l??"alpha-asc"),d=j.length===0,{page:f,numberOfPages:F,onPageChange:A,pageItems:da}=(0,K.W)(j,1,H.FG);return(0,t.jsx)("div",{className:r.container,children:(0,t.jsxs)(C.B,{direction:"column",gap:3,children:[(0,t.jsx)(I.Z,{value:n,onChange:h,placeholder:(0,u.t)("alerting.alerts-folder-view.name-filter-placeholder-search-alert-rules-by-name","Search alert rules by name"),"data-testid":"name-filter"}),(0,t.jsxs)(C.B,{direction:"row",children:[(0,t.jsx)(W.l6,{value:l,onChange:({value:c})=>c&&m(c),options:X,width:25,"aria-label":(0,u.t)("alerting.alerts-folder-view.aria-label-sort","Sort"),placeholder:(0,u.t)("alerting.alerts-folder-view.placeholder-sort-default-az","Sort (Default A-Z)"),prefix:(0,t.jsx)(O.I,{name:l==="alpha-asc"?"sort-amount-up":"sort-amount-down"})}),(0,t.jsx)(I.Z,{value:o,onChange:i,placeholder:(0,u.t)("alerting.alerts-folder-view.label-filter-placeholder-search-alerts-by-labels","Search alerts by labels"),className:r.filterLabelsInput,"data-testid":"label-filter"})]}),(0,t.jsx)(C.B,{direction:"column",children:da.map(({grafana_alert:c,labels:L={}})=>(0,t.jsxs)(p.Z,{noMargin:!0,href:aa(c),className:r.card,"data-testid":"alert-card-row",children:[(0,t.jsx)(p.Z.Heading,{children:c.title}),(0,t.jsx)(p.Z.Tags,{children:(0,t.jsx)($.L,{onClick:g,tags:Object.entries(L).map(([ca,ua])=>`${ca}=${ua}`)})}),(0,t.jsx)(p.Z.Meta,{children:(0,t.jsxs)("div",{children:[(0,t.jsx)(O.I,{name:"folder"})," ",e.title]})})]},c.uid))}),d&&(0,t.jsx)("div",{className:r.noResults,children:(0,t.jsx)(u.x6,{i18nKey:"alerting.alerts-folder-view.no-alert-rules-found",children:"No alert rules found"})}),(0,t.jsx)("div",{className:r.pagination,children:(0,t.jsx)(G.d,{currentPage:f,numberOfPages:F,onNavigate:A,hideWhenSinglePage:!0})})]})})};var k=(e=>(e.nameFilter="nameFilter",e.labelFilter="labelFilter",e.sortOrder="sort",e))(k||{});function q(){const[e,s]=(0,z.l)(),[r,g]=(0,x.useState)(e.get("nameFilter")??""),[n,o]=(0,x.useState)(e.get("labelFilter")??""),l=e.get("sort"),h=(()=>{if(l==="alpha-asc")return"alpha-asc";if(l==="alpha-desc")return"alpha-desc"})(),[i,m]=(0,x.useState)(h);return(0,Y.A)(()=>s({nameFilter:(0,y.fE)(r),labelFilter:(0,y.fE)(n),sort:(0,y.fE)(i)},!0),400,[r,n,i]),{nameFilter:r,labelFilter:n,sortOrder:i,setNameFilter:g,setLabelFilter:o,setSortOrder:m}}function _(e,s,r,g){const n=(0,J.Zc)(r),o=e.filter(l=>{const h=l.grafana_alert.title.toLowerCase().includes(s.toLowerCase()),i=(0,M.Av)(l.labels??{},n);return h&&i});return(0,E.orderBy)(o,l=>l.grafana_alert.title.toLowerCase(),[g==="alpha-asc"?"asc":"desc"])}function aa(e){return Q.PP.detailsPageLink(T.hY,{uid:e.uid,ruleSourceName:T.hY},void 0)}const ea=e=>({container:(0,v.css)({padding:e.spacing(1)}),card:(0,v.css)({gridTemplateColumns:"auto 1fr 2fr"}),pagination:(0,v.css)({alignSelf:"center"}),filterLabelsInput:(0,v.css)({flex:1,width:"auto",minWidth:"240px"}),noResults:(0,v.css)({padding:e.spacing(2),backgroundColor:e.colors.background.secondary,borderRadius:e.shape.radius.lg,fontStyle:"italic"})});var ta=a(70327),sa=a(55143),ra=a(77256),la=a(29609),na=a(12518);const{useRulerNamespaceQuery:oa}=ta.hK;function D(){const{uid:e=""}=(0,B.g)(),{data:s,isLoading:r}=(0,N.u$)(e),{data:g={},isLoading:n,error:o}=oa({rulerConfig:sa.b,namespace:e}),[l]=(0,N.HP)(),h=(0,x.useMemo)(()=>{if(!s)return;const d=(0,Z.R4)(s),f=(0,Z.Fk)(s.uid),F=d.children?.find(A=>A.id===f);return F&&(F.active=!0),d},[s]),i=e?async d=>{if(s){const f=await l({...s,title:d});if("error"in f)throw f.error}}:void 0,m=r||n,j=Object.values(g).flatMap(d=>d).flatMap(d=>d.rules).filter(la.p.grafana.rule);return(0,t.jsx)(R.Y,{navId:"dashboards/browse",pageNav:h,onEditTitle:i,actions:s&&(0,t.jsx)(na.A,{folderDTO:s}),children:(0,t.jsxs)(R.Y.Contents,{isLoading:m,children:[!s&&(0,t.jsx)(b.F,{title:(0,u.t)("browse-dashboards.browse-folder-alerting-page.title-folder-not-found","Folder not found")}),!!o&&(0,t.jsx)(b.F,{title:(0,u.t)("browse-dashboards.browse-folder-alerting-page.title-ruler-namespace-error","Cannot load rules"),severity:"error",children:(0,ra.JZ)(o)}),s&&(0,t.jsx)(w,{folder:s,rules:j})]})})}const ia=D},58033(P,S,a){P.exports=a.p+"static/img/user_profile.4d4fc140.png"}}]);

//# sourceMappingURL=FolderAlerting-react19.c9d5c2a5277a2f70a53b.js.map