"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3196,3511],{13272(u,g,t){t.r(g),t.d(g,{default:()=>ot});var n=t(74848),T=t(29189),B=t(96540),I=t(54148),a=t(52358),$=t(45415),F=t(33100),v=t(45270),N=t(58908),y=t(77127),P=t(37916),W=t(31612),S=t(51389),O=t(64536),Y=t(63244),K=t(38742),M=t(25877),Q=t(18740),Z=t(44629),z=t(35109),H=t(95988),J=t(93684),V=t(25945),X=t(80570),x=t(82586),G=t(29959),m=t(93621),C=t(68584),U=t(2830),b=t(68763),k=t(74144),w=t(31138);const q=({name:o})=>{const{returnTo:e}=(0,w.h)("/alerting/list");return(0,n.jsxs)(b.B,{direction:"row",gap:1,minWidth:0,alignItems:"center",children:[(0,n.jsx)(v.z9,{"aria-label":(0,a.t)("alerting.group-details.title.back","Back to alerting"),variant:"secondary",icon:"angle-left",href:e}),(0,n.jsx)(k.E,{element:"h1",truncate:!0,children:o})]})},{useDiscoverDsFeaturesQuery:_}=K.L,{usePrometheusRuleNamespacesQuery:tt,useGetRuleGroupForNamespaceQuery:nt}=Y.hK;function rt(){const{dataSourceUid:o="",namespaceId:e="",groupName:r=""}=(0,I.g)();return(0,C.dg)(r)?(0,n.jsx)(S.L,{entity:(0,a.t)("alerting.entities.group","Group")}):(0,n.jsx)(et,{dataSourceUid:o,namespaceId:e,groupName:r})}function et({dataSourceUid:o,namespaceId:e,groupName:r}){const s=o===x.hY,{folder:i,loading:L}=(0,Z.a)(s?e:""),{data:l,isLoading:p,error:d}=_({uid:s?O.l$:o}),{data:c,isLoading:R,error:h}=tt(l&&!l.rulerConfig?{ruleSourceName:l?.name??"",namespace:e,groupName:r}:T.hT,{selectFromResult:j=>({...j,data:j.data?.[0]?.groups.find(ct=>ct.name===r)})}),{data:E,isLoading:st,error:D}=nt(l?.rulerConfig?{rulerConfig:l?.rulerConfig,namespace:e,group:r}:T.hT),A=s?x.hY:(0,x.$e)(o)?.name,lt=L||p||R||st,it=c?.interval?(0,U.an)(c.interval*1e3):E?.interval??H.T6,f=i?.title??e,ut=(0,m.tx)([["namespace",f]]),dt=s?(0,a.t)("alerting.group-details.folder","Folder"):(0,a.t)("alerting.group-details.namespace","Namespace"),gt=i?(0,n.jsx)($.Y,{href:(0,G.NH)(i.uid),inline:!1,children:i.title}):e;return(0,n.jsx)(M.d,{pageNav:{text:r,parentItem:{text:f,url:ut}},renderTitle:j=>(0,n.jsx)(q,{name:j}),subTitle:(0,a.t)("alerting.titles.group-view.subtitle","Manage alert rules, recording rules and evaluation interval"),info:[{label:dt,value:gt},{label:(0,a.t)("alerting.group-details.interval","Interval"),value:it}],navId:(0,z.I)(),isLoading:lt,actions:(0,n.jsx)(n.Fragment,{children:l&&(0,n.jsx)(at,{dsFeatures:l,namespaceId:e,groupName:r,folder:i,rulerGroup:E})}),children:(0,n.jsxs)(n.Fragment,{children:[!!d&&(0,n.jsx)(F.F,{title:(0,a.t)("alerting.group-details.ds-features-error","Error loading data source details"),bottomSpacing:0,topSpacing:2,children:(0,n.jsx)("div",{children:(0,G.JZ)(d)})}),!!(h||D)&&(0,n.jsx)(F.F,{title:(0,a.t)("alerting.group-details.group-loading-error","Error loading the group"),bottomSpacing:0,topSpacing:2,children:(0,n.jsx)("div",{children:(0,G.JZ)(h||D)})}),!c&&!E&&(0,n.jsx)(S.L,{entity:`${e}/${r}`}),A&&(0,n.jsx)("ul",{role:"tree",children:s?(0,n.jsx)(V.$,{groupIdentifier:{groupName:r,groupOrigin:"grafana",namespace:{uid:e}},namespaceName:f}):(0,n.jsx)(J.e,{groupIdentifier:{groupName:r,groupOrigin:"datasource",namespace:{name:f},rulesSource:{name:A,uid:o,ruleSourceType:"datasource"}}})})]})},r)}function at({dsFeatures:o,namespaceId:e,groupName:r,folder:s,rulerGroup:i}){const{canEditRules:L}=(0,X.V)(),[l,p]=(0,B.useState)(!1),d=o.uid===x.hY,c=d?!!s?.canSave:!0,R=i?(0,C.MZ)(i).readOnly:!1,h=!!o.rulerConfig&&L(o.name)&&c&&!R;return(0,n.jsxs)(n.Fragment,{children:[d&&(0,n.jsx)(v.$n,{onClick:()=>p(!0),icon:"file-download",variant:"secondary",children:(0,n.jsx)(a.x6,{i18nKey:"alerting.group-details.export",children:"Export"})}),h&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(v.z9,{icon:"pen",href:m.TN.editPageLink(o.uid,e,r,{includeReturnTo:!0}),variant:"secondary",children:(0,n.jsx)(a.x6,{i18nKey:"alerting.group-details.edit",children:"Edit"})}),d&&(0,n.jsx)(N.m,{overlay:(0,n.jsxs)(y.W,{children:[(0,n.jsx)(y.W.Item,{icon:"bell",url:m.TN.newAlertRuleLink(s?.title,s?.uid,r),label:(0,a.t)("alerting.alert-rule.term","Alert rule")}),(0,n.jsx)(y.W.Item,{icon:"record-audio",url:m.TN.newRecordingRuleLink(s?.title,s?.uid,r),label:(0,a.t)("alerting.recording-rule.term","Recording rule")})]}),children:(0,n.jsxs)(v.$n,{variant:"primary",children:[(0,a.t)("alerting.group-details.new","New"),(0,n.jsx)(P.I,{name:"angle-down"})]})})]}),s&&l&&(0,n.jsx)(Q.l,{folderUid:s.uid,groupName:r,onClose:()=>p(!1)})]})}const ot=(0,W.Xc)(rt,{style:"page"})},86559(u,g,t){u.exports=t.p+"static/img/loki_icon.abc01135.svg"},27323(u,g,t){u.exports=t.p+"static/img/mimir_logo.ac01ecbc.svg"},33611(u,g,t){u.exports=t.p+"static/img/prometheus_logo.3e9d4662.svg"}}]);

//# sourceMappingURL=AlertingGroupDetails.66f7fb6a82e41d8baa9d.js.map