D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
share
/
grafana
/
public
/
build
/
Filename :
1608.e48b1efacfa85511f0cf.js
back
Copy
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1608],{75429:(k,R,t)=>{t.d(R,{x:()=>p});var r=t(27702),e=t(18771),n=t(92071);function p(g){const N=(0,e.useDispatch)(),l=(0,r.useRef)(g);l.current=g,(0,r.useEffect)(()=>()=>{N((0,n.e)({cleanupAction:l.current}))},[N])}},278:(k,R,t)=>{t.d(R,{w:()=>Te,X:()=>Pe});var r=t(42844),e=t(27702),n=t(46089),p=t(23852),g=t(66310),N=t(67437),l=t(22209),S=t(79978),u=t(1128),x=t(16310),O=t(42074),U=t(80011),b=t(73453),ce=t(28722),ue=t(52467),de=t(10027),T=t(22513),me=t(447),ge=t(10759),ae=t(98658),q=t(89949),Y=t(3935),w=t(66670),pe=t(28580),_=t(13741),ve=t(5933),V=t(91368),Fe=t(77799),H=t(18771),Se=t(47702),Re=t(85184),Ee=t(22446),Oe=t(18629),fe=t(41482);const v=()=>{const a=(0,g.wW)(M),o=()=>window.open("https://github.com/grafana/grafana/issues/42947","_blank");return e.createElement(p.K,{gap:.5},e.createElement("div",{className:a.slashNotAllowed},"Folders with '/' character are not allowed."),e.createElement(U.u,{placement:"top",content:"Link to the Github issue",theme:"info"},e.createElement(b.J,{name:"info-circle",size:"xs",className:a.infoIcon,onClick:o})))},E=a=>a.indexOf("/")!==-1;function I(a){const{value:o}=a,s={warningCondition:d=>E(d),warningComponent:v},m={disallowValues:!0,isAllowedValue:d=>!E(d)};return e.createElement(fe.Fz,{showRoot:!1,rootName:"",allowEmpty:!0,initialTitle:o?.title,initialFolderUid:o?.uid,searchQueryType:H.SearchQueryType.AlertFolder,...a,permissionLevel:H.PermissionLevelString.Edit,customAdd:m,folderWarning:s})}const M=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 A=t(95017);const X=1e3,ee=a=>{const o=(0,H.useDispatch)();(0,e.useEffect)(()=>{o((0,Se.UR)({rulesSourceName:T.GC}))},[o]);const s=(0,de._)(c=>c.rulerRules)[T.GC];return{groupOptions:((0,ue.Zo)(T.GC).find(c=>c.name===a)?.groups??[]).map(c=>({label:c.name,value:c.name,description:c.interval??Re.EB,isDisabled:C(c)})).sort(j),loading:s?.loading}},C=a=>a.rules.some(o=>(0,Ee.Pc)(o.rulerRule)&&!!o.rulerRule.grafana_alert.provenance),j=(a,o)=>a.label?.localeCompare(o.label??"")||0,he=(a,o)=>a.label?.toLowerCase().includes(o.toLowerCase());function Ge({groupfoldersForGrafana:a}){const{formState:{errors:o},watch:i,setValue:s,control:m}=(0,n.Gc)(),d=(0,g.wW)($),F=i("folder"),c=i("group"),{groupOptions:y,loading:h}=ee(F?.title??""),[B,G]=(0,e.useState)(!1),[L,Q]=(0,e.useState)(!1),P=()=>G(!0),W=()=>Q(!0),se=D=>{xe(),s("folder",D),G(!1)},Ae=(D,K)=>{s("group",D),s("evaluateEvery",K),Q(!1)},xe=(0,e.useCallback)(()=>{s("group","")},[s]),Ie=(0,e.useCallback)(async D=>{const K=D?y.filter(ie=>he(ie,D)):y;return(0,q.take)(K,X)},[y]),$e=(0,e.useMemo)(()=>(0,q.debounce)(Ie,300,{leading:!0}),[Ie]),z=c?{value:c,label:c}:void 0;return e.createElement("div",{className:d.container},e.createElement("div",{className:d.evaluationGroupsContainer},e.createElement(l.g,{label:e.createElement(S._,{htmlFor:"folder",description:"Select a folder to store your rule."},"Folder"),className:d.formInput,error:o.folder?.message,invalid:!!o.folder?.message,"data-testid":"folder-picker"},!B&&e.createElement(x.g,{render:({field:{ref:D,...K}})=>e.createElement(I,{inputId:"folder",...K,enableReset:!0,onChange:({title:ie,uid:te})=>{K.onChange({title:ie,uid:te}),xe()}}),name:"folder",rules:{required:{value:!0,message:"Select a folder"},validate:{pathSeparator:D=>(0,A.p0)(D.title)}}})||e.createElement("div",null,"Creating new folder...")),e.createElement("div",{className:d.addButton},e.createElement("span",null,"or"),e.createElement(w.zx,{onClick:P,type:"button",icon:"plus",fill:"outline",variant:"secondary",disabled:!V.contextSrv.hasPermission(H.AccessControlAction.FoldersCreate)},"New folder")),B&&e.createElement(Ce,{onCreate:se,onClose:()=>G(!1)})),e.createElement("div",{className:d.evaluationGroupsContainer},e.createElement(l.g,{label:"Evaluation group","data-testid":"group-picker",description:"Rules within the same group are evaluated sequentially over the same time interval.",className:d.formInput,error:o.group?.message,invalid:!!o.group?.message},e.createElement(x.g,{render:({field:{ref:D,...K},fieldState:ie})=>e.createElement(pe.qb,{disabled:!F||h,inputId:"group",key:(0,q.uniqueId)(),...K,onChange:te=>{K.onChange(te.label??"")},isLoading:h,invalid:!!F&&!c&&!!ie.error,loadOptions:$e,cacheOptions:!0,loadingMessage:"Loading groups...",defaultValue:z,defaultOptions:y,getOptionLabel:te=>e.createElement("div",null,e.createElement("span",null,te.label),te.isDisabled&&e.createElement(e.Fragment,null," ",e.createElement(Oe.C0,null))),placeholder:"Select an evaluation group..."}),name:"group",control:m,rules:{required:{value:!0,message:"Must enter a group name"},validate:{pathSeparator:D=>(0,A.p0)(D)}}})),e.createElement("div",{className:d.addButton},e.createElement("span",null,"or"),e.createElement(w.zx,{onClick:W,type:"button",icon:"plus",fill:"outline",variant:"secondary",disabled:!F},"New evaluation group")),L&&e.createElement(ye,{onCreate:Ae,onClose:()=>Q(!1),groupfoldersForGrafana:a})))}function Ce({onClose:a,onCreate:o}){const i=(0,g.wW)($),[s,m]=(0,e.useState)(""),d=async()=>{const c=await(0,Fe.L6)({title:s});if(!c.uid){ve.Z.emit(Y.SI.alertError,["Folder could not be created"]);return}const y={title:c.title,uid:c.uid};o(y),ve.Z.emit(Y.SI.alertSuccess,["Folder Created","OK"])},F=E(s);return e.createElement(_.u,{className:i.modal,isOpen:!0,title:"New folder",onDismiss:a,onClickBackdrop:a},e.createElement("div",{className:i.modalTitle},"Create a new folder to store your rule"),e.createElement("form",{onSubmit:d},e.createElement(l.g,{label:e.createElement(S._,{htmlFor:"folder"},"Folder name"),error:"The folder name can't contain slashes",invalid:F},e.createElement(u.I,{autoFocus:!0,id:"folderName",placeholder:"Enter a name",value:s,onChange:c=>m(c.currentTarget.value),className:i.formInput})),e.createElement(_.u.ButtonRow,null,e.createElement(w.zx,{variant:"secondary",type:"button",onClick:a},"Cancel"),e.createElement(w.zx,{type:"submit",disabled:!s||F},"Create"))))}function ye({onClose:a,onCreate:o,groupfoldersForGrafana:i}){const s=(0,g.wW)($),m=()=>{o(W("group"),W("evaluateEvery"))},{watch:d}=(0,n.Gc)(),F="eval-every-input",[c,y]=d(["group","folder.title"]),h=(i&&i[y]?.find(se=>se.name===c)?.rules)??[],B=()=>{a()},G=(0,n.cI)({defaultValues:{group:"",evaluateEvery:""},mode:"onChange",shouldFocusError:!0}),{register:L,handleSubmit:Q,formState:P,getValues:W}=G;return e.createElement(_.u,{className:s.modal,isOpen:!0,title:"New evaluation group",onDismiss:B,onClickBackdrop:B},e.createElement("div",{className:s.modalTitle},"Create a new evaluation group to use for this alert rule."),e.createElement(n.RV,{...G},e.createElement("form",{onSubmit:Q(()=>m())},e.createElement(l.g,{label:e.createElement(S._,{htmlFor:"group"},"Evaluation group name"),error:P.errors.group?.message,invalid:!!P.errors.group},e.createElement(u.I,{className:s.formInput,autoFocus:!0,id:"group",placeholder:"Enter a name",...L("group",{required:{value:!0,message:"Required."}})})),e.createElement(l.g,{error:P.errors.evaluateEvery?.message,invalid:!!P.errors.evaluateEvery,label:e.createElement(S._,{htmlFor:F,description:"How often is the rule evaluated. Applies to every rule within the group."},"Evaluation interval")},e.createElement(u.I,{className:s.formInput,id:F,placeholder:"e.g. 5m",...L("evaluateEvery",(0,ae.MD)(h))})),e.createElement(_.u.ButtonRow,null,e.createElement(w.zx,{variant:"secondary",type:"button",onClick:B},"Cancel"),e.createElement(w.zx,{type:"submit",disabled:!P.isValid},"Create")))))}const $=a=>({container:(0,r.css)` margin-top: ${a.spacing(1)}; display: flex; flex-direction: column; align-items: baseline; max-width: ${a.breakpoints.values.lg}px; justify-content: space-between; `,evaluationGroupsContainer:(0,r.css)` width: 100%; display: flex; flex-direction: row; gap: ${a.spacing(2)}; `,addButton:(0,r.css)` display: flex; direction: row; gap: ${a.spacing(2)}; line-height: 2; margin-top: 35px; `,formInput:(0,r.css)` max-width: ${a.breakpoints.values.sm}px; flex-grow: 1; label { width: ${a.breakpoints.values.sm}px; } `,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 J=t(18447);const ne=[{value:J.g0.Alerting,label:"Alerting"},{value:J.g0.NoData,label:"No Data"},{value:J.g0.OK,label:"OK"},{value:J.g0.Error,label:"Error"}],re=({includeNoData:a,includeError:o,...i})=>{const s=(0,e.useMemo)(()=>a?o?ne:ne.filter(m=>m.value!==J.g0.Error):ne.filter(m=>m.value!==J.g0.NoData),[a,o]);return e.createElement(pe.Ph,{options:s,...i})};var Me=t(51317),oe=t(82669);const Pe=10,De=a=>({required:{value:!0,message:"Required."},validate:o=>{if(o==="0")return!0;try{const i=(0,me.nd)(o);if(i===0)return!0;try{const s=(0,me.nd)(a);return i>=s?!0:"For duration must be greater than or equal to the evaluation interval."}catch{return!0}}catch(i){return i instanceof Error?i.message:"Failed to parse duration"}}}),Z=(a,o)=>{const{groupOptions:i}=ee(a);return!(0,e.useCallback)(m=>i.some(d=>d.label===m),[i])(o)};function be({evaluateEvery:a,setEvaluateEvery:o}){const i=(0,g.wW)(f),{watch:s,setValue:m,getValues:d}=(0,n.Gc)(),[F,c]=(0,e.useState)(!1),[y,h]=s(["group","folder.title"]),G=(0,de._)(z=>z.rulerRules)[T.GC],Q=(0,ue.Zo)(T.GC).find(z=>z.name===h),P=Q?.groups.find(z=>z.name===y),W=Z(h??"",y);(0,e.useEffect)(()=>{!W&&P?.interval&&o(P.interval)},[o,W,m,P]);const se=(z=!1)=>{z||(0,ce.PN)(ce.z7.leavingRuleGroupEdit),c(!1)},Ae=()=>c(!0),xe=G?.loading||W||!h||!y,Ie={name:h,rulesSource:T.GC,groups:[]},$e={name:y,interval:a,rules:[],totals:{}};return e.createElement("div",null,e.createElement(Ge,{groupfoldersForGrafana:G?.result}),h&&F&&e.createElement(ae.vq,{namespace:Q??Ie,group:P??$e,onClose:()=>se(),intervalEditOnly:!0,hideFolder:!0}),h&&y&&e.createElement("div",{className:i.evaluationContainer},e.createElement(p.K,{direction:"column",gap:0},e.createElement("div",{className:i.marginTop},e.createElement(p.K,{direction:"column",gap:1},d("group")&&d("evaluateEvery")&&e.createElement("span",null,"All rules in the selected group are evaluated every ",a,"."," ",!W&&e.createElement(N.h,{name:"pen","aria-label":"Edit",disabled:xe,onClick:Ae})))))))}function le({evaluateEvery:a}){const o=(0,g.wW)(f),{register:i,formState:{errors:s}}=(0,n.Gc)(),m="eval-for-input";return e.createElement(p.K,{direction:"row","justify-content":"flex-start","align-items":"flex-start"},e.createElement(l.g,{label:e.createElement(S._,{htmlFor:"evaluateFor",description:"Period in which an alert rule can be in breach of the condition until the alert rule fires."},"Pending period"),className:o.inlineField,error:s.evaluateFor?.message,invalid:!!s.evaluateFor?.message,validationMessageHorizontalOverflow:!0},e.createElement(u.I,{id:m,width:8,...i("evaluateFor",De(a))})))}function Ne(){const a="Define how the alert rule is evaluated.",o="https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rules/rule-evaluation/";return e.createElement(p.K,{gap:.5},`${a}`,e.createElement(Me.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:o,linkText:"Read about evaluation",title:"Evaluation"}))}function Te({evaluateEvery:a,setEvaluateEvery:o,existing:i}){const s=(0,g.wW)(f),[m,d]=(0,e.useState)(!1),{watch:F,setValue:c}=(0,n.Gc)(),y=F("isPaused");return e.createElement(oe.z,{stepNo:3,title:"Set alert evaluation behavior",description:Ne()},e.createElement(p.K,{direction:"column","justify-content":"flex-start","align-items":"flex-start"},e.createElement(be,{setEvaluateEvery:o,evaluateEvery:a}),e.createElement(le,{evaluateEvery:a}),i&&e.createElement(l.g,{htmlFor:"pause-alert-switch"},e.createElement(x.g,{render:()=>e.createElement(p.K,{gap:1,direction:"row",alignItems:"center"},e.createElement(O.r,{id:"pause-alert",onChange:h=>{c("isPaused",h.currentTarget.checked)},value:!!y}),e.createElement("label",{htmlFor:"pause-alert",className:s.switchLabel},"Pause evaluation",e.createElement(U.u,{placement:"top",content:"Turn on to pause evaluation for this alert rule.",theme:"info"},e.createElement(b.J,{tabIndex:0,name:"info-circle",size:"sm",className:s.infoIcon})))),name:"isPaused"}))),e.createElement(ge.U,{isCollapsed:!m,onToggle:h=>d(!h),text:"Configure no data and error handling",className:s.collapseToggle}),m&&e.createElement(e.Fragment,null,e.createElement(l.g,{htmlFor:"no-data-state-input",label:"Alert state if no data or all values are null"},e.createElement(x.g,{render:({field:{onChange:h,ref:B,...G}})=>e.createElement(re,{...G,inputId:"no-data-state-input",width:42,includeNoData:!0,includeError:!1,onChange:L=>h(L?.value)}),name:"noDataState"})),e.createElement(l.g,{htmlFor:"exec-err-state-input",label:"Alert state if execution error or timeout"},e.createElement(x.g,{render:({field:{onChange:h,ref:B,...G}})=>e.createElement(re,{...G,inputId:"exec-err-state-input",width:42,includeNoData:!1,includeError:!0,onChange:L=>h(L?.value)}),name:"execErrState"}))))}const f=a=>({inlineField:(0,r.css)` margin-bottom: 0; `,collapseToggle:(0,r.css)` margin: ${a.spacing(2,0,2,-1)}; `,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}, `)})},51317:(k,R,t)=>{t.d(R,{h:()=>l});var r=t(42844),e=t(27702),n=t(23852),p=t(66310),g=t(16532),N=t(73453);function l({contentText:u,externalLink:x,linkText:O,title:U}){const b=(0,p.wW)(S);return e.createElement(g.P,{content:e.createElement("div",{className:b.mutedText},u),title:e.createElement(n.K,{gap:1,direction:"row"},e.createElement(N.J,{name:"question-circle"}),U),footer:x?e.createElement("a",{href:x,target:"_blank",rel:"noreferrer"},e.createElement("div",{className:b.infoLink},O," ",e.createElement(N.J,{name:"external-link-alt"}))):void 0,closeButton:!0,placement:"bottom-start"},e.createElement("div",{className:b.helpInfo},e.createElement(N.J,{name:"question-circle"}),e.createElement("div",{className:b.helpInfoText},"Need help?")))}const S=u=>({mutedText:(0,r.css)` color: ${u.colors.text.secondary}; font-size: ${u.typography.size.sm}; `,helpInfo:(0,r.css)` display: flex; flex-direction: row; align-items: center; width: fit-content; font-weight: ${u.typography.fontWeightMedium}; margin-left: ${u.spacing(1)}; font-size: ${u.typography.size.sm}; cursor: pointer; color: ${u.colors.text.primary}; `,helpInfoText:(0,r.css)` margin-left: ${u.spacing(.5)}; text-decoration: underline; `,infoLink:(0,r.css)` color: ${u.colors.text.link}; `})},82669:(k,R,t)=>{t.d(R,{z:()=>g});var r=t(42844),e=t(27702),n=t(66310),p=t(5229);const g=({title:l,stepNo:S,children:u,description:x})=>{const O=(0,n.wW)(N);return e.createElement("div",{className:O.parent},e.createElement("div",null,e.createElement("span",{className:O.stepNo},S)),e.createElement("div",{className:O.content},e.createElement(p.C,{label:l,className:O.fieldset},x&&e.createElement("div",{className:O.description},x),u)))},N=l=>({fieldset:(0,r.css)` legend { font-size: 16px; padding-top: ${l.spacing(.5)}; } `,parent:(0,r.css)` display: flex; flex-direction: row; max-width: ${l.breakpoints.values.xl}; & + & { margin-top: ${l.spacing(4)}; } `,description:(0,r.css)` margin-top: -${l.spacing(2)}; color: ${l.colors.text.secondary}; `,stepNo:(0,r.css)` display: inline-block; width: ${l.spacing(4)}; height: ${l.spacing(4)}; line-height: ${l.spacing(4)}; border-radius: ${l.shape.radius.circle}; text-align: center; color: ${l.colors.text.maxContrast}; background-color: ${l.colors.background.canvas}; font-size: ${l.typography.size.lg}; margin-right: ${l.spacing(2)}; `,content:(0,r.css)` flex: 1; `})},98658:(k,R,t)=>{t.d(R,{vq:()=>Oe,MD:()=>Ee});var r=t(42844),e=t(89949),n=t(27702),p=t(46089),g=t(23852),N=t(25357),l=t(66310),S=t(13741),u=t(22209),x=t(79978),O=t(1128),U=t(66670),b=t(73807),ce=t(75429),ue=t(18771),de=t(10027),T=t(47702),me=t(76384),ge=t(22513),ae=t(84369),q=t(22446),Y=t(447),w=t(45986),pe=t(34667),_=t(63439);const ve=()=>n.createElement(_.b,{severity:"warning",title:"Global evalutation interval limit exceeded"},"A minimum evaluation interval of ",n.createElement("strong",null,pe.config.unifiedAlerting.minInterval)," has been configured in Grafana.",n.createElement("br",null),"Please contact the administrator to configure a lower interval.");var V=t(278);const Fe=10;function H({message:v,error:E}){return E?n.createElement(N.C,{color:"red",icon:"exclamation-circle",text:"Error",tooltip:v}):n.createElement(N.C,{color:"orange",icon:"exclamation-triangle",text:"Unknown",tooltip:v})}const Se=v=>{try{const E=(0,Y.nd)(v);return!(E<V.X*1e3||E%(V.X*1e3)!==0)}catch{return!1}},Re=({rulesWithoutRecordingRules:v})=>{const E=(0,l.wW)(fe),{watch:I}=(0,p.Gc)(),M=I("groupInterval"),A=!M,X=v.slice().map((C,j)=>({id:j,data:(0,q.qd)(C,M)})).sort((C,j)=>(0,Y.Bg)(C.data.forDuration)-(0,Y.Bg)(j.data.forDuration)),ee=(0,n.useMemo)(()=>[{id:"alertName",label:"Alert",renderCell:({data:{alertName:C}})=>n.createElement(n.Fragment,null,C),size:"330px"},{id:"for",label:"For",renderCell:({data:{forDuration:C}})=>n.createElement(n.Fragment,null,C),size:.5},{id:"numberEvaluations",label:"#Eval",renderCell:({data:{evaluationsToFire:C}})=>A?n.createElement(H,{message:"#Evaluations not available."}):Se(M)?C===0?n.createElement(H,{message:"Invalid 'For' value: it should be greater or equal to evaluation interval.",error:!0}):n.createElement(n.Fragment,null,C):n.createElement(H,{message:"Invalid evaluation interval format",error:!0}),size:.4}],[M,A]);return n.createElement("div",{className:E.tableWrapper},n.createElement(w.t,{items:X,cols:ee,pagination:{itemsPerPage:Fe}}))},Ee=v=>({required:{value:!0,message:"Required."},validate:E=>{try{const I=(0,Y.nd)(E);return I<V.X*1e3?`Cannot be less than ${V.X} seconds.`:I%(V.X*1e3)!==0?`Must be a multiple of ${V.X} seconds.`:(0,T.iH)(v,E).length===0?!0:"Invalid evaluation interval. Evaluation interval should be smaller or equal to 'For' values for existing rules in this group."}catch(I){return I instanceof Error?I.message:"Failed to parse duration"}}});function Oe(v){const{namespace:E,group:I,onClose:M,intervalEditOnly:A}=v,X=(0,l.wW)(fe),ee=(0,ue.useDispatch)(),{loading:C,error:j,dispatched:he}=(0,de._)(f=>f.updateLotexNamespaceAndGroup)??ae.oq,Ge=(0,b.iG)(),Ce=(0,n.useMemo)(()=>({namespaceName:E.name,groupName:I.name,groupInterval:I.interval??""}),[E,I]),ye=(0,ge.EG)(E.rulesSource),$=ye===ge.GC,J=$?"Folder":"Namespace";(0,n.useEffect)(()=>{he&&!C&&!j&&M(!0)},[he,C,M,j]),(0,ce.x)(f=>f.unifiedAlerting.updateLotexNamespaceAndGroup=ae.oq);const ne=f=>{ee((0,T.hv)({rulesSourceName:ye,groupName:I.name,newGroupName:f.groupName,namespaceName:E.name,newNamespaceName:f.namespaceName,groupInterval:f.groupInterval||void 0}))},re=(0,p.cI)({mode:"onBlur",defaultValues:Ce,shouldFocusError:!0}),{handleSubmit:Me,register:oe,watch:Pe,formState:{isDirty:De,errors:Z}}=re,be=()=>{Ge.error("There are errors in the form. Correct the errors and retry.")},le=(0,e.compact)(I.rules.map(f=>f.rulerRule).filter(f=>!(0,q.yF)(f))),Ne=le.length>0,Te=A||$?"Edit evaluation group":"Edit namespace or evaluation group";return n.createElement(S.u,{className:X.modal,isOpen:!0,title:Te,onDismiss:M,onClickBackdrop:M},n.createElement(p.RV,{...re},n.createElement("form",{onSubmit:f=>f.preventDefault(),key:JSON.stringify(Ce)},n.createElement(n.Fragment,null,!v.hideFolder&&n.createElement(u.g,{label:n.createElement(x._,{htmlFor:"namespaceName",description:!$&&"Change the current namespace name. Moving groups between namespaces is not supported"},J),invalid:!!Z.namespaceName,error:Z.namespaceName?.message},n.createElement(g.K,{gap:1,direction:"row"},n.createElement(O.I,{id:"namespaceName",readOnly:A||$,...oe("namespaceName",{required:"Namespace name is required."}),className:X.formInput}),$&&v.folderUrl&&n.createElement(U.Qj,{href:v.folderUrl,title:"Go to folder",variant:"secondary",icon:"folder-open",target:"_blank"}))),n.createElement(u.g,{label:n.createElement(x._,{htmlFor:"groupName"},"Evaluation group name"),invalid:!!Z.groupName,error:Z.groupName?.message},n.createElement(O.I,{autoFocus:!0,id:"groupName",readOnly:A,...oe("groupName",{required:"Evaluation group name is required."})})),n.createElement(u.g,{label:n.createElement(x._,{htmlFor:"groupInterval",description:"How often is the rule evaluated. Applies to every rule within the group."},n.createElement(g.K,{gap:.5},"Evaluation interval")),invalid:!!Z.groupInterval,error:Z.groupInterval?.message},n.createElement(O.I,{id:"groupInterval",placeholder:"1m",...oe("groupInterval",Ee(le))})),(0,me.f)(Pe("groupInterval")).exceedsLimit&&n.createElement(ve,null),!Ne&&n.createElement("div",null,"This group does not contain alert rules."),Ne&&n.createElement(n.Fragment,null,n.createElement("div",null,"List of rules that belong to this group"),n.createElement("div",{className:X.evalRequiredLabel},"#Eval column represents the number of evaluations needed before alert starts firing."),n.createElement(Re,{rulesWithoutRecordingRules:le})),n.createElement("div",{className:X.modalButtons},n.createElement(S.u.ButtonRow,null,n.createElement(U.zx,{variant:"secondary",type:"button",disabled:C,onClick:()=>M(!1),fill:"outline"},"Cancel"),n.createElement(U.zx,{type:"button",disabled:!De||C,onClick:Me(f=>ne(f),be)},C?"Saving...":"Save")))))))}const fe=v=>({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: ${v.spacing(2)}; margin-bottom: ${v.spacing(2)}; height: 100%; `,evalRequiredLabel:(0,r.css)` font-size: ${v.typography.bodySmall.fontSize}; `})},79003:(k,R,t)=>{t.d(R,{j:()=>p});var r=t(27702),e=t(7662),n=t(26129);function p(){const{search:g}=(0,e.TH)(),N=(0,r.useMemo)(()=>new URLSearchParams(g),[g]),l=(0,r.useCallback)((S,u)=>{n.E1.partial(S,u)},[]);return[N,l]}},13963:(k,R,t)=>{t.d(R,{B:()=>n});var r=t(27702),e=t(2082);function n(){return(0,r.useMemo)(()=>(0,e.Rv)(),[])}}}]); //# sourceMappingURL=1608.e48b1efacfa85511f0cf.js.map