Skip to content

Commit

Permalink
fix: show first 20 users only in admin view
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed May 22, 2024
1 parent 4d08147 commit b6d129a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/Livewire/Team/AdminView.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class AdminView extends Component
{
public $users;
public ?string $search = "";
public bool $lots_of_users = false;
private $number_of_users_to_show = 20;
public function mount()
{
if (!isInstanceAdmin()) {
Expand All @@ -32,8 +34,14 @@ public function submitSearch()
}
public function getUsers()
{
$this->users = User::where('id', '!=', auth()->id())->get();
// $this->users = User::all();
$users = User::where('id', '!=', auth()->id())->get();
if ($users->count() > $this->number_of_users_to_show) {
$this->lots_of_users = true;
$this->users = $users->take($this->number_of_users_to_show);
} else {
$this->lots_of_users = false;
$this->users = $users;
}
}
private function finalizeDeletion(User $user, Team $team)
{
Expand All @@ -59,6 +67,9 @@ private function finalizeDeletion(User $user, Team $team)
}
public function delete($id)
{
if (!auth()->user()->isInstanceAdmin()) {
return $this->dispatch('error', 'You are not authorized to delete users');
}
$user = User::find($id);
$teams = $user->teams;
foreach ($teams as $team) {
Expand Down
3 changes: 3 additions & 0 deletions resources/views/livewire/team/admin-view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ class="font-bold text-red-500 dark:text-warning">from the server (if it's reacha
@empty
<div>No users found other than the root.</div>
@endforelse
@if ($lots_of_users)
<div>There are more users than shown. Please use the search bar to find the user you are looking for.</div>
@endif
</div>
</div>

0 comments on commit b6d129a

Please sign in to comment.