From b4ce4bddea5f98b5bea93a862af780f3f3ace238 Mon Sep 17 00:00:00 2001 From: jacobdekeizer Date: Wed, 8 May 2024 10:59:48 +0200 Subject: [PATCH] Add support for Laravel Horizon 5.24.4 (#3) * Add support for Laravel Horizon 5.24.4 * Fix typos --- CHANGELOG.md | 13 +- Plugin.php | 16 +-- README.md | 12 +- classes/PathHelper.php | 55 -------- composer.json | 2 +- config/config.php | 2 - http/controllers/HomeController.php | 28 ---- serviceproviders/HorizonServiceProvider.php | 29 ---- updates/version.yaml | 3 +- views/layout.blade.php | 142 -------------------- 10 files changed, 20 insertions(+), 282 deletions(-) delete mode 100644 classes/PathHelper.php delete mode 100644 http/controllers/HomeController.php delete mode 100644 views/layout.blade.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 76ac311..f7dc063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.0] - UNRELEASED + +### Added + +- Added support for Laravel Horizon 5.24.4. + +### Deprecated + +- The `HORIZON_USE_DARK_THEME` environment variable can be removed. The dark theme is now based on the system settings. +- The `horizon:publish` command can be removed. The assets don't need to be published anymore. + ## [3.1.1] - 2023-02-06 ### Changed @@ -50,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - The location of the Horizon assets has been changed. The Horizon assets are published into the plugin directory itself (`plugins/vdlp/horizon/assets`). Please note that you need to re-publish the assets when you are deploying your October CMS website or application using the `php artisan horizon:assets` command otherwise the Horizon Dashboard will not be available. -- The `horizon:assets` command can now be used to (re-)publish the Horizon Assets required for the Horizon Dashboard. +- The `horizon:assets` command can now be used to (re-)publish the Horizon Assets required for the Horizon Dashboard. - Renamed `PushExampleJobs` to `PushExampleJobsCommand`. ### Removed diff --git a/Plugin.php b/Plugin.php index 8c1c982..d5c35d1 100644 --- a/Plugin.php +++ b/Plugin.php @@ -16,15 +16,6 @@ final class Plugin extends PluginBase { - private Backend $backend; - - public function __construct($app) - { - parent::__construct($app); - - $this->backend = resolve(Backend::class); - } - public function pluginDetails(): array { return [ @@ -52,8 +43,6 @@ public function boot(): void || $user->isSuperUser(); }); - Horizon::$useDarkTheme = config('vdlp.horizon::use_dark_theme', true); - $this->bootNotificationSettings(); if (config('app.debug') === true) { @@ -87,10 +76,13 @@ public function registerPermissions(): array public function registerNavigation(): array { + /** @var Backend $backend */ + $backend = $this->app->make(Backend::class); + return [ 'dashboard' => [ 'label' => 'Horizon', - 'url' => $this->backend->url('vdlp/horizon/dashboard'), + 'url' => $backend->url('vdlp/horizon/dashboard'), 'iconSvg' => '/plugins/vdlp/horizon/assets/icons/horizon.svg', 'permissions' => ['vdlp.horizon.access_dashboard'], 'order' => 500, diff --git a/README.md b/README.md index aeb871b..376d6ef 100644 --- a/README.md +++ b/README.md @@ -50,22 +50,12 @@ You should add the `dont-discover` option to your projects `composer.json` file > IMPORTANT: Make sure the `composer.json` is deployed to your hosting site. This will be parsed by te framework to determine which service providers should be ignored. -## Assets & Configuration +## Configuration ``` php artisan horizon:install ``` -## Update Horizon Assets - -To update the Horizon Assets you can use the following command: - -``` -php artisan horizon:publish -``` - -> IMPORTANT: Add the above command to your deployment logic or composer update scripts. This way the assets will always be up to date on your staging or production environment. - * Configure Laravel Horizon settings file at `config/horizon.php`, please make sure `use` contains `horizon` (see the configuration snippet below). ``` diff --git a/classes/PathHelper.php b/classes/PathHelper.php deleted file mode 100644 index 75eab04..0000000 --- a/classes/PathHelper.php +++ /dev/null @@ -1,55 +0,0 @@ -urlGenerator = $urlGenerator; - $this->filesystem = $filesystem; - } - - public function getAssetsPath(?string $path = null): string - { - $assetsPath = plugins_path('vdlp/horizon/assets'); - - if ($path !== null) { - $assetsPath .= DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR); - } - - return $assetsPath; - } - - public function getAssetsUrlPath(?string $path = null): string - { - $assetsUrlPath = $this->urlGenerator->asset('plugins/vdlp/horizon/assets'); - - if ($path !== null) { - $assetsUrlPath .= '/' . ltrim($path, '/'); - } - - return $assetsUrlPath; - } - - public function assetsAreCurrent(): bool - { - $publishedPath = $this->getAssetsPath('mix-manifest.json'); - $vendorPath = base_path('vendor/laravel/horizon/public/mix-manifest.json'); - - try { - return $this->filesystem->get($publishedPath) === $this->filesystem->get($vendorPath); - } catch (Throwable $exception) { - return false; - } - } -} diff --git a/composer.json b/composer.json index f58aad0..dc5bbfd 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-posix": "*", "ext-redis": "*", "composer/installers": "^1.0 || ^2.0", - "laravel/horizon": "^5.0", + "laravel/horizon": "^5.24.4", "october/rain": "^3.0" }, "require-dev": { diff --git a/config/config.php b/config/config.php index 5c2c4fd..7c497ce 100644 --- a/config/config.php +++ b/config/config.php @@ -14,6 +14,4 @@ 'sms_notifications_enabled' => env('HORIZON_SMS_NOTIFICATIONS_ENABLED', false), 'sms_notifications_to' => env('HORIZON_SMS_NOTIFICATIONS_TO'), - 'use_dark_theme' => env('HORIZON_USE_DARK_THEME', true), - ]; diff --git a/http/controllers/HomeController.php b/http/controllers/HomeController.php deleted file mode 100644 index 4cdd6e4..0000000 --- a/http/controllers/HomeController.php +++ /dev/null @@ -1,28 +0,0 @@ - $pathHelper->assetsAreCurrent(), - 'cssFile' => Horizon::$useDarkTheme ? 'app-dark.css' : 'app.css', - 'horizonScriptVariables' => Horizon::scriptVariables(), - 'isDownForMaintenance' => App::isDownForMaintenance(), - ]); - } -} diff --git a/serviceproviders/HorizonServiceProvider.php b/serviceproviders/HorizonServiceProvider.php index e81a8f9..fc77b8a 100644 --- a/serviceproviders/HorizonServiceProvider.php +++ b/serviceproviders/HorizonServiceProvider.php @@ -4,20 +4,12 @@ namespace Vdlp\Horizon\ServiceProviders; -use Illuminate\Support\Facades\Route; use Laravel\Horizon; use Laravel\Horizon\HorizonServiceProvider as HorizonServiceProviderBase; use Vdlp\Horizon\Listeners\SendNotification; final class HorizonServiceProvider extends HorizonServiceProviderBase { - public function defineAssetPublishing(): void - { - $this->publishes([ - HORIZON_PATH . '/public' => plugins_path('vdlp/horizon/assets'), - ], 'horizon-assets'); - } - protected function registerEvents(): void { $this->events[Horizon\Events\LongWaitDetected::class] = [ @@ -26,25 +18,4 @@ protected function registerEvents(): void parent::registerEvents(); } - - protected function registerResources(): void - { - $this->loadViewsFrom(plugins_path('vdlp/horizon/views'), 'horizon'); - } - - protected function registerRoutes(): void - { - parent::registerRoutes(); - - Route::group([ - 'domain' => config('horizon.domain'), - 'prefix' => config('horizon.path'), - 'namespace' => 'Vdlp\Horizon\Http\Controllers', - 'middleware' => config('horizon.middleware', 'web'), - ], static function (): void { - Route::get('/{view?}', 'HomeController@index') - ->where('view', '(.*)') - ->name('horizon.index'); - }); - } } diff --git a/updates/version.yaml b/updates/version.yaml index b60f02b..901f649 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -6,4 +6,5 @@ v3.0.0: "Upgrade to Horizon 5.x" v3.1.0: - "Add migration for Job Batches table" - 20220923_0001_create_job_batches_table.php -v3.1.1: "Update Horizon Dashboard Layout (new UI)" \ No newline at end of file +v3.1.1: "Update Horizon Dashboard Layout (new UI)" +v3.2.0: "Add support for Horizon 5.24.4" diff --git a/views/layout.blade.php b/views/layout.blade.php deleted file mode 100644 index d61e1f4..0000000 --- a/views/layout.blade.php +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - Horizon{{ config('app.name') ? ' - ' . config('app.name') : '' }} - - - - - - - -
- - -
-
- - - -
- -
- - -
- @if (! $assetsAreCurrent) -
- The published Horizon assets are not up-to-date with the installed version. To update, run:
php artisan horizon:publish -
- @endif - - @if ($isDownForMaintenance) -
- This application is in "maintenance mode". Queued jobs may not be processed unless your worker is using the "force" flag. -
- @endif - - -
-
-
-
- - - - - - -