"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2776],{81036:(L,D,e)=>{e.d(D,{F:()=>d});var l=e(41407),n=e(39953),h=e(82803),E=e(47224);const d=({renderExpandedContent:r,...s})=>{const i=(0,h.wW)(t);return n.createElement(E.t,{renderExpandedContent:r?(T,C,y)=>n.createElement(n.Fragment,null,C!==y.length-1&&n.createElement("div",{className:(0,l.cx)(i.contentGuideline,i.guideline)}),r(T,C,y)):void 0,renderPrefixHeader:()=>n.createElement("div",{className:i.relative},n.createElement("div",{className:(0,l.cx)(i.headerGuideline,i.guideline)})),renderPrefixCell:(T,C,y)=>n.createElement("div",{className:i.relative},n.createElement("div",{className:(0,l.cx)(i.topGuideline,i.guideline)}),C!==y.length-1&&n.createElement("div",{className:(0,l.cx)(i.bottomGuideline,i.guideline)})),...s})},t=r=>({relative:(0,l.css)`
    position: relative;
    height: 100%;
  `,guideline:(0,l.css)`
    left: -19px;
    border-left: 1px solid ${r.colors.border.weak};
    position: absolute;

    ${r.breakpoints.down("md")} {
      display: none;
    }
  `,topGuideline:(0,l.css)`
    width: 18px;
    border-bottom: 1px solid ${r.colors.border.medium};
    top: 0;
    bottom: 50%;
  `,bottomGuideline:(0,l.css)`
    top: 50%;
    bottom: 0;
  `,contentGuideline:(0,l.css)`
    top: 0;
    bottom: 0;
    left: -49px !important;
  `,headerGuideline:(0,l.css)`
    top: -17px;
    bottom: 0;
  `})},61324:(L,D,e)=>{e.d(D,{C0:()=>t,Uv:()=>E,Xq:()=>d});var l=e(39953),n=e(33155),h=e(12608),E=(r=>(r.ContactPoint="contact point",r.Template="template",r.MuteTiming="mute timing",r.AlertRule="alert rule",r.RootNotificationPolicy="root notification policy",r))(E||{});const d=({resource:r})=>l.createElement(n.b,{title:`This ${r} cannot be edited through the UI`,severity:"info"},"This ",r," has been provisioned, that means it was created by config. Please contact your server admin to update this ",r,"."),t=()=>l.createElement(h.C,{text:"Provisioned",color:"purple"})},38153:(L,D,e)=>{e.d(D,{V:()=>h});var l=e(39953),n=e(12190);const h=({namespace:E,group:d})=>d?l.createElement(l.Fragment,null,E," ",l.createElement(n.J,{name:"angle-right"})," ",d):l.createElement(l.Fragment,null,E)},3910:(L,D,e)=>{e.d(D,{V:()=>t});var l=e(41407),n=e(39953),h=e(82803),E=e(69865),d=e(12190);const t=({rule:s})=>{const i=(0,h.wW)(r);return s.health==="err"||s.health==="error"?n.createElement(E.u,{theme:"error",content:s.lastError||"No error message provided."},n.createElement("div",{className:i.warn},n.createElement(d.J,{name:"exclamation-triangle"}),n.createElement("span",null,"error"))):n.createElement(n.Fragment,null,s.health)},r=s=>({warn:(0,l.css)`
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: ${s.spacing(1)};

    color: ${s.colors.warning.text};
  `})},6320:(L,D,e)=>{e.d(D,{p:()=>T});var l=e(41407),n=e(39953),h=e(5195),E=e(27366),d=e(82803),t=e(28409),r=e(17330),s=e(15032),i=e(10162);const T=({rule:y,isDeleting:G,isCreating:V,isPaused:x})=>{const N=(0,d.wW)(C),{promRule:g}=y,F=(0,n.useMemo)(()=>{if(g&&(0,s.x_)(g)&&g.alerts?.length&&g.state!==r.x_.Inactive){const W=g.activeAt?new Date(g.activeAt):(0,s.ub)(g);if(W)return n.createElement("span",{title:String(W),className:N.for},"for"," ",(0,h.vT)({start:W,end:new Date},!1))}return null},[g,N]);return G?n.createElement(E.K,{gap:1},n.createElement(t.$,null),"Deleting"):V?n.createElement(E.K,{gap:1},n.createElement(t.$,null),"Creating"):g&&(0,s.x_)(g)?n.createElement(E.K,{gap:1},n.createElement(i.l,{state:g.state,isPaused:x}),F):g&&(0,s.OP)(g)?n.createElement(n.Fragment,null,"Recording rule"):n.createElement(n.Fragment,null,"n/a")},C=y=>({for:(0,l.css)`
    font-size: ${y.typography.bodySmall.fontSize};
    color: ${y.colors.text.secondary};
    white-space: nowrap;
    padding-top: 2px;
  `})},72776:(L,D,e)=>{e.d(D,{i:()=>Me});var l=e(41407),n=e(201),h=e(73053);function E(a,p){(0,h.Z)(2,arguments);var M=(0,n.Z)(a),R=(0,n.Z)(p);return M.getTime()<R.getTime()}var d=e(80100),t=e(39953),r=e(5195),s=e(92403),i=e(48069),T=e(82803),C=e(69865),y=e(74602),G=e(2592),V=e(63483),x=e(15032),N=e(47224),g=e(81036),F=e(61324),W=e(38153),k=e(89066),q=e(86832),_=e(53721),ee=e(27366),te=e(13601),b=e(4919),ne=e(36210),S=e(13767),ae=e(58047),Y=e(12190),le=e(32840),oe=e(90634),re=e(57721),se=e(41222),ie=e(79493),H=e(95712),j=e(76716),z=e(30391),Q=e(24597),ce=e(49376);const Ie=a=>window.matchMedia(`(max-width: ${a}px)`).matches,me=({rule:a,rulesSource:p})=>{const M=(0,re.useDispatch)(),R=(0,_.TH)(),I=(0,oe.iG)(),A=(0,T.wW)(ue),[c,o]=(0,t.useState)(void 0),{namespace:m,group:v,rulerRule:f}=a,[u,P]=(0,t.useState)(),B=(0,H.EG)(p),$=(0,x.Pc)(a.rulerRule)&&!!a.rulerRule.grafana_alert.provenance,K=[],U=[],X=(0,x.Jq)(v),{isEditable:Ce,isRemovable:ye}=(0,se.M)(B,f),w=R.pathname+R.search,Z=de(R.pathname),Te=()=>{if(u&&u.rulerRule){const O=z.Zk((0,H.EG)(u.namespace.rulesSource),u.namespace.name,u.group.name,u.rulerRule);M((0,ie.hS)(O,{navigateTo:Z?"/alerting/list":void 0})),P(void 0)}},Oe=()=>(0,j.t6)(p,a),xe=(0,H.EG)(p);if(Z||K.push(t.createElement(C.u,{placement:"top",content:"View"},t.createElement(b.Qj,{className:A.button,title:"View",size:"sm",key:"view",variant:"secondary",icon:"eye",href:(0,j.V2)(p,a,w)}))),f&&!X){const O=z.Zk(xe,m.name,v.name,f);if(Ce){if(!$){const J=(0,Q.u)(`/alerting/${encodeURIComponent(z.$V(O))}/edit`,{returnTo:w});Z&&K.push(t.createElement(ne.m,{key:"copy",icon:"copy",onClipboardError:Ae=>{I.error("Error while copying URL",Ae)},className:A.button,size:"sm",getText:Oe},"Copy link to rule")),K.push(t.createElement(C.u,{placement:"top",content:"Edit"},t.createElement(b.Qj,{title:"Edit",className:A.button,size:"sm",key:"edit",variant:"secondary",icon:"pen",href:J})))}U.push(t.createElement(S.v.Item,{label:"Duplicate",icon:"copy",onClick:()=>o({identifier:O,isProvisioned:$})}))}(0,x.Pc)(f)&&U.push(t.createElement(S.v.Item,{label:"Modify export",icon:"edit",onClick:()=>te.E1.push((0,Q.u)(`/alerting/${encodeURIComponent(z.$V(O))}/modify-export`,{returnTo:R.pathname+R.search}))}))}return ye&&f&&!X&&!$&&U.push(t.createElement(S.v.Item,{label:"Delete",icon:"trash-alt",onClick:()=>P(a)})),K.length||U.length?t.createElement(t.Fragment,null,t.createElement(ee.K,{gap:1},K.map((O,J)=>t.createElement(t.Fragment,{key:J},O)),U.length>0&&t.createElement(ae.L,{overlay:t.createElement(S.v,null,U.map(O=>t.createElement(t.Fragment,{key:(0,q.uniqueId)("action_")},O)))},t.createElement(b.zx,{variant:"secondary",size:"sm"},"More",t.createElement(Y.J,{name:"angle-down"})))),!!u&&t.createElement(le.s,{isOpen:!0,title:"Delete rule",body:t.createElement("div",null,t.createElement("p",null,'Deleting "',t.createElement("strong",null,u.name),'" will permanently remove it from your alert rule list.'),t.createElement("p",null,"Are you sure you want to delete this rule?")),confirmText:"Yes, delete",icon:"exclamation-triangle",onConfirm:Te,onDismiss:()=>P(void 0)}),c&&t.createElement(ce._,{identifier:c.identifier,isProvisioned:c.isProvisioned,onDismiss:()=>o(void 0)})):null};function de(a){return a.endsWith("/view")}const ue=a=>({button:(0,l.css)`
    padding: 0 ${a.spacing(2)};
  `});var Ee=e(32688),ve=e(73895);function ge({rule:a}){const p=(0,T.wW)(pe),{exceedsLimit:M}=(0,t.useMemo)(()=>(0,ve.f)(a.group.interval),[a.group.interval]);return M?t.createElement(C.u,{theme:"error",content:t.createElement("div",null,"A minimum evaluation interval of"," ",t.createElement("span",{className:p.globalLimitValue},Ee.config.unifiedAlerting.minInterval)," has been configured in Grafana and will be used instead of the ",a.group.interval," interval configured for the Rule Group.")},t.createElement(Y.J,{name:"stopwatch-slash",className:p.icon})):null}function pe(a){return{globalLimitValue:(0,l.css)`
      font-weight: ${a.typography.fontWeightBold};
    `,icon:(0,l.css)`
      fill: ${a.colors.warning.text};
    `}}var fe=e(61403),De=e(3910),he=e(6320);const Me=({rules:a,className:p,showGuidelines:M=!1,emptyMessage:R="No rules found.",showGroupColumn:I=!1,showSummaryColumn:A=!1,showNextEvaluationColumn:c=!1})=>{const o=(0,T.wW)(Re),m=(0,l.cx)(o.wrapper,p,{[o.wrapperMargin]:M}),v=(0,t.useMemo)(()=>a.map((P,B)=>({id:`${P.namespace.name}-${P.group.name}-${P.name}-${B}`,data:P})),[a]),f=Pe(A,I,c);if(!a.length)return t.createElement("div",{className:(0,l.cx)(m,o.emptyMessage)},R);const u=M?g.F:N.t;return t.createElement("div",{className:m,"data-testid":"rules-table"},t.createElement(u,{cols:f,isExpandable:!0,items:v,renderExpandedContent:({data:P})=>t.createElement(fe.Ii,{rule:P}),pagination:{itemsPerPage:y.gN},paginationStyles:o.pagination}))},Re=a=>({wrapperMargin:(0,l.css)`
    ${a.breakpoints.up("md")} {
      margin-left: 36px;
    }
  `,emptyMessage:(0,l.css)`
    padding: ${a.spacing(1)};
  `,wrapper:(0,l.css)`
    width: auto;
    border-radius: ${a.shape.radius.default};
  `,pagination:(0,l.css)`
    display: flex;
    margin: 0;
    padding-top: ${a.spacing(1)};
    padding-bottom: ${a.spacing(.25)};
    justify-content: center;
    border-left: 1px solid ${a.colors.border.medium};
    border-right: 1px solid ${a.colors.border.medium};
    border-bottom: 1px solid ${a.colors.border.medium};
  `});function Pe(a,p,M){const{hasRuler:R,rulerRulesLoaded:I}=(0,G.h)(),A=(0,t.useCallback)(c=>{const o=c.promRule?.lastEvaluation&&(0,r.qb)(c.promRule.lastEvaluation),m=c.group.interval&&(0,r.jO)(c.group.interval);if(!o||!m||(0,x.E)(c))return;const v=(0,r.RA)(c.group.interval),f=Date.parse(c.promRule?.lastEvaluation||""),u=(0,r.Ks)(f,v);return E(u,new Date)?{humanized:`within ${(0,d.Z)(v)}`,fullDate:`within ${(0,d.Z)(v)}`}:{humanized:`in ${(0,s.CQ)(u).locale("en").fromNow(!0)}`,fullDate:(0,i.dq)(u,{format:"YYYY-MM-DD HH:mm:ss"})}},[]);return(0,t.useMemo)(()=>{const c=[{id:"state",label:"State",renderCell:({data:o})=>{const{namespace:m}=o,{rulesSource:v}=m,{promRule:f,rulerRule:u}=o,P=!!(R(v)&&I(v)&&f&&!u),B=!!(R(v)&&I(v)&&u&&!f),$=(0,x.E)(o);return t.createElement(he.p,{rule:o,isDeleting:P,isCreating:B,isPaused:$})},size:"165px"},{id:"name",label:"Name",renderCell:({data:o})=>o.name,size:M?4:5},{id:"provisioned",label:"",renderCell:({data:o})=>{const m=o.rulerRule;return(0,x.Pc)(m)&&m.grafana_alert.provenance?t.createElement(F.C0,null):null},size:"100px"},{id:"warnings",label:"",renderCell:({data:o})=>t.createElement(ge,{rule:o}),size:"45px"},{id:"health",label:"Health",renderCell:({data:{promRule:o,group:m}})=>o?t.createElement(De.V,{rule:o}):null,size:"75px"}];return a&&c.push({id:"summary",label:"Summary",renderCell:({data:o})=>t.createElement(k.Z,{input:o.annotations[V.q6.summary]??""}),size:M?4:5}),M&&c.push({id:"nextEvaluation",label:"Next evaluation",renderCell:({data:o})=>{const m=A(o);return m&&t.createElement(C.u,{placement:"top",content:`${m?.fullDate}`,theme:"info"},t.createElement("span",null,m?.humanized))},size:2}),p&&c.push({id:"group",label:"Group",renderCell:({data:o})=>{const{namespace:m,group:v}=o;return v.name==="default"?t.createElement(W.V,{namespace:m.name}):t.createElement(W.V,{namespace:m.name,group:v.name})},size:5}),c.push({id:"actions",label:"Actions",renderCell:({data:o})=>t.createElement(me,{rule:o,rulesSource:o.namespace.rulesSource}),size:"200px"}),c},[a,p,M,R,I,A])}},2592:(L,D,e)=>{e.d(D,{h:()=>E});var l=e(39953),n=e(95712),h=e(26544);function E(){const d=(0,h._)(s=>s.rulerRules),t=(0,l.useCallback)(s=>{const i=typeof s=="string"?s:s.name;return i===n.GC||!!d[i]?.result},[d]),r=(0,l.useCallback)(s=>{const i=(0,n.EG)(s);return!!d[i]?.result},[d]);return{hasRuler:t,rulerRulesLoaded:r}}}}]);

//# sourceMappingURL=2776.96c69170618a970c2882.js.map