"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7918],{39513:(K,C,e)=>{e.r(C),e.d(C,{RedirectToRuleViewer:()=>E,default:()=>u});var c=e(42844),t=e(27702),f=e(7662),v=e(75136),p=e(34667),T=e(66310),g=e(63439),L=e(52419),i=e(50230),r=e(73453),o=e(37647),P=e(8254),d=e(89462),n=e(19552),s=e(22513),l=e(39036);const a="Find rule",m=p.config.appSubUrl;function M(){const A=(0,v.Z)().pathname?.replace(m,"").split("/")??[],O=decodeURIComponent(A[3]),U=decodeURIComponent(A[2]);return{name:O,sourceName:U}}function E(){const _=(0,T.wW)(D),{name:A,sourceName:O}=M(),{error:U,loading:h,result:I,dispatched:$}=(0,n.X)(A,O);if(U)return t.createElement(d.$,{title:a},t.createElement(g.b,{title:`Failed to load rules from ${O}`},t.createElement("details",{className:_.errorMessage},U.message,t.createElement("br",null),!!U?.stack&&U.stack)));if(h||!$||!Array.isArray(I))return t.createElement(d.$,{title:a},t.createElement(L.u,{text:"Loading rule..."}));if(!A||!O)return t.createElement(f.l_,{to:"/notfound"});const W=(0,s.o_)(O);if(!W)return t.createElement(d.$,{title:a},t.createElement(g.b,{title:"Could not view rule"},t.createElement("details",{className:_.errorMessage},`Could not find data source with name: ${O}.`)));if(I.length===1){const[R]=I,B=(0,l.V2)(W,R,"/alerting/list").replace(m,"");return t.createElement(f.l_,{to:B})}return t.createElement(d.$,{title:a},t.createElement("div",null,"Several rules in ",t.createElement("span",{className:_.param},O)," matched the name"," ",t.createElement("span",{className:_.param},A),", please select the rule you want to view."),t.createElement("div",{className:_.rules},I.map((R,B)=>t.createElement(i.Z,{key:`${R.name}-${B}`,href:(0,l.V2)(W,R,"/alerting/list")},t.createElement(i.Z.Heading,null,R.name),t.createElement(i.Z.Meta,{separator:""},t.createElement(r.J,{name:"folder"}),t.createElement("span",{className:_.namespace},`${R.namespace.name} / ${R.group.name}`)),t.createElement(i.Z.Tags,null,t.createElement(P.s,{labels:R.labels}))))))}function D(_){return{param:(0,c.css)`
      font-style: italic;
      color: ${_.colors.text.secondary};
    `,rules:(0,c.css)`
      margin-top: ${_.spacing(2)};
    `,namespace:(0,c.css)`
      margin-left: ${_.spacing(1)};
    `,errorMessage:(0,c.css)`
      white-space: pre-wrap;
    `}}const u=(0,o.Pf)(E,{style:"page"})},89462:(K,C,e)=>{e.d(C,{$:()=>T,l:()=>g});var c=e(42844),t=e(27702),f=e(66310),v=e(44644);const p={icon:"bell",id:"alert-rule-view"};function T(r){const{wrapInContent:o=!0,children:P,title:d}=r,n=(0,f.wW)(L);return t.createElement(v.T,{pageNav:{...p,text:d},navId:"alert-list"},t.createElement(v.T.Contents,null,t.createElement("div",{className:n.content},o?t.createElement(g,{...r}):P)))}function g({children:r,padding:o=2}){const P=(0,f.wW)(i(o));return t.createElement("div",{className:P.wrapper},r)}const L=r=>({content:(0,c.css)`
      max-width: ${r.breakpoints.values.xxl}px;
    `}),i=r=>o=>({wrapper:(0,c.css)`
      background: ${o.colors.background.primary};
      border: 1px solid ${o.colors.border.weak};
      border-radius: ${o.shape.borderRadius()};
      padding: ${o.spacing(r)};
    `})},19552:(K,C,e)=>{e.d(C,{H:()=>r,X:()=>o});var c=e(27702),t=e(25111),f=e(18771),v=e(47702),p=e(84369),T=e(96437),g=e(22446),L=e(52467),i=e(10027);function r(n,s){const l=P(s,n),a=(0,L.Zo)(s),m=(0,c.useMemo)(()=>{if(!(!n||!s||a.length===0))for(const M of a)for(const E of M.groups)for(const D of E.rules){const u=T.Yd(s,D);if(T.Dg(u,n))return D}},[n,s,a]);return{...l,result:m}}function o(n,s){const l=P(s),a=(0,L.Zo)(s),m=(0,c.useMemo)(()=>{if(!n||!s||a.length===0)return[];const M=[];for(const E of a)for(const D of E.groups)for(const u of D.rules)u.name===n&&M.push(u);return M},[n,s,a]);return{...l,result:m}}function P(n,s){const l=(0,f.useDispatch)(),a=(0,i._)(u=>u.promRules),m=d(n,a),M=(0,i._)(u=>u.rulerRules),E=d(n,M),{loading:D}=(0,t.Z)(async()=>{n&&await l((0,v.dn)({rulesSourceName:n,identifier:s}))},[l,n]);return{loading:D,error:m.error??(0,g.m$)(E)?void 0:E.error,dispatched:m.dispatched&&E.dispatched}}function d(n,s){if(!n)return p.oq;const l=s[n];return l||p.oq}}}]);

//# sourceMappingURL=AlertingRedirectToRule.c931a4a04d05966e2e10.js.map