diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index 38cc106c5..abefe136b 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -59,7 +59,7 @@ public function instantSave() $this->application->settings->is_force_https_enabled = $this->is_force_https_enabled; $this->application->settings->save(); $this->application->refresh(); - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); $this->checkWildCardDomain(); } protected function checkWildCardDomain() diff --git a/app/Http/Livewire/Project/Application/Source.php b/app/Http/Livewire/Project/Application/Source.php index 4d7274cdb..0a39b03f6 100644 --- a/app/Http/Livewire/Project/Application/Source.php +++ b/app/Http/Livewire/Project/Application/Source.php @@ -40,6 +40,6 @@ public function submit() $this->application->git_commit_sha = 'HEAD'; } $this->application->save(); - $this->emit('saved', 'Application source updated!'); + $this->emit('success', 'Application source updated!'); } } diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepository.php b/app/Http/Livewire/Project/New/GithubPrivateRepository.php index 6159b8197..89dab6b72 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepository.php @@ -157,6 +157,6 @@ public function instantSave() $this->port = 3000; $this->publish_directory = null; } - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); } } diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 52e63bb70..6f97bc10f 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -56,7 +56,7 @@ public function instantSave() $this->port = 3000; $this->publish_directory = null; } - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); } public function load_branches() { diff --git a/app/Http/Livewire/Server/New/ByIp.php b/app/Http/Livewire/Server/New/ByIp.php index 23a76f5f9..c2cc1cd06 100644 --- a/app/Http/Livewire/Server/New/ByIp.php +++ b/app/Http/Livewire/Server/New/ByIp.php @@ -39,7 +39,7 @@ public function setPrivateKey(string $private_key_id) } public function instantSave() { - $this->emit('saved', 'Application settings updated!'); + $this->emit('success', 'Application settings updated!'); } public function submit() { diff --git a/app/Http/Livewire/Settings/Configuration.php b/app/Http/Livewire/Settings/Configuration.php index 04e12980b..57de5e165 100644 --- a/app/Http/Livewire/Settings/Configuration.php +++ b/app/Http/Livewire/Settings/Configuration.php @@ -37,7 +37,7 @@ public function instantSave() $this->settings->is_auto_update_enabled = $this->is_auto_update_enabled; $this->settings->is_registration_enabled = $this->is_registration_enabled; $this->settings->save(); - $this->emit('saved', 'Settings updated!'); + $this->emit('success', 'Settings updated!'); } private function setup_instance_fqdn() { diff --git a/app/Http/Livewire/Team/InviteLink.php b/app/Http/Livewire/Team/InviteLink.php index 60fb30a0f..c57ed4b81 100644 --- a/app/Http/Livewire/Team/InviteLink.php +++ b/app/Http/Livewire/Team/InviteLink.php @@ -59,9 +59,9 @@ private function generate_invite_link(bool $isEmail = false) ]); if ($isEmail) { $user->first()->notify(new InvitationLinkEmail()); - $this->emit('message', 'Invitation sent via email successfully.'); + $this->emit('success', 'Invitation sent via email successfully.'); } else { - $this->emit('message', 'Invitation link generated.'); + $this->emit('success', 'Invitation link generated.'); } $this->emit('refreshInvitations'); } catch (\Throwable $e) { diff --git a/app/Http/Livewire/ForceUpgrade.php b/app/Http/Livewire/Upgrade.php similarity index 63% rename from app/Http/Livewire/ForceUpgrade.php rename to app/Http/Livewire/Upgrade.php index a41651bf0..0ac47576b 100644 --- a/app/Http/Livewire/ForceUpgrade.php +++ b/app/Http/Livewire/Upgrade.php @@ -2,17 +2,19 @@ namespace App\Http\Livewire; +use Masmerise\Toaster\Toaster; use App\Jobs\InstanceAutoUpdateJob; use Livewire\Component; -class ForceUpgrade extends Component +class Upgrade extends Component { - public bool $visible = false; + public bool $showProgress = false; public function upgrade() { try { - $this->visible = true; + $this->showProgress = true; dispatch(new InstanceAutoUpdateJob(force: true)); + Toaster::success('Update started.'); } catch (\Exception $e) { return general_error_handler(err: $e, that: $this); } diff --git a/app/Http/Livewire/Upgrading.php b/app/Http/Livewire/Upgrading.php deleted file mode 100644 index b9de9bb03..000000000 --- a/app/Http/Livewire/Upgrading.php +++ /dev/null @@ -1,15 +0,0 @@ -visible = true; - } -} diff --git a/app/Jobs/InstanceAutoUpdateJob.php b/app/Jobs/InstanceAutoUpdateJob.php index 607664739..a08caf23f 100644 --- a/app/Jobs/InstanceAutoUpdateJob.php +++ b/app/Jobs/InstanceAutoUpdateJob.php @@ -27,24 +27,6 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique public function __construct(private bool $force = false) { } - private function update() - { - if (config('app.env') === 'local') { - ray('Running update on local docker container'); - instant_remote_process([ - "sleep 10" - ], $this->server); - ray('Update done'); - return; - } else { - ray('Running update on production server'); - instant_remote_process([ - "curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh", - "bash /data/coolify/source/upgrade.sh $this->latest_version" - ], $this->server); - return; - } - } public function handle(): void { try { @@ -81,6 +63,25 @@ public function handle(): void return; } } + private function update() + { + if (config('app.env') === 'local') { + ray('Running update on local docker container'); + instant_remote_process([ + "sleep 10" + ], $this->server); + ray('Update done'); + return; + } else { + ray('Running update on production server'); + instant_remote_process([ + "curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh", + "bash /data/coolify/source/upgrade.sh $this->latest_version" + ], $this->server); + return; + } + } + public function failed(Exception $exception) { return; diff --git a/composer.json b/composer.json index 06470793d..8fe9ce5dc 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "laravel/ui": "^4.2", "lcobucci/jwt": "^5.0.0", "livewire/livewire": "^v2.12.3", + "masmerise/livewire-toaster": "^1.2", "nubs/random-name-generator": "^2.2", "sentry/sentry-laravel": "^3.4", "spatie/laravel-activitylog": "^4.7.3", @@ -91,4 +92,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 11410a490..f4d2b9c40 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "77b718b33a7ba99083fd327821f968a2", + "content-hash": "d9173515bca399807784102128591e1e", "packages": [ { "name": "bacon/bacon-qr-code", @@ -2738,6 +2738,74 @@ ], "time": "2023-03-03T20:12:38+00:00" }, + { + "name": "masmerise/livewire-toaster", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/masmerise/livewire-toaster.git", + "reference": "2706d3822e111af8272ebc117cb2c69228d14faf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/masmerise/livewire-toaster/zipball/2706d3822e111af8272ebc117cb2c69228d14faf", + "reference": "2706d3822e111af8272ebc117cb2c69228d14faf", + "shasum": "" + }, + "require": { + "laravel/framework": "^10.0", + "livewire/livewire": "^2.0", + "php": "~8.2" + }, + "require-dev": { + "dive-be/php-crowbar": "^1.1", + "laravel/pint": "^1.0", + "nunomaduro/larastan": "^2.0", + "orchestra/testbench": "^8.0", + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Toaster": "Masmerise\\Toaster\\Toaster" + }, + "providers": [ + "Masmerise\\Toaster\\ToasterServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Masmerise\\Toaster\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Muhammed Sari", + "email": "support@muhammedsari.me", + "role": "Developer" + } + ], + "description": "Beautiful toast notifications for Laravel / Livewire.", + "homepage": "https://github.com/masmerise/livewire-toaster", + "keywords": [ + "alert", + "laravel", + "livewire", + "toast", + "toaster" + ], + "support": { + "issues": "https://github.com/masmerise/livewire-toaster/issues", + "source": "https://github.com/masmerise/livewire-toaster/tree/1.2.0" + }, + "time": "2023-06-13T11:44:44+00:00" + }, { "name": "monolog/monolog", "version": "3.3.1", diff --git a/config/toaster.php b/config/toaster.php new file mode 100644 index 000000000..805927210 --- /dev/null +++ b/config/toaster.php @@ -0,0 +1,48 @@ + true, + + /** + * The vertical alignment of the toast container. + * + * Supported: "bottom", "middle" or "top" + */ + 'alignment' => 'top', + + /** + * Allow users to close toast messages prematurely. + * + * Supported: true | false + */ + 'closeable' => true, + + /** + * The on-screen duration of each toast. + * + * Minimum: 3000 (in milliseconds) + */ + 'duration' => 3000, + + /** + * The horizontal position of each toast. + * + * Supported: "center", "left" or "right" + */ + 'position' => 'right', + + /** + * Whether messages passed as translation keys should be translated automatically. + * + * Supported: true | false + */ + 'translate' => true, +]; diff --git a/resources/js/app.js b/resources/js/app.js index 2dc18bf8c..ccfeee5c2 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -2,6 +2,10 @@ import Alpine from "alpinejs"; import { createApp } from "vue"; import MagicBar from "./components/MagicBar.vue"; +import Toaster from "../../vendor/masmerise/livewire-toaster/resources/js"; + +Alpine.plugin(Toaster); + window.Alpine = Alpine; Alpine.start(); diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index 7a949b8c8..773c08a04 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -26,6 +26,7 @@
@livewireScripts +