-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to edit and delete user roles
Updated relevant blade files to include the option for an administrator to edit and delete user roles. Also, fixed some assertions in on some Livewire test files.
- Loading branch information
Showing
10 changed files
with
107 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Livewire\Admin\Roles; | ||
|
||
use Illuminate\Contracts\View\View; | ||
use Livewire\Component; | ||
|
||
class Row extends Component | ||
{ | ||
public $role; | ||
|
||
public function render(): View | ||
{ | ||
return view('livewire.admin.roles.row'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<tr> | ||
<td>{{ $role->label }}</td> | ||
<td> | ||
<div class="flex space-x-2"> | ||
|
||
@can('edit_roles') | ||
<a href="{{ route('admin.settings.roles.edit', ['role' => $role->id]) }}">{{ __('Edit') }}</a> | ||
@endcan | ||
|
||
@if ($role->name !== 'admin') | ||
@can('delete_roles') | ||
|
||
<x-dialog> | ||
<x-dialog.open> | ||
<a class="link" href="#">{{ __('Delete') }}</a> | ||
</x-dialog.open> | ||
|
||
<x-dialog.panel> | ||
|
||
<div class="flex flex-col gap-6" x-data="{ confirmation: '' }"> | ||
<h2 class="font-semibold text-3xl">{{ __('Are you sure you want to delete this role?') }}</h2> | ||
|
||
<form wire:submit="$dispatch('delete')"> | ||
|
||
<label class="flex flex-col gap-2"> | ||
{{ __('Type') }} "{{ $role->label }}" {{ __('to confirm') }} | ||
<input autofocus x-model="confirmation" class="px-3 py-2 border border-slate-300 rounded-lg" placeholder="CONFIRM"> | ||
</label> | ||
|
||
<x-dialog.footer> | ||
<x-dialog.close> | ||
<button type="button" class="btn mr-5">{{ __('Cancel') }}</button> | ||
</x-dialog.close> | ||
|
||
<x-dialog.close> | ||
<button type="submit" :disabled="confirmation !== '{{ $role->label }}'" class="btn btn-red text-center disabled:cursor-not-allowed disabled:opacity-50">{{ __('Delete Role') }}</button> | ||
</x-dialog.close> | ||
</x-dialog.footer> | ||
|
||
</form> | ||
</div> | ||
|
||
</x-dialog.panel> | ||
|
||
</x-dialog> | ||
@endcan | ||
@endif | ||
</div> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ | |
|
||
Livewire::test(Users::class) | ||
->set('email', '[email protected]') | ||
->set('created_at', '2023-01-01 to 2023-01-31') | ||
->set('joined', '2023-01-01 to 2023-01-31') | ||
->call('users') | ||
->assertOk() | ||
->assertSet('openFilter', true) | ||
|