1import{j as e,c as _,u as E,a as w,e as y}from"./@react-query-B7aWO4oz.js";import{S as I}from"./scroll-area-BRinHNSQ.js";import{c as k}from"./index-8ntJgCKG.js";import{aH as T,D as m,eD as P,eC as z,P as A,eU as M,F as N,ar as u,bK as C,aD as $}from"./main-D6lnA1fr.js";import{E as R,a as O,b as Q,c as B,d as F,e as L}from"./empty-CBfpxw_g.js";import{L as h}from"./@tanstack-router-C5q29I5r.js";import{b as W,f as H,s as K,g as q,A as U}from"./webhook-provider-icon-BYxFmyVF.js";import{g as S}from"./get-api-error-message-uyVq6Qd7.js";import{C as Y}from"./confirm-dialog-Czr6oJWP.js";import{u as G}from"./use-is-admin-DvWIXz-C.js";import{b as J,h as V,c as X,e as Z,g as ee,d as se,f as te}from"./item-FDmN-bgh.js";import{S as ae}from"./switch-DbZN7Fxs.js";import{T as le,a as re,b as ie}from"./tooltip-B-boOwwp.js";import{D as ne}from"./dot-separator-KX9Bu0hO.js";import{S as oe}from"./status-badge-zCykKRPA.js";import{A as ce,b as de}from"./alert-summary-text-CuCEEHgU.js";import{u as me}from"./useTitle-CsdsS0pb.js";import"./@radix-ui-CWA3xdIh.js";import"./zod-FlNnpX36.js";import"./dialog-Di2b5CED.js";import"./separator-BYTuZ_4Q.js";import"./badge-51NKKn01.js";import"./alert-definitions--2M8pUgf.js";function xe({recipients:s}){const l=e.jsx(M,{className:"size-4 shrink-0 text-muted-foreground"});return s.length===1?e.jsxs("span",{className:"inline-flex min-w-0 cursor-default items-center gap-1.5 text-sm text-foreground",children:[l,e.jsx("span",{className:"truncate",children:s[0]})]}):e.jsxs(le,{children:[e.jsx(re,{asChild:!0,children:e.jsxs("span",{className:"inline-flex cursor-default items-center gap-1.5 text-sm text-foreground underline",children:[l,s.length," recipients"]})}),e.jsx(ie,{align:"start",children:e.jsx("ul",{className:"flex flex-col gap-1",children:s.map(o=>e.jsx("li",{className:"break-all",children:o},o))})})]})}function ue({definition:s,onDelete:l,onToggleActive:o,isToggling:c}){const{webhook:r,email_recipients:a}=s,x=r?.is_deleted===!0,p=!r&&a.length===0,n=x?null:r;return e.jsxs(J,{variant:"outline",className:"gap-3",children:[e.jsxs(V,{children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(X,{variant:"icon",className:"size-6",children:e.jsx(T,{className:"size-4 text-muted-foreground"})}),e.jsx(Z,{className:k("min-w-0 text-base",!s.is_active&&"text-muted-foreground"),children:e.jsx("span",{className:"truncate",children:s.name})}),!s.is_active&&e.jsx(oe,{icon:null,label:"Disabled",status:"offline",className:"min-w-0 shrink-0"})]}),e.jsxs(ee,{className:"shrink-0 gap-4",children:[e.jsx(ae,{"aria-label":`${s.is_active?"Disable":"Enable"} ${s.name}`,checked:s.is_active,disabled:c,onCheckedChange:o,size:"sm"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(m,{variant:"ghost-secondary",size:"icon-xs","aria-label":`Edit ${s.name}`,asChild:!0,children:e.jsx(h,{to:"/settings/alerts/$alertId",params:{alertId:s.public_id},children:e.jsx(P,{})})}),e.jsx(m,{variant:"ghost-secondary",size:"icon-xs","aria-label":`Delete ${s.name}`,onClick:l,children:e.jsx(z,{})})]})]})]}),e.jsxs(se,{className:"gap-2",children:[e.jsx(te,{children:e.jsx(ce,{segments:de({trigger:s.alert_trigger,conditions:s.conditions,logic:s.condition_logic})})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.length>0&&e.jsx(xe,{recipients:a}),a.length>0&&n&&e.jsx(ne,{}),n&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-foreground",children:[e.jsx(W,{provider:n.provider,className:"size-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:n.name})]}),p&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground",children:[e.jsx(A,{className:"size-4 shrink-0"}),"No destination â this alert won't notify anyone"]})]}),x&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-destructive",children:[e.jsx(A,{className:"size-4 shrink-0"}),e.jsxs("span",{children:["The webhook this alert notified was deleted",a.length===0&&", so the alert was disabled","."]}),e.jsx(m,{variant:"link",size:"sm",className:"h-auto p-0",asChild:!0,children:e.jsx(h,{to:"/settings/alerts/$alertId",params:{alertId:s.public_id},children:"Choose a new destination"})})]})]})]})}function he(){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(N,{className:"h-9 w-full rounded-md"}),e.jsx(N,{className:"h-9 w-32 shrink-0 rounded-sm"})]}),e.jsx("div",{className:"flex flex-col gap-4",children:Array.from({length:3}).map((s,l)=>e.jsx(N,{className:"h-[136px] w-full shrink-0 rounded-md"},l))})]})}function pe(){const s=G(),l=_(),{data:o,isPending:c}=E({...H(),enabled:s}),[r,a]=w.useState(null),[x,p]=w.useState(new Set),n=(t,i)=>p(j=>
1{const f=new Set(j);return i?f.add(t):f.delete(t),f}),b=()=>l.invalidateQueries({queryKey:U}),D=y({...K(),onSuccess:t=>{b(),u.success(`Alert "${t.name}" ${t.is_active?"enabled":"disabled"}`)},onError:(t,{publicId:i})=>{console.error("Alert enable/disable failed",{publicId:i,error:t}),u.error("Failed to update alert",{description:S(t)})},onSettled:(t,i,{publicId:j})=>n(j,!1)}),v=y({...q(),onSuccess:()=>{b(),u.success("Alert deleted"),a(null)},onError:(t,i)=>{console.error("Alert deletion failed",{publicId:i,error:t}),u.error("Failed to delete alert",{description:S(t)})}});if(!s)return null;const d=o??[],g=!c&&d.length===0;return e.jsxs("div",{className:k("flex flex-col gap-3",g&&"h-full"),children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create alerts for important build events and choose who or what should be notified."}),!c&&!g&&e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"flex h-9 w-full items-center rounded-md bg-muted px-3",children:e.jsxs("span",{className:"text-sm font-medium text-muted-foreground uppercase",children:[d.length," ",d.length===1?"alert rule":"alert rules"]})}),e.jsx(m,{size:"default",className:"shrink-0",asChild:!0,children:e.jsxs(h,{to:"/settings/alerts/new",children:[e.jsx(C,{}),"Create alert"]})})]}),c&&e.jsx(he,{}),g&&e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs(R,{className:"max-w-sm",children:[e.jsxs(O,{children:[e.jsx(Q,{variant:"icon",children:e.jsx($,{})}),e.jsx(B,{children:"No alerts yet"}),e.jsx(F,{children:"Create an alert to get notified when a build starts or ends."})]}),e.jsx(L,{children:e.jsx(m,{asChild:!0,children:e.jsxs(h,{to:"/settings/alerts/new",children:[e.jsx(C,{}),"Create alert"]})})})]})}),d.length>0&&e.jsx("div",{className:"flex flex-col gap-4",children:d.map(t=>e.jsx(ue,{definition:t,isToggling:x.has(t.public_id),onToggleActive:i=>{n(t.public_id,!0),D.mutate({publicId:t.public_id,isActive:i})},onDelete:()=>a(t)},t.public_id))}),e.jsx(Y,{open:r!==null,onOpenChange:t=>{t||a(null)},title:"Delete alert",description:`Delete "${r?.name}"? It will stop sending notifications.`,confirmLabel:"Delete",onConfirm:()=>{r&&v.mutate(r.public_id)},disabled:v.isPending})]})}const Qe=()=>(me("Incredibuild | Alerts"),e.jsx(I,{className:"flex-1 min-h-0 p-4",children:e.jsx(pe,{})}));export{Qe as component};
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.