PageSourceSearch

https://app.middleware.io/static/UhUOqmZv.production.bundle.min.js

js middleware.io collected 2026-10-02 03:34:20 UTC 10,638 bytes, 1 lines download raw bytes

1import{af as te,r as c,M as H,b as z,j as e,A as re,C as se,d as ae}from"./CZzrexQa.production.bundle.min.js";import{B as v}from"./YCM_kEyP.production.bundle.min.js";import{B as oe}from"./ByHEZCgb.production.bundle.min.js";import{e$ as ne,r as le,en as ie,em as ce,b$ as me,P as ue,f0 as pe,f1 as de,f2 as fe,f3 as he,q as ge}from"./DeceMiF-.production.bundle.min.js";import{A as xe}from"./CXT9N8xZ.production.bundle.min.js";import{D as ye,a as be}from"./D8sKcCdJ.production.bundle.min.js";import{N as U}from"./DWUNlcjA.production.bundle.min.js";import{aa as Ce}from"./b2Mkg01q.production.bundle.min.js";import{I as Te,c as je}from"./C_cH1u9D.production.bundle.min.js";import{A as we}from"./D4lvmK5r.production.bundle.min.js";import{l as G}from"./DGAisTA8.production.bundle.min.js";import{u as Se,s as B}from"./9eHdvLN4.production.bundle.min.js";import{i as _e,f as ke}from"./DQegFpUo.production.bundle.min.js";import{G as Ae}from"./B2jjARHc.production.bundle.min.js";import{G as Ne}from"./CJIgguc4.production.bundle.min.js";import{T as K}from"./C1w8154Z.production.bundle.min.js";import{T as Ee}from"./kkIr59yR.production.bundle.min.js";import{u as V}from"./DvLd3evF.production.bundle.min.js";import{E as Re,A as Ie}from"./3wIbuO__.production.bundle.min.js";import{A as Le}from"./Ci_hGDFV.production.bundle.min.js";import{B as ve}from"./zzLyrqbE.production.bundle.min.js";import"./DGYQp8fe.production.bundle.min.js";import"./D-90pMQ7.production.bundle.min.js";import"./CUZmxn9S.production.bundle.min.js";import"./E6csxmgU.production.bundle.min.js";import"./tkddr5kZ.production.bundle.min.js";import"./BmBjCq8D.production.bundle.min.js";import"./CHClG9UV.production.bundle.min.js";import"./Dsqj8S3w.production.bundle.min.js";import"./Y4Ob0Is8.production.bundle.min.js";import"./oN3AJijl.production.bundle.min.js";import"./DFn2u8qh.production.bundle.min.js";import"./Bm1LOIPR.production.bundle.min.js";import"./D0x1Z4HE.production.bundle.min.js";import"./DtpVAsok.production.bundle.min.js";import"./2mZBARql.production.bundle.min.js";import"./vhNSgALD.production.bundle.min.js";import"./C_Ln3svq.production.bundle.min.js";import"./7LcJfZNO.production.bundle.min.js";import"./CNsPFEJO.production.bundle.min.js";import"./CiD4UJCU.production.bundle.min.js";import"./B0uEge7d.production.bundle.min.js";import"./DwmhJbxl.production.bundle.min.js";import"./CpVN2k6O.production.bundle.min.js";import"./B7Fri_dM.production.bundle.min.js";import"./CLBsRoPD.production.bundle.min.js";import"./Ch78CD0x.production.bundle.min.js";import"./D1TNtnEv.production.bundle.min.js";import"./DnQqxH0F.production.bundle.min.js";const Be=()=>({type:"none",channels:[],addresses:[],webhook:""});function $e(f){var C;const t=structuredClone(f);delete t.id,delete t.editMode,delete t.valid,delete t.description,delete t.project_id,delete t.project_uid,delete t.created_by,t.notification_setting={...Be(),...t.notification_setting||{}},t.permission={permission_type:ne.UNRESTRICTED,users:[],...t.permission};const n=t.type===le.billing?60*60*6:60;t.notify_condition={status_slice:[],renotify_interval:n,renotify_count:-1,...t.notify_condition};const d=(t.conditions||[]).map(g=>({...g,isChecked:!0})),l={...t,conditions:d.filter(g=>g.isChecked!==!1),formulas:t.formulas||[],config:t.config||[]};let m={label:"",builderId:0,scopeId:0,widgetAppId:te.TimeseriesChart,builderConfig:l.config,formulas:l.formulas,builderViewOptions:{},returnOnlyFormulaResult:(((C=l.formulas)==null?void 0:C.length)??0)>0};return m=ie(ce(m)),l.config=m.builderConfig,l}function Pe(f){var d;const t=f,n=(d=t==null?void 0:t.response)==null?void 0:d.data;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"){if(typeof n.message=="string"&&n.message.trim())return n.message;if(typeof n.error=="string"&&n.error.trim())return n.error}return t!=null&&t.message?t.message:"Request failed"}const $="alert_templates_search",De=f=>`alert-templates-table-${f.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`,_=8,Me=[{label:"Installed Integrations Only",value:"installed_integrations"},{label:"All",value:"all"}];function Fe(f){const{isOpen:t,onTemplateSelect:n,onClose:d}=f,l=Se(),m=c.useContext(xe),C=c.useContext(H),g=z(),h=V(_e),T=C.params.query.get($)??"",[j,N]=c.useState("installed_integrations"),[w,u]=c.useState({}),[b,E]=c.useState(!1);c.useEffect(()=>{l(ke())},[]),c.useEffect(()=>{u({})},[j]),c.useEffect(()=>{u({})},[T]);const k=c.useMemo(()=>{let s=[];if(j==="all")s=[...G.cloneDeep(K)];else{const r=new Set((h==null?void 0:h.resources)||[]);
1G.cloneDeep(K).forEach(o=>{const a=[];o.templates.forEach(i=>{for(const x of i.config||[])if(r.has(x.source.name)){a.push(i);break}}),s.push({...o,templates:a})})}return s.filter(r=>r.templates.length>0)},[j,h==null?void 0:h.resources]),P=c.useMemo(()=>{const s=T.trim().toLowerCase();return s?k.map(r=>({...r,templates:r.templates.filter(o=>{var a,i,x,y;return((i=(a=o==null?void 0:o.name)==null?void 0:a.toLowerCase())==null?void 0:i.includes(s))||((y=(x=r==null?void 0:r.name)==null?void 0:x.toLowerCase())==null?void 0:y.includes(s))})})).filter(r=>r.templates.length>0):k},[k,T]),D=c.useMemo(()=>Object.values(w).flatMap(s=>s.map(r=>r.record)),[w]),R=c.useMemo(()=>{const s=new Set,r=[];for(const o of D){const a=`${o.type}\0${o.name}`;s.has(a)||(s.add(a),r.push(o))}return r},[D]),Q=c.useCallback(async()=>{var M,F,O,q;if(R.length===0||b)return;E(!0);const s=p=>new Promise(A=>{let I;try{I=$e(p)}catch(S){A({name:p.name,ok:!1,error:S instanceof Error?S.message:"Could not build alert from template"});return}l(pe(I,(S,L)=>{if(S&&(L==null?void 0:L.status)===200){A({name:p.name,ok:!0});return}A({name:p.name,ok:!1,error:Pe(L)})}))}),r=await Promise.all(R.map(p=>s(p)));E(!1);const o=r.filter(p=>p.ok),a=r.filter(p=>!p.ok),i=o.length,x=a.length,y=r.length;if(i>0&&(l(me(ue.AlertRules)),((F=(M=m.user)==null?void 0:M.project_meta_data)==null?void 0:F.user_created_alert_rule)===!1&&m.changeContext({key:"user",value:{...m.user,project_meta_data:{...(O=m.user)==null?void 0:O.project_meta_data,user_created_alert_rule:!0}}})),x===0){u({}),l(B("success",`${i} alert${i===1?"":"s"} created successfully.`,{title:"Alerts created"})),d(),g("/alerts/rules");return}if(i===0){const p=a.map(S=>S.name).slice(0,_),A=a.length>_?` (+${a.length-_} more)`:"",I=(q=a[0])!=null&&q.error?` ${a[0].error}`:"";l(B("error",`Could not create alerts: ${p.join(", ")}${A}.${I}`,{title:"Alerts not created"}));return}const Y=a.map(p=>p.name).slice(0,_),ee=a.length>_?` (+${a.length-_} more)`:"";u({}),l(B("warning",`${i} of ${y} alert${y===1?"":"s"} created. Failed: ${Y.join(", ")}${ee}.`,{title:"Some alerts could not be created"})),d(),g("/alerts/rules")},[b,m,l,d,R]),W=()=>e.jsx(ye,{mode:be.Default,onChange:s=>{N(s)},options:Me,selectedValues:j,showSearch:!1}),X=c.useCallback(()=>[{title:"Template Name",columnKey:"name",width:180,fixed:!0,render:(s,r)=>{const o=r;return e.jsx("span",{className:"template-name-text",children:o.name})}},{title:"Details",columnKey:"details",width:400,fixed:!0,render:(s,r)=>{const o=r==null?void 0:r.description;return e.jsx(Ee,{content:o,children:o})}},{title:"Action",columnKey:Te,width:72,fixed:"right",align:we.Center,disableResize:!0,render:(s,r)=>{const o=r;return e.jsx("div",{className:"template-edit-cell",onClick:a=>a.stopPropagation(),children:e.jsx("button",{type:"button",className:"template-edit-trigger","aria-label":`Use template ${o.name}`,onClick:()=>n(o),children:e.jsx(Re,{size:15})})})}}],[n]),Z=s=>{var a;const r=s.name,o=s.templates.map(i=>({...i}));return e.jsx(Ce,{title:e.jsxs("span",{className:"template-section-expand-title",children:[e.jsx("div",{className:"icon-wrapper",children:s.icon}),e.jsx("span",{className:"section-title-text",children:s.name})]}),customExpandIcon:e.jsx(Le,{}),customCollapseIcon:e.jsx(Ie,{}),defaultExpanded:!0,children:e.jsx("div",{className:"template-section-table",children:e.jsx(je,{columns:X(),dataProvider:o,loading:!1,uniqId:De(r),onSelectRow:i=>u(x=>({...x,[r]:i.map(y=>({key:y.key,record:y.record}))})),selectedRowKeys:((a=w[r])==null?void 0:a.map(i=>i.key))??[]})})},r)},J=()=>e.jsx("div",{className:"alert-templates-toolbar",children:e.jsx("div",{className:"alerts-header-outer-wrapper",children:e.jsx(Ae,{caller:$,placeholder:"Search by alert name or type",hideGroupByLabel:!0})})});return e.jsx(Ne,{isOpen:t,onClose:d,title:"Alert Templates",onBackBtnClick:d,datePicker:!1,rightAlignedHeaderElements:W(),dialogContentClassName:"alert-templates",footer:e.jsxs("div",{className:"footer-elements",children:[e.jsx(v,{secondary:!0,error:!0,disabled:b,onClick:d,children:"Cancel"}),e.jsx(v,{primary:!0,loading:b,disabled:R.length===0||b,onClick:()=>{Q()},children:"Create Alert"})]}),children:h.apiStatus===re.LOADING?e.jsx(se,{}):e.jsxs(e.Fragment,{children:[J(),k.length===0?e.jsx(U,{exmpySpaceText:"No templates available for the current filter."}):P.length===0?e.jsx(U,{exmpySpaceText:"No templates match your search. Try a different name."}):e.jsx("div",{className:"template-sections",children:P.map(s=>Z(s))})]})})}const Oe={host:"Hosts",metric:"Metrics",trace:"Traces",log:"Logs",rum:"RUM",llm:"LLM",kubernetes:"K8s",custom:"Custom",anomaly:"Anomaly",forecast:"Forecast",billing:"Billing",error_tracking:"Error Tracking"};function Pt(){var N,w;const f=z(),t=c.useContext(H),{pathname:n}=ae(),[d,l]=c.useState(!1),m=n==="/alerts/new-rule",C=()=>
1{if(m)return"Add New Rule";const u=n.match(/\/(host|metric|trace|log|rum|llm|kubernetes|custom|anomaly|forecast|billing|error_tracking)/),b=n.startsWith("/alerts/edit-rule");if(u){const E=u[1];return`${b?"Edit":"Create"} ${Oe[E]} Rule`}return"Rule"},g=(w=(N=t==null?void 0:t.params)==null?void 0:N.query)==null?void 0:w.get(de),h=V(fe),T=c.useMemo(()=>{const u=h??he(g);return u==null?void 0:u.name},[g,h]),j=()=>{f("/alerts/rules")};return e.jsxs(e.Fragment,{children:[e.jsx(ge,{breadcrumbs:[{label:C()},...T?[{label:e.jsx("div",{className:"alert-name-label",children:T??""})}]:[]],activeTabIndex:0,preFixChildren:e.jsx("div",{className:"back-btn",children:e.jsx(v,{onClick:j,outlined:!0,prefixicon:e.jsx(ve,{color:"var(--color-black)",className:"button-v2 is-outlined"})})}),className:"alert-header",dataTestIdDatePicker:"header-datepicker-status-page",showLiveOrHistoryToggle:!m,showShareableURL:!m,showRefreshBtn:!m,children:m?e.jsx("div",{children:e.jsx(v,{onClick:()=>{l(!0)},prefixicon:e.jsx(oe,{}),secondary:!0,children:"Browse Templates"})}):null}),e.jsx(Fe,{isOpen:d,onClose:()=>{l(!1),t.params.query.delete($),t.params.query.redirect()},onTemplateSelect:u=>{l(!1),t.params.query.set("template",encodeURIComponent(u.name)),f(`/alerts/new-rule/${u.type}/step-1`)}})]})}export{Pt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.