1import{r as n,j as e,p as h,aZ as b,aU as f,u as w,k as g,q as j,_ as N,i as y,C as v,a_ as k,M as C,S,t as W}from"../index.js";import{A as d}from"./admin-04b020fe.js";function A({workspace:t,users:a,deletionProtected:s=!1}){var l;const r=n.useRef(null),c=async()=>{var o;if(!window.confirm(`Are you sure you want to delete ${t.name}? 2After you do this it will be unavailable in this instance of AnythingLLM. 3 4This action is irreversible.`))return!1;(o=r==null?void 0:r.current)==null||o.remove(),await d.deleteWorkspace(t.id)};return e.jsx(e.Fragment,{children:e.jsxs("tr",{ref:r,className:"bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10",children:[e.jsx("th",{scope:"row",className:"px-6 whitespace-nowrap",children:t.name}),e.jsx("td",{className:"px-6",children:e.jsxs("a",{href:h.workspace.chat(t.slug),target:"_blank",rel:"noreferrer",className:"text-white flex items-center hover:underline",children:[e.jsx(b,{className:"mr-2 w-4 h-4"})," ",t.slug]})}),e.jsx("td",{className:"px-6",children:e.jsx("a",{href:h.workspace.settings.members(t.slug),className:"text-white flex items-center underline",children:(l=t.userIds)==null?void 0:l.length})}),e.jsx("td",{className:"px-6",children:t.createdAt}),e.jsx("td",{className:"px-6",children:!s&&e.jsx("button",{onClick:c,className:"text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10",children:e.jsx(f,{className:"h-5 w-5"})})})]})})}function M({closeModal:t}){const[a,s]=n.useState(null),{t:r}=w(),c=async l=>{s(null),l.preventDefault();const o=new FormData(l.target),{workspace:x,error:i}=await d.newWorkspace(o.get("name"));x&&window.location.reload(),s(i)};return e.jsx("div",{className:"fixed inset-0 z-50 overflow-auto bg-black bg-opacity-50 flex items-center justify-center",children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-theme-bg-secondary rounded-lg shadow border-2 border-theme-modal-border",children:[e.jsxs("div",{className:"relative p-6 border-b rounded-t border-theme-modal-border",children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center",children:e.jsx("h3",{className:"text-xl font-semibold text-white overflow-hidden overflow-ellipsis whitespace-nowrap",children:"Create new workspace"})}),e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(g,{size:24,weight:"bold",className:"text-white"})})]}),e.jsx("div",{className:"p-6",children:e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block mb-2 text-sm font-medium text-white",children:r("common.workspaces-name")}),e.jsx("input",{name:"name",type:"text",className:"border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"My workspace",minLength:4,required:!0,autoComplete:"off"})]}),a&&e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",a]}),e.jsx("p",{className:"text-white text-opacity-60 text-xs md:text-sm",children:"After creating this workspace only admins will be able to see it. You can add users after it has been created."})]}),e.jsxs("div",{className:"flex justify-between items-center mt-6 pt-6 border-t border-theme-modal-border",children:[e.jsx("button",{onClick:t,type:"button",className:"transition-all duration-300 text-white hover:bg-zinc-700 px-4 py-2 rounded-lg text-sm",children:"Cancel"}),e.jsx("button",{type:"submit",className:"transition-all duration-300 bg-white text-black hover:opacity-60 px-4 py-2 rounded-lg text-sm",children:"Create workspace"})]})]})})]})})}function L(){const{isOpen:t,openModal:a,closeModal:s}=j();return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg
4-container flex",children:[e.jsx(N,{}),e.jsxs("div",{style:{height:y?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:[e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Instance Workspaces"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"These are all the workspaces that exist on this instance. Removing a workspace will delete all of its associated chats and settings."})]}),e.jsx("div",{className:"w-full justify-end flex",children:e.jsxs(v,{onClick:a,className:"mt-3 mr-0 mb-4 md:-mb-14 z-10",children:[e.jsx(k,{className:"h-4 w-4",weight:"bold"})," New Workspace"]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(D,{})})]}),e.jsx(C,{isOpen:t,children:e.jsx(M,{closeModal:s})})]})]})}function D(){const[t,a]=n.useState(!0),[s,r]=n.useState([]),[c,l]=n.useState([]),[o,x]=n.useState(!1);return n.useEffect(()=>{async function i(){const[p,u,m]=await Promise.all([d.users(),d.workspaces(),W.keys()]);r(p),l(u),x((m==null?void 0:m.WorkspaceDeletionProtection)===!0),a(!1)}i()},[]),t?e.jsx(S,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-6",containerClassName:"flex w-full"}):e.jsxs("table",{className:"w-full text-xs text-left rounded-lg mt-6 min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:"Name"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Link"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Users"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Created On"}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:c.map(i=>e.jsx(A,{workspace:i,users:s,deletionProtected:o},i.id))})]})}export{L 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.