"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5516],{15102(G,f,r){r.r(f),r.d(f,{RedirectToRuleViewer:()=>$,default:()=>z});var e=r(14553),l=r(22803),w=r(55501),p=r(54148),L=r(87586),P=r(93374),i=r(92745),T=r(43173),I=r(68143),x=r(63142),N=r(34999),F=r(6975),g=r(8073),M=r(30703),y=r(13791),U=r(1512);const V={icon:"bell",id:"alert-rule-view"};function c(s){const{wrapInContent:a=!0,children:n,title:u,renderTitle:o}=s,m=(0,x.of)(A);return(0,e.jsx)(y.Y,{pageNav:{...V,text:u},renderTitle:o,navId:(0,U.I)(),children:(0,e.jsx)(y.Y.Contents,{children:(0,e.jsx)("div",{className:m.content,children:a?(0,e.jsx)(Z,{...s}):n})})})}function Z({children:s,padding:a=2}){const n=(0,x.of)(K(a));return(0,e.jsx)("div",{className:n.wrapper,children:s})}const A=s=>({content:(0,l.css)({maxWidth:`${s.breakpoints.values.xxl}px`})}),K=s=>a=>({wrapper:(0,l.css)({background:a.colors.background.primary,border:`1px solid ${a.colors.border.weak}`,borderRadius:a.shape.radius.default,padding:a.spacing(s)})});var Y=r(44109),B=r(52161),C=r(77256),R=r(94646),E=r(88547);const d="Find rule",S=T.$.appSubUrl;function H(){const s=(0,L.A)();return(0,w.useMemo)(()=>{const a=s.pathname?.replace(S,"").split("/")??[],n=(0,R.c)(decodeURIComponent((0,R.c)(a[3]))),u=decodeURIComponent(a[2]),o=new URLSearchParams(s.search);return{name:n,sourceName:u,namespace:o.get("namespace")??void 0,group:o.get("group")??void 0}},[s])}function $(){const s=(0,x.of)(W),{name:a,sourceName:n,namespace:u,group:o}=H(),{error:m,loading:D,rules:v=[]}=(0,Y.we)(a,n,{namespace:u,groupName:o});if(!a||!n)return(0,e.jsx)(p.C5,{replace:!0,to:"/notfound"});if(m)return(0,e.jsx)(c,{title:d,children:(0,e.jsx)(N.F,{title:(0,i.t)("alerting.redirect-to-rule-viewer.title-failed-to-load","Failed to load rules from {{sourceName}}",{sourceName:n}),children:(0,I.NF)(m)&&(0,e.jsxs)("details",{className:s.errorMessage,children:[m.message,(0,e.jsx)("br",{})]})})});if(D)return(0,e.jsx)(c,{title:d,children:(0,e.jsx)(F._,{text:(0,i.t)("alerting.redirect-to-rule-viewer.text-loading-rule","Loading rule...")})});const h=(0,B.Zw)(n);if(!h)return(0,e.jsx)(c,{title:d,children:(0,e.jsx)(N.F,{title:(0,i.t)("alerting.redirect-to-rule-viewer.title-could-not-view-rule","Could not view rule"),children:(0,e.jsx)("details",{className:s.errorMessage,children:`Could not find data source with name: ${n}.`})})});if(v.length===1){const[t]=v,j=(0,C.w$)(h,t,"/alerting/list").replace(S,"");return(0,e.jsx)(p.C5,{replace:!0,to:j})}return v.length===0?(0,e.jsx)(c,{title:d,children:(0,e.jsx)("div",{"data-testid":"no-rules",children:(0,e.jsxs)(i.x6,{i18nKey:"alerting.redirect-to-rule-viewer.no-rules-found",values:{sourceName:n,name:a},children:["No rules in ",(0,e.jsx)("span",{className:s.param,children:"{{sourceName}}"})," matched the name"," ",(0,e.jsx)("span",{className:s.param,children:"{{name}}"})]})})}):(0,e.jsxs)(c,{title:d,children:[(0,e.jsx)("div",{children:(0,e.jsxs)(i.x6,{i18nKey:"alerting.redirect-to-rule-viewer.several-rules-found",values:{sourceName:n,name:a},children:["Several rules in ",(0,e.jsx)("span",{className:s.param,children:"{{sourceName}}"})," matched the name"," ",(0,e.jsx)("span",{className:s.param,children:"{{name}}"}),", please select the rule you want to view."]})}),(0,e.jsx)("div",{className:s.rules,children:v.map((t,j)=>(0,e.jsxs)(g.Z,{noMargin:!0,href:(0,C.w$)(h,t,"/alerting/list"),children:[(0,e.jsx)(g.Z.Heading,{children:t.name}),(0,e.jsxs)(g.Z.Meta,{separator:"",children:[(0,e.jsx)(M.I,{name:"folder"}),(0,e.jsx)("span",{className:s.namespace,children:`${t.namespace.name} / ${t.group.name}`})]}),(0,e.jsx)(g.Z.Tags,{children:(0,e.jsx)(P.m,{labels:t.labels})})]},`${t.name}-${j}`))})]})}function W(s){return{param:(0,l.css)({fontStyle:"italic",color:s.colors.text.secondary}),rules:(0,l.css)({marginTop:s.spacing(2)}),namespace:(0,l.css)({marginLeft:s.spacing(1)}),errorMessage:(0,l.css)({whiteSpace:"pre-wrap"})}}const z=(0,E.S)($)}}]);

//# sourceMappingURL=AlertingRedirectToRule-react19.42031b7084a48aae13e2.js.map