Signed-off-by: Nguyen Van Nguyen <nguyennv1981@gmail.com>
This commit is contained in:
Nguyen Van Nguyen 2024-04-26 09:50:08 +07:00
parent 8d8edc3aeb
commit 954be77bea
5 changed files with 11 additions and 6 deletions

View file

@ -21,16 +21,16 @@ enum UserRole: string implements HasLabel
{ {
case Administrator = 'administrator'; case Administrator = 'administrator';
case Agency = 'agency'; case Agency = 'agency';
case DomainManager = 'domain-manager'; case DomainAdmin = 'domain-admin';
case GroupManager = 'group-manager'; case GroupAdmin = 'group-admin';
public function getLabel(): string public function getLabel(): string
{ {
return match ($this) { return match ($this) {
self::Administrator => __('Administrator'), self::Administrator => __('Administrator'),
self::Agency => __('Agency'), self::Agency => __('Agency'),
self::DomainManager => __('Domain Manager'), self::DomainAdmin => __('Domain Admin'),
self::GroupManager => __('Group Manager'), self::GroupAdmin => __('Group Admin'),
}; };
} }
} }

View file

@ -49,6 +49,8 @@ class ManageZimbraSettings extends SettingsPage
->required()->label(__('Admin User')), ->required()->label(__('Admin User')),
TextInput::make('adminPassword') TextInput::make('adminPassword')
->password()->required()->label(__('Admin Password')), ->password()->required()->label(__('Admin Password')),
TextInput::make('defaultDomain')
->required()->label(__('Default Domain')),
]); ]);
} }

View file

@ -10,7 +10,7 @@ namespace App\Filament\Resources\UserResource\Pages;
use App\Enums\UserRole; use App\Enums\UserRole;
use App\Filament\Resources\UserResource; use App\Filament\Resources\UserResource;
use App\Models\Domain; use App\Settings\ZimbraSettings;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Forms\Components\{ use Filament\Forms\Components\{
Select, Select,
@ -39,7 +39,7 @@ class CreateUser extends CreateRecord
TextInput::make('name')->required()->label(__('Name')), TextInput::make('name')->required()->label(__('Name')),
TextInput::make('email')->email()->required()->unique() TextInput::make('email')->email()->required()->unique()
->endsWith( ->endsWith(
Domain::all()->pluck('name', 'name') app(ZimbraSettings::class)->defaultDomain
)->validationMessages([ )->validationMessages([
'unique' => __('The email address has already been taken.'), 'unique' => __('The email address has already been taken.'),
'ends_with' => __('The email address does not belong to any domains.'), 'ends_with' => __('The email address does not belong to any domains.'),

View file

@ -25,6 +25,8 @@ class ZimbraSettings extends Settings
public string $adminPassword; public string $adminPassword;
public string $defaultDomain;
public static function group(): string public static function group(): string
{ {
return 'zimbra'; return 'zimbra';

View file

@ -9,5 +9,6 @@ return new class extends SettingsMigration
$this->migrator->add('zimbra.serviceUrl', ''); $this->migrator->add('zimbra.serviceUrl', '');
$this->migrator->add('zimbra.adminUser', ''); $this->migrator->add('zimbra.adminUser', '');
$this->migrator->addEncrypted('zimbra.adminPassword', ''); $this->migrator->addEncrypted('zimbra.adminPassword', '');
$this->migrator->add('zimbra.defaultDomain', '');
} }
}; };