-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4434342
commit b87aff2
Showing
11 changed files
with
213 additions
and
90 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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enums; | ||
|
||
use App\Concerns\Enums\Arrayable; | ||
use App\Concerns\Enums\Comparable; | ||
use App\Concerns\Enums\HasLabel; | ||
|
||
enum AdminPermission: string | ||
{ | ||
use Arrayable; | ||
use Comparable; | ||
use HasLabel; | ||
|
||
case CAN_CHANGE_NOMENCLATURE = 'can_change_nomenclature'; | ||
case CAN_CHANGE_STAFF = 'can_change_staff'; | ||
case CAN_CHANGE_ORGANISATION_PROFILE = 'can_change_organisation_profile'; | ||
|
||
protected function labelKeyPrefix(): ?string | ||
{ | ||
return 'enum.admin_permission'; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enums; | ||
|
||
use App\Concerns\Enums\Arrayable; | ||
use App\Concerns\Enums\Comparable; | ||
use App\Concerns\Enums\HasLabel; | ||
|
||
enum CasePermission: string | ||
{ | ||
use Arrayable; | ||
use Comparable; | ||
use HasLabel; | ||
|
||
case HAS_ACCESS_TO_ALL_CASES = 'has_access_to_all_cases'; | ||
case CAN_SEARCH_CASES_IN_ALL_CENTERS = 'can_search_cases_in_all_centers'; | ||
case CAN_COPY_CASES_IN_ALL_CENTERS = 'can_copy_cases_in_all_centers'; | ||
case HAS_ACCESS_TO_STATISTICS = 'has_access_to_statistics'; | ||
|
||
protected function labelKeyPrefix(): ?string | ||
{ | ||
return 'enum.case_permissions'; | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
app/Filament/Organizations/Resources/UserResource/Actions/DeactivateUserAction.php
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Organizations\Resources\UserResource\Actions; | ||
|
||
use App\Enums\UserStatus; | ||
use App\Models\User; | ||
use Filament\Actions\Action; | ||
|
||
class DeactivateUserAction extends Action | ||
{ | ||
public static function getDefaultName(): ?string | ||
{ | ||
return 'deactivate'; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->visible(fn (User $record) => UserStatus::isValue($record->status, UserStatus::ACTIVE)); | ||
|
||
$this->label(__('user.actions.deactivate')); | ||
|
||
$this->color('danger'); | ||
|
||
// $this->icon('heroicon-s-ban'); | ||
|
||
$this->modalHeading(__('user.action_deactivate_confirm.title')); | ||
|
||
$this->modalWidth('md'); | ||
|
||
$this->action(function (User $record) { | ||
$record->deactivate(); | ||
$this->success(); | ||
}); | ||
|
||
$this->successNotificationTitle(__('user.action_deactivate_confirm.success')); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
app/Filament/Organizations/Resources/UserResource/Actions/ResendInvitationAction.php
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,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Organizations\Resources\UserResource\Actions; | ||
|
||
use App\Enums\UserStatus; | ||
use App\Models\User; | ||
use Filament\Actions\Action; | ||
use Filament\Notifications\Notification; | ||
use Illuminate\Support\Facades\RateLimiter; | ||
|
||
class ResendInvitationAction extends Action | ||
{ | ||
public static function getDefaultName(): ?string | ||
{ | ||
return 'resend_invitation'; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->visible(fn (User $record) => UserStatus::isValue($record->status, UserStatus::PENDING)); | ||
|
||
$this->label(__('user.actions.resend_invitation')); | ||
|
||
// $this->icon('heroicon-o-mail'); | ||
|
||
$this->modalHeading(__('user.action_resend_invitation_confirm.title')); | ||
|
||
$this->modalWidth('md'); | ||
|
||
$this->action(function (User $record) { | ||
$key = $this->getRateLimiterKey($record); | ||
$maxAttempts = 1; | ||
|
||
if (RateLimiter::tooManyAttempts($key, $maxAttempts)) { | ||
return $this->failure(); | ||
} | ||
|
||
RateLimiter::increment($key, HOUR_IN_SECONDS); | ||
|
||
$record->sendWelcomeNotification(); | ||
$this->success(); | ||
}); | ||
|
||
$this->successNotificationTitle(__('user.action_resend_invitation_confirm.success')); | ||
|
||
$this->failureNotification( | ||
fn (Notification $notification) => $notification | ||
->danger() | ||
->title(__('user.action_resend_invitation_confirm.failure_title')) | ||
->body(__('user.action_resend_invitation_confirm.failure_body')) | ||
); | ||
} | ||
|
||
private function getRateLimiterKey(User $user): string | ||
{ | ||
return 'resend-invitation:' . $user->id; | ||
} | ||
} |
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
41 changes: 0 additions & 41 deletions
41
database/migrations/2024_05_20_132306_add_columns_in_users_table.php
This file was deleted.
Oops, something went wrong.
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