Skip to content

Commit

Permalink
[Chore] Cleaned up enums (#1800)
Browse files Browse the repository at this point in the history
* cleaned up enums

* changed result colors
  • Loading branch information
alexjustesen authored Nov 20, 2024
1 parent d2bb171 commit 437f2e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
20 changes: 8 additions & 12 deletions app/Enums/ResultStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,27 @@

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
use Illuminate\Support\Str;

enum ResultStatus: string implements HasColor, HasLabel
{
case Completed = 'completed'; // a speedtest that ran successfully.
case Failed = 'failed'; // a speedtest that failed to run successfully.
case Started = 'started'; // a speedtest that has been started by a worker but has not finished running.
case Skipped = 'skipped'; // a speedtest that was skipped.
case Completed = 'completed';
case Failed = 'failed';
case Started = 'started';
case Skipped = 'skipped';

public function getColor(): ?string
{
return match ($this) {
self::Completed => 'success',
self::Failed => 'danger',
self::Started => 'warning',
self::Skipped => 'info', // Adding Skipped state with a color
self::Started => 'info',
self::Skipped => 'gray',
};
}

public function getLabel(): ?string
{
return match ($this) {
self::Completed => 'Completed',
self::Failed => 'Failed',
self::Started => 'Started',
self::Skipped => 'Skipped',
};
return Str::title($this->name);
}
}
6 changes: 2 additions & 4 deletions app/Enums/UserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
use Illuminate\Support\Str;

enum UserRole: string implements HasColor, HasLabel
{
Expand All @@ -20,9 +21,6 @@ public function getColor(): ?string

public function getLabel(): ?string
{
return match ($this) {
self::Admin => 'Admin',
self::User => 'User',
};
return Str::title($this->name);
}
}

0 comments on commit 437f2e9

Please sign in to comment.