"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3196,3511],{3746(d,c,a){a.r(c),a.d(c,{default:()=>ra});var e=a(74848),F=a(29189),C=a(96540),D=a(54148),r=a(92745),A=a(89640),N=a(34999),m=a(45861),B=a(88559),L=a(61848),$=a(30703),P=a(36303),W=a(1506),Y=a(86791),K=a(70327),Q=a(55143),U=a(36826),z=a(94302),H=a(18404),J=a(1512),M=a(84523),O=a(93167),V=a(48760),Z=a(88721),p=a(52161),I=a(77256),x=a(29442),S=a(29609),X=a(15629),b=a(41654),k=a(66404),w=a(39187);const q=({name:s})=>{const{returnTo:o}=(0,w.h)("/alerting/list");return(0,e.jsxs)(b.B,{direction:"row",gap:1,minWidth:0,alignItems:"center",children:[(0,e.jsx)(m.z9,{"aria-label":(0,r.t)("alerting.group-details.title.back","Back to alerting"),variant:"secondary",icon:"angle-left",href:o}),(0,e.jsx)(k.E,{element:"h1",truncate:!0,children:s})]})},{useDiscoverDsFeaturesQuery:_}=Q.L,{usePrometheusRuleNamespacesQuery:aa,useGetRuleGroupForNamespaceQuery:ea}=K.hK;function na(){const{dataSourceUid:s="",namespaceId:o="",groupName:n=""}=(0,D.g)(),t=s===p.hY,{folder:l,loading:R}=(0,H.a)(t?o:""),{data:i,isLoading:h,error:u}=_({uid:t?Y.l$:s}),{data:g,isLoading:E,error:f}=aa(i&&!i.rulerConfig?{ruleSourceName:i?.name??"",namespace:o,groupName:n}:F.hT,{selectFromResult:y=>({...y,data:y.data?.[0]?.groups.find(ca=>ca.name===n)})}),{data:v,isLoading:oa,error:T}=ea(i?.rulerConfig?{rulerConfig:i?.rulerConfig,namespace:o,group:n}:F.hT),G=t?p.hY:(0,p.$e)(s)?.name,sa=R||h||E||oa,la=g?.interval?(0,X.an)(g.interval*1e3):v?.interval??M.T6,j=l?.title??o,ia=(0,x.tx)([["namespace",j]]),da=t?(0,r.t)("alerting.group-details.folder","Folder"):(0,r.t)("alerting.group-details.namespace","Namespace"),ua=l?(0,e.jsx)(A.Y,{href:(0,I.NH)(l.uid),inline:!1,children:l.title}):o;return(0,e.jsx)(U.d,{pageNav:{text:n,parentItem:{text:j,url:ia}},renderTitle:y=>(0,e.jsx)(q,{name:y}),subTitle:(0,r.t)("alerting.titles.group-view.subtitle","Manage alert rules, recording rules and evaluation interval"),info:[{label:da,value:ua},{label:(0,r.t)("alerting.group-details.interval","Interval"),value:la}],navId:(0,J.I)(),isLoading:sa,actions:(0,e.jsx)(e.Fragment,{children:i&&(0,e.jsx)(ta,{dsFeatures:i,namespaceId:o,groupName:n,folder:l,rulerGroup:v})}),children:(0,e.jsxs)(e.Fragment,{children:[!!u&&(0,e.jsx)(N.F,{title:(0,r.t)("alerting.group-details.ds-features-error","Error loading data source details"),bottomSpacing:0,topSpacing:2,children:(0,e.jsx)("div",{children:(0,I.JZ)(u)})}),!!(f||T)&&(0,e.jsx)(N.F,{title:(0,r.t)("alerting.group-details.group-loading-error","Error loading the group"),bottomSpacing:0,topSpacing:2,children:(0,e.jsx)("div",{children:(0,I.JZ)(f||T)})}),!g&&!v&&(0,e.jsx)(W.L,{entity:`${o}/${n}`}),G&&(0,e.jsx)("ul",{role:"tree",children:t?(0,e.jsx)(V.$,{groupIdentifier:{groupName:n,groupOrigin:"grafana",namespace:{uid:o}},namespaceName:j}):(0,e.jsx)(O.e,{groupIdentifier:{groupName:n,groupOrigin:"datasource",namespace:{name:j},rulesSource:{name:G,uid:s,ruleSourceType:"datasource"}}})})]})})}function ta({dsFeatures:s,namespaceId:o,groupName:n,folder:t,rulerGroup:l}){const{canEditRules:R}=(0,Z.V)(),[i,h]=(0,C.useState)(!1),u=s.uid===p.hY,g=u?!!t?.canSave:!0,E=l?(0,S.YN)(l):!1,f=l?(0,S.oI)(l):!1,v=!!s.rulerConfig&&R(s.name)&&g&&!E&&!f;return(0,e.jsxs)(e.Fragment,{children:[u&&(0,e.jsx)(m.$n,{onClick:()=>h(!0),icon:"file-download",variant:"secondary",children:(0,e.jsx)(r.x6,{i18nKey:"alerting.group-details.export",children:"Export"})}),v&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.z9,{icon:"pen",href:x.TN.editPageLink(s.uid,o,n,{includeReturnTo:!0}),variant:"secondary",children:(0,e.jsx)(r.x6,{i18nKey:"alerting.group-details.edit",children:"Edit"})}),u&&(0,e.jsx)(B.m,{overlay:(0,e.jsxs)(L.W,{children:[(0,e.jsx)(L.W.Item,{icon:"bell",url:x.TN.newAlertRuleLink(t?.title,t?.uid,n),label:(0,r.t)("alerting.alert-rule.term","Alert rule")}),(0,e.jsx)(L.W.Item,{icon:"record-audio",url:x.TN.newRecordingRuleLink(t?.title,t?.uid,n),label:(0,r.t)("alerting.recording-rule.term","Recording rule")})]}),children:(0,e.jsxs)(m.$n,{variant:"primary",children:[(0,r.t)("alerting.group-details.new","New"),(0,e.jsx)($.I,{name:"angle-down"})]})})]}),t&&i&&(0,e.jsx)(z.l,{folderUid:t.uid,groupName:n,onClose:()=>h(!1)})]})}const ra=(0,P.Xc)(na,{style:"page"})},86559(d,c,a){d.exports=a.p+"static/img/loki_icon.abc01135.svg"},27323(d,c,a){d.exports=a.p+"static/img/mimir_logo.ac01ecbc.svg"},33611(d,c,a){d.exports=a.p+"static/img/prometheus_logo.3e9d4662.svg"}}]);

//# sourceMappingURL=AlertingGroupDetails.08ed3c1d977e89082664.js.map