Skip to content

Commit 437f2e9

Browse files
authored
[Chore] Cleaned up enums (alexjustesen#1800)
* cleaned up enums * changed result colors
1 parent d2bb171 commit 437f2e9

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

app/Enums/ResultStatus.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,27 @@
44

55
use Filament\Support\Contracts\HasColor;
66
use Filament\Support\Contracts\HasLabel;
7+
use Illuminate\Support\Str;
78

89
enum ResultStatus: string implements HasColor, HasLabel
910
{
10-
case Completed = 'completed'; // a speedtest that ran successfully.
11-
case Failed = 'failed'; // a speedtest that failed to run successfully.
12-
case Started = 'started'; // a speedtest that has been started by a worker but has not finished running.
13-
case Skipped = 'skipped'; // a speedtest that was skipped.
11+
case Completed = 'completed';
12+
case Failed = 'failed';
13+
case Started = 'started';
14+
case Skipped = 'skipped';
1415

1516
public function getColor(): ?string
1617
{
1718
return match ($this) {
1819
self::Completed => 'success',
1920
self::Failed => 'danger',
20-
self::Started => 'warning',
21-
self::Skipped => 'info', // Adding Skipped state with a color
21+
self::Started => 'info',
22+
self::Skipped => 'gray',
2223
};
2324
}
2425

2526
public function getLabel(): ?string
2627
{
27-
return match ($this) {
28-
self::Completed => 'Completed',
29-
self::Failed => 'Failed',
30-
self::Started => 'Started',
31-
self::Skipped => 'Skipped',
32-
};
28+
return Str::title($this->name);
3329
}
3430
}

app/Enums/UserRole.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Filament\Support\Contracts\HasColor;
66
use Filament\Support\Contracts\HasLabel;
7+
use Illuminate\Support\Str;
78

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

2122
public function getLabel(): ?string
2223
{
23-
return match ($this) {
24-
self::Admin => 'Admin',
25-
self::User => 'User',
26-
};
24+
return Str::title($this->name);
2725
}
2826
}

0 commit comments

Comments
 (0)