1import{r as n,a2 as F,a3 as B,a4 as M,j as e,X as _,B as N,b as T,c as $,L as q,W as D,H,A as Q,P as K,a as z}from"./index-CjVU7RJX.js";import{F as V,P as U}from"./PageHeading-tk3gRXHI.js";import{p as L,u as O,F as Z}from"./useDebounce-BCSwqGX1.js";import{C as X,a as W}from"./CardBody-vXk6tbSV.js";import{Q as G,a as Y,u as J,i as ee}from"./useApiQuery-CyBBzKaQ.js";import{T as ae}from"./Table-Xrb_h12D.js";import{B as C}from"./Badge-BhyCpPRK.js";import{u as te,v as se,D as re,L as ne}from"./usePopper-DORNHtJB.js";import{C as k}from"./Checkbox-Bcs7mtha.js";import{X as ie,x as le,L as ce}from"./disclosure-NX8VKsi-.js";import{I as oe}from"./Input-DpFJLBe-.js";import{c as de}from"./objects-Dx7fAKlz.js";import{C as E,D as I}from"./DateCell-Dn2ErbZ3.js";import{F as ue,a as he}from"./pipelines-BY_YA4xW.js";import{F as me}from"./PlusIcon-CnNYBBiQ.js";import"./menu-DgMaZ7qq.js";import"./use-tab-direction-Drjcgx88.js";import"./en-US-DaC6fNmD.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"61deeeaade68dd91b27c04a9789aa675b15aa5d2"}}catch{}})();try{(function(){var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="2b8d70d8-d524-40c5-b84a-7d232f32df91",a._sentryDebugIdIdentifier="sentry-dbid-2b8d70d8-d524-40c5-b84a-7d232f32df91")})()}catch{}function fe({title:a,titleId:t,...i},s){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},i),a?n.createElement("title",{id:t},a):null,n.createElement("path",{fillRule:"evenodd",d:"M15.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 1 1-1.06-1.06l3.22-3.22H7.5a.75.75 0 0 1 0-1.5h11.69l-3.22-3.22a.75.75 0 0 1 0-1.06Zm-7.94 9a.75.75 0 0 1 0 1.06l-3.22 3.22H16.5a.75.75 0 0 1 0 1.5H4.81l3.22 3.22a.75.75 0 1 1-1.06 1.06l-4.5-4.5a.75.75 0 0 1 0-1.06l4.5-4.5a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const pe=n.forwardRef(fe);function ge({title:a,titleId:t,...i},s){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},i),a?n.createElement("title",{id:t},a):null,n.createElement("path",{fillRule:"evenodd",d:"M11.47 7.72a.75.75 0 0 1 1.06 0l7.5 7.5a.75.75 0 1 1-1.06 1.06L12 9.31l-6.97 6.97a.75.75 0 0 1-1.06-1.06l7.5-7.5Z",clipRule:"evenodd"}))}const xe=n.forwardRef(ge);function ve({title:a,titleId:t,...i},s){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},i),a?n.createElement("title",{id:t},a):null,n.createElement("path",{fillRule:"evenodd",d:"M3.792 2.938A49.069 49.069 0 0 1 12 2.25c2.797 0 5.54.236 8.209.688a1.857 1.857 0 0 1 1.541 1.836v1.044a3 3 0 0 1-.879 2.121l-6.182 6.182a1.5 1.5 0 0 0-.439 1.061v2.927a3 3 0 0 1-1.658 2.684l-1.757.878A.75.75 0 0 1 9.75 21v-5.818a1.5 1.5 0 0 0-.44-1.06L3.13 7.938a3 3 0 0 1-.879-2.121V4.774c0-.897.64-1.683 1.542-1.836Z",clipRule:"evenodd"}))}const be=n.forwardRef(ve);var we=class extends G{constructor(a,t){super(a,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(a){super.setOptions({...a,behavior:F()})}getOptimisticResult(a){return a.behavior=F(),super.getOptimisticResult(a)}fetchNextPage(a){return this.fetch({...a,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(a){return this.fetch({...a,meta:{fetchMore:{direction:"backward"}}})}createResult(a,t){const{state:i}=a,s=super.createResult(a,t),{isFetching:d,isRefetching:u,isError:m,isRefetchError:f}=s,h=i.fetchMeta?.fetchMore?.direction,l=m&&h==="forward",p=d&&h==="forward",b=m&&h==="backward",j=d&&h==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:M(t,i.data),hasPreviousPage:B(t,i.data),isFetchNextPageError:l,isFetchingNextPage:p,isFetchPreviousPageError:b,isFetchingPreviousPage:j,isRefetchError:f&&!l&&!b,isRefetching:u&&!p&&
1!j}}};function ye(a,t){return Y(a,we)}const je=({selectedCount:a,maxCount:t,onClick:i})=>{const s=a>t,d=L("scenario",t),u=`Maximum of ${t} ${d} can be compared at a time`;return e.jsx(_,{id:"compare-count-exceeded",label:s?u:"",children:e.jsx("span",{children:e.jsxs(N,{disabled:s,onClick:i,children:[e.jsx("div",{className:"-ml-1 mr-2 h-5 w-5",children:a>0?e.jsx("div",{className:T("rounded-full fade-in",{"text-red-300 bg-red-50":s,"bg-gray-200 text-gray-500":!s}),children:a}):e.jsx(pe,{"aria-hidden":"true",className:"fade-in"})}),"Compare"]})})})};function Se({url:a,columns:t,queryParams:i,clickableRow:s,onSelectedRowsChange:d,selectedRowIds:u}){const m=new URLSearchParams(i),{data:f,fetchNextPage:h,hasNextPage:l,isFetchingNextPage:p,isLoading:b}=ye({queryKey:[a,i],queryFn:({pageParam:g=1})=>(m.set("page",g.toString()),$(`${a}?${m.toString()}`)),initialPageParam:1,getNextPageParam:(g,R)=>{if(!(R.flatMap(w=>w.results).length>=g.count))return R.length+1}}),j=f?f.pages.flatMap(g=>g.results):[],S=b,o=p,v=!l,r=()=>e.jsx(N,{disabled:o||v,onClick:()=>h(),variant:"default",children:o?e.jsx(q,{size:24}):v?"No more":"Load more"});return e.jsxs(e.Fragment,{children:[e.jsx(ae,{columns:t,data:j,className:"my-3",clickableRow:s,loading:S,selectedRowIds:u,onSelectedRowsChange:d}),e.jsx("div",{className:"flex flex-row justify-center mt-6",children:!S&&r()})]})}const Pe=({filters:a=[],onChange:t,debounceDelay:i=500})=>{const[s,d]=n.useState(a),u=O(s,i),[m,f]=n.useState(null),[h,l]=n.useState(null),{styles:p,attributes:b}=te(m,h);n.useEffect(()=>{d(a)},[a]),n.useEffect(()=>{t(u)},[u]);const j=()=>{const o=s.map(v=>({...v,options:v.options.map(r=>({...r,checked:!1}))}));d(o)},S=o=>{const v=s.map(r=>({...r,options:r.options.map(g=>g.id===o.id?{...g,checked:!o.checked}:g)}));d(v)};return e.jsxs(se,{as:"div",className:"z-50",children:[e.jsx(re,{ref:f,children:e.jsxs(N,{as:"link","data-testid":"filter-menu-button",variant:"primary",children:[e.jsx(be,{className:"-ml-1 mr-2 h-5 w-5","aria-hidden":"true"}),"Filters",e.jsx(V,{className:"-mr-1 ml-2 h-5 w-5","aria-hidden":"true"})]})}),e.jsx(ne,{transition:!0,ref:l,style:p.popper,className:"transition ease-out duration-200 data-[closed]:opacity-0 data-[closed]:translate-y-1",...b.popper,children:e.jsx("div",{"data-testid":"popover-panel",className:"max-w-sm px-4 pt-2",style:{minWidth:300},children:e.jsxs("div",{className:"max-w-md mx-auto bg-white rounded-lg shadow-2xl",children:[e.jsxs("div",{className:"flex flex-row justify-between items-center pl-3.5 pr-2.5 pt-2 pb-2 text-lg font-semibold border-b",children:[e.jsx("div",{children:"Filters"}),e.jsx("div",{children:e.jsx(N,{variant:"ghost",onClick:j,children:"Reset"})})]}),s.map((o,v)=>e.jsxs(ie,{as:"div",defaultOpen:o.defaultOpen,children:[e.jsxs(le,{className:"group flex justify-between border-b w-full px-4 py-2 text-sm font-medium text-left hover:bg-gray-100 focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75",children:[e.jsx("span",{"data-testid":"filter-menu-section-title",children:o.title}),e.jsx(xe,{className:"w-5 h-5 group-data-[open]:rotate-180 transition-transform"})]}),e.jsx(ce,{transition:!0,"data-testid":"filter-menu-section",className:T("p-4 text-sm text-gray-500 bg-gray-50 transition-all duration-200 origin-top data-[closed]:opacity-0 data-[closed]:scale-y-0",{"rounded-lg":v===s.length-1}),children:o.options.map(r=>e.jsx("div",{className:"flex flex-row my-2",children:e.jsx(k,{"data-testid":"filter-menu-checkbox",checked:r.checked,onChange:()=>S(r),children:r.label})},r.label))})]},o.title))]})})})]})},Re=({searchPlaceholder:a,filters:t=[],debounceDelay:i=500,onChangeFilters:s,onChangeSearch:d})=>{const[u,m]=n.useState(t),[f,h]=n.useState(""),l=O(f.trim(),i);n.useEffect(()=>{d(l)},[l]);const p=r=>h(r?.target?.value),b=r=>{m(r),s(r)},j=r=>{const g=u.map(R=>({...R,options:R.options.map(c=>c.value===r.value?{...c,checked:!1}:c)}));m(g),s(g)},S=()=>{h("")},o=u?.map(r=>r.options)?.flat()?.filter(r=>r.checked),v=!!o.length||!!l.length;return e.jsx("div",{className:"flex flex-col w-full",children:e.jsxs("div",{className:"w-full flex flex-wrap justify-between items-center",style:{minHeight:66},children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx(Pe,{filters:u,onChange:b}),e.jsx("div",{className:"ml-3 w-full sm:w-72 max-w-sm",children:e.jsx(oe,{"data-testid":"table-filters-search",inputClasses:"h-10",leftAddon:e.jsx(Z,{}),placeholder:a,value:f,onChange:p})})]}),v&&e.jsxs("div",{className:"flex flex-wrap my-4 fade-in",children:[e.jsx("span",{className:"mr-3 m-1 text-gray-500 font-medium",children:"Active Filters:"}),o.map(r=>e.jsx("div",{"data-testid":"table-filter-badge",className:"m-1 fade-in",children:e.jsx(C,{variant:"note",size:"lg",removable:!0,onRemove:()=>j(r),children:r.label})},r.label)),!!l&&e.jsx("div",{"data-testid":"table-filter-search-badge",className:"m-1 fade-in",children:e.jsx(C,{variant:"note",size:"lg",removable:!0,onRemove:S,children:`Search: '${l}'`})})]})]})})},Ne=({row:a})=>e.jsx(k,{checked:a.getIsSelected(),onChange:a.getToggleSelectedHandler()}),Ce=({table:a})=>e.jsx(k,{checked:a.getIsAllRowsSelected(),indeterminate:a.getIsSomeRowsSelected(),onChange:a.getToggleAllRowsSelectedHandler()}),ke={success:"success",queued:"note",started:"note",cached:"note",skipped:"note",failed:"error","failed-dependency":"error"},Fe=({id:a,name:t})=>e.jsx(C,{variant:ke[a],children:t}),Ee=({getValue:a})=>{const t=a();return e.jsx(Fe,{...t})},Ie=[{header:Ce,id:"isSelected",cell:Ne,meta:{className:"condensed",preventClick:!0},enableSorting:!1},{header:"Name",accessorKey:"name",meta:{className:"font-bold"}},{header:"Owner",accessorKey:"scenario.organisation.name"},{header:"Is Public",accessorKey:"is_public",cell:E},{header:"Archived",accessorKey:"archived",cell:E},{header:"Status",accessorKey:"status",cell:Ee},{header:"Created At",accessorKey:"created_at",cell:I},{header:"Updated At",accessorKey:"updated_at",cell:I}],Ae=[{title:"Scenarios",defaultOpen:!0,options:[{id:"scenarios_global",queryParam:"is_public",label:"Include Global Scenarios",value:void 0,uncheckedValue:!1,checked:!0},{id:"scenarios_archived",queryParam:"archived",label:"Include Archived Scenarios",value:void 0,uncheckedValue:!1,checked:!1}
1]},{title:"Status",defaultOpen:!0,queryParam:"status",options:[{id:"status_success",label:"Success",value:"Success",checked:!1},{id:"status_started",label:"In Progress",value:"started",checked:!1},{id:"status_failed",label:"Failed",value:"failed",checked:!1}]},{title:"Tags",defaultOpen:!0,queryParam:"tags",options:[]}],Te=({onSelectedRowsChange:a})=>{const[t,i]=n.useState(Ae),[s,d]=n.useState(""),[u,m]=n.useState([]),[f,h]=n.useState([]),[l,p]=n.useState({}),{data:b,isValidating:j}=J("/v1/pipelines/tags"),S=e.jsx("div",{className:"relative",children:e.jsx("div",{className:"absolute fade-in",style:{top:-16,left:2},children:e.jsx("p",{className:"text-gray-500 text-sm",children:`${L("scenario",f.length,!0)} selected`})})});n.useEffect(()=>{if(!j&&Array.isArray(b)){const c=t.find(y=>y.title==="Tags"),w=c.options;c.options=b.map(y=>({id:`tag-${y}`,label:y,value:y,checked:w.find(P=>P.label===y)?.checked||!1}))||[],i([...t.filter(y=>y.title!=="Tags"),c])}},[b]);const o=()=>{const c=t.map(w=>{const y=w.options.filter(x=>x.checked&&x.value!==void 0).map(x=>[x.queryParam||w.queryParam,x.value]),P=w.options.filter(x=>!x.checked&&x.uncheckedValue!==void 0).map(x=>[x.queryParam||w.queryParam,x.uncheckedValue]);return[...y,...P]}).flat();s.length&&c.push(["search",s]),m(c)};n.useEffect(()=>{o()},[t,s]);const v=c=>{i(c)},r=c=>{d(c)},g=c=>`/scenarios/${c.original.uuid}/overview`,R=c=>{const w=c.filter(P=>P.getIsSelected()).reduce((P,x)=>({...P,[x.id]:x.getIsSelected()}),{});!de(l,w)&&(p(w),h(c.filter(P=>P.getIsSelected())),a&&a(c))};return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx(Re,{searchPlaceholder:"Search for name, status, tags",onChangeFilters:v,onChangeSearch:r,filters:t})}),e.jsx(X,{sectionLabel:"scenario table",children:e.jsxs(W,{children:[e.jsx(Se,{url:"/v1/pipelines/requests",columns:Ie,queryParams:u,clickableRow:g,selectedRowIds:l,onSelectedRowsChange:R}),!!f.length&&S]})})]})},Le="/scenarios/create",A=5,Je=()=>{const a=D(),{siteConfig:t}=z(),[i,s]=n.useState([]),d=()=>{const l=t?.routeOverrides?.addScenario;a(l?{to:t?.routeOverrides?.addScenario}:{to:Le})},u=()=>{i.length<=A&&a({to:"/scenarios/compare",search:{uuid:i.map(l=>l.original.uuid)}})},m=async()=>{await Promise.all(i.map(async l=>{const p=l.original.uuid;await he(p)})),ee("/v1/pipeline/requests*"),window.location.reload()},f=l=>{s(l.filter(p=>p.getIsSelected()))},h=e.jsx(je,{maxCount:A,selectedCount:i.length,onClick:u});return e.jsxs(e.Fragment,{children:[e.jsx(H,{children:e.jsx("title",{children:"Scenarios"})}),e.jsx(U,{title:"Scenarios",actions:[{type:Q.Node,node:h},{Icon:ue,label:"Archive Selected",onClick:m,variant:i.length?"default":"disabled"},{Icon:me,label:"Add Scenario",onClick:d,variant:"primary"}]}),e.jsx(K,{className:"min-h-screen",backgroundColor:"bg-gray-50",children:e.jsx(Te,{onSelectedRowsChange:f})})]})};export{Je as default}; 2//# sourceMappingURL=index-BwfTtj8u.js.map
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.