mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 12:31:26 -05:00
feat: Add refresh button and admin restrictions
This commit is contained in:
@@ -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>
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user