feat: Add refresh button and admin restrictions

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 19:08:01 +00:00
parent c7825fbe03
commit 661bf77d95
2 changed files with 25 additions and 11 deletions

View File

@@ -37,7 +37,7 @@ export function UserRoleManager() {
const [searchResults, setSearchResults] = useState<any[]>([]);
const [actionLoading, setActionLoading] = useState<string | null>(null);
const { user } = useAuth();
const { isAdmin } = useUserRole();
const { isAdmin, isSuperuser, permissions } = useUserRole();
const { toast } = useToast();
const fetchUserRoles = async () => {
@@ -271,7 +271,9 @@ export function UserRoleManager() {
</SelectTrigger>
<SelectContent>
<SelectItem value="moderator">Moderator</SelectItem>
<SelectItem value="admin">Administrator</SelectItem>
{isSuperuser() && (
<SelectItem value="admin">Administrator</SelectItem>
)}
</SelectContent>
</Select>
</div>
@@ -343,14 +345,17 @@ export function UserRoleManager() {
</Badge>
</div>
<Button
variant="outline"
size="sm"
onClick={() => revokeRole(userRole.id)}
disabled={actionLoading === userRole.id}
>
<X className="w-4 h-4" />
</Button>
{/* Only show revoke button if current user can manage this role */}
{(isSuperuser() || (isAdmin() && !['admin', 'superuser'].includes(userRole.role))) && (
<Button
variant="outline"
size="sm"
onClick={() => revokeRole(userRole.id)}
disabled={actionLoading === userRole.id}
>
<X className="w-4 h-4" />
</Button>
)}
</CardContent>
</Card>
))