Skip to content

Commit f4fb782

Browse files
committed
Add info banners when dashboard content is empty
Fixes hydephp/realtime-compiler#21
1 parent d81a619 commit f4fb782

File tree

2 files changed

+105
-86
lines changed

2 files changed

+105
-86
lines changed

RELEASE_NOTES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This serves two purposes:
1010
2. At release time, you can move the Unreleased section changes into a new release version section.
1111

1212
### Added
13-
- for new features.
13+
- Added info banners when dashboard content sections are empty in https://github.com/hydephp/develop/pull/1494
1414

1515
### Changed
1616
- Shortened the path printed to console when using the dashboard to create a page in https://github.com/hydephp/develop/pull/1492

packages/realtime-compiler/resources/dashboard.blade.php

+104-85
Original file line numberDiff line numberDiff line change
@@ -217,46 +217,58 @@
217217
</div>
218218
</div>
219219
<div class="card-body">
220-
<table class="table table-bordered">
221-
<tr>
222-
@foreach(['Page Type', 'Route Key', 'Source File', 'Output File', 'Identifier'] as $header)
223-
<th>{{ $header }}</th>
224-
@endforeach
225-
<th class="text-end">Actions</th>
226-
</tr>
227-
@foreach($dashboard->getPageList() as $route)
228-
<tr id="pageRow-{{ $route->getRouteKey() }}" @class(['page-table-row', $dashboard->getFlash('justCreatedPage') === $route->getRouteKey() ? 'justCreatedPage active' : ''])>
229-
<td>
230-
<code title="\{{ $route->getPageClass() }}">{{ class_basename($route->getPageClass()) }}</code>
231-
</td>
232-
<td>
233-
{{ $route->getRouteKey() }}
234-
</td>
235-
<td>
236-
{{ $route->getSourcePath() }}
237-
</td>
238-
<td>
239-
{{ $route->getOutputPath() }}
240-
</td>
241-
<td>
242-
{{ $route->getPageIdentifier() }}
243-
</td>
244-
<td class="text-end">
245-
<div class="d-flex justify-content-end">
246-
@if($dashboard->isInteractive())
247-
<form class="buttonActionForm" action="" method="POST">
248-
<input type="hidden" name="_token" value="{{ $csrfToken }}">
249-
<input type="hidden" name="action" value="openPageInEditor">
250-
<input type="hidden" name="routeKey" value="{{ $route->getRouteKey() }}">
251-
<button type="submit" class="btn btn-outline-primary btn-sm me-2" title="Open in system default application">Edit</button>
252-
</form>
253-
@endif
254-
<a href="{{ $route->getLink() }}" class="btn btn-outline-primary btn-sm" title="Open this page preview in browser">View</a>
255-
</div>
256-
</td>
220+
@if(empty($dashboard->getPageList()))
221+
<div class="alert alert-info">
222+
<strong>Info:</strong>
223+
There are no pages yet.
224+
@if($dashboard->isInteractive())
225+
Why not create one using the button above?
226+
@else
227+
Why not create some?
228+
@endif
229+
</div>
230+
@else
231+
<table class="table table-bordered">
232+
<tr>
233+
@foreach(['Page Type', 'Route Key', 'Source File', 'Output File', 'Identifier'] as $header)
234+
<th>{{ $header }}</th>
235+
@endforeach
236+
<th class="text-end">Actions</th>
257237
</tr>
258-
@endforeach
259-
</table>
238+
@foreach($dashboard->getPageList() as $route)
239+
<tr id="pageRow-{{ $route->getRouteKey() }}" @class(['page-table-row', $dashboard->getFlash('justCreatedPage') === $route->getRouteKey() ? 'justCreatedPage active' : ''])>
240+
<td>
241+
<code title="\{{ $route->getPageClass() }}">{{ class_basename($route->getPageClass()) }}</code>
242+
</td>
243+
<td>
244+
{{ $route->getRouteKey() }}
245+
</td>
246+
<td>
247+
{{ $route->getSourcePath() }}
248+
</td>
249+
<td>
250+
{{ $route->getOutputPath() }}
251+
</td>
252+
<td>
253+
{{ $route->getPageIdentifier() }}
254+
</td>
255+
<td class="text-end">
256+
<div class="d-flex justify-content-end">
257+
@if($dashboard->isInteractive())
258+
<form class="buttonActionForm" action="" method="POST">
259+
<input type="hidden" name="_token" value="{{ $csrfToken }}">
260+
<input type="hidden" name="action" value="openPageInEditor">
261+
<input type="hidden" name="routeKey" value="{{ $route->getRouteKey() }}">
262+
<button type="submit" class="btn btn-outline-primary btn-sm me-2" title="Open in system default application">Edit</button>
263+
</form>
264+
@endif
265+
<a href="{{ $route->getLink() }}" class="btn btn-outline-primary btn-sm" title="Open this page preview in browser">View</a>
266+
</div>
267+
</td>
268+
</tr>
269+
@endforeach
270+
</table>
271+
@endif
260272
</div>
261273
</div>
262274
</div>
@@ -270,57 +282,64 @@
270282
</div>
271283
</div>
272284
<div class="card-body">
273-
<div class="container d-flex flex-wrap" style="margin: 0 -0.5rem">
274-
@foreach(\Hyde\Support\Filesystem\MediaFile::all() as $mediaFile)
275-
<div class="col-lg-4 p-2 d-flex flex-grow-1">
276-
<figure class="card w-100 p-2 mb-0">
277-
@if(in_array($mediaFile->getExtension(), ['svg', 'png', 'jpg', 'jpeg', 'gif']))
278-
<img loading="lazy" src="media/{{ $mediaFile->getIdentifier() }}" alt="{{ $mediaFile->getName() }}" class="object-fit-cover w-100 rounded-2" style="height: 240px;">
279-
@else
280-
<code style="height: 240px; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, white 60%, transparent);" role="presentation">
281-
@if($dashboard::isMediaFileProbablyMinified($mediaFile->getContents()))
282-
<pre style="white-space: normal;">{{ $dashboard::highlightMediaLibraryCode($mediaFile->getContents()) }}</pre>
283-
@else
284-
<pre class="overflow-hidden">{{ $dashboard::highlightMediaLibraryCode($mediaFile->getContents()) }}</pre>
285-
@endif
286-
</code>
287-
@endif
288-
<figcaption class="container mt-3">
289-
<div class="row flex-nowrap">
290-
<div class="col-auto px-0">
291-
<div class="file-icon" data-type="{{ $mediaFile->getExtension() }}"></div>
292-
</div>
293-
<div class="col">
294-
<div class="row flex-nowrap justify-content-start">
295-
<p class="col-auto text-truncate mb-0 pe-2">
296-
<strong title="{{ $mediaFile->getPath() }}">{{ $mediaFile->getName() }}</strong>
297-
</p>
298-
<div class="col px-0 text-nowrap">
299-
<small class="text-muted">({{ $dashboard::bytesToHuman($mediaFile->getContentLength()) }})</small>
300-
</div>
285+
@if(empty(\Hyde\Support\Filesystem\MediaFile::all()))
286+
<div class="alert alert-info">
287+
<strong>Info:</strong>
288+
There are no media files yet. Why not add some?
289+
</div>
290+
@else
291+
<div class="container d-flex flex-wrap" style="margin: 0 -0.5rem">
292+
@foreach(\Hyde\Support\Filesystem\MediaFile::all() as $mediaFile)
293+
<div class="col-lg-4 p-2 d-flex flex-grow-1">
294+
<figure class="card w-100 p-2 mb-0">
295+
@if(in_array($mediaFile->getExtension(), ['svg', 'png', 'jpg', 'jpeg', 'gif']))
296+
<img loading="lazy" src="media/{{ $mediaFile->getIdentifier() }}" alt="{{ $mediaFile->getName() }}" class="object-fit-cover w-100 rounded-2" style="height: 240px;">
297+
@else
298+
<code style="height: 240px; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, white 60%, transparent);" role="presentation">
299+
@if($dashboard::isMediaFileProbablyMinified($mediaFile->getContents()))
300+
<pre style="white-space: normal;">{{ $dashboard::highlightMediaLibraryCode($mediaFile->getContents()) }}</pre>
301+
@else
302+
<pre class="overflow-hidden">{{ $dashboard::highlightMediaLibraryCode($mediaFile->getContents()) }}</pre>
303+
@endif
304+
</code>
305+
@endif
306+
<figcaption class="container mt-3">
307+
<div class="row flex-nowrap">
308+
<div class="col-auto px-0">
309+
<div class="file-icon" data-type="{{ $mediaFile->getExtension() }}"></div>
301310
</div>
302-
<div class="row small align-items-center">
303-
<div class="w-auto pe-0">
304-
<a href="media/{{ $mediaFile->getIdentifier() }}" title="Open this image in the browser" target="_blank">Fullscreen</a>
311+
<div class="col">
312+
<div class="row flex-nowrap justify-content-start">
313+
<p class="col-auto text-truncate mb-0 pe-2">
314+
<strong title="{{ $mediaFile->getPath() }}">{{ $mediaFile->getName() }}</strong>
315+
</p>
316+
<div class="col px-0 text-nowrap">
317+
<small class="text-muted">({{ $dashboard::bytesToHuman($mediaFile->getContentLength()) }})</small>
318+
</div>
305319
</div>
306-
@if($dashboard->isInteractive())
307-
<div class="w-auto ps-0">
308-
<form class="buttonActionForm" action="" method="POST">
309-
<input type="hidden" name="_token" value="{{ $csrfToken }}">
310-
<input type="hidden" name="action" value="openMediaFileInEditor">
311-
<input type="hidden" name="identifier" value="{{ $mediaFile->getIdentifier() }}">
312-
<button type="submit" class="btn btn-link btn-sm py-0" title="Open this image in the system editor">Edit</button>
313-
</form>
320+
<div class="row small align-items-center">
321+
<div class="w-auto pe-0">
322+
<a href="media/{{ $mediaFile->getIdentifier() }}" title="Open this image in the browser" target="_blank">Fullscreen</a>
314323
</div>
315-
@endif
324+
@if($dashboard->isInteractive())
325+
<div class="w-auto ps-0">
326+
<form class="buttonActionForm" action="" method="POST">
327+
<input type="hidden" name="_token" value="{{ $csrfToken }}">
328+
<input type="hidden" name="action" value="openMediaFileInEditor">
329+
<input type="hidden" name="identifier" value="{{ $mediaFile->getIdentifier() }}">
330+
<button type="submit" class="btn btn-link btn-sm py-0" title="Open this image in the system editor">Edit</button>
331+
</form>
332+
</div>
333+
@endif
334+
</div>
316335
</div>
317336
</div>
318-
</div>
319-
</figcaption>
320-
</figure>
321-
</div>
322-
@endforeach
323-
</div>
337+
</figcaption>
338+
</figure>
339+
</div>
340+
@endforeach
341+
</div>
342+
@endif
324343
</div>
325344
</div>
326345
</div>

0 commit comments

Comments
 (0)