1import{r as i,P as E,x as p,j as a,S as h,G as o,v,T as l,g as T,h as C,I as z,b as I,o as _,m as L,E as $,d as B}from"./index-CB1LRsvg.js";import{I as M}from"./IconSearch-CqQSV7iv.js";import{I as x}from"./IconStar-9-CEEvth.js";import{S as P}from"./StatusText-gwUfW1V-.js";import{u as W}from"./usePageTitle-PP7G01cs.js";import{C as N}from"./Card-DwzWyE8m.js";import{T as A}from"./ThemeIcon-DUJfKgY0.js";import{B as b}from"./Badge-CvorhVBt.js";import{S as F}from"./Switch-BZSEpu01.js";function Q(){W("Site Admin · Examples");const[n,c]=i.useState(null),[d,y]=i.useState(""),[w,g]=i.useState(null),{teams:j}=E(),k=i.useMemo(()=>new Set((j??[]).map(e=>e.id)),[j]),f=i.useCallback(async()=>{try{const e=await fetch("/v2/workspaces/admin/all-workspaces",{credentials:"include",cache:"no-store"});if(!e.ok)throw new Error(`status ${e.status}`);c(await e.json())}catch(e){p.show({title:"Couldn't load workspaces",message:e.message,color:"red"}),c([])}},[]);i.useEffect(()=>{f()},[f]);const S=async(e,s)=>{g(e.id),c(r=>r&&r.map(t=>t.id===e.id?{...t,public:s,discoverable:s}:t));try{const r=await fetch(`/v2/workspaces/${e.id}/visibility`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({public:s,discoverable:s})});if(!r.ok)throw new Error(`status ${r.status}`);p.show({title:s?"Marked as Example":"Removed from Examples",message:s?`${e.name} is now featured on the Explore page.`:`${e.name} has been removed from the Explore page.`,color:s?"blue":"gray"})}catch(r){c(t=>t&&t.map(u=>u.id===e.id?{...u,public:!s,discoverable:!s}:u)),p.show({title:"Couldn't update",message:r.message,color:"red"})}finally{g(null)}},m=i.useMemo(()=>{if(!n)return null;const e=d.trim().toLowerCase();return e?n.filter(s=>s.name.toLowerCase().includes(e)||s.slug.toLowerCase().includes(e)||s.team_name.toLowerCase().includes(e)||(s.owner_username??"").toLowerCase().includes(e)||(s.owner_display_name??"").toLowerCase().includes(e)):n},[n,d]);return a.jsxs(h,{gap:"md",children:[a.jsxs("div",{children:[a.jsxs(o,{gap:"xs",mb:"xs",children:[a.jsx(x,{size:20,"aria-hidden":!0}),a.jsx(v,{order:2,m:0,children:"Examples"})]}),a.jsxs(l,{c:"dimmed",maw:640,children:["Curate which workspaces appear as ",a.jsx("strong",{children:"Examples"})," on the Explore page. Marking a workspace as an Example makes it visible to any logged-in user along with all of its decks and visualizations. This list spans every team on the installation, because Explore is a single public page."]})]}),a.jsx(T,{"aria-label":"Search workspaces",placeholder:"Search by workspace, slug, team, or owner",leftSection:a.jsx(M,{size:16,"aria-hidden":!0}),value:d,onChange:e=>y(e.currentTarget.value)}),m===null?a.jsx(o,{justify:"center",py:"xl",role:"status","aria-label":"Loading workspaces",children:a.jsx(C,{size:"sm"})}):m.length===0?a.jsx(P,{c:"dimmed",ta:"center",py:"xl",children:n&&n.length===0?"No workspaces exist yet.":"No matches."}):a.jsx(h,{gap:"sm",children:m.map(e=>a.jsx(N,{withBorder:!0,p:"md",children:a.jsxs(o,{justify:"space-between",wrap:"nowrap",align:"flex-start",children:[a.jsxs(o,{gap:"md",wrap:"nowrap",style:{minWidth:0},children:[a.jsx(A,{variant:"light",size:"lg",radius:"md",color:"blue",children:a.jsx(z,{size:20,"aria-hidden":!0})}),a.jsxs(h,{gap:2,style:{minWidth:0},children:[a.jsxs(o,{gap:"xs",wrap:"nowrap",children:[k.has(e.team_id)?a.jsx(l,{component:I,to:`/${e.id}`,fw:600,truncate:!0,style:{color:"inherit"},children:e.name}):a.jsx(_,{label:`Join ${e.team_name} to open this workspace`,children:a.jsx(l,{fw:600,truncate:!0,tabIndex:0,children:e.name})}),e.discoverable&&a.jsx(b,{variant:"outline",color:"blue",leftSection:a.jsx(x,{size:12,"aria-hidden":!0}),children:"Example"})]}),a.jsxs(o,{gap:6,wrap:"nowrap",children:[a.jsxs(l,{size:"xs",c:"dimmed",truncate:!0,children:["/",e.slug]}),a.jsx(b,{size:"xs",variant:"light",color:"gray",children:e.team_name})]}),(e.owner_display_name||e.owner_username)&&a.jsxs(o,{gap:4,wrap:"nowrap",children:[a.jsx(L,{size:14,color:"var(--sd-color-text-muted)","aria-hidden":!0}),a.jsx(l,{size:"xs",c:"dimmed",truncate:!0,children:e.owner_display_name||e.owner_username})]})]})]}),a.jsx($,{style:{flexShrink:0},children:a.jsx(F,{size:"md",onLabel:a.jsx(x,{size:12,"aria-hidden":!0}),offLabel:a.jsx(B,{size:12,"aria-hidden":!0}),checked:e.discoverable,disabled:w===e.id,"aria-label":`Feature ${e.name} as an example`,onChange:s=>S(e,s.currentTarget.checked)})})]})},e.id))})]})}export{Q 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.