"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2019],{94762:(L,T,t)=>{t.d(T,{F:()=>f});var n=t(52423),u=t(68404),N=t(72648),M=t(53731);const f=({renderExpandedContent:v,...h})=>{const m=(0,N.wW)(e);return u.createElement(M.t,{renderExpandedContent:v?(x,p,P)=>u.createElement(u.Fragment,null,p!==P.length-1&&u.createElement("div",{className:(0,n.cx)(m.contentGuideline,m.guideline)}),v(x,p,P)):void 0,renderPrefixHeader:()=>u.createElement("div",{className:m.relative},u.createElement("div",{className:(0,n.cx)(m.headerGuideline,m.guideline)})),renderPrefixCell:(x,p,P)=>u.createElement("div",{className:m.relative},u.createElement("div",{className:(0,n.cx)(m.topGuideline,m.guideline)}),p!==P.length-1&&u.createElement("div",{className:(0,n.cx)(m.bottomGuideline,m.guideline)})),...h})},e=v=>({relative:n.css`
    position: relative;
    height: 100%;
  `,guideline:n.css`
    left: -19px;
    border-left: 1px solid ${v.colors.border.medium};
    position: absolute;

    ${v.breakpoints.down("md")} {
      display: none;
    }
  `,topGuideline:n.css`
    width: 18px;
    border-bottom: 1px solid ${v.colors.border.medium};
    top: 0;
    bottom: 50%;
  `,bottomGuideline:n.css`
    top: 50%;
    bottom: 0;
  `,contentGuideline:n.css`
    top: 0;
    bottom: 0;
    left: -49px !important;
  `,headerGuideline:n.css`
    top: -25px;
    bottom: 0;
  `})},29721:(L,T,t)=>{t.d(T,{V:()=>N});var n=t(68404),u=t(39904);const N=({namespace:M,group:f})=>f?n.createElement(n.Fragment,null,M," ",n.createElement(u.J,{name:"angle-right"})," ",f):n.createElement(n.Fragment,null,M)},62019:(L,T,t)=>{t.d(T,{i:()=>Ne});var n=t(52423),u=t(85719),N=t(29122);function M(a,s){(0,N.Z)(2,arguments);var c=(0,u.Z)(a),i=(0,u.Z)(s);return c.getTime()<i.getTime()}var f=t(14016),e=t(68404),v=t(37556),h=t(46519),m=t(38849),x=t(72648),p=t(61860),P=t(84952),K=t(8055),Y=t(37190),b=t(79662),Z=t(53731),j=t(94762),J=t(40106),V=t(29721),Q=t(46587),X=t(70356),w=t(26418),z=t(31403),k=t(94599),q=t(98102),_=t(60499),ee=t(81168),te=t(44391),ae=t(72004),A=t(45849),U=t(10505),I=t(60048),ne=t(93411),le=t(41273);const Ie=a=>window.matchMedia(`(max-width: ${a}px)`).matches,se=({rule:a,rulesSource:s})=>{const c=(0,ee.useDispatch)(),i=(0,X.TH)(),R=(0,_.iG)(),D=(0,x.wW)(re),{namespace:d,group:l,rulerRule:o}=a,[r,y]=(0,e.useState)(),E=(0,A.EG)(s),g=(0,b.Pc)(a.rulerRule)&&Boolean(a.rulerRule.grafana_alert.provenance),C=[],O=(0,b.Jq)(l),{isEditable:G,isRemovable:$e}=(0,te.M)(E,o),H=i.pathname+i.search,B=oe(i.pathname),Se=()=>{if(r&&r.rulerRule){const $=I.Zk((0,A.EG)(r.namespace.rulesSource),r.namespace.name,r.group.name,r.rulerRule);c((0,ae.hS)($,{navigateTo:B?"/alerting/list":void 0})),y(void 0)}},Le=()=>(0,U.t6)(s,a),ze=(0,A.EG)(s);if(B||C.push(e.createElement(p.u,{placement:"top",content:"View"},e.createElement(z.Qj,{className:D.button,title:"View",size:"sm",key:"view",variant:"secondary",icon:"eye",href:(0,U.V2)(s,a,H)}))),G&&o&&!O){const $=I.Zk(ze,d.name,l.name,o);if(!g){const W=(0,ne.u)(`/alerting/${encodeURIComponent(I.$V($))}/edit`,{returnTo:H});B&&C.push(e.createElement(k.m,{key:"copy",icon:"copy",onClipboardError:Ae=>{R.error("Error while copying URL",Ae)},className:D.button,size:"sm",getText:Le},"Copy link to rule")),C.push(e.createElement(p.u,{placement:"top",content:"Edit"},e.createElement(z.Qj,{title:"Edit",className:D.button,size:"sm",key:"edit",variant:"secondary",icon:"pen",href:W})))}C.push(e.createElement(p.u,{placement:"top",content:"Copy"},e.createElement(le.E,{ruleIdentifier:$,isProvisioned:g,className:D.button})))}return $e&&o&&!O&&!g&&C.push(e.createElement(p.u,{placement:"top",content:"Delete"},e.createElement(z.zx,{title:"Delete",className:D.button,size:"sm",type:"button",key:"delete",variant:"secondary",icon:"trash-alt",onClick:()=>y(a)}))),C.length?e.createElement(e.Fragment,null,e.createElement(w.Stack,{gap:1},C.map(($,W)=>e.createElement(e.Fragment,{key:W},$))),!!r&&e.createElement(q.s,{isOpen:!0,title:"Delete rule",body:"Deleting this rule will permanently remove it from your alert rule list. Are you sure you want to delete this rule?",confirmText:"Yes, delete",icon:"exclamation-triangle",onConfirm:Se,onDismiss:()=>y(void 0)})):null};function oe(a){return a.endsWith("/view")}const re=a=>({button:n.css`
    padding: 0 ${a.spacing(2)};
  `});var ie=t(35645),ce=t(39904),me=t(82963);function ue({rule:a}){const s=(0,x.wW)(de),{exceedsLimit:c}=(0,e.useMemo)(()=>(0,me.f)(a.group.interval),[a.group.interval]);return c?e.createElement(p.u,{theme:"error",content:e.createElement("div",null,"A minimum evaluation interval of"," ",e.createElement("span",{className:s.globalLimitValue},ie.v.unifiedAlerting.minInterval)," has been configured in Grafana and will be used instead of the ",a.group.interval," interval configured for the Rule Group.")},e.createElement(ce.J,{name:"stopwatch-slash",className:s.icon})):null}function de(a){return{globalLimitValue:n.css`
      font-weight: ${a.typography.fontWeightBold};
    `,icon:n.css`
      fill: ${a.colors.warning.text};
    `}}var ve=t(53739),F=t(20383),pe=t(52694),S=t(80498),Ee=t(49279),ge=t(68854),fe=t(24990),he=t(8674),Re=t(78443);const De=15,ye=({rule:a})=>{const s=(0,x.wW)(xe),{namespace:{rulesSource:c}}=a,i=Object.entries(a.annotations).filter(([R,D])=>!!D.trim());return e.createElement("div",null,e.createElement(Ee.f,{rule:a,rulesSource:c,isViewMode:!1}),e.createElement("div",{className:s.wrapper},e.createElement("div",{className:s.leftSide},e.createElement(Ce,{rule:a}),!!a.labels&&!!Object.keys(a.labels).length&&e.createElement(S.C,{label:"Labels",horizontal:!0},e.createElement(pe.s,{labels:a.labels})),e.createElement(he.C,{rulesSource:c,rule:a,annotations:i}),e.createElement(ge.J,{annotations:i})),e.createElement("div",{className:s.rightSide},e.createElement(fe.C,{rulesSource:c,rule:a}))),e.createElement(Re.M,{rule:a,itemsDisplayLimit:De}))},Ce=({rule:a})=>{let s,c=a.group.interval,i=a.promRule?.lastEvaluation,R=a.promRule?.evaluationTime;return(0,b.yF)(a.rulerRule)||(s=a.rulerRule?.for),e.createElement(e.Fragment,null,c&&e.createElement(S.C,{label:"Evaluate",horizontal:!0},"Every ",c),s&&e.createElement(S.C,{label:"For",horizontal:!0},s),i&&!(0,F.gV)(i)&&e.createElement(S.C,{label:"Last evaluation",horizontal:!0},e.createElement(p.u,{placement:"top",content:`${(0,m.dq)(i,{format:"YYYY-MM-DD HH:mm:ss"})}`,theme:"info"},e.createElement("span",null,`${(0,h.CQ)(i).locale("en").fromNow(!0)} ago`))),i&&!(0,F.gV)(i)&&R!==void 0&&e.createElement(S.C,{label:"Evaluation time",horizontal:!0},e.createElement(p.u,{placement:"top",content:`${R}s`,theme:"info"},e.createElement("span",null,(0,ve.q)({timeInMs:R*1e3,humanize:!0})))))},xe=a=>({wrapper:n.css`
    display: flex;
    flex-direction: row;

    ${a.breakpoints.down("md")} {
      flex-direction: column;
    }
  `,leftSide:n.css`
    flex: 1;
  `,rightSide:n.css`
    ${a.breakpoints.up("md")} {
      padding-left: 90px;
      width: 300px;
    }
  `});var Me=t(80399),Te=t(48208);const Ne=({rules:a,className:s,showGuidelines:c=!1,emptyMessage:i="No rules found.",showGroupColumn:R=!1,showSummaryColumn:D=!1,showNextEvaluationColumn:d=!1})=>{const l=(0,x.wW)(Pe),o=(0,n.cx)(l.wrapper,s,{[l.wrapperMargin]:c}),r=(0,e.useMemo)(()=>a.map((g,C)=>({id:`${g.namespace.name}-${g.group.name}-${g.name}-${C}`,data:g})),[a]),y=be(D,R,d);if(!a.length)return e.createElement("div",{className:(0,n.cx)(o,l.emptyMessage)},i);const E=c?j.F:Z.t;return e.createElement("div",{className:o,"data-testid":"rules-table"},e.createElement(E,{cols:y,isExpandable:!0,items:r,renderExpandedContent:({data:g})=>e.createElement(ye,{rule:g}),pagination:{itemsPerPage:P.gN},paginationStyles:l.pagination}))},Pe=a=>({wrapperMargin:n.css`
    ${a.breakpoints.up("md")} {
      margin-left: 36px;
    }
  `,emptyMessage:n.css`
    padding: ${a.spacing(1)};
  `,wrapper:n.css`
    width: auto;
    border-radius: ${a.shape.borderRadius()};
  `,pagination:n.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.strong};
    border-right: 1px solid ${a.colors.border.strong};
    border-bottom: 1px solid ${a.colors.border.strong};
  `});function be(a,s,c){const{hasRuler:i,rulerRulesLoaded:R}=(0,K.h)(),D=(0,e.useCallback)(d=>{const l=d.promRule?.lastEvaluation&&(0,v.qb)(d.promRule.lastEvaluation),o=d.group.interval&&(0,v.jO)(d.group.interval);if(!l||!o||(0,b.E)(d))return;const r=(0,v.RA)(d.group.interval),y=Date.parse(d.promRule?.lastEvaluation||""),E=(0,v.Ks)(y,r);return M(E,new Date)?{humanized:`within ${(0,f.Z)(r)}`,fullDate:`within ${(0,f.Z)(r)}`}:{humanized:`in ${(0,h.CQ)(E).locale("en").fromNow(!0)}`,fullDate:(0,m.dq)(E,{format:"YYYY-MM-DD HH:mm:ss"})}},[]);return(0,e.useMemo)(()=>{const d=[{id:"state",label:"State",renderCell:({data:l})=>{const{namespace:o}=l,{rulesSource:r}=o,{promRule:y,rulerRule:E}=l,g=!!(i(r)&&R(r)&&y&&!E),C=!!(i(r)&&R(r)&&E&&!y),G=(0,b.Pc)(E)&&Boolean(E.grafana_alert.is_paused);return e.createElement(Te.p,{rule:l,isDeleting:g,isCreating:C,isPaused:G})},size:"165px"},{id:"name",label:"Name",renderCell:({data:l})=>l.name,size:c?4:5},{id:"provisioned",label:"",renderCell:({data:l})=>{const o=l.rulerRule;return(0,b.Pc)(o)&&o.grafana_alert.provenance?e.createElement(J.C0,null):null},size:"100px"},{id:"warnings",label:"",renderCell:({data:l})=>e.createElement(ue,{rule:l}),size:"45px"},{id:"health",label:"Health",renderCell:({data:{promRule:l,group:o}})=>l?e.createElement(Me.V,{rule:l}):null,size:"75px"}];return a&&d.push({id:"summary",label:"Summary",renderCell:({data:l})=>e.createElement(Q.Z,{input:l.annotations[Y.q6.summary]??""}),size:c?4:5}),c&&d.push({id:"nextEvaluation",label:"Next evaluation",renderCell:({data:l})=>{const o=D(l);return o&&e.createElement(p.u,{placement:"top",content:`${o?.fullDate}`,theme:"info"},e.createElement("span",null,o?.humanized))},size:2}),s&&d.push({id:"group",label:"Group",renderCell:({data:l})=>{const{namespace:o,group:r}=l;return r.name==="default"?e.createElement(V.V,{namespace:o.name}):e.createElement(V.V,{namespace:o.name,group:r.name})},size:5}),d.push({id:"actions",label:"Actions",renderCell:({data:l})=>e.createElement(se,{rule:l,rulesSource:l.namespace.rulesSource}),size:"200px"}),d},[a,s,c,i,R,D])}},8055:(L,T,t)=>{t.d(T,{h:()=>M});var n=t(68404),u=t(45849),N=t(69945);function M(){const f=(0,N._)(h=>h.rulerRules),e=(0,n.useCallback)(h=>{const m=typeof h=="string"?h:h.name;return m===u.GC||!!f[m]?.result},[f]),v=(0,n.useCallback)(h=>{const m=(0,u.EG)(h),x=f[m]?.result;return Boolean(x)},[f]);return{hasRuler:e,rulerRulesLoaded:v}}}}]);

//# sourceMappingURL=2019.7411fb29c95f458544af.js.map