diff --git a/frontend/src/admin/AdminApp.vue b/frontend/src/admin/AdminApp.vue index 79d0c6d..0973862 100644 --- a/frontend/src/admin/AdminApp.vue +++ b/frontend/src/admin/AdminApp.vue @@ -70,6 +70,48 @@ function availableOrgsForPermission(pid) { return orgs.value.filter(o => !o.permissions.includes(pid)) } +async function renamePermissionDisplay(p) { + const newName = prompt('New display name', p.display_name) + if (!newName || newName === p.display_name) return + try { + const body = { id: p.id, display_name: newName } + const res = await fetch(`/auth/admin/permission?permission_id=${encodeURIComponent(p.id)}`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body) + }) + const data = await res.json() + if (data.detail) throw new Error(data.detail) + await refreshPermissionsContext() + } catch (e) { + alert(e.message || 'Failed to rename display name') + } +} + +async function renamePermissionId(p) { + const newId = prompt('New permission id', p.id) + if (!newId || newId === p.id) return + try { + const body = { old_id: p.id, new_id: newId, display_name: p.display_name } + const res = await fetch('/auth/admin/permission/rename', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(body) + }) + let data + try { data = await res.json() } catch(_) { data = {} } + if (!res.ok || data.detail) throw new Error(data.detail || data.error || `Failed (${res.status})`) + await refreshPermissionsContext() + } catch (e) { + alert((e && e.message) ? e.message : 'Failed to rename permission id') + } +} + +async function refreshPermissionsContext() { + // Reload both lists so All Permissions table shows new associations promptly. + await Promise.all([loadPermissions(), loadOrgs()]) +} + async function attachPermissionToOrg(pid, orgUuid) { if (!orgUuid) return try { @@ -184,6 +226,10 @@ async function updateOrg(org) { } async function deleteOrg(org) { + if (!info.value?.is_global_admin) { + alert('Only global admins may delete organizations.') + return + } if (!confirm(`Delete organization ${org.display_name}?`)) return const res = await fetch(`/auth/admin/orgs/${org.uuid}`, { method: 'DELETE' }) const data = await res.json() @@ -586,8 +632,8 @@ async function toggleRolePermission(role, permId, checked) {
Actions