1import{j as e,r as o,K as R,aI as J,aJ as z,aK as Q,H as B,A as w,aL as M,aM as K,S as k,aN as I,w as q,I as T,P as G,v as W,k as X,aO as Y,D as Z,aP as ee,B as se,C as P,x as te,V as F,l as O,aQ as ae,s as re,p as ne,aR as L,N as le,h as ie}from"./root-C9LVyve2.js";import{C as ce}from"./CopyModal-CmyVog17.js";import"./index-DPxt4TBf.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"distillery-frontend"};var r=new s.Error().stack;r&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[r]="3ea9de38-8bd0-4a99-bbfe-193088a36c5f",s._sentryDebugIdIdentifier="sentry-dbid-3ea9de38-8bd0-4a99-bbfe-193088a36c5f")}catch{}})();const H=({children:s})=>e.jsx("dl",{className:"mt-2 border-t border-b border-gray-200 divide-y divide-gray-200",children:s}),E=({term:s,details:r})=>e.jsxs("div",{className:"py-2 flex justify-between text-sm font-medium",children:[e.jsx("dt",{className:"text-gray-500 pl-2",children:s}),e.jsx("dd",{className:"text-gray-900 pr-2",children:r})]}),oe=({pk:s,objectType:r,clientSlug:i,accountSlug:l})=>{const[n,a]=o.useState(!1),t=()=>{a(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(ce,{open:n,handleClose:t,fetchURL:`/api/v2/archive/bundle/cl-${i}/${s}/`,targetElement:r,accountSlug:l}),e.jsx(R.Ghost,{iconName:"copy",size:"sm",onClick:()=>a(!0),tooltipPosition:"top",tooltipText:`Copy ${r} to clipboard`})]})},de=({open:s,onClose:r,clientSlug:i,pk:l,deleteArchive:n})=>{const[a,t]=o.useState(!1),c=`/api/v2/archive/delete/cl-${i}/${l}/`,x=()=>{n(c),t(!0)},d=()=>{r(),t(!1)};return e.jsx(J,{onClose:d,open:s,children:e.jsxs(z,{children:[e.jsx(Q,{title:"Delete Archive Object"}),e.jsxs(B,{children:[e.jsx("p",{children:"Are you sure you want to delete this archive object?"}),e.jsx("p",{children:"There is no undo."}),a&&e.jsx(w,{variant:"success",message:"Deleted from archive."})]}),e.jsx(M,{classes:"flex justify-end gap-3",children:a?e.jsx(e.Fragment,{children:e.jsx(k,{onClick:()=>d(),variant:"primary",children:"Close"})}):e.jsxs(e.Fragment,{children:[e.jsx(K,{onClick:()=>d(),variant:"primary",children:"Cancel"}),e.jsx(k,{onClick:()=>x(),variant:"danger",children:"Delete"})]})})]})})},he=({clientSlug:s,pk:r,deleteArchive:i})=>{const[l,n]=o.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(de,{onClose:()=>n(!1),open:l,clientSlug:s,pk:r,deleteArchive:i}),e.jsx(R.Plain,{iconName:"trashCan",size:"sm",variant:"danger",onClick:()=>n(!0),"aria-label":"Delete from Archive",tooltipPosition:"top",tooltipText:"Delete from Archive"})]})},ue=({archivedObject:s,clientSlug:r,deleteArchive:i})=>e.jsxs("li",{className:"w-full rounded-md bg-gray-50 shadow",children:[e.jsxs("div",{className:"flex content-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mx-3 my-2 text-lg",children:s.name}),e.jsx("div",{className:"mx-3 my-2",children:s.description})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(oe,{pk:s.pk,objectType:s.object_type,clientSlug:r,accountSlug:s?.account?.slug}),e.jsx(he,{clientSlug:r,pk:s.pk,deleteArchive:i})]})]}),e.jsxs("div",{className:"mx-2 my-2 grid grid-cols-2 gap-4",children:[e.jsxs(H,{
1children:[e.jsx(E,{term:"Site Name",details:s?.account.name}),e.jsx(E,{term:"Object Type",details:s?.object_type})]}),e.jsxs(H,{children:[e.jsx(E,{term:"Archived By",details:s?.archived_by?.first_name}),e.jsx(E,{term:"Archived On",details:s?.archived_on})]})]})]}),me=({availableAccounts:s,availableObjectTypes:r,availableUsers:i,filters:l,updateFilter:n,clearFilter:a})=>e.jsxs("div",{className:"bg-white px-6 py-4",children:[e.jsxs("div",{className:"grid justify-items-stretch gap-2 self-stretch md:grid-cols-3 ",children:[e.jsxs("div",{className:"mr-2",children:[e.jsx(I,{label:"Sites",id:"filter-archive-site"}),e.jsxs("select",{id:"filter-archive-site",value:l.account_slug,onChange:t=>{n("account_slug",t.target.value)},className:"form-select sp-input sp-select-field",children:[e.jsx("option",{value:"",children:"All"}),s.map((t,c)=>e.jsx("option",{value:t.slug,children:t.name},c))]})]}),e.jsxs("div",{className:"mr-2",children:[e.jsx(I,{label:"Object Type",id:"filter-archive-object-type"}),e.jsxs("select",{id:"filter-archive-object-type",value:l.object_type,onChange:t=>{n("object_type",t.target.value)},className:"form-select sp-input sp-select-field",children:[e.jsx("option",{value:"",children:"All"}),r.map((t,c)=>e.jsx("option",{value:t[0],children:t[1]},c))]})]}),e.jsxs("div",{className:"mr-2",children:[e.jsx(I,{label:"Archived By",id:"filter-archive-by"}),e.jsxs("select",{id:"filter-archive-by",value:l.archived_by,onChange:t=>{n("archived_by",t.target.value)},className:"form-select sp-input sp-select-field",children:[e.jsx("option",{value:"",children:"All"}),i.map((t,c)=>e.jsx("option",{value:t.username,children:`${t.first_name} ${t.last_name}`},c))]})]}),e.jsx("div",{className:"mr-2",children:e.jsx(q,{label:"Date Archived After",initialDate:l.archived_on_after,updateDate:t=>{n("archived_on_after",t)}})}),e.jsx("div",{className:"mr-2",children:e.jsx(q,{label:"Date Archived Before",initialDate:l.archived_on_before,updateDate:t=>{n("archived_on_before",t)}})}),e.jsx("div",{className:"mr-2",children:e.jsx(T,{label:"Search Name and Description",value:l.search,onChangeFunction:n,onChangeParameters:["search"]})})]}),e.jsx(G,{variant:"primary",size:"sm",onClick:a,leftIcon:e.jsx(W,{name:"closeCross",size:"sm"}),children:"Clear Filter"})]}),xe=({open:s,onClose:r,availableAccounts:i,archiveCreateEndpoint:l,refetch:n})=>{const[a,t]=o.useState(null),[c,x]=o.useState(!1),[d,g]=o.useState(""),[p,b]=o.useState(!1),[A,y]=o.useState(!1),[j,C]=o.useState(""),[N,D]=o.useState(""),[S,v]=o.useState(""),h=u=>{try{t(JSON.parse(atob(u)))}catch{x(!0)}};o.useEffect(()=>{a&&x(!1)},[a]);const f=()=>{t(null),D(""),v(""),x(!1),g(""),y(!1),r()},_=X("csrftoken"),U=()=>{b(!0),g("");const u={account_slug:j,name:N,description:S,bundle:btoa(JSON.stringify(a))};fetch(l,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":_||""},body:JSON.stringify(u)}).then(m=>{if(m.ok)return m.json();throw g("Something went wrong. Please make sure all fields are filled in correctly. If problem persists, please speak to someone from the team."),Error(`request rejected with status ${m.status}`)}).then(m=>{b(!1),y(!0)}).catch(m=>{b(!1),console.error("Error:",m)}),n()};let $="";!c&&a&&($=a);const V=j!==""&&N!==""&&S!==""&&a!==null;return e.jsx(J,{onClose:f,open:s,children:e.jsxs(z,{children:[e.jsx(Q,{title:"Archive Object"}),e.jsxs(B,{children:[e.jsx("span",{className:"text-right",children:e.jsx(Y,{children:"* indicates a required field"})}),e.jsx("div",{className:"mb-2",children:e.jsxs(Z,{"aria-label":"select-account",label:"Site*",value:j,onChangeFunction:C,onChangeParameters:[],required:!0,children:[e.jsx("option",{value:"",disabled:!0,children:"Select site"}),i.map((u,m)=>e.jsxs("option",{value:u.slug,children:[" ",u.name]},m))]})}),e.jsx("div",{className:"mb-2",children:e.jsx(T,{"aria-label":"archive-name",label:"Name*",value:N,onChangeFunction:D,onChangeParameters:[],required:!0})}),e.jsx("div",{className:"mb-2",children:e.jsx(T,{"aria-label":"archive-description",label:"Description*",value:S,onChangeFunction:v,onChangeParameters:[],required:!0})}),a&&!c?e.jsxs("div",{className:"mt-4 overflow-hidden rounded-lg bg-gray-50 px-4 py-4 shadow",children:[e.jsxs("p",{className:"py-2",children:[e.jsx("span",{className:"font-bold",children:"Name: "}),e.jsx("code",{className:"bg-orange-100 p-1 text-sm text-orange-500",children:a.name})]}),e.jsxs("p",{className:"py-2",children:[e.jsx("span",{className:"font-bold",children:"Instructions: "}),a.instructions]}),Object.keys(a[`${a.level}_objects`]).map((u,m)=>e.jsxs("p",{className:"py-2",children:[e.jsxs("span",{className:"font-bold",children:["Number of exported"," ",u==="split_test"?"split tests":u.replace(/_/g," "),":"]}),e.jsx("code",{className:"bg-orange-100 p-1 text-sm text-orange-500",children:Array.isArray(a[`${a.level}_objects`][u])?a[`${a.level}_objects`][u].length:1})]},m))]}):e.jsx(ee,{"aria-label":"text-area",id:"exportArchive",label:"Paste from Clipboard*",onChangeParameters:[],onChangeFunction:h,value:$,required:!0,errorText:c?"Error - please check this is the correct export":void 0}),d&&e.jsx(w,{variant:"error",message:d}),A?e.jsx(w,{variant:"success",message:"Saved to Archive."}):null]}),e.jsx(M,{classes:"flex justify-end gap-3",children:A?e.jsx(k,{onClick:()=>f(),variant:"primary",children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"primary",onClick:()=>f(),children:"Cancel"}),e.jsx(k,{"aria-label":"Archive",loading:p,onClick:()=>U(),variant:"primary",disabled:!V,children:"Archive"})]})})]})})},pe=({availableAccounts:s,archiveCreateEndpoint:r,refetch:i})=>{const[l,n]=o.useState(!1);return e.jsxs("div",{className:"py-2",children:[e.jsx(xe,{open:l,onClose:()=>n(!1),availableAccounts:s,archiveCreateEndpoint:r,refetch:i}),e.jsx(k,{leftIcon:e.jsx(W,{color:"white",hoverColor:void 0,name:"storageBox"}),onClick:()=>n(!0),variant:"primary",children:"Add to Archive"})]})},je=({archivedObjects:s,total:r,limit:i,offset:l,setLimit:n,setOffset:a,availableAccounts:t,availableObjectTypes:c,availableUsers:x,archiveCreateEndpoint:d,filters:g,updateFilter:p,clearFilter:b,clientSlug:A,deleteArchive:y,refetch:j})=>{let C;return s.length?C=e.jsx("ul",{className:"grid gap-2.5 sm:grid-cols-2",children:s.map((N,D)=>e.jsx(ue,{archivedObject:N,clientSlug:A,deleteArchive:y},`archived-object-${D}`))}):C=e.jsx("div",{className:"flex justify-center my-8",children:e.jsx("p",{children:"No results found. We can't find any item matching your filters."})}),e.jsx("div",{children:e.jsxs(se,{children:[e.jsxs(P,{children:[e.jsxs(P.Content,{children:[e.jsx(P.Title,{children:"Archive Dashboard"}),e.jsx(P.Description,{children:"List of archived sections, rules, tests and values"})]}),e.jsx(pe,{availableAccounts:t,archiveCreateEndpoint:d,refetch:j})]}),e.jsx(me,{availableAccounts:t,availableObjectTypes:c,availableUsers:x,filters:g,updateFilter:p,clearFilter:b}),e.jsx(B,{children:C}),e.jsx(M,{children:e.jsx(te,{totalCount:r,listItems:s,setLimit:n,setOffset:a,offset:l,limit:i})})]})})},ve=()=>{const s=F("archive-dashboard-react-target","available-accounts-b64",null),r=F("archive-dashboard-react-target","available-object-types-b64",null),i=F("archive-dashboard-react-target","available-users-b64",null),l=O("archive-dashboard-react-target","archive-endpoint"),n=O("archive-dashboard-react-target","archive-create-endpoint"),a=O("archive-dashboard-react-target","client-slug"),[t,c]=o.useState({}),x=ae(t,500),[d,g]=o.useState(30),[p,b]=o.useState(0),{error:A,data:y}=re({queryKey:["archivedObjects",a,x,d,p],queryFn:async()=>await j(x,d,p)}),j=async(v,h,f)=>{const _=L(v);if(_.offset=f,_.limit=h,l)return await le(l,_)};if(A)return e.jsx("div",{className:"m-8",children:e.jsx(w,{variant:"error",message:"There was an unexpected error fetching the archive. Please try again later"})});const C=(v,h)=>{const f=L(t);h?f[v]=h:delete f[v],c(f)},N=v=>
1{ne(v).then(h=>h.json()).then(h=>{h.status==="ok"&&j(t,d,p)}).catch(h=>console.error(h))},D=()=>{j(t,d,p)},S=()=>{c({})};return e.jsx(je,{archivedObjects:y?.queryset||[],total:y?.total||0,limit:d,setLimit:g,setOffset:b,offset:p,availableAccounts:s,availableObjectTypes:r,availableUsers:i,archiveCreateEndpoint:n,filters:t,updateFilter:C,clearFilter:S,clientSlug:a,deleteArchive:N,refetch:D})},ye=()=>{const s=document.getElementById("archive-dashboard-react-target");return s?ie.createPortal(e.jsx(ve,{}),s):null};export{ye as default}; 2//# sourceMappingURL=index-DALwiO4j.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.