"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7918],{29309:(K,C,e)=>{e.r(C),e.d(C,{RedirectToRuleViewer:()=>E,default:()=>u});var c=e(9892),t=e(66111),f=e(56895),v=e(16753),p=e(35645),T=e(72648),g=e(45253),A=e(61744),i=e(72948),r=e(39904),o=e(53546),P=e(52694),d=e(28104),n=e(76277),s=e(45849),l=e(10505);const a="Find rule",m=p.v.appSubUrl;function M(){const L=(0,v.Z)().pathname?.replace(m,"").split("/")??[],O=decodeURIComponent(L[3]),U=decodeURIComponent(L[2]);return{name:O,sourceName:U}}function E(){const _=(0,T.wW)(D),{name:L,sourceName:O}=M(),{error:U,loading:h,result:I,dispatched:$}=(0,n.X)(L,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(A.u,{text:"Loading rule..."}));if(!L||!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},L),", 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:c.css`
      font-style: italic;
      color: ${_.colors.text.secondary};
    `,rules:c.css`
      margin-top: ${_.spacing(2)};
    `,namespace:c.css`
      margin-left: ${_.spacing(1)};
    `,errorMessage:c.css`
      white-space: pre-wrap;
    `}}const u=(0,o.Pf)(E,{style:"page"})},28104:(K,C,e)=>{e.d(C,{$:()=>T,l:()=>g});var c=e(9892),t=e(66111),f=e(72648),v=e(8412);const p={icon:"bell",id:"alert-rule-view",breadcrumbs:[{title:"Alert rules",url:"alerting/list"}]};function T(r){const{wrapInContent:o=!0,children:P,title:d}=r,n=(0,f.wW)(A);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 A=r=>({content:c.css`
      max-width: ${r.breakpoints.values.xxl}px;
    `}),i=r=>o=>({wrapper:c.css`
      background: ${o.colors.background.primary};
      border: 1px solid ${o.colors.border.weak};
      border-radius: ${o.shape.borderRadius()};
      padding: ${o.spacing(r)};
    `})},76277:(K,C,e)=>{e.d(C,{H:()=>r,X:()=>o});var c=e(66111),t=e(59679),f=e(27876),v=e(72004),p=e(46818),T=e(60048),g=e(79662),A=e(61627),i=e(69945);function r(n,s){const l=P(s,n),a=(0,A.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,A.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.2737f98b311649f73bb7.js.map