Skip to content

Commit 02ec290

Browse files
committed
wip
1 parent 05a653b commit 02ec290

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

resources/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
":incidents Incidents": ":incidents Incident|:incidents Incidents",
2+
":count Incident": ":count Incident|:count Incidents",
33
"Admin": "Admin",
44
"Always Hidden": "Always Hidden",
55
"Always collapsed": "Always collapsed",

resources/views/components/component-group.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
<x-heroicon-o-chevron-up ::class="!$disclosure.isOpen && 'rotate-180'" class="size-4 transition" />
1515
</button>
1616

17-
@if(($incidentCount = $componentGroup->components()->sum('incidents_count')) > 0)
18-
<a href="#" class="rounded border border-zinc-800 px-2 py-1 text-xs font-semibold text-zinc-800 dark:border-zinc-600 dark:text-zinc-400">
19-
{{ trans_choice(':incidents Incidents', $incidentCount, ['incidents' => $incidentCount]) }}
20-
</a>
17+
@if(($incidentCount = $componentGroup->components->sum('incidents_count')) > 0)
18+
<span class="rounded border border-zinc-800 px-2 py-1 text-xs font-semibold text-zinc-800 dark:border-zinc-600 dark:text-zinc-400">
19+
{{ trans_choice(':count Incident', $incidentCount) }}
20+
</span>
2121
@endif
2222
</div>
2323

resources/views/components/component.blade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
@endif
2323
</div>
2424

25+
@if ($component->incidents_count > 0)
26+
<a href="{{ route('cachet.status-page.incident', [$component->incidents->first()]) }}"><x-cachet::component-badge :type="$component->status" /></a>
27+
@else
2528
<x-cachet::component-badge :type="$component->status" />
29+
@endif
2630
</div>
2731
</li>

src/Http/Controllers/StatusPage/StatusPageController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Cachet\Models\ComponentGroup;
99
use Cachet\Models\Incident;
1010
use Cachet\Models\Schedule;
11+
use Illuminate\Database\Eloquent\Builder;
12+
use Illuminate\Database\Eloquent\Relations\HasMany;
1113
use Illuminate\View\View;
1214

1315
class StatusPageController
@@ -19,9 +21,9 @@ public function index(): View
1921
{
2022
return view('cachet::status-page.index', [
2123
'componentGroups' => ComponentGroup::query()
22-
->with(['components' => fn ($query) => $query->enabled()->orderBy('order')->withCount('incidents')])
24+
->with(['components' => fn (HasMany $query) => $query->enabled()->orderBy('order')->withCount('incidents')])
2325
->visible(auth()->check())
24-
->when(auth()->check(), fn ($query) => $query->users(), fn ($query) => $query->guests())
26+
->when(auth()->check(), fn (Builder $query) => $query->users(), fn ($query) => $query->guests())
2527
->get(),
2628
'ungroupedComponents' => (new ComponentGroup([
2729
'name' => __('Other Components'),

src/Models/Component.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public function group(): BelongsTo
5353
/**
5454
* Get the incidents for the component.
5555
*/
56-
public function incidents(): HasMany
56+
public function incidents(): BelongsToMany
5757
{
58-
return $this->hasMany(Incident::class);
58+
return $this->belongsToMany(Incident::class, 'incident_components')->withPivot('status');
5959
}
6060

6161
/**

0 commit comments

Comments
 (0)