Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/Filament/Admin/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use App\Traits\Filament\CanCustomizeHeaderWidgets;
use App\Traits\Filament\CanCustomizeTabs;
use BackedEnum;
use BladeUI\Icons\Exceptions\SvgNotFound;
use BladeUI\Icons\Factory as IconFactory;
use Exception;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
Expand Down Expand Up @@ -68,6 +70,8 @@ class Settings extends Page implements HasSchemas

protected CaptchaService $captchaService;

protected IconFactory $iconFactory;

/** @var array<mixed>|null */
public ?array $data = [];

Expand All @@ -76,11 +80,12 @@ public function mount(): void
$this->form->fill();
}

public function boot(OAuthService $oauthService, AvatarService $avatarService, CaptchaService $captchaService): void
public function boot(OAuthService $oauthService, AvatarService $avatarService, CaptchaService $captchaService, IconFactory $iconFactory): void
{
$this->oauthService = $oauthService;
$this->avatarService = $avatarService;
$this->captchaService = $captchaService;
$this->iconFactory = $iconFactory;
}

public static function canAccess(): bool
Expand Down Expand Up @@ -565,9 +570,18 @@ private function oauthSettings(): array
foreach ($oauthSchemas as $schema) {
$key = $schema->getConfigKey();

$icon = $schema->getIcon();
if (is_string($icon)) {
try {
$this->iconFactory->svg($icon);
} catch (SvgNotFound) {
$icon = null;
}
}

$formFields[] = Section::make($schema->getName())
->columns(5)
->icon($schema->getIcon() ?? TablerIcon::BrandOauth)
->icon($icon ?? TablerIcon::BrandOauth)
->collapsed(fn () => !$schema->isEnabled())
->collapsible()
->schema([
Expand Down
18 changes: 16 additions & 2 deletions app/Filament/Pages/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use App\Extensions\Captcha\CaptchaService;
use App\Extensions\OAuth\OAuthService;
use BladeUI\Icons\Exceptions\SvgNotFound;
use BladeUI\Icons\Factory as IconFactory;
use Filament\Actions\Action;
use Filament\Auth\Pages\Login as BaseLogin;
use Filament\Forms\Components\TextInput;
Expand All @@ -19,10 +21,13 @@ class Login extends BaseLogin

protected CaptchaService $captchaService;

public function boot(OAuthService $oauthService, CaptchaService $captchaService): void
protected IconFactory $iconFactory;

public function boot(OAuthService $oauthService, CaptchaService $captchaService, IconFactory $iconFactory): void
{
$this->oauthService = $oauthService;
$this->captchaService = $captchaService;
$this->iconFactory = $iconFactory;
}

public function form(Schema $schema): Schema
Expand Down Expand Up @@ -87,9 +92,18 @@ protected function getOAuthFormComponent(): Component
$color = $schema->getHexColor();
$color = is_string($color) ? Color::hex($color) : null;

$icon = $schema->getIcon();
if (is_string($icon)) {
try {
$this->iconFactory->svg($icon);
} catch (SvgNotFound) {
$icon = null;
}
}

$actions[] = Action::make("oauth_$id")
->label($schema->getName())
->icon($schema->getIcon())
->icon($icon)
->color($color)
->url(route('auth.oauth.redirect', ['driver' => $id], false));
}
Expand Down