// "Manage workspaces" modal for the platform Users admin page. Lets a platform // admin see/manage ALL of a user's workspace memberships: list each with an // inline role dropdown + Remove, and add the user to more workspaces via a // type-to-filter picker. Backed by /api/admin/users/:id/workspaces. import { api } from '../api.js'; import { t } from '../i18n.js'; import { showToast } from '../components/toast.js'; // Display order = least-privilege first (the default for the add row). The SET // must match the server's accepted WORKSPACE_ROLES (routes/admin.js). const WORKSPACE_ROLES = ['workspace_viewer', 'workspace_editor', 'workspace_admin']; const STAFF_ROLES = ['platform_admin', 'superadmin', 'platform_operator']; function esc(s) { return String(s ?? '').replace(/[&<>"']/g, c => ({ '&':'&','<':'<','>':'>','"':'"',"'":''' }[c])); } function roleOptions(selected) { return WORKSPACE_ROLES.map(r => ``).join(''); } const wsLabel = w => `${w.organization_name || '—'} / ${w.name}`; // user: { id, name, email, role }; opts.onClose fires (once) if anything changed. export function openManageWorkspacesModal(user, opts = {}) { const { onClose } = opts; const isStaff = STAFF_ROLES.includes(user.role); const overlay = document.createElement('div'); overlay.className = 'modal-overlay'; overlay.innerHTML = `
${t('manage_ws.staff_note')}
` : ''}${t('manage_ws.empty')}
`; return; } listEl.innerHTML = memberships.map(m => `${esc(e.message || 'Failed to load')}
`; } })(); }