This commit is contained in:
Andras Bacsai 2023-06-20 19:08:43 +02:00
parent f648ab49f7
commit 9f0ca1cc2e
19 changed files with 226 additions and 197 deletions

View File

@ -1,23 +0,0 @@
<?php
namespace App\Data;
use Spatie\LaravelData\Data;
class SmtpConfiguration extends Data
{
public function __construct(
public bool $smtp_enabled = false,
public string $smtp_host,
public int $smtp_port,
public ?string $smtp_encryption,
public ?string $smtp_username,
public ?string $smtp_password,
public ?int $smtp_timeout,
public string $smtp_from_address,
public string $smtp_from_name,
public ?string $smtp_recipients,
public ?string $smtp_test_recipients,
) {
}
}

View File

@ -10,20 +10,21 @@ class DiscordSettings extends Component
{
public Team $model;
protected $rules = [
'model.extra_attributes.discord_enabled' => 'nullable|boolean',
'model.extra_attributes.discord_webhook_url' => 'required|url',
'model.extra_attributes.notifications_discord_test' => 'nullable|boolean',
'model.extra_attributes.notifications_discord_deployments' => 'nullable|boolean',
'model.discord.enabled' => 'nullable|boolean',
'model.discord.webhook_url' => 'required|url',
'model.discord_notifications.test' => 'nullable|boolean',
'model.discord_notifications.deployments' => 'nullable|boolean',
];
protected $validationAttributes = [
'model.extra_attributes.discord_webhook_url' => 'Discord Webhook',
'model.discord.webhook_url' => 'Discord Webhook',
];
public function instantSave()
{
try {
$this->submit();
} catch (\Exception $e) {
$this->model->extra_attributes->discord_enabled = false;
$this->model->discord->enabled = false;
$this->validate();
}
}

View File

@ -12,53 +12,55 @@ class EmailSettings extends Component
public Team $model;
protected $rules = [
'model.extra_attributes.smtp_enabled' => 'nullable|boolean',
'model.extra_attributes.smtp_from_address' => 'required|email',
'model.extra_attributes.smtp_from_name' => 'required',
'model.extra_attributes.smtp_recipients' => 'nullable',
'model.extra_attributes.smtp_host' => 'required',
'model.extra_attributes.smtp_port' => 'required',
'model.extra_attributes.smtp_encryption' => 'nullable',
'model.extra_attributes.smtp_username' => 'nullable',
'model.extra_attributes.smtp_password' => 'nullable',
'model.extra_attributes.smtp_timeout' => 'nullable',
'model.extra_attributes.smtp_test_recipients' => 'nullable',
'model.extra_attributes.notifications_smtp_test' => 'nullable|boolean',
'model.extra_attributes.notifications_email_deployments' => 'nullable|boolean',
'model.smtp.enabled' => 'nullable|boolean',
'model.smtp.from_address' => 'required|email',
'model.smtp.from_name' => 'required',
'model.smtp.recipients' => 'nullable',
'model.smtp.host' => 'required',
'model.smtp.port' => 'required',
'model.smtp.encryption' => 'nullable',
'model.smtp.username' => 'nullable',
'model.smtp.password' => 'nullable',
'model.smtp.timeout' => 'nullable',
'model.smtp.test_recipients' => 'nullable',
'model.smtp_notifications.test' => 'nullable|boolean',
'model.smtp_notifications.deployments' => 'nullable|boolean',
'model.discord_notifications.test' => 'nullable|boolean',
'model.discord_notifications.deployments' => 'nullable|boolean',
];
protected $validationAttributes = [
'model.extra_attributes.smtp_from_address' => 'From Address',
'model.extra_attributes.smtp_from_name' => 'From Name',
'model.extra_attributes.smtp_recipients' => 'Recipients',
'model.extra_attributes.smtp_host' => 'Host',
'model.extra_attributes.smtp_port' => 'Port',
'model.extra_attributes.smtp_encryption' => 'Encryption',
'model.extra_attributes.smtp_username' => 'Username',
'model.extra_attributes.smtp_password' => 'Password',
'model.extra_attributes.smtp_test_recipients' => 'Test Recipients',
'model.smtp.from_address' => 'From Address',
'model.smtp.from_name' => 'From Name',
'model.smtp.recipients' => 'Recipients',
'model.smtp.host' => 'Host',
'model.smtp.port' => 'Port',
'model.smtp.encryption' => 'Encryption',
'model.smtp.username' => 'Username',
'model.smtp.password' => 'Password',
'model.smtp.test_recipients' => 'Test Recipients',
];
public function copySMTP()
public function copyFromInstanceSettings()
{
$settings = InstanceSettings::get();
$this->model->extra_attributes->smtp_enabled = true;
$this->model->extra_attributes->smtp_from_address = $settings->extra_attributes->smtp_from_address;
$this->model->extra_attributes->smtp_from_name = $settings->extra_attributes->smtp_from_name;
$this->model->extra_attributes->smtp_recipients = $settings->extra_attributes->smtp_recipients;
$this->model->extra_attributes->smtp_host = $settings->extra_attributes->smtp_host;
$this->model->extra_attributes->smtp_port = $settings->extra_attributes->smtp_port;
$this->model->extra_attributes->smtp_encryption = $settings->extra_attributes->smtp_encryption;
$this->model->extra_attributes->smtp_username = $settings->extra_attributes->smtp_username;
$this->model->extra_attributes->smtp_password = $settings->extra_attributes->smtp_password;
$this->model->extra_attributes->smtp_timeout = $settings->extra_attributes->smtp_timeout;
$this->model->extra_attributes->smtp_test_recipients = $settings->extra_attributes->smtp_test_recipients;
$this->model->smtp->enabled = true;
$this->model->smtp->from_address = $settings->smtp->from_address;
$this->model->smtp->from_name = $settings->smtp->from_name;
$this->model->smtp->recipients = $settings->smtp->recipients;
$this->model->smtp->host = $settings->smtp->host;
$this->model->smtp->port = $settings->smtp->port;
$this->model->smtp->encryption = $settings->smtp->encryption;
$this->model->smtp->username = $settings->smtp->username;
$this->model->smtp->password = $settings->smtp->password;
$this->model->smtp->timeout = $settings->smtp->timeout;
$this->model->smtp->test_recipients = $settings->smtp->test_recipients;
$this->saveModel();
}
public function submit()
{
$this->resetErrorBag();
$this->validate();
$this->model->extra_attributes->smtp_recipients = str_replace(' ', '', $this->model->extra_attributes->smtp_recipients);
$this->model->extra_attributes->smtp_test_recipients = str_replace(' ', '', $this->model->extra_attributes->smtp_test_recipients);
$this->model->smtp->recipients = str_replace(' ', '', $this->model->smtp->recipients);
$this->model->smtp->test_recipients = str_replace(' ', '', $this->model->smtp->test_recipients);
$this->saveModel();
}
public function saveModel()
@ -79,7 +81,7 @@ public function instantSave()
try {
$this->submit();
} catch (\Exception $e) {
$this->model->extra_attributes->smtp_enabled = false;
$this->model->smtp->enabled = false;
$this->validate();
}
}

View File

@ -12,34 +12,34 @@ class Email extends Component
public InstanceSettings $settings;
protected $rules = [
'settings.extra_attributes.smtp_enabled' => 'nullable|boolean',
'settings.extra_attributes.smtp_host' => 'required',
'settings.extra_attributes.smtp_port' => 'required|numeric',
'settings.extra_attributes.smtp_encryption' => 'nullable',
'settings.extra_attributes.smtp_username' => 'nullable',
'settings.extra_attributes.smtp_password' => 'nullable',
'settings.extra_attributes.smtp_timeout' => 'nullable',
'settings.extra_attributes.smtp_test_recipients' => 'nullable',
'settings.extra_attributes.smtp_from_address' => 'required|email',
'settings.extra_attributes.smtp_from_name' => 'required',
'settings.smtp.enabled' => 'nullable|boolean',
'settings.smtp.host' => 'required',
'settings.smtp.port' => 'required|numeric',
'settings.smtp.encryption' => 'nullable',
'settings.smtp.username' => 'nullable',
'settings.smtp.password' => 'nullable',
'settings.smtp.timeout' => 'nullable',
'settings.smtp.test_recipients' => 'nullable',
'settings.smtp.from_address' => 'required|email',
'settings.smtp.from_name' => 'required',
];
protected $validationAttributes = [
'settings.extra_attributes.smtp_from_address' => 'From Address',
'settings.extra_attributes.smtp_from_name' => 'From Name',
'settings.extra_attributes.smtp_recipients' => 'Recipients',
'settings.extra_attributes.smtp_host' => 'Host',
'settings.extra_attributes.smtp_port' => 'Port',
'settings.extra_attributes.smtp_encryption' => 'Encryption',
'settings.extra_attributes.smtp_username' => 'Username',
'settings.extra_attributes.smtp_password' => 'Password',
'settings.extra_attributes.smtp_test_recipients' => 'Test Recipients',
'settings.smtp.from_address' => 'From Address',
'settings.smtp.from_name' => 'From Name',
'settings.smtp.recipients' => 'Recipients',
'settings.smtp.host' => 'Host',
'settings.smtp.port' => 'Port',
'settings.smtp.encryption' => 'Encryption',
'settings.smtp.username' => 'Username',
'settings.smtp.password' => 'Password',
'settings.smtp.test_recipients' => 'Test Recipients',
];
public function instantSave()
{
try {
$this->submit();
} catch (\Exception $e) {
$this->settings->extra_attributes->smtp_enabled = false;
$this->settings->smtp->enabled = false;
$this->validate();
}
}
@ -51,7 +51,7 @@ public function test_email()
public function submit()
{
$this->validate();
$this->settings->extra_attributes->smtp_test_recipients = str_replace(' ', '', $this->settings->extra_attributes->smtp_test_recipients);
$this->settings->smtp->test_recipients = str_replace(' ', '', $this->settings->smtp->test_recipients);
$this->settings->save();
}
}

View File

@ -7,20 +7,24 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
use Spatie\SchemalessAttributes\SchemalessAttributesTrait;
class InstanceSettings extends Model implements SendsEmail
{
use Notifiable;
protected $casts = [
'extra_attributes' => SchemalessAttributes::class,
use Notifiable, SchemalessAttributesTrait;
protected $schemalessAttributes = [
'smtp',
];
public function scopeWithExtraAttributes(): Builder
protected $casts = [
'smtp' => SchemalessAttributes::class,
];
public function scopeWithSmtp(): Builder
{
return $this->extra_attributes->modelScope();
return $this->smtp->modelScope();
}
public function routeNotificationForEmail(string $attribute = 'smtp_test_recipients')
public function routeNotificationForEmail(string $attribute = 'test_recipients')
{
$recipients = $this->extra_attributes->get($attribute, '');
$recipients = $this->smtp->get($attribute, '');
if (is_null($recipients) || $recipients === '') {
return [];
}

View File

@ -8,40 +8,64 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
use Spatie\SchemalessAttributes\SchemalessAttributesTrait;
class Team extends Model implements SendsDiscord, SendsEmail
{
use Notifiable;
use Notifiable, SchemalessAttributesTrait;
protected $schemalessAttributes = [
'smtp',
'discord',
'smtp_notifications',
'discord_notifications',
];
protected $casts = [
'extra_attributes' => SchemalessAttributes::class,
'smtp' => SchemalessAttributes::class,
'discord' => SchemalessAttributes::class,
'smtp_notifications' => SchemalessAttributes::class,
'discord_notifications' => SchemalessAttributes::class,
'personal_team' => 'boolean',
];
public function scopeWithSmtp(): Builder
{
return $this->smtp->modelScope();
}
public function scopeWithDiscord(): Builder
{
return $this->discord->modelScope();
}
public function scopeWithSmtpNotifications(): Builder
{
return $this->smtp_notifications->modelScope();
}
public function scopeWithDiscordNotifications(): Builder
{
return $this->discord_notifications->modelScope();
}
protected $fillable = [
'id',
'name',
'description',
'personal_team',
'extra_attributes',
'smtp',
'discord'
];
public function routeNotificationForDiscord()
{
return $this->extra_attributes->get('discord_webhook_url');
return $this->discord->get('webhook_url');
}
public function routeNotificationForEmail(string $attribute = 'smtp_recipients')
public function routeNotificationForEmail(string $attribute = 'recipients')
{
$recipients = $this->extra_attributes->get($attribute, '');
$recipients = $this->smtp->get($attribute, '');
if (is_null($recipients) || $recipients === '') {
return [];
}
return explode(',', $recipients);
}
public function scopeWithExtraAttributes(): Builder
{
return $this->extra_attributes->modelScope();
}
public function projects()
{

View File

@ -34,10 +34,20 @@ protected static function boot()
$team = [
'name' => $user->name . "'s Team",
'personal_team' => true,
'extra_attributes' => [
'notifications_smtp_test' => true,
'notifications_discord_test' => true,
]
'smtp' => [
'enabled' => false,
],
'smtp_notifications' => [
'test' => true,
'deployments' => false,
],
'discord' => [
'enabled' => false,
],
'discord_notifications' => [
'test' => true,
'deployments' => false,
],
];
if ($user->id === 0) {
$team['id'] = 0;

View File

@ -12,7 +12,7 @@ public function send(SendsEmail $notifiable, Notification $notification): void
{
$this->bootConfigs($notifiable);
$bcc = $notifiable->routeNotificationForEmail('smtp_test_recipients');
$bcc = $notifiable->routeNotificationForEmail('test_recipients');
if (count($bcc) === 0) {
if ($notifiable instanceof \App\Models\Team) {
$bcc = $notifiable->members()->pluck('email')->toArray();
@ -24,8 +24,8 @@ public function send(SendsEmail $notifiable, Notification $notification): void
[],
fn (Message $message) => $message
->from(
$notifiable->extra_attributes?->get('smtp_from_address'),
$notifiable->extra_attributes?->get('smtp_from_name')
data_get($notifiable, 'smtp.from_address'),
data_get($notifiable, 'smtp.from_name'),
)
->bcc($bcc)
->subject($mailMessage->subject)
@ -38,12 +38,12 @@ private function bootConfigs($notifiable): void
config()->set('mail.default', 'smtp');
config()->set('mail.mailers.smtp', [
"transport" => "smtp",
"host" => $notifiable->extra_attributes?->get('smtp_host'),
"port" => $notifiable->extra_attributes?->get('smtp_port'),
"encryption" => $notifiable->extra_attributes?->get('smtp_encryption'),
"username" => $notifiable->extra_attributes?->get('smtp_username'),
"password" => $notifiable->extra_attributes?->get('smtp_password'),
"timeout" => $notifiable->extra_attributes?->get('smtp_timeout'),
"host" => data_get($notifiable, 'smtp.host'),
"port" => data_get($notifiable, 'smtp.port'),
"encryption" => data_get($notifiable, 'smtp.encryption'),
"username" => data_get($notifiable, 'smtp.username'),
"password" => data_get($notifiable, 'smtp.password'),
"timeout" => data_get($notifiable, 'smtp.timeout'),
"local_domain" => null,
]);
}

View File

@ -13,23 +13,22 @@ class TransactionalEmailChannel
public function send(User $notifiable, Notification $notification): void
{
$settings = InstanceSettings::get();
if ($settings->extra_attributes?->get('smtp_enabled') !== true) {
if (data_get($settings, 'smtp.enabled') !== true) {
return;
}
$email = $notifiable->email;
if (!$email) {
return;
}
$this->bootConfigs($settings);
$this->bootConfigs();
$mailMessage = $notification->toMail($notifiable);
Mail::send(
[],
[],
fn (Message $message) => $message
->from(
$settings->extra_attributes?->get('smtp_from_address'),
$settings->extra_attributes?->get('smtp_from_name')
data_get($settings, 'smtp.from_address'),
data_get($settings, 'smtp.from_name')
)
->to($email)
->subject($mailMessage->subject)
@ -37,7 +36,7 @@ public function send(User $notifiable, Notification $notification): void
);
}
private function bootConfigs(InstanceSettings $settings): void
private function bootConfigs(): void
{
set_transanctional_email_settings();
}

View File

@ -43,10 +43,15 @@ public function __construct(Application $application, string $deployment_uuid, A
public function via(object $notifiable): array
{
$channels = [];
if ($notifiable->extra_attributes?->get('smtp_enabled') && $notifiable->extra_attributes?->get('notifications_email_deployments')) {
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments');
$isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments');
if ($isEmailEnabled && $isSubscribedToEmailDeployments) {
$channels[] = EmailChannel::class;
}
if ($notifiable->extra_attributes?->get('discord_enabled') && $notifiable->extra_attributes?->get('notifications_discord_deployments')) {
if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) {
$channels[] = DiscordChannel::class;
}
return $channels;

View File

@ -44,10 +44,15 @@ public function __construct(Application $application, string $deployment_uuid, A
public function via(object $notifiable): array
{
$channels = [];
if ($notifiable->extra_attributes?->get('smtp_enabled') && $notifiable->extra_attributes?->get('notifications_email_deployments')) {
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments');
$isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments');
if ($isEmailEnabled && $isSubscribedToEmailDeployments) {
$channels[] = EmailChannel::class;
}
if ($notifiable->extra_attributes?->get('discord_enabled') && $notifiable->extra_attributes?->get('notifications_discord_deployments')) {
if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) {
$channels[] = DiscordChannel::class;
}
return $channels;

View File

@ -20,12 +20,21 @@ public function __construct(string|null $type = null)
public function via(object $notifiable): array
{
$channels = [];
if (($this->type === 'smtp' || is_null($this->type)) && $notifiable->extra_attributes?->get('smtp_enabled') && $notifiable->extra_attributes?->get('notifications_smtp_test')) {
$isSmtp = $this->type === 'smtp' || is_null($this->type);
$isDiscord = $this->type === 'discord' || is_null($this->type);
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isSubscribedToEmailTests = data_get($notifiable, 'smtp_notifications.test');
$isSubscribedToDiscordTests = data_get($notifiable, 'discord_notifications.test');
if ($isEmailEnabled && $isSubscribedToEmailTests && $isSmtp) {
$channels[] = EmailChannel::class;
}
if (($this->type === 'discord' || is_null($this->type)) && $notifiable->extra_attributes?->get('discord_enabled') && $notifiable->extra_attributes?->get('notifications_discord_test')) {
if ($isDiscordEnabled && $isSubscribedToDiscordTests && $isDiscord) {
$channels[] = DiscordChannel::class;
}
return $channels;
}
public function toMail(): MailMessage
@ -39,7 +48,7 @@ public function toMail(): MailMessage
public function toDiscord(): string
{
return 'This is a test Discord notification from Coolify.
[Go to your dashboard](' . base_url() . ')';
}
}

View File

@ -69,7 +69,7 @@ function generate_application_name(string $git_repository, string $git_branch)
function is_transactional_emails_active()
{
return data_get(InstanceSettings::get(), 'extra_attributes.smtp_enabled');
return data_get(InstanceSettings::get(), 'smtp.enabled');
}
function set_transanctional_email_settings()
@ -78,12 +78,12 @@ function set_transanctional_email_settings()
config()->set('mail.default', 'smtp');
config()->set('mail.mailers.smtp', [
"transport" => "smtp",
"host" => $settings->extra_attributes?->get('smtp_host'),
"port" => $settings->extra_attributes?->get('smtp_port'),
"encryption" => $settings->extra_attributes?->get('smtp_encryption'),
"username" => $settings->extra_attributes?->get('smtp_username'),
"password" => $settings->extra_attributes?->get('smtp_password'),
"timeout" => $settings->extra_attributes?->get('smtp_timeout'),
"host" => data_get($settings, 'smtp.host'),
"port" => data_get($settings, 'smtp.port'),
"encryption" => data_get($settings, 'smtp.encryption'),
"username" => data_get($settings, 'smtp.username'),
"password" => data_get($settings, 'smtp.password'),
"timeout" => data_get($settings, 'smtp.timeout'),
"local_domain" => null,
]);
}

View File

@ -16,7 +16,10 @@ public function up(): void
$table->string('name');
$table->string('description')->nullable();
$table->boolean('personal_team')->default(false);
$table->schemalessAttributes('extra_attributes');
$table->schemalessAttributes('smtp');
$table->schemalessAttributes('smtp_notifications');
$table->schemalessAttributes('discord');
$table->schemalessAttributes('discord_notifications');
$table->timestamps();
});
}

View File

@ -23,7 +23,7 @@ public function up(): void
$table->boolean('do_not_track')->default(false);
$table->boolean('is_auto_update_enabled')->default(true);
$table->boolean('is_registration_enabled')->default(true);
$table->schemalessAttributes('extra_attributes');
$table->schemalessAttributes('smtp');
// $table->string('custom_dns_servers')->default('1.1.1.1,8.8.8.8');
// $table->boolean('is_dns_check_enabled')->default(true);
$table->timestamps();

View File

@ -2,7 +2,6 @@
namespace Database\Seeders;
use App\Data\SmtpConfiguration;
use App\Models\InstanceSettings;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Process;
@ -17,14 +16,14 @@ public function run(): void
InstanceSettings::create([
'id' => 0,
'is_registration_enabled' => true,
'extra_attributes' => SmtpConfiguration::from([
'smtp_enabled' => true,
'smtp_test_recipients' => 'test@example.com,test2@example.com',
'smtp_host' => 'coolify-mail',
'smtp_port' => 1025,
'smtp_from_address' => 'hi@localhost.com',
'smtp_from_name' => 'Coolify',
])
'smtp' => [
'enabled' => true,
'test_recipients' => 'test@example.com,test2@example.com',
'host' => 'coolify-mail',
'port' => 1025,
'from_address' => 'hi@localhost.com',
'from_name' => 'Coolify',
]
]);
try {
$ipv4 = Process::run('curl -4s https://ifconfig.io')->output();

View File

@ -5,7 +5,7 @@
<x-forms.button type="submit">
Save
</x-forms.button>
@if ($model->extra_attributes->discord_enabled)
@if ($model->discord->enabled)
<x-forms.button class="text-white normal-case btn btn-xs no-animation btn-primary"
wire:click="sendTestNotification">
Send Test Notifications
@ -13,20 +13,20 @@
@endif
</div>
<div class="w-48">
<x-forms.checkbox instantSave id="model.extra_attributes.discord_enabled" label="Notification Enabled" />
<x-forms.checkbox instantSave id="model.discord.enabled" label="Notification Enabled" />
</div>
<x-forms.input type="string"
helper="Generate a webhook in Discord.<br>Example: https://discord.com/api/webhooks/...." required
id="model.extra_attributes.discord_webhook_url" label="Webhook" />
id="model.discord.webhook_url" label="Webhook" />
</form>
@if (data_get($model, 'extra_attributes.discord_enabled'))
@if (data_get($model, 'discord.enabled'))
<h4 class="mt-4">Subscribe to events</h4>
<div class="w-64 ">
@if (isDev())
<x-forms.checkbox instantSave="saveModel" id="model.extra_attributes.notifications_discord_test"
<x-forms.checkbox instantSave="saveModel" id="model.discord_notifications.test"
label="Test Notifications" />
@endif
<x-forms.checkbox instantSave="saveModel" id="model.extra_attributes.notifications_discord_deployments"
<x-forms.checkbox instantSave="saveModel" id="model.discord_notifications.deployments"
label="New Deployments" />
</div>
@endif

View File

@ -6,11 +6,11 @@
Save
</x-forms.button>
@if (auth()->user()->isInstanceAdmin())
<x-forms.button wire:click='copySMTP'>
<x-forms.button wire:click='copyFromInstanceSettings'>
Copy from Instance Settings
</x-forms.button>
@endif
@if ($model->extra_attributes->smtp_enabled)
@if ($model->smtp->enabled)
<x-forms.button class="text-white normal-case btn btn-xs no-animation btn-primary"
wire:click="sendTestNotification">
Send Test Notifications
@ -18,49 +18,44 @@
@endif
</div>
<div class="w-48">
<x-forms.checkbox instantSave id="model.extra_attributes.smtp_enabled" label="Notification Enabled" />
<x-forms.checkbox instantSave id="model.smtp.enabled" label="Notification Enabled" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.extra_attributes.smtp_recipients"
placeholder="If empty, all users will be notified in the team."
<x-forms.input id="model.smtp.recipients" placeholder="If empty, all users will be notified in the team."
helper="Email list to send the all notifications to, separated by comma." label="Recipients" />
<x-forms.input id="model.extra_attributes.smtp_test_recipients" label="Test Notification Recipients"
<x-forms.input id="model.smtp.test_recipients" label="Test Notification Recipients"
placeholder="If empty, all users will be notified in the team."
helper="Email list to send the test notification to, separated by comma." />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.extra_attributes.smtp_host" helper="SMTP Hostname"
placeholder="smtp.mailgun.org" label="Host" />
<x-forms.input required id="model.extra_attributes.smtp_port" helper="SMTP Port" placeholder="587"
label="Port" />
<x-forms.input helper="If SMTP through SSL, set it to 'tls'." placeholder="tls"
id="model.extra_attributes.smtp_encryption" label="Encryption" />
<x-forms.input required id="model.smtp.host" helper="SMTP Hostname" placeholder="smtp.mailgun.org"
label="Host" />
<x-forms.input required id="model.smtp.port" helper="SMTP Port" placeholder="587" label="Port" />
<x-forms.input helper="If SMTP through SSL, set it to 'tls'." placeholder="tls" id="model.smtp.encryption"
label="Encryption" />
</div>
<div class="flex flex-col">
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.extra_attributes.smtp_username" helper="SMTP Username" label="Username" />
<x-forms.input type="password" helper="SMTP Password" id="model.extra_attributes.smtp_password"
label="Password" />
<x-forms.input id="model.smtp.username" helper="SMTP Username" label="Username" />
<x-forms.input type="password" helper="SMTP Password" id="model.smtp.password" label="Password" />
</div>
<x-forms.input id="model.extra_attributes.smtp_timeout" helper="Timeout value for sending emails."
label="Timeout" />
<x-forms.input id="model.smtp.timeout" helper="Timeout value for sending emails." label="Timeout" />
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.extra_attributes.smtp_from_name" helper="Name used in emails."
label="From Name" />
<x-forms.input required id="model.extra_attributes.smtp_from_address"
helper="Email address used in emails." label="From Address" />
<x-forms.input required id="model.smtp.from_name" helper="Name used in emails." label="From Name" />
<x-forms.input required id="model.smtp.from_address" helper="Email address used in emails."
label="From Address" />
</div>
</div>
</form>
@if (data_get($model, 'extra_attributes.smtp_enabled'))
@if (data_get($model, 'smtp.enabled'))
<h4 class="mt-4">Subscribe to events</h4>
<div class="w-64 ">
<div class="w-64">
@if (isDev())
<x-forms.checkbox instantSave="saveModel" id="model.extra_attributes.notifications_smtp_test"
<x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications.test"
label="Test Notifications" />
@endif
<x-forms.checkbox instantSave="saveModel" id="model.extra_attributes.notifications_email_deployments"
<x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications.deployments"
label="New Deployments" />
</div>
@endif

View File

@ -8,12 +8,12 @@
</div>
<div class="pt-2 pb-4 ">SMTP settings for password resets, invitations, etc.</div>
<div class="flex flex-col">
<x-forms.checkbox instantSave id="settings.extra_attributes.smtp_enabled" label="Enabled" />
<x-forms.checkbox instantSave id="settings.smtp.enabled" label="Enabled" />
</div>
<div class="flex items-end gap-2">
<x-forms.input id="settings.extra_attributes.smtp_test_recipients" label="Test Recipients"
<x-forms.input id="settings.smtp.test_recipients" label="Test Recipients"
helper="Email list to send a test email to, separated by comma." />
@if ($settings->extra_attributes->smtp_enabled)
@if ($settings->smtp->enabled)
<x-forms.button wire:click='test_email'>
Send Test Email
</x-forms.button>
@ -21,26 +21,22 @@
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<div class="flex flex-col w-full">
<x-forms.input required id="settings.extra_attributes.smtp_host" helper="SMTP Hostname"
placeholder="smtp.mailgun.org" label="Host" />
<x-forms.input required id="settings.extra_attributes.smtp_port" helper="SMTP Port" placeholder="587"
label="Port" />
<x-forms.input id="settings.extra_attributes.smtp_encryption"
helper="If SMTP through SSL, set it to 'tls'." placeholder="tls" label="Encryption" />
<x-forms.input required id="settings.smtp.host" helper="SMTP Hostname" placeholder="smtp.mailgun.org"
label="Host" />
<x-forms.input required id="settings.smtp.port" helper="SMTP Port" placeholder="587" label="Port" />
<x-forms.input id="settings.smtp.encryption" helper="If SMTP through SSL, set it to 'tls'."
placeholder="tls" label="Encryption" />
</div>
<div class="flex flex-col w-full">
<x-forms.input id="settings.extra_attributes.smtp_username" helper="SMTP Username"
label="SMTP Username" />
<x-forms.input id="settings.extra_attributes.smtp_password" type="password" helper="SMTP Password"
<x-forms.input id="settings.smtp.username" helper="SMTP Username" label="SMTP Username" />
<x-forms.input id="settings.smtp.password" type="password" helper="SMTP Password"
label="SMTP Password" />
<x-forms.input id="settings.extra_attributes.smtp_timeout" helper="Timeout value for sending emails."
label="Timeout" />
<x-forms.input id="settings.smtp.timeout" helper="Timeout value for sending emails." label="Timeout" />
</div>
<div class="flex flex-col w-full">
<x-forms.input required id="settings.extra_attributes.smtp_from_name" helper="Name used in emails."
label="From Name" />
<x-forms.input required id="settings.extra_attributes.smtp_from_address"
helper="Email address used in emails." label="From Address" />
<x-forms.input required id="settings.smtp.from_name" helper="Name used in emails." label="From Name" />
<x-forms.input required id="settings.smtp.from_address" helper="Email address used in emails."
label="From Address" />
</div>
</div>
</form>