Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed scheduled maintenance should appear in timeline #93 #117

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions resources/views/components/incident.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
@props([
'date',
'incidents',
'schedules',
])

@php($empty = true)

<div class="relative flex flex-col gap-5" x-data="{ forDate: new Date(@js($date)) }">
<h3 class="text-xl font-semibold"><time datetime="{{ $date }}" x-text="forDate.toLocaleDateString()"></time></h3>
@foreach($incidents as $incident)
@php($empty = false)
<div x-data="{ timestamp: new Date(@js($incident->timestamp)) }" class="bg-white border divide-y rounded-lg ml-9 dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-800">
<div @class([
'flex flex-col bg-zinc-50 p-4 dark:bg-zinc-900 gap-2',
Expand Down Expand Up @@ -73,60 +67,3 @@
</div>
</div>
@endforeach
@foreach($schedules[$date] as $schedule)
@php($empty = false)
<div x-data="{ timestamp: new Date(@js($schedule->completed_at)) }" class="bg-white border divide-y rounded-lg ml-9 dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-800">
<div @class([
'flex flex-col bg-zinc-50 p-4 dark:bg-zinc-900 gap-2',
'rounded-lg',
])>
@if ($schedule->components()->exists())
<div class="text-xs font-medium">
{{ $schedule->components()->pluck('name')->join(', ', ' and ') }}
</div>
@endif
<div class="flex flex-col sm:flex-row justify-between gap-2 flex-col-reverse items-start sm:items-center">
<div class="flex flex-col flex-1">
<div class="flex gap-2 items-center">
<h3 class="max-w-full text-base font-semibold break-words sm:text-xl">
{{ $schedule->name}}
</h3>
@auth
<a href="{{ $schedule->filamentDashboardEditUrl() }}" class="underline text-right text-sm text-zinc-500 hover:text-zinc-400 dark:text-zinc-400 dark:hover:text-zinc-300" title="{{ __('Edit Incident') }}">
<x-heroicon-m-pencil-square class="size-4" />
</a>
@endauth
</div>
<span class="text-xs text-zinc-500 dark:text-zinc-400">
{{ $schedule->completed_at->diffForHumans() }} — <time datetime="{{ $schedule->completed_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
</span>
</div>
<div class="flex justify-start sm:justify-end">
<x-cachet::badge :status="$schedule->status" />
</div>
</div>
</div>
<div class="relative">
<div class="absolute inset-y-0 -left-9">
<div class="ml-3.5 h-full border-l-2 border-dashed dark:border-zinc-700"></div>
<div class="absolute inset-x-0 top-0 w-full h-24 bg-gradient-to-t from-transparent to-zinc-50 dark:from-transparent dark:to-zinc-900"></div>
<div class="absolute inset-x-0 bottom-0 w-full h-24 bg-gradient-to-b from-transparent to-zinc-50 dark:from-transparent dark:to-zinc-900"></div>
</div>
<div class="flex flex-col px-4 divide-y dark:divide-zinc-700">
<div class="relative py-4" x-data="{ timestamp: new Date(@js($schedule->completed_at)) }">
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-primary-500 prose-a:underline prose-p:leading-normal">{!! $schedule->formattedMessage() !!}</div>
</div>
</div>
</div>
</div>
@endforeach
@if($empty)
<div class="bg-white border divide-y rounded-lg ml-9 dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-800">
<div class="flex flex-col p-4 divide-y dark:divide-zinc-700">
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-primary-500 prose-a:underline prose-p:leading-normal">
{{ __('No incidents reported.') }}
</div>
</div>
</div>
@endif
</div>
43 changes: 43 additions & 0 deletions resources/views/components/schedule-timeline.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@use('Cachet\Enums\ScheduleStatusEnum')
@props([
'date',
'schedules',
])

@foreach($schedules as $schedule)
<div x-data="{ timestamp: new Date(@js($schedule->completed_at)) }" class="bg-white border divide-y rounded-lg ml-9 dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-800">
<div @class([
'flex flex-col bg-zinc-50 p-4 dark:bg-zinc-900 gap-2',
'rounded-lg',
])>
<div class="flex flex-col sm:flex-row justify-between gap-2 flex-col-reverse items-start sm:items-center">
<div class="flex flex-col flex-1">
<div class="flex gap-2 items-center">
<h3 class="max-w-full text-base font-semibold break-words sm:text-xl">
{{ $schedule->name}}
</h3>
@auth
<a href="{{ $schedule->filamentDashboardEditUrl() }}" class="underline text-right text-sm text-zinc-500 hover:text-zinc-400 dark:text-zinc-400 dark:hover:text-zinc-300" title="{{ __('Edit Incident') }}">
<x-heroicon-m-pencil-square class="size-4" />
</a>
@endauth
</div>
<span class="text-xs text-zinc-500 dark:text-zinc-400">
{{ $schedule->completed_at->diffForHumans() }} — <time datetime="{{ $schedule->completed_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
</span>
</div>
<div class="flex justify-start sm:justify-end">
<x-cachet::badge :status="$schedule->status" />
</div>
</div>
</div>

<div class="relative">
<div class="flex flex-col px-4 divide-y dark:divide-zinc-700">
<div class="relative py-4" x-data="{ timestamp: new Date(@js($schedule->completed_at)) }">
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-primary-500 prose-a:underline prose-p:leading-normal">{!! $schedule->formattedMessage() !!}</div>
</div>
</div>
</div>
</div>
@endforeach
5 changes: 5 additions & 0 deletions resources/views/components/schedule.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
{{ $schedule->scheduled_at->diffForHumans() }} — <time datetime="{{ $schedule->scheduled_at->toW3cString() }}" x-text="timestamp.toLocaleString()"></time>
</span>
</div>
@auth
<a href="{{ $schedule->filamentDashboardEditUrl() }}" class="underline text-right text-sm text-zinc-500 hover:text-zinc-400 dark:text-zinc-400 dark:hover:text-zinc-300" title="{{ __('Edit Incident') }}">
<x-heroicon-m-pencil-square class="size-4" />
</a>
@endauth
<div class="flex justify-start sm:justify-end">
<x-cachet::badge :status="$schedule->status" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
</div>

<div class="flex flex-col gap-14 w-full">
@forelse ($incidents as $date => $incident)
<x-cachet::incident :date="$date" :incidents="$incident" :schedules="$schedules" />
@empty
<div class="text-zinc-500 dark:text-zinc-400 text-center">
{{ __('No incidents reported between :from and :to.', ['from' => $from, 'to' => $to]) }}
@foreach ($incidents as $date => $incident)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this, I think that if incidents are empty, but schedules aren't, then nothing will show.

<div class="relative flex flex-col gap-5" x-data="{ forDate: new Date(@js($date)) }">
<h3 class="text-xl font-semibold"><time datetime="{{ $date }}" x-text="forDate.toLocaleDateString()"></time></h3>
<x-cachet::incident :date="$date" :incidents="$incident" />
<x-cachet::schedule-timeline :date="$date" :schedules="$schedules[$date]" />
@if(count($incident) === 0 && count($schedules[$date]) === 0)
<div class="bg-white border divide-y rounded-lg ml-9 dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-800">
<div class="flex flex-col p-4 divide-y dark:divide-zinc-700">
<div class="prose-sm md:prose prose-zinc dark:prose-invert prose-a:text-primary-500 prose-a:underline prose-p:leading-normal">
{{ __('No incidents reported.') }}
</div>
</div>
</div>
@endif
@endforeach
</div>
@endforelse
</div>

<div class="flex justify-between">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/status-page/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<x-cachet::schedules :schedules="$schedules" />
@endif

<x-cachet::incident-timeline />
<x-cachet::timeline />
</div>

<x-cachet::footer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Illuminate\Support\Collection;
use Illuminate\View\Component;

class IncidentTimeline extends Component
class Timeline extends Component
{
public function __construct(private AppSettings $appSettings)
{
Expand All @@ -24,7 +24,7 @@ public function render(): View
$startDate = Carbon::createFromFormat('Y-m-d', request('from', now()->toDateString()));
$endDate = $startDate->clone()->subDays($incidentDays);

return view('cachet::components.incident-timeline', [
return view('cachet::components.timeline', [
'incidents' => $this->incidents(
$startDate,
$endDate,
Expand Down