Compare commits

..

1 Commits

Author SHA1 Message Date
Lance Pioch
61a9cbbc6c Auto-update alert banners with Livewire polling (#1492)
Add wire:poll.visible.15s to the alert banner container so new alerts
are picked up without requiring a manual page refresh.
2026-02-06 01:52:25 -05:00
14 changed files with 30 additions and 151 deletions

View File

@@ -78,15 +78,11 @@ class Console extends Page
$feature = data_get($data, 'key');
$feature = $this->featureService->get($feature);
if (!$feature) {
if (!$feature || $this->getMountedAction()) {
return;
}
if ($this->getMountedAction()) {
$this->replaceMountedAction($feature->getId());
} else {
$this->mountAction($feature->getId());
}
$this->mountAction($feature->getId());
sleep(2); // TODO find a better way
}
public function getWidgetData(): array

View File

@@ -209,18 +209,16 @@ class ListFiles extends ListRecords
->required()
->live(),
TextEntry::make('new_location')
->state(fn (Get $get, File $file) => resolve_path(join_paths($this->path, str_ends_with($get('location') ?? '/', '/') ? join_paths($get('location') ?? '/', $file->name) : $get('location') ?? '/'))),
->state(fn (Get $get, File $file) => resolve_path(join_paths($this->path, $get('location') ?? '/', $file->name))),
])
->action(function ($data, File $file) {
$location = $data['location'];
$endsWithSlash = str_ends_with($location, '/');
$to = $endsWithSlash ? join_paths($location, $file->name) : $location;
$files = [['to' => $to, 'from' => $file->name]];
$files = [['to' => join_paths($location, $file->name), 'from' => $file->name]];
$this->getDaemonFileRepository()->renameFiles($this->path, $files);
$oldLocation = join_paths($this->path, $file->name);
$newLocation = resolve_path(join_paths($this->path, $to));
$newLocation = resolve_path(join_paths($this->path, $location, $file->name));
Activity::event('server:file.rename')
->property('directory', $this->path)

View File

@@ -74,7 +74,7 @@ class OAuthController extends Controller
$email = $oauthUser->getEmail();
if (!$email) {
return $this->errorRedirect('No email was linked to your account on the OAuth provider.');
return $this->errorRedirect();
}
$user = User::whereEmail($email)->first();

View File

@@ -358,7 +358,7 @@ class Node extends Model implements Validatable
'disk_used' => 0,
];
return cache()->flexible("nodes.$this->id.statistics", [5, 30], function () use ($default) {
return cache()->remember("nodes.$this->id.statistics", now()->addSeconds(360), function () use ($default) {
try {
$data = Http::daemon($this)

View File

@@ -23,16 +23,14 @@ class AccountCreated extends Notification implements ShouldQueue
public function toMail(User $notifiable): MailMessage
{
$locale = $notifiable->language ?? 'en';
$message = (new MailMessage())
->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale))
->line(trans('mail.account_created.body', ['app' => config('app.name')], $locale))
->line(trans('mail.account_created.username', ['username' => $notifiable->username], $locale))
->line(trans('mail.account_created.email', ['email' => $notifiable->email], $locale));
->greeting('Hello ' . $notifiable->username . '!')
->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.')
->line('Username: ' . $notifiable->username)
->line('Email: ' . $notifiable->email);
if (!is_null($this->token)) {
return $message->action(trans('mail.account_created.action', locale: $locale), Filament::getPanel('app')->getResetPasswordUrl($this->token, $notifiable));
return $message->action('Setup Your Account', Filament::getPanel('app')->getResetPasswordUrl($this->token, $notifiable));
}
return $message;

View File

@@ -24,12 +24,10 @@ class AddedToServer extends Notification implements ShouldQueue
public function toMail(User $notifiable): MailMessage
{
$locale = $notifiable->language ?? 'en';
return (new MailMessage())
->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale))
->line(trans('mail.added_to_server.body', locale: $locale))
->line(trans('mail.added_to_server.server_name', ['name' => $this->server->name], $locale))
->action(trans('mail.added_to_server.action', locale: $locale), Console::getUrl(panel: 'server', tenant: $this->server));
->greeting('Hello ' . $notifiable->username . '!')
->line('You have been added as a subuser for the following server, allowing you certain control over the server.')
->line('Server Name: ' . $this->server->name)
->action('Visit Server', Console::getUrl(panel: 'server', tenant: $this->server));
}
}

View File

@@ -20,11 +20,9 @@ class MailTested extends Notification
public function toMail(): MailMessage
{
$locale = $this->user->language ?? 'en';
return (new MailMessage())
->subject(trans('mail.mail_tested.subject', locale: $locale))
->greeting(trans('mail.greeting', ['name' => $this->user->username], $locale))
->line(trans('mail.mail_tested.body', locale: $locale));
->subject('Panel Test Message')
->greeting('Hello ' . $this->user->username . '!')
->line('This is a test of the Panel mail system. You\'re good to go!');
}
}

View File

@@ -23,13 +23,11 @@ class RemovedFromServer extends Notification implements ShouldQueue
public function toMail(User $notifiable): MailMessage
{
$locale = $notifiable->language ?? 'en';
return (new MailMessage())
->error()
->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale))
->line(trans('mail.removed_from_server.body', locale: $locale))
->line(trans('mail.removed_from_server.server_name', ['name' => $this->server->name], $locale))
->action(trans('mail.removed_from_server.action', locale: $locale), url(''));
->greeting('Hello ' . $notifiable->username . '.')
->line('You have been removed as a subuser for the following server.')
->line('Server Name: ' . $this->server->name)
->action('Visit Panel', url(''));
}
}

View File

@@ -24,12 +24,10 @@ class ServerInstalled extends Notification implements ShouldQueue
public function toMail(User $notifiable): MailMessage
{
$locale = $notifiable->language ?? 'en';
return (new MailMessage())
->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale))
->line(trans('mail.server_installed.body', locale: $locale))
->line(trans('mail.server_installed.server_name', ['name' => $this->server->name], $locale))
->action(trans('mail.server_installed.action', locale: $locale), Console::getUrl(panel: 'server', tenant: $this->server));
->greeting('Hello ' . $notifiable->username . '.')
->line('Your server has finished installing and is now ready for you to use.')
->line('Server Name: ' . $this->server->name)
->action('Login and Begin Using', Console::getUrl(panel: 'server', tenant: $this->server));
}
}

View File

@@ -92,7 +92,7 @@ class EggExporterService
return $this->yamlExport($decoded);
}
return str_replace("\r\n", "\n", $data);
return str_replace(["\r\n", '\\r\\n', '\\n'], "\n", $data);
}
if (is_array($data)) {

View File

@@ -1,35 +0,0 @@
<?php
return [
'greeting' => 'Hello :name!',
'account_created' => [
'body' => 'You are receiving this email because an account has been created for you on :app.',
'username' => 'Username: :username',
'email' => 'Email: :email',
'action' => 'Setup Your Account',
],
'added_to_server' => [
'body' => 'You have been added as a subuser for the following server, allowing you certain control over the server.',
'server_name' => 'Server Name: :name',
'action' => 'Visit Server',
],
'removed_from_server' => [
'body' => 'You have been removed as a subuser for the following server.',
'server_name' => 'Server Name: :name',
'action' => 'Visit Panel',
],
'server_installed' => [
'body' => 'Your server has finished installing and is now ready for you to use.',
'server_name' => 'Server Name: :name',
'action' => 'Login and Begin Using',
],
'mail_tested' => [
'subject' => 'Panel Test Message',
'body' => 'This is a test of the Panel mail system. You\'re good to go!',
],
];

View File

@@ -5,10 +5,6 @@
RewriteEngine On
# Handle X-Forwarded-Proto Header
RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
RewriteRule .* - [E=HTTPS:on]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

View File

@@ -1,4 +1,4 @@
<div id="alert-banner-container" class="flex flex-col gap-4">
<div wire:poll.visible.15s id="alert-banner-container" class="flex flex-col gap-4">
@foreach ($alertBanners as $alertBanner)
{{ $alertBanner }}
@endforeach

View File

@@ -1,66 +0,0 @@
<?php
namespace App\Tests\Unit\Services\Eggs;
use App\Services\Eggs\Sharing\EggExporterService;
use PHPUnit\Framework\TestCase;
class EggExporterServiceTest extends TestCase
{
private EggExporterService $service;
protected function setUp(): void
{
parent::setUp();
$this->service = new EggExporterService();
}
public function test_yaml_export_preserves_literal_backslash_n_in_scripts(): void
{
$script = <<<'BASH'
if [[ "${STEAM_USER}" == "" ]] || [[ "${STEAM_PASS}" == "" ]]; then
echo -e "steam user is not set.\n"
echo -e "Using anonymous user.\n"
STEAM_USER=anonymous
STEAM_PASS=""
STEAM_AUTH=""
else
echo -e "user set to ${STEAM_USER}"
fi
BASH;
$result = $this->callYamlExport($script);
$this->assertStringContainsString('echo -e "steam user is not set.\n"', $result);
$this->assertStringContainsString('echo -e "Using anonymous user.\n"', $result);
}
public function test_yaml_export_preserves_literal_backslash_r_backslash_n(): void
{
$script = 'echo -e "line ending\\r\\n"';
$result = $this->callYamlExport($script);
$this->assertSame($script, $result);
}
public function test_yaml_export_normalizes_real_crlf_to_lf(): void
{
$script = "line one\r\nline two\r\nline three";
$result = $this->callYamlExport($script);
$this->assertSame("line one\nline two\nline three", $result);
}
/**
* Call the protected yamlExport method via reflection.
*/
private function callYamlExport(mixed $data): mixed
{
$reflection = new \ReflectionMethod($this->service, 'yamlExport');
return $reflection->invoke($this->service, $data);
}
}