Skip to content

Commit

Permalink
Merge pull request #1395 from hydephp/realtime-compiler-dashboard-imp…
Browse files Browse the repository at this point in the history
…rovements

Update realtime compiler dashboard configuration schema
  • Loading branch information
caendesilva authored Oct 27, 2023
2 parents 28b18a9 + 45fffad commit b563dc6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This serves two purposes:

### Changed
- Realtime Compiler: The `DashboardController` class is now marked as internal, as it is not intended to be used outside of the package https://github.com/hydephp/develop/pull/1394
- Updated the realtime compiler server configuration options in https://github.com/hydephp/develop/pull/1395 (backwards compatible)

### Deprecated
- for soon-to-be removed features.
Expand Down
17 changes: 11 additions & 6 deletions config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@
|--------------------------------------------------------------------------
|
| Here you can configure settings for the built-in realtime compiler server.
| The server also includes a magic dashboard feature that supercharges
| your local development! This feature can alo be customised here.
|
*/

Expand All @@ -412,14 +414,17 @@
// Should preview pages be saved to the output directory?
'save_preview' => true,

// Should the realtime compiler dashboard be enabled?
'dashboard' => env('SERVER_DASHBOARD', true),
// Configure the realtime compiler dashboard
'dashboard' => [
// Should the realtime compiler dashboard be enabled?
'enabled' => env('SERVER_DASHBOARD', true),

// Can the dashboard make edits to the project file system?
'dashboard_editor' => true,
// Can the dashboard make edits to the project file system?
'interactive' => true,

// Should the dashboard show tips?
'dashboard_tips' => true,
// Should the dashboard show tips?
'tips' => true,
],

],

Expand Down
17 changes: 11 additions & 6 deletions packages/framework/config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@
|--------------------------------------------------------------------------
|
| Here you can configure settings for the built-in realtime compiler server.
| The server also includes a magic dashboard feature that supercharges
| your local development! This feature can alo be customised here.
|
*/

Expand All @@ -412,14 +414,17 @@
// Should preview pages be saved to the output directory?
'save_preview' => true,

// Should the realtime compiler dashboard be enabled?
'dashboard' => env('SERVER_DASHBOARD', true),
// Configure the realtime compiler dashboard
'dashboard' => [
// Should the realtime compiler dashboard be enabled?
'enabled' => env('SERVER_DASHBOARD', true),

// Can the dashboard make edits to the project file system?
'dashboard_editor' => true,
// Can the dashboard make edits to the project file system?
'interactive' => true,

// Should the dashboard show tips?
'dashboard_tips' => true,
// Should the dashboard show tips?
'tips' => true,
],

],

Expand Down
19 changes: 14 additions & 5 deletions packages/realtime-compiler/src/Http/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
use function rtrim;
use function strlen;
use function substr;
use function is_bool;
use function basename;
use function in_array;
use function json_decode;
use function json_encode;
use function substr_count;
use function array_combine;
use function trigger_error;
use function escapeshellarg;
use function file_get_contents;
use function str_starts_with;
Expand All @@ -67,8 +69,8 @@ class DashboardController
'This dashboard won\'t be saved to your static site.',
'Got stuck? Ask for help on [GitHub](https://github.com/hydephp/hyde)!',
'Found a bug? Please report it on [GitHub](https://github.com/hydephp/hyde)!',
'You can disable tips using by setting `server.dashboard_tips` to `false` in `config/hyde.php`.',
'The dashboard update your project files. You can disable this by setting `server.dashboard_editor` to `false` in `config/hyde.php`.',
'You can disable tips using by setting `server.dashboard.tips` to `false` in `config/hyde.php`.',
'The dashboard update your project files. You can disable this by setting `server.dashboard.interactive` to `false` in `config/hyde.php`.',
];

public function __construct()
Expand Down Expand Up @@ -227,7 +229,7 @@ public static function highlightMediaLibraryCode(string $contents): HtmlString

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

public function getTip(): HtmlString
Expand All @@ -237,7 +239,14 @@ public function getTip(): HtmlString

public static function enabled(): bool
{
return config('hyde.server.dashboard', true);
// Previously, the setting was hyde.server.dashboard, so for backwards compatability we need this
if (is_bool($oldConfig = config('hyde.server.dashboard'))) {
trigger_error('Using `hyde.server.dashboard` as boolean is deprecated. Please use `hyde.server.dashboard.enabled` instead.', E_USER_DEPRECATED);

return $oldConfig;
}

return config('hyde.server.dashboard.enabled', true);
}

// This method is called from the PageRouter and allows us to serve a dynamic welcome page
Expand Down Expand Up @@ -273,7 +282,7 @@ public static function renderIndexPage(HydePage $page): string

public function isInteractive(): bool
{
return config('hyde.server.dashboard_editor', true);
return config('hyde.server.dashboard.interactive', true);
}

public function getScripts(): string
Expand Down

0 comments on commit b563dc6

Please sign in to comment.