diff --git a/composer.json b/composer.json index 347c842b..49659774 100644 --- a/composer.json +++ b/composer.json @@ -69,7 +69,10 @@ "Workbench\\App\\": "workbench/app/", "Workbench\\Database\\Factories\\": "workbench/database/factories/", "Workbench\\Database\\Seeders\\": "workbench/database/seeders/" - } + }, + "files": [ + "workbench/bootstrap/suppress-deprecations.php" + ] }, "config": { "allow-plugins": { diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index e6aca69c..bd5aefa4 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -90,7 +90,7 @@ public function run(): void ]); /** @phpstan-ignore-next-line argument.type Larastan bug */ - $componentGroup->components()->createMany([ + [$website, $documentation, $blog] = $componentGroup->components()->createMany([ [ 'name' => 'Cachet Website', 'description' => 'The Cachet website.', @@ -182,6 +182,8 @@ public function run(): void 'occurred_at' => $timestamp, ]); + $incident->components()->attach($documentation); + $update = new Update([ 'status' => IncidentStatusEnum::identified, 'message' => 'We\'ve identified the issue and are working on a fix.', diff --git a/resources/lang/de/incident.php b/resources/lang/de/incident.php index d445918c..29a308b5 100644 --- a/resources/lang/de/incident.php +++ b/resources/lang/de/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Vorfall bearbeiten', 'new_button' => 'Vorfall hinzufügen', 'no_incidents_reported' => 'Keine Vorfälle gemeldet.', + 'affected_components_header' => 'Betroffene Komponenten', 'timeline' => [ 'past_incidents_header' => 'Vergangene Vorfälle', 'recent_incidents_header' => 'Jüngste Vorfälle', diff --git a/resources/lang/de_AT/incident.php b/resources/lang/de_AT/incident.php index d445918c..29a308b5 100644 --- a/resources/lang/de_AT/incident.php +++ b/resources/lang/de_AT/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Vorfall bearbeiten', 'new_button' => 'Vorfall hinzufügen', 'no_incidents_reported' => 'Keine Vorfälle gemeldet.', + 'affected_components_header' => 'Betroffene Komponenten', 'timeline' => [ 'past_incidents_header' => 'Vergangene Vorfälle', 'recent_incidents_header' => 'Jüngste Vorfälle', diff --git a/resources/lang/de_CH/incident.php b/resources/lang/de_CH/incident.php index d445918c..29a308b5 100644 --- a/resources/lang/de_CH/incident.php +++ b/resources/lang/de_CH/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Vorfall bearbeiten', 'new_button' => 'Vorfall hinzufügen', 'no_incidents_reported' => 'Keine Vorfälle gemeldet.', + 'affected_components_header' => 'Betroffene Komponenten', 'timeline' => [ 'past_incidents_header' => 'Vergangene Vorfälle', 'recent_incidents_header' => 'Jüngste Vorfälle', diff --git a/resources/lang/en/incident.php b/resources/lang/en/incident.php index 91a51c10..e62ad5e2 100644 --- a/resources/lang/en/incident.php +++ b/resources/lang/en/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Edit Incident', 'new_button' => 'New Incident', 'no_incidents_reported' => 'No incidents reported.', + 'affected_components_header' => 'Affected Components', 'timeline' => [ 'past_incidents_header' => 'Past Incidents', 'recent_incidents_header' => 'Recent Incidents', diff --git a/resources/lang/es_ES/incident.php b/resources/lang/es_ES/incident.php index 7f2a2a46..38eb1a7b 100644 --- a/resources/lang/es_ES/incident.php +++ b/resources/lang/es_ES/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Editar Incidente', 'new_button' => 'Nuevo Incidente', 'no_incidents_reported' => 'No se han reportado incidentes.', + 'affected_components_header' => 'Componentes Afectados', 'timeline' => [ 'past_incidents_header' => 'Incidentes Pasados', 'recent_incidents_header' => 'Incidentes Recientes', diff --git a/resources/lang/fr/incident.php b/resources/lang/fr/incident.php index 497f953e..411cf6d2 100644 --- a/resources/lang/fr/incident.php +++ b/resources/lang/fr/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Modifier l’incident', 'new_button' => 'Nouvel incident', 'no_incidents_reported' => 'Aucun incident signalé.', + 'affected_components_header' => 'Composants affectés', 'timeline' => [ 'past_incidents_header' => 'Incidents passés', 'recent_incidents_header' => 'Incidents récents', diff --git a/resources/lang/ko/incident.php b/resources/lang/ko/incident.php index bb811d8f..e6e2c367 100644 --- a/resources/lang/ko/incident.php +++ b/resources/lang/ko/incident.php @@ -13,6 +13,7 @@ 'edit_button' => '사고 수정', 'new_button' => '새 사고', 'no_incidents_reported' => '보고된 사고가 없습니다.', + 'affected_components_header' => '영향받는 구성 요소', 'timeline' => [ 'past_incidents_header' => '과거 사고', 'recent_incidents_header' => '최근 사고', diff --git a/resources/lang/nl/incident.php b/resources/lang/nl/incident.php index 35db6c5d..aac7344e 100644 --- a/resources/lang/nl/incident.php +++ b/resources/lang/nl/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Incident bewerken', 'new_button' => 'Incident toevoegen', 'no_incidents_reported' => 'Er zijn geen incidenten gemeld.', + 'affected_components_header' => 'Getroffen componenten', 'timeline' => [ 'past_incidents_header' => 'Eerdere incidenten', 'recent_incidents_header' => 'Recente incidenten', diff --git a/resources/lang/ph/incident.php b/resources/lang/ph/incident.php index c0ae536c..d4f3bb51 100644 --- a/resources/lang/ph/incident.php +++ b/resources/lang/ph/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'I-edit ang Insidente', 'new_button' => 'Bagong Insidente', 'no_incidents_reported' => 'Walang naiulat na insidente.', + 'affected_components_header' => 'Mga Apektadong Komponente', 'timeline' => [ 'past_incidents_header' => 'Mga Nakaraang Insidente', 'recent_incidents_header' => 'Mga Kamakailang Insidente', diff --git a/resources/lang/pt_BR/incident.php b/resources/lang/pt_BR/incident.php index 9dbb0a00..59df2ef8 100644 --- a/resources/lang/pt_BR/incident.php +++ b/resources/lang/pt_BR/incident.php @@ -13,6 +13,7 @@ 'edit_button' => 'Editar Incidente', 'new_button' => 'Novo Incidente', 'no_incidents_reported' => 'Nenhum incidente reportado.', + 'affected_components_header' => 'Componentes Afetados', 'timeline' => [ 'past_incidents_header' => 'Incidentes Anteriores', 'recent_incidents_header' => 'Incidentes Recentes', diff --git a/resources/lang/zh_CN/incident.php b/resources/lang/zh_CN/incident.php index 5972c7e9..9d631a96 100644 --- a/resources/lang/zh_CN/incident.php +++ b/resources/lang/zh_CN/incident.php @@ -13,6 +13,7 @@ 'edit_button' => '编辑事件', 'new_button' => '新建事件', 'no_incidents_reported' => '没有事件被报告。', + 'affected_components_header' => '受影响的组件', 'timeline' => [ 'past_incidents_header' => '过去的事件', 'recent_incidents_header' => '最近的事件', diff --git a/resources/lang/zh_TW/incident.php b/resources/lang/zh_TW/incident.php index f586db4c..9035d019 100644 --- a/resources/lang/zh_TW/incident.php +++ b/resources/lang/zh_TW/incident.php @@ -13,6 +13,7 @@ 'edit_button' => '編輯事件', 'new_button' => '新建事件', 'no_incidents_reported' => '沒有事件被報告。', + 'affected_components_header' => '受影響的元件', 'timeline' => [ 'past_incidents_header' => '過去的事件', 'recent_incidents_header' => '最近的事件', diff --git a/resources/views/components/component.blade.php b/resources/views/components/component.blade.php index 14e6685f..e4a35b28 100644 --- a/resources/views/components/component.blade.php +++ b/resources/views/components/component.blade.php @@ -23,30 +23,32 @@ @endif -
-
- @if ($component->incidents_count > 0) - - - - @else - - @endif -
+ @unless ($hideStatus ?? false) +
+
+ @if ($component->incidents_count > 0) + + + + @else + + @endif +
-
- {{ __('cachet::component.last_updated', ['timestamp' => $component->updated_at]) }} +
+ {{ __('cachet::component.last_updated', ['timestamp' => $component->updated_at]) }} +
-
+ @endunless
{{ \Cachet\Facades\CachetView::renderHook(\Cachet\View\RenderHook::STATUS_PAGE_BODY_AFTER) }} diff --git a/resources/views/status-page/incident.blade.php b/resources/views/status-page/incident.blade.php index 9af8608b..24996730 100644 --- a/resources/views/status-page/incident.blade.php +++ b/resources/views/status-page/incident.blade.php @@ -4,6 +4,22 @@
+ @if ($incident->components->isNotEmpty()) +
+ + +

+ {{ __('cachet::incident.affected_components_header') }} +

+ +
    + @foreach ($incident->components as $component) + + @endforeach +
+
+ @endif +
diff --git a/src/View/Components/Component.php b/src/View/Components/Component.php index a627474d..b1329de4 100644 --- a/src/View/Components/Component.php +++ b/src/View/Components/Component.php @@ -11,8 +11,10 @@ class Component extends ViewComponent /** * Create a new component instance. */ - public function __construct(public \Cachet\Models\Component $component) - { + public function __construct( + public \Cachet\Models\Component $component, + public bool $hideStatus = false, + ) { // } diff --git a/tests/Feature/StatusPage/IncidentPageTest.php b/tests/Feature/StatusPage/IncidentPageTest.php new file mode 100644 index 00000000..ed726ee4 --- /dev/null +++ b/tests/Feature/StatusPage/IncidentPageTest.php @@ -0,0 +1,26 @@ +create(['name' => 'API']); + $incident = Incident::factory()->create(); + $incident->components()->attach($component, [ + 'component_status' => ComponentStatusEnum::performance_issues->value, + ]); + + $this->get(route('cachet.status-page.incident', $incident)) + ->assertOk() + ->assertSee(__('cachet::incident.affected_components_header')) + ->assertSee('API'); +}); + +it('does not show the affected components box when none are attached', function () { + $incident = Incident::factory()->create(); + + $this->get(route('cachet.status-page.incident', $incident)) + ->assertOk() + ->assertDontSee(__('cachet::incident.affected_components_header')); +}); diff --git a/workbench/bootstrap/suppress-deprecations.php b/workbench/bootstrap/suppress-deprecations.php new file mode 100644 index 00000000..a9b32998 --- /dev/null +++ b/workbench/bootstrap/suppress-deprecations.php @@ -0,0 +1,24 @@ +