"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7091],{65892:(Ge,_,t)=>{t.d(_,{J:()=>G,O:()=>ge});var r=t(85960),e=t(8134),n=t(20989),A=t(90857),S=t(79055),ee=t(66681),F=t(6753),P=t(47257),L=t(74042),K=t(14607),M=t(29165),B=t(49199);const le=({localStoreKey:i,startClosed:E=!1,severity:f="error",collapseText:O,collapseTooltip:m,collapseJustify:d="flex-end",alertTitle:c,children:x})=>{const $=(0,P.l4)(),W=oe($,f),[U,v]=(0,F.Z)(i,E);return r.createElement(r.Fragment,null,U&&r.createElement(L.Lh,{justify:d},r.createElement(K.u,{content:m,placement:"bottom"},r.createElement(M.zx,{fill:"text",variant:"secondary",icon:(0,B.j)(f),className:W.warningButton,onClick:()=>v(!1)},O))),!U&&r.createElement(B.b,{severity:f,title:c,onRemove:()=>v(!0)},x))},oe=(i,E)=>{const f=i.colors[E];return{warningButton:(0,ee.css)({color:f.text,"&:hover":{background:f.transparent}})}},se="grafana.unifiedalerting.upgrade.previewNotice",ie=()=>A.config.unifiedAlertingEnabled||!A.config.featureToggles.alertingPreviewUpgrade?null:r.createElement(le,{localStoreKey:se,alertTitle:"This is a preview of the upgraded Grafana Alerting",collapseText:"Grafana Alerting Preview",collapseTooltip:"Show preview warning",severity:"warning"},r.createElement("p",null,"No rules are being evaluated and legacy alerting is still running.",r.createElement("br",null),"Please contact your administrator to upgrade permanently."),r.createElement(S.h,{external:!0,href:"https://grafana.com/docs/grafana/latest/alerting/set-up/migrating-alerts/"},"Read about upgrading"));var V=t(84954),w=t(84933),te=t(27436),ce=t(76679);function ae(i){return i.name===ce.GC?"Grafana":i.name.slice(0,37)}const z=({disabled:i=!1})=>{const E=(0,P.wW)(ue),{selectedAlertmanager:f,availableAlertManagers:O,setSelectedAlertmanager:m}=(0,V.ZA)(),d=(0,r.useMemo)(()=>O.map(c=>({label:ae(c),value:c.name,imgUrl:c.imgUrl,meta:c.meta})),[O]);return r.createElement(w._,{className:E.field,label:i?"Alertmanager":"Choose Alertmanager",disabled:i||d.length===1,"data-testid":"alertmanager-picker"},r.createElement(te.Ph,{"aria-label":i?"Alertmanager":"Choose Alertmanager",width:29,className:"ds-picker select-container",backspaceRemovesValue:!1,onChange:c=>{c?.value&&m(c.value)},options:d,maxMenuHeight:500,noOptionsMessage:"No datasources found",value:f,getOptionLabel:c=>c.label}))},ue=i=>({field:(0,ee.css)`
    margin: 0;
  `}),me=()=>r.createElement(B.b,{title:"No Alertmanager found",severity:"warning"},"We could not find any external Alertmanagers and you may not have access to the built-in Grafana Alertmanager."),D=()=>r.createElement(B.b,{title:"Selected Alertmanager not found.",severity:"warning"},"The selected Alertmanager no longer exists or you may not have permission to access it. You can select a different Alertmanager from the dropdown."),de=({availableAlertManagers:i})=>{const E=i.length>0;return r.createElement("div",null,E?r.createElement(D,null):r.createElement(me,null))},G=({children:i,isLoading:E,...f})=>r.createElement(n.T,{...f},r.createElement(n.T.Contents,{isLoading:E},r.createElement("div",null,r.createElement(ie,null),i))),ge=({children:i,accessType:E,...f})=>{const O=ne();return r.createElement(V.h5,{accessType:E},r.createElement(G,{...f,actions:r.createElement(z,{disabled:O})},r.createElement(fe,null,i)))};function ne(){const i=(0,e.Z)();return["/edit","/new"].some(f=>i?.pathname?.includes(f))}const fe=({children:i})=>{const{availableAlertManagers:E,selectedAlertmanager:f}=(0,V.ZA)();return f?r.createElement(r.Fragment,null,i):r.createElement(de,{availableAlertManagers:E})}},8944:(Ge,_,t)=>{t.d(_,{w:()=>De,X:()=>Q});var r=t(66681),e=t(85960),n=t(53285),A=t(47257),S=t(13086),ee=t(75064),F=t(20519),P=t(57445),L=t(24956),K=t(40377),M=t(96130),B=t(5999),le=t(14607),oe=t(97666),se=t(34456),ie=t(68700),V=t(92746),w=t(76679),te=t(47689),ce=t(44211),ae=t(68684),z=t(56375),ue=t(47475),me=t(61353),D=t(29165),de=t(27436),G=t(7288),ge=t(60484),ne=t(41879),fe=t(32737),i=t(95162),E=t(5970),f=t(38884),O=t(9001),m=t(84237),d=t(9561);const c=()=>{const a=(0,A.wW)(W),l=()=>window.open("https://github.com/grafana/grafana/issues/42947","_blank");return e.createElement(S.K,{gap:.5},e.createElement("div",{className:a.slashNotAllowed},"Folders with '/' character are not allowed."),e.createElement(le.u,{placement:"top",content:"Link to the Github issue",theme:"info"},e.createElement(oe.J,{name:"info-circle",size:"xs",className:a.infoIcon,onClick:l})))},x=a=>a.indexOf("/")!==-1;function $(a){const{value:l}=a,s={warningCondition:y=>x(y),warningComponent:c},u={disallowValues:!0,isAllowedValue:y=>!x(y)};return e.createElement(d.Fz,{showRoot:!1,rootName:"",allowEmpty:!0,initialTitle:l?.title,initialFolderUid:l?.uid,searchQueryType:i.SearchQueryType.AlertFolder,...a,permissionLevel:i.PermissionLevelString.Edit,customAdd:u,folderWarning:s})}const W=a=>({slashNotAllowed:(0,r.css)`
    color: ${a.colors.warning.main};
    font-size: 12px;
    margin-bottom: 2px;
  `,infoIcon:(0,r.css)`
    color: ${a.colors.warning.main};
    font-size: 12px;
    margin-bottom: 2px;
    cursor: pointer;
  `});var U=t(90943);const v=1e3,H=(a,l)=>{const o=(0,i.useDispatch)();(0,e.useEffect)(()=>{o((0,E.UR)({rulesSourceName:w.GC}))},[o]);const u=(0,V._)(g=>g.rulerRules)[w.GC];return{groupOptions:((0,ie.Zo)(w.GC).find(g=>g.name===a)?.groups??[]).map(g=>{const N=Ne(g);return{label:g.name,value:g.name,description:g.interval??f.EB,isDisabled:l?!1:N,isProvisioned:N}}).sort(be),loading:u?.loading}},Ne=a=>a.rules.some(l=>(0,O.Pc)(l.rulerRule)&&!!l.rulerRule.grafana_alert.provenance),be=(a,l)=>a.label?.localeCompare(l.label??"")||0,xe=(a,l)=>a.label?.toLowerCase().includes(l.toLowerCase());function Ie({groupfoldersForGrafana:a,enableProvisionedGroups:l}){const{formState:{errors:o},watch:s,setValue:u,control:y}=(0,n.Gc)(),I=(0,A.wW)(Ee),C=s("folder"),g=s("group"),{groupOptions:N,loading:p}=H(C?.title??"",l),[Y,b]=(0,e.useState)(!1),[k,R]=(0,e.useState)(!1),Z=()=>b(!0),q=()=>R(!0),Be=T=>{Se(),u("folder",T),b(!1)},we=(T,J)=>{u("group",T),u("evaluateEvery",J),R(!1)},Se=(0,e.useCallback)(()=>{u("group","")},[u]),Fe=(0,e.useCallback)(async T=>{const J=T?N.filter(Ce=>xe(Ce,T)):N;return(0,z.take)(J,v)},[N]),ze=(0,e.useMemo)(()=>(0,z.debounce)(Fe,300,{leading:!0}),[Fe]),j=g?{value:g,label:g}:void 0;return e.createElement("div",{className:I.container},e.createElement(S.K,{alignItems:"center"},e.createElement(F.g,{label:e.createElement(P._,{htmlFor:"folder",description:"Select a folder to store your rule."},"Folder"),className:I.formInput,error:o.folder?.message,invalid:!!o.folder?.message,"data-testid":"folder-picker"},!Y&&e.createElement(M.g,{render:({field:{ref:T,...J}})=>e.createElement("div",{style:{width:420}},e.createElement($,{inputId:"folder",...J,enableReset:!0,onChange:({title:Ce,uid:pe})=>{J.onChange({title:Ce,uid:pe}),Se()}})),name:"folder",rules:{required:{value:!0,message:"Select a folder"},validate:{pathSeparator:T=>(0,U.p0)(T.title)}}})||e.createElement("div",null,"Creating new folder...")),e.createElement(me.x,{marginTop:2.5,gap:1,display:"flex",alignItems:"center"},e.createElement(K.x,{color:"secondary"},"or"),e.createElement(D.zx,{onClick:Z,type:"button",icon:"plus",fill:"outline",variant:"secondary",disabled:!ne.contextSrv.hasPermission(i.AccessControlAction.FoldersCreate)},"New folder"))),Y&&e.createElement(re,{onCreate:Be,onClose:()=>b(!1)}),e.createElement(S.K,{alignItems:"center"},e.createElement("div",{style:{width:420}},e.createElement(F.g,{label:"Evaluation group","data-testid":"group-picker",description:"Rules within the same group are evaluated concurrently over the same time interval.",className:I.formInput,error:o.group?.message,invalid:!!o.group?.message},e.createElement(M.g,{render:({field:{ref:T,...J},fieldState:Ce})=>e.createElement(de.qb,{disabled:!C||p,inputId:"group",key:(0,z.uniqueId)(),...J,onChange:pe=>{J.onChange(pe.label??"")},isLoading:p,invalid:!!C&&!g&&!!Ce.error,loadOptions:ze,cacheOptions:!0,loadingMessage:"Loading groups...",defaultValue:j,defaultOptions:N,getOptionLabel:pe=>e.createElement("div",null,e.createElement("span",null,pe.label),pe.isProvisioned&&e.createElement(e.Fragment,null," ",e.createElement(m.C0,null))),placeholder:"Select an evaluation group..."}),name:"group",control:y,rules:{required:{value:!0,message:"Must enter a group name"},validate:{pathSeparator:T=>(0,U.p0)(T)}}}))),e.createElement(me.x,{marginTop:4,gap:1,display:"flex",alignItems:"center"},e.createElement(K.x,{color:"secondary"},"or"),e.createElement(D.zx,{onClick:q,type:"button",icon:"plus",fill:"outline",variant:"secondary",disabled:!C},"New evaluation group")),k&&e.createElement(Re,{onCreate:we,onClose:()=>R(!1),groupfoldersForGrafana:a})))}function re({onClose:a,onCreate:l}){const o=(0,A.wW)(Ee),[s,u]=(0,e.useState)(""),y=async()=>{const C=await(0,fe.L6)({title:s});if(!C.uid){ge.Z.emit(ue.SI.alertError,["Folder could not be created"]);return}const g={title:C.title,uid:C.uid};l(g),ge.Z.emit(ue.SI.alertSuccess,["Folder Created","OK"])},I=x(s);return e.createElement(G.u,{className:o.modal,isOpen:!0,title:"New folder",onDismiss:a,onClickBackdrop:a},e.createElement("div",{className:o.modalTitle},"Create a new folder to store your rule"),e.createElement("form",{onSubmit:y},e.createElement(F.g,{label:e.createElement(P._,{htmlFor:"folder"},"Folder name"),error:"The folder name can't contain slashes",invalid:I},e.createElement(L.I,{autoFocus:!0,id:"folderName",placeholder:"Enter a name",value:s,onChange:C=>u(C.currentTarget.value),className:o.formInput})),e.createElement(G.u.ButtonRow,null,e.createElement(D.zx,{variant:"secondary",type:"button",onClick:a},"Cancel"),e.createElement(D.zx,{type:"submit",disabled:!s||I},"Create"))))}function Re({onClose:a,onCreate:l,groupfoldersForGrafana:o}){const s=(0,A.wW)(Ee),u=()=>{l(Z("group"),Z("evaluateEvery"))},{watch:y}=(0,n.Gc)(),I="eval-every-input",[C,g]=y(["group","folder.title"]),N=(o&&o[g]?.find(q=>q.name===C)?.rules)??[],p=()=>{a()},Y=(0,n.cI)({defaultValues:{group:"",evaluateEvery:""},mode:"onChange",shouldFocusError:!0}),{register:b,handleSubmit:k,formState:R,getValues:Z}=Y;return e.createElement(G.u,{className:s.modal,isOpen:!0,title:"New evaluation group",onDismiss:p,onClickBackdrop:p},e.createElement("div",{className:s.modalTitle},"Create a new evaluation group to use for this alert rule."),e.createElement(n.RV,{...Y},e.createElement("form",{onSubmit:k(()=>u())},e.createElement(F.g,{label:e.createElement(P._,{htmlFor:"group"},"Evaluation group name"),error:R.errors.group?.message,invalid:!!R.errors.group},e.createElement(L.I,{className:s.formInput,autoFocus:!0,id:"group",placeholder:"Enter a name",...b("group",{required:{value:!0,message:"Required."}})})),e.createElement(F.g,{error:R.errors.evaluateEvery?.message,invalid:!!R.errors.evaluateEvery,label:e.createElement(P._,{htmlFor:I,description:"How often is the rule evaluated. Applies to every rule within the group."},"Evaluation interval")},e.createElement(L.I,{className:s.formInput,id:I,placeholder:"e.g. 5m",...b("evaluateEvery",(0,ae.MD)(N))})),e.createElement(G.u.ButtonRow,null,e.createElement(D.zx,{variant:"secondary",type:"button",onClick:p},"Cancel"),e.createElement(D.zx,{type:"submit",disabled:!R.isValid},"Create")))))}const Ee=a=>({container:(0,r.css)`
    display: flex;
    flex-direction: column;
    align-items: baseline;
    max-width: ${a.breakpoints.values.lg}px;
    justify-content: space-between;
  `,formInput:(0,r.css)`
    flex-grow: 1;
  `,modal:(0,r.css)`
    width: ${a.breakpoints.values.sm}px;
  `,modalTitle:(0,r.css)`
    color: ${a.colors.text.secondary};
    margin-bottom: ${a.spacing(2)};
  `});var X=t(25119);const he=[{value:X.g0.Alerting,label:"Alerting"},{value:X.g0.NoData,label:"No Data"},{value:X.g0.OK,label:"OK"},{value:X.g0.Error,label:"Error"}],ve=({includeNoData:a,includeError:l,...o})=>{const s=(0,e.useMemo)(()=>a?l?he:he.filter(u=>u.value!==X.g0.Error):he.filter(u=>u.value!==X.g0.NoData),[a,l]);return e.createElement(de.Ph,{options:s,...o})};var Te=t(21863),Pe=t(78985);const Q=10,Me=a=>({required:{value:!0,message:"Required."},validate:l=>{if(l==="0")return!0;try{const o=(0,te.nd)(l);if(o===0)return!0;try{const s=(0,te.nd)(a);return o>=s?!0:"For duration must be greater than or equal to the evaluation interval."}catch{return!0}}catch(o){return o instanceof Error?o.message:"Failed to parse duration"}}}),ye=(a,l)=>{const{groupOptions:o}=H(a,!1);return!(0,e.useCallback)(u=>o.some(y=>y.label===u),[o])(l)};function Ae({evaluateEvery:a,setEvaluateEvery:l,enableProvisionedGroups:o}){const s=(0,A.wW)(Le),{watch:u,setValue:y,getValues:I}=(0,n.Gc)(),[C,g]=(0,e.useState)(!1),[N,p]=u(["group","folder.title"]),b=(0,V._)(j=>j.rulerRules)[w.GC],R=(0,ie.Zo)(w.GC).find(j=>j.name===p),Z=R?.groups.find(j=>j.name===N),q=ye(p??"",N);(0,e.useEffect)(()=>{!q&&Z?.interval&&l(Z.interval)},[l,q,y,Z]);const Be=(j=!1)=>{j||(0,se.PN)(se.z7.leavingRuleGroupEdit),g(!1)},we=()=>g(!0),Se=b?.loading||q||!p||!N,Fe={name:p,rulesSource:w.GC,groups:[]},ze={name:N,interval:a,rules:[],totals:{}};return e.createElement("div",null,e.createElement(Ie,{groupfoldersForGrafana:b?.result,enableProvisionedGroups:o}),p&&C&&e.createElement(ae.vq,{namespace:R??Fe,group:Z??ze,onClose:()=>Be(),intervalEditOnly:!0,hideFolder:!0}),p&&N&&e.createElement("div",{className:s.evaluationContainer},e.createElement(S.K,{direction:"column",gap:0},e.createElement("div",{className:s.marginTop},e.createElement(S.K,{direction:"column",gap:1},I("group")&&I("evaluateEvery")&&e.createElement("span",null,"All rules in the selected group are evaluated every ",a,"."," ",!q&&e.createElement(ee.h,{name:"pen","aria-label":"Edit",disabled:Se,onClick:we})))))))}function Oe({evaluateEvery:a}){const l=(0,A.wW)(Le),{register:o,formState:{errors:s}}=(0,n.Gc)(),u="eval-for-input";return e.createElement(S.K,{direction:"row","justify-content":"flex-start","align-items":"flex-start"},e.createElement(F.g,{label:e.createElement(P._,{htmlFor:"evaluateFor",description:"Period in which an alert rule can be in breach of the condition until the alert rule fires."},"Pending period"),className:l.inlineField,error:s.evaluateFor?.message,invalid:!!s.evaluateFor?.message,validationMessageHorizontalOverflow:!0},e.createElement(L.I,{id:u,width:8,...o("evaluateFor",Me(a))})))}function h(){const a="https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rules/rule-evaluation/";return e.createElement(S.K,{direction:"row",gap:.5,alignItems:"baseline"},e.createElement(K.x,{variant:"bodySmall",color:"secondary"},"Define how the alert rule is evaluated."),e.createElement(Te.h,{contentText:"Evaluation groups are containers for evaluating alert and recording rules. An evaluation group defines an evaluation interval - how often a rule is checked. Alert rules within the same evaluation group are evaluated sequentially",externalLink:a,linkText:"Read about evaluation",title:"Evaluation"}))}function De({evaluateEvery:a,setEvaluateEvery:l,existing:o,enableProvisionedGroups:s}){const u=(0,A.wW)(Le),[y,I]=(0,e.useState)(!1),{watch:C,setValue:g}=(0,n.Gc)(),N=C("isPaused");return e.createElement(Pe.z,{stepNo:3,title:"Set evaluation behavior",description:h()},e.createElement(S.K,{direction:"column","justify-content":"flex-start","align-items":"flex-start"},e.createElement(Ae,{setEvaluateEvery:l,evaluateEvery:a,enableProvisionedGroups:s}),e.createElement(Oe,{evaluateEvery:a}),o&&e.createElement(F.g,{htmlFor:"pause-alert-switch"},e.createElement(M.g,{render:()=>e.createElement(S.K,{gap:1,direction:"row",alignItems:"center"},e.createElement(B.r,{id:"pause-alert",onChange:p=>{g("isPaused",p.currentTarget.checked)},value:!!N}),e.createElement("label",{htmlFor:"pause-alert",className:u.switchLabel},"Pause evaluation",e.createElement(le.u,{placement:"top",content:"Turn on to pause evaluation for this alert rule.",theme:"info"},e.createElement(oe.J,{tabIndex:0,name:"info-circle",size:"sm",className:u.infoIcon})))),name:"isPaused"}))),e.createElement(ce.U,{isCollapsed:!y,onToggle:p=>I(!p),text:"Configure no data and error handling"}),y&&e.createElement(e.Fragment,null,e.createElement(F.g,{htmlFor:"no-data-state-input",label:"Alert state if no data or all values are null"},e.createElement(M.g,{render:({field:{onChange:p,ref:Y,...b}})=>e.createElement(ve,{...b,inputId:"no-data-state-input",width:42,includeNoData:!0,includeError:!1,onChange:k=>p(k?.value)}),name:"noDataState"})),e.createElement(F.g,{htmlFor:"exec-err-state-input",label:"Alert state if execution error or timeout"},e.createElement(M.g,{render:({field:{onChange:p,ref:Y,...b}})=>e.createElement(ve,{...b,inputId:"exec-err-state-input",width:42,includeNoData:!1,includeError:!0,onChange:k=>p(k?.value)}),name:"execErrState"}))))}const Le=a=>({inlineField:(0,r.css)`
    margin-bottom: 0;
  `,evaluateLabel:(0,r.css)`
    margin-right: ${a.spacing(1)};
  `,evaluationContainer:(0,r.css)`
    color: ${a.colors.text.secondary};
    max-width: ${a.breakpoints.values.sm}px;
    font-size: ${a.typography.size.sm};
  `,intervalChangedLabel:(0,r.css)`
    margin-bottom: ${a.spacing(1)};
  `,warningIcon:(0,r.css)`
    justify-self: center;
    margin-right: ${a.spacing(1)};
    color: ${a.colors.warning.text};
  `,infoIcon:(0,r.css)`
    margin-left: 10px;
  `,warningMessage:(0,r.css)`
    color: ${a.colors.warning.text};
  `,bold:(0,r.css)`
    font-weight: bold;
  `,alignInterval:(0,r.css)`
    margin-top: ${a.spacing(1)};
    margin-left: -${a.spacing(1)};
  `,marginTop:(0,r.css)`
    margin-top: ${a.spacing(1)};
  `,switchLabel:(0,r.css)(`
    color: ${a.colors.text.primary},
    cursor: 'pointer',
    fontSize: ${a.typography.bodySmall.fontSize},
  `)})},68684:(Ge,_,t)=>{t.d(_,{vq:()=>f,MD:()=>E});var r=t(66681),e=t(56375),n=t(85960),A=t(53285),S=t(67192),ee=t(47257),F=t(7288),P=t(13086),L=t(20519),K=t(57445),M=t(24956),B=t(29165),le=t(93991),oe=t(95500),se=t(95162),ie=t(92746),V=t(5970),w=t(39374),te=t(76679),ce=t(30422),ae=t(9001),z=t(47689),ue=t(79253),me=t(90857),D=t(49199);const de=()=>n.createElement(D.b,{severity:"warning",title:"Global evalutation interval limit exceeded"},"A minimum evaluation interval of ",n.createElement("strong",null,me.config.unifiedAlerting.minInterval)," has been configured in Grafana.",n.createElement("br",null),"Please contact the administrator to configure a lower interval.");var G=t(8944);const ge=10;function ne({message:m,error:d}){return d?n.createElement(S.C,{color:"red",icon:"exclamation-circle",text:"Error",tooltip:m}):n.createElement(S.C,{color:"orange",icon:"exclamation-triangle",text:"Unknown",tooltip:m})}const fe=m=>{try{const d=(0,z.nd)(m);return!(d<G.X*1e3||d%(G.X*1e3)!==0)}catch{return!1}},i=({rulesWithoutRecordingRules:m})=>{const d=(0,ee.wW)(O),{watch:c}=(0,A.Gc)(),x=c("groupInterval"),$=!x,W=m.slice().map((v,H)=>({id:H,data:(0,ae.qd)(v,x)})).sort((v,H)=>(0,z.Bg)(v.data.forDuration)-(0,z.Bg)(H.data.forDuration)),U=(0,n.useMemo)(()=>[{id:"alertName",label:"Alert",renderCell:({data:{alertName:v}})=>n.createElement(n.Fragment,null,v),size:"330px"},{id:"for",label:"For",renderCell:({data:{forDuration:v}})=>n.createElement(n.Fragment,null,v),size:.5},{id:"numberEvaluations",label:"#Eval",renderCell:({data:{evaluationsToFire:v}})=>$?n.createElement(ne,{message:"#Evaluations not available."}):fe(x)?v===0?n.createElement(ne,{message:"Invalid 'For' value: it should be greater or equal to evaluation interval.",error:!0}):n.createElement(n.Fragment,null,v):n.createElement(ne,{message:"Invalid evaluation interval format",error:!0}),size:.4}],[x,$]);return n.createElement("div",{className:d.tableWrapper},n.createElement(ue.t,{items:W,cols:U,pagination:{itemsPerPage:ge}}))},E=m=>({required:{value:!0,message:"Required."},validate:d=>{try{const c=(0,z.nd)(d);return c<G.X*1e3?`Cannot be less than ${G.X} seconds.`:c%(G.X*1e3)!==0?`Must be a multiple of ${G.X} seconds.`:(0,V.iH)(m,d).length===0?!0:"Invalid evaluation interval. Evaluation interval should be smaller or equal to 'For' values for existing rules in this group."}catch(c){return c instanceof Error?c.message:"Failed to parse duration"}}});function f(m){const{namespace:d,group:c,onClose:x,intervalEditOnly:$}=m,W=(0,ee.wW)(O),U=(0,se.useDispatch)(),{loading:v,error:H,dispatched:Ne}=(0,ie._)(h=>h.updateLotexNamespaceAndGroup)??ce.oq,be=(0,le.iG)(),xe=(0,n.useMemo)(()=>({namespaceName:d.name,groupName:c.name,groupInterval:c.interval??""}),[d,c]),Ie=(0,te.EG)(d.rulesSource),re=Ie===te.GC,Re=re?"Folder":"Namespace";(0,n.useEffect)(()=>{Ne&&!v&&!H&&x(!0)},[Ne,v,x,H]),(0,oe.x)(h=>h.unifiedAlerting.updateLotexNamespaceAndGroup=ce.oq);const Ee=h=>{U((0,V.hv)({rulesSourceName:Ie,groupName:c.name,newGroupName:h.groupName,namespaceName:d.name,newNamespaceName:h.namespaceName,groupInterval:h.groupInterval||void 0}))},X=(0,A.cI)({mode:"onBlur",defaultValues:xe,shouldFocusError:!0}),{handleSubmit:he,register:ve,watch:Te,formState:{isDirty:Pe,errors:Q}}=X,Me=()=>{be.error("There are errors in the form. Correct the errors and retry.")},ye=(0,e.compact)(c.rules.map(h=>h.rulerRule).filter(h=>!(0,ae.yF)(h))),Ae=ye.length>0,Oe=$||re?"Edit evaluation group":"Edit namespace or evaluation group";return n.createElement(F.u,{className:W.modal,isOpen:!0,title:Oe,onDismiss:x,onClickBackdrop:x},n.createElement(A.RV,{...X},n.createElement("form",{onSubmit:h=>h.preventDefault(),key:JSON.stringify(xe)},n.createElement(n.Fragment,null,!m.hideFolder&&n.createElement(P.K,{gap:1,alignItems:"center"},n.createElement(L.g,{className:W.formInput,label:n.createElement(K._,{htmlFor:"namespaceName",description:!re&&"Change the current namespace name. Moving groups between namespaces is not supported"},Re),invalid:!!Q.namespaceName,error:Q.namespaceName?.message},n.createElement(M.I,{id:"namespaceName",readOnly:$||re,...ve("namespaceName",{required:"Namespace name is required."})})),re&&m.folderUrl&&n.createElement(B.Qj,{href:m.folderUrl,title:"Go to folder",variant:"secondary",icon:"folder-open",target:"_blank"})),n.createElement(L.g,{label:n.createElement(K._,{htmlFor:"groupName"},"Evaluation group name"),invalid:!!Q.groupName,error:Q.groupName?.message},n.createElement(M.I,{autoFocus:!0,id:"groupName",readOnly:$,...ve("groupName",{required:"Evaluation group name is required."})})),n.createElement(L.g,{label:n.createElement(K._,{htmlFor:"groupInterval",description:"How often is the rule evaluated. Applies to every rule within the group."},n.createElement(P.K,{gap:.5},"Evaluation interval")),invalid:!!Q.groupInterval,error:Q.groupInterval?.message},n.createElement(M.I,{id:"groupInterval",placeholder:"1m",...ve("groupInterval",E(ye))})),(0,w.f)(Te("groupInterval")).exceedsLimit&&n.createElement(de,null),!Ae&&n.createElement("div",null,"This group does not contain alert rules."),Ae&&n.createElement(n.Fragment,null,n.createElement("div",null,"List of rules that belong to this group"),n.createElement("div",{className:W.evalRequiredLabel},"#Eval column represents the number of evaluations needed before alert starts firing."),n.createElement(i,{rulesWithoutRecordingRules:ye})),n.createElement("div",{className:W.modalButtons},n.createElement(F.u.ButtonRow,null,n.createElement(B.zx,{variant:"secondary",type:"button",disabled:v,onClick:()=>x(!1),fill:"outline"},"Cancel"),n.createElement(B.zx,{type:"button",disabled:!Pe||v,onClick:he(h=>Ee(h),Me)},v?"Saving...":"Save")))))))}const O=m=>({modal:(0,r.css)`
    max-width: 560px;
  `,modalButtons:(0,r.css)`
    top: -24px;
    position: relative;
  `,formInput:(0,r.css)`
    flex: 1;
  `,tableWrapper:(0,r.css)`
    margin-top: ${m.spacing(2)};
    margin-bottom: ${m.spacing(2)};
    height: 100%;
  `,evalRequiredLabel:(0,r.css)`
    font-size: ${m.typography.bodySmall.fontSize};
  `})},44097:(Ge,_,t)=>{t.d(_,{B:()=>n});var r=t(85960),e=t(5907);function n(){return(0,r.useMemo)(()=>(0,e.Rv)(),[])}}}]);

//# sourceMappingURL=7091.a4b3cc2feccda88d3c31.js.map