-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathComponentStatusEnum.php
More file actions
105 lines (95 loc) 路 3.36 KB
/
Copy pathComponentStatusEnum.php
File metadata and controls
105 lines (95 loc) 路 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
namespace Cachet\Enums;
use Filament\Support\Colors\Color;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasIcon;
use Filament\Support\Contracts\HasLabel;
enum ComponentStatusEnum: int implements HasColor, HasIcon, HasLabel
{
case operational = 1;
case performance_issues = 2;
case partial_outage = 3;
case major_outage = 4;
case unknown = 5;
case under_maintenance = 6;
public static function outage(): array
{
return [
self::performance_issues,
self::partial_outage,
self::major_outage,
];
}
public function getLabel(): string
{
return match ($this) {
self::operational => __('cachet::component.status.operational'),
self::performance_issues => __('cachet::component.status.performance_issues'),
self::partial_outage => __('cachet::component.status.partial_outage'),
self::major_outage => __('cachet::component.status.major_outage'),
self::under_maintenance => __('cachet::component.status.under_maintenance'),
default => __('cachet::component.status.unknown'),
};
}
public function getIcon(): string
{
return match ($this) {
self::operational => 'cachet-circle-check',
self::performance_issues => 'cachet-component-performance-issues',
self::partial_outage => 'cachet-component-partial-outage',
self::major_outage => 'cachet-component-major-outage',
self::under_maintenance => 'cachet-component-under-maintenance',
default => 'cachet-unknown',
};
}
/**
* Rank the status by severity, most severe highest.
*/
public function severity(): int
{
return match ($this) {
self::major_outage => 5,
self::partial_outage => 4,
self::performance_issues => 3,
self::under_maintenance => 2,
self::unknown => 1,
self::operational => 0,
};
}
/**
* Get the text color classes used on the status page.
*/
public function getTextColorClasses(): string
{
return match ($this) {
self::operational => 'text-green-600 dark:text-green-400',
self::performance_issues => 'text-purple-600 dark:text-purple-400',
self::partial_outage => 'text-amber-600 dark:text-amber-400',
self::major_outage => 'text-red-600 dark:text-red-400',
self::under_maintenance => 'text-orange-600 dark:text-orange-400',
default => 'text-blue-600 dark:text-blue-400',
};
}
public function getBadgeColor(): string
{
return match ($this) {
self::operational => 'brightgreen',
self::performance_issues => 'yellow',
self::partial_outage => 'orange',
self::major_outage => 'red',
self::under_maintenance => 'orange',
self::unknown => 'lightgray',
};
}
public function getColor(): array
{
return match ($this) {
self::operational => Color::Green,
self::performance_issues => Color::Purple,
self::partial_outage => Color::Amber,
self::major_outage => Color::Red,
self::under_maintenance => Color::Orange,
default => Color::Blue,
};
}
}