PageSourceSearch

https://slatedata.ai/assets/page-CRQIxgDE.js

js slatedata.ai collected 2026-10-05 15:05:07 UTC 5,467 bytes, 1 lines download raw bytes

1import{p as K,f as Q,u as X,q as Z,t as ee,r as i,j as e,S as D,v as y,T as m,G as v,g as ae,B as k,w as se,D as P,x as c}from"./index-CB1LRsvg.js";import{I as te}from"./IconAlertTriangle-oE-1p8q2.js";import{I as ne}from"./IconTrash-B56plgcD.js";import{u as re}from"./usePageTitle-PP7G01cs.js";import{u as ie}from"./useConfirm-B_NA31aX.js";import{u as oe}from"./use-form-CaiTdMy3.js";import{A as le}from"./Alert-Dvpb9ICu.js";import{S as ce}from"./Switch-BZSEpu01.js";import"./index-C148XJoK.js";function xe(){re("Workspace Settings");const{workspace:o}=K(),S=Q(),{workspaces:w,removeWorkspace:U,refresh:A}=X(),{capability:F}=Z(o),x=F==="manage",L=x,{ai:O}=ee(),{confirm:z,confirmDialog:q}=ie(),a=w==null?void 0:w.find(s=>s.id===o),I=(a==null?void 0:a.ai_disabled)??!1,[$,R]=i.useState(!1),r=oe({mode:"controlled",initialValues:{name:""},validate:{name:s=>s.trim()?null:"Workspace name cannot be empty"}}),W=r.values.name,[C,B]=i.useState(null),[T,G]=i.useState(null),[t,N]=i.useState(!1),u=i.useRef(!1),[E,p]=i.useState(!1),[j,H]=i.useState(""),h=(a==null?void 0:a.id)??null,d=(a==null?void 0:a.name)??null;i.useEffect(()=>{h&&d!==null&&(h!==T||d!==C)&&(r.setValues({name:d}),r.clearErrors(),B(d),G(h))},[h,d,T,C]);const M=()=>{const s=W.trim();!a||t||u.current||s===a.name||(H(s),p(!0))},f=W.trim(),J=!a||t||!f||f===(a==null?void 0:a.name),b=a?f?f===a.name?"Change the name to enable Save.":null:"Enter a name to save.":null,V=async()=>{if(!(!j||!a||t||u.current)){u.current=!0,N(!0);try{const s=await fetch(`/v2/workspaces/${o}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j})});if(!s.ok){let n="Unable to rename workspace. Please try again.";try{const g=await s.json();typeof(g==null?void 0:g.detail)=="string"&&(n=g.detail)}catch{}r.setFieldError("name",n),c.show({title:"Rename failed",message:n,color:"red"});return}let l=o;try{const n=await s.json();typeof(n==null?void 0:n.id)=="string"&&n.id&&(l=n.id)}catch{}await A(),r.clearFieldError("name"),c.show({title:"Workspace renamed",message:"The workspace name has been updated."}),l!==o&&S(`/${l}/settings/general`,{replace:!0})}catch{const s="Unable to rename workspace. Please try again.";r.setFieldError("name",s),c.show({title:"Rename failed",message:s,color:"red"})}finally{u.current=!1,N(!1),p(!1)}}},_=async s=>{R(!0);try{const l=await fetch(`/v2/workspaces/${o}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({ai_disabled:s})});if(!l.ok)throw new Error(`status ${l.status}`);await A(),c.show({title:"AI settings updated",message:s?"AI features are now disabled for this workspace.":"AI features are now enabled for this workspace."})}catch{c.show({title:"Update failed",message:"Unable to update AI settings. Please try again.",color:"red"})}finally{R(!1)}},Y=async()=>{if(!await z({title:"Delete workspace",message:"Are you sure you want to delete this workspace? You will permanently lose all visualizations associated with this workspace.",confirmLabel:"Delete workspace"}))return;if(!await U(o))return c.show({title:"Workspace Error",message:"Unable to delete workspace. Please try again.",color:"red"});S("/workspaces")};return e.jsxs(D,{gap:"md",children:[x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(y,{order:2,mb:"xs",children:"Workspace name"}),e.jsx(m,{c:"dimmed",mb:"sm",children:"Rename this workspace. The workspace URL changes to match the new name, and links to the old URL will stop working."}),e.jsxs("form",{onSubmit:r.onSubmit(M),children:[e.jsxs(v,{align:"flex-end",children:[e.jsx(ae,{label:"Workspace name",required:!0,disabled:t||E,...r.getInputProps("name"),style:{flex:1}}),e.jsx(k,{type:"submit",variant:"primary",loading:t,disabled:J,"aria-describedby":b?"workspace-name-save-hint":void 0,children:"Save"})]}),b&&e.jsx(m,{id:"workspace-name-save-hint",size:"xs",c:"dimmed",mt:4,children:b})]})]}),e.jsx(se,{opened:E,onClose:()=>{t||p(!1)},closeOnClickOutside:!t,closeOnEscape:!t,title:"Change workspace URL?",children:e.jsxs(D,{gap:"md",children:[e.jsxs(m,{children:["Renaming this workspace to ",e.jsx("strong",{children:j})," will also change its URL."]}),e.jsx(le,{color:"yellow",icon:e.jsx(te,{size:16,"aria-hidden":!0}),title:"Existing links will break",children:"Bookmarks and shared links pointing to the old URL will stop working once you rename."}),e.jsxs(v,{justify:"flex-end",children:[e.jsx(k,{variant:"default",onClick:()=>p(!1),disabled:t,children:"Cancel"}),e.jsx(k,{color:"red",onClick:V,loading:t,children:"Rename anyway"})]})]})})]}),O&&x&&e.jsxs(e.Fragment,{children:[e.jsx(P,{my:"sm"}),e.jsxs("div",{children:[e.jsx(y,{order:2,mb:"xs",children:"AI features"}),e.jsx(m,{c:"dimmed",mb:"sm",children:"When disabled, AI-backed features (query agent, dataset summaries, automatic analysis) are turned off for this workspace."}),e.jsx(ce,{checked:!I,disabled:$||!a,onChange:s=>_(!s.currentTarget.checked),"aria-label":"AI features",label:I?"AI disabled":"AI enabled"})]})]}),q,L&&e.jsxs(e.Fragment,{children:[e.jsx(P,{my:"sm"}),e.jsxs("div",{children:[e.jsx(y,{order:2,c:"var(--sd-color-danger)",mb:"xs",children:"Danger zone"}),e.jsx(m,{c:"dimmed",mb:"sm",children:"Deleting a workspace is permanent and cannot be undone."}),e.jsx(v,{justify:"flex-start",children:e.jsx(k,{leftSection:e.jsx(ne,{size:16,"aria-hidden":!0}
1),onClick:Y,color:"red",variant:"light",children:"Delete Workspace"})})]})]})]})}export{xe 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.