Skip to content

Commit

Permalink
Add a tips banner to the realtime compiler dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Oct 20, 2023
1 parent 0dd4cf1 commit 619e14c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
'host' => env('SERVER_HOST', 'localhost'),
'dashboard' => env('SERVER_DASHBOARD', true),
'save_preview' => true,
'tips' => true,
],

/*
Expand Down
1 change: 1 addition & 0 deletions packages/framework/config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
'host' => env('SERVER_HOST', 'localhost'),
'dashboard' => env('SERVER_DASHBOARD', true),
'save_preview' => true,
'tips' => true,
],

/*
Expand Down
10 changes: 10 additions & 0 deletions packages/realtime-compiler/resources/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@
</div>
</div>
</section>
@if($dashboard->showTips())
<section>
<div class="col-xl-10 mx-auto pt-3 px-5">
<div class="alert alert-success">
<strong>Tip:</strong>
{{ $dashboard->getTip() }}
</div>
</div>
</section>
@endif
</main>
<footer class="bg-light text-center py-3 mt-3">
<div class="container d-flex align-items-center justify-content-between">
Expand Down
19 changes: 19 additions & 0 deletions packages/realtime-compiler/src/Http/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

use Hyde\Hyde;
use OutOfBoundsException;
use Illuminate\Support\Str;
use Illuminate\Support\Arr;
use Hyde\Pages\Concerns\HydePage;
use Illuminate\Support\HtmlString;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\Framework\Actions\AnonymousViewCompiler;
use Desilva\Microserve\Request;
Expand All @@ -24,6 +27,12 @@ class DashboardController
{
public string $title;

protected static array $tips = [
'This dashboard won\'t be saved to your static site.',
'Got stuck? Ask for help on [GitHub](https://github.com/hydephp/hyde)!',
'You can disable tips using by setting `server.tips` to `false` in `config/hyde.php`.',
];

public function __construct()
{
$this->title = config('hyde.name').' - Dashboard';
Expand Down Expand Up @@ -59,6 +68,16 @@ public function getPageList(): array
return Hyde::routes()->all();
}

public function showTips(): bool
{
return config('hyde.server.tips', true);
}

public function getTip(): HtmlString
{
return new HtmlString(Str::inlineMarkdown(Arr::random(static::$tips)));
}

public static function enabled(): bool
{
return config('hyde.server.dashboard', true);
Expand Down

0 comments on commit 619e14c

Please sign in to comment.