This commit is contained in:
Andras Bacsai
2023-06-01 13:24:20 +02:00
parent 0aa816b4f2
commit 6e094eaf42
10 changed files with 65 additions and 64 deletions

View File

@@ -13,11 +13,11 @@ class DiscordSettings extends Component
public Team|Server $model;
protected $rules = [
'model.smtp_attributes.discord_active' => 'nullable|boolean',
'model.smtp_attributes.discord_webhook' => 'required|url',
'model.extra_attributes.discord_active' => 'nullable|boolean',
'model.extra_attributes.discord_webhook' => 'required|url',
];
protected $validationAttributes = [
'model.smtp_attributes.discord_webhook' => 'Discord Webhook',
'model.extra_attributes.discord_webhook' => 'Discord Webhook',
];
public function mount($model)
{
@@ -28,8 +28,8 @@ class DiscordSettings extends Component
try {
$this->submit();
} catch (\Exception $e) {
$this->model->smtp_attributes->discord_active = false;
$this->addError('model.smtp_attributes.discord_webhook', $e->getMessage());
$this->model->extra_attributes->discord_active = false;
$this->validate();
}
}
private function saveModel()

View File

@@ -13,27 +13,27 @@ class EmailSettings extends Component
public Team|Server $model;
protected $rules = [
'model.smtp_attributes.smtp_active' => 'nullable|boolean',
'model.smtp_attributes.from_address' => 'required',
'model.smtp_attributes.from_name' => 'required',
'model.smtp_attributes.recipients' => 'required',
'model.smtp_attributes.smtp_host' => 'required',
'model.smtp_attributes.smtp_port' => 'required',
'model.smtp_attributes.smtp_encryption' => 'nullable',
'model.smtp_attributes.smtp_username' => 'nullable',
'model.smtp_attributes.smtp_password' => 'nullable',
'model.smtp_attributes.smtp_timeout' => 'nullable',
'model.smtp_attributes.test_address' => 'nullable',
'model.extra_attributes.smtp_active' => 'nullable|boolean',
'model.extra_attributes.from_address' => 'required|email',
'model.extra_attributes.from_name' => 'required',
'model.extra_attributes.recipients' => 'required',
'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.test_notification_email' => 'nullable|email',
];
protected $validationAttributes = [
'model.smtp_attributes.from_address' => 'From Address',
'model.smtp_attributes.from_name' => 'From Name',
'model.smtp_attributes.recipients' => 'Recipients',
'model.smtp_attributes.smtp_host' => 'Host',
'model.smtp_attributes.smtp_port' => 'Port',
'model.smtp_attributes.smtp_encryption' => 'Encryption',
'model.smtp_attributes.smtp_username' => 'Username',
'model.smtp_attributes.smtp_password' => 'Password',
'model.extra_attributes.from_address' => 'From Address',
'model.extra_attributes.from_name' => 'From Name',
'model.extra_attributes.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',
];
public function mount($model)
{
@@ -54,6 +54,11 @@ class EmailSettings extends Component
}
public function instantSave()
{
$this->saveModel();
try {
$this->submit();
} catch (\Exception $e) {
$this->model->extra_attributes->smtp_active = false;
$this->validate();
}
}
}