mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-08 23:59:29 +01:00
Cleanup
This commit is contained in:
parent
2ba50e616c
commit
53599feff9
@ -44,4 +44,10 @@ class AvatarService
|
|||||||
|
|
||||||
$this->schemas[$schema->getId()] = $schema;
|
$this->schemas[$schema->getId()] = $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array<string, string> */
|
||||||
|
public function getMapping(): array
|
||||||
|
{
|
||||||
|
return collect($this->schemas)->mapWithKeys(fn ($schema) => [$schema->getId() => $schema->getName()])->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Extensions\Features;
|
namespace App\Extensions\Features;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
|
||||||
class FeatureService
|
class FeatureService
|
||||||
{
|
{
|
||||||
/** @var FeatureSchemaInterface[] */
|
/** @var FeatureSchemaInterface[] */
|
||||||
@ -28,4 +30,12 @@ class FeatureService
|
|||||||
|
|
||||||
$this->schemas[$schema->getId()] = $schema;
|
$this->schemas[$schema->getId()] = $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array<string, array<string>> */
|
||||||
|
public function getMappings(Server $server): array
|
||||||
|
{
|
||||||
|
return collect($this->get($server->egg->features))->mapWithKeys(fn (FeatureSchemaInterface $schema) => [
|
||||||
|
$schema->getId() => $schema->getListeners(),
|
||||||
|
])->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,10 @@ interface OAuthSchemaInterface
|
|||||||
{
|
{
|
||||||
public function getId(): string;
|
public function getId(): string;
|
||||||
|
|
||||||
|
public function getName(): string;
|
||||||
|
|
||||||
|
public function getConfigKey(): string;
|
||||||
|
|
||||||
/** @return ?class-string */
|
/** @return ?class-string */
|
||||||
public function getSocialiteProvider(): ?string;
|
public function getSocialiteProvider(): ?string;
|
||||||
|
|
||||||
@ -23,8 +27,6 @@ interface OAuthSchemaInterface
|
|||||||
/** @return Step[] */
|
/** @return Step[] */
|
||||||
public function getSetupSteps(): array;
|
public function getSetupSteps(): array;
|
||||||
|
|
||||||
public function getName(): string;
|
|
||||||
|
|
||||||
public function getIcon(): ?string;
|
public function getIcon(): ?string;
|
||||||
|
|
||||||
public function getHexColor(): ?string;
|
public function getHexColor(): ?string;
|
||||||
|
|||||||
@ -6,8 +6,10 @@ final class CommonSchema extends OAuthSchema
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly string $id,
|
private readonly string $id,
|
||||||
private readonly ?string $icon,
|
private readonly ?string $name = null,
|
||||||
private readonly ?string $hexColor
|
private readonly ?string $configName = null,
|
||||||
|
private readonly ?string $icon = null,
|
||||||
|
private readonly ?string $hexColor = null
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function getId(): string
|
public function getId(): string
|
||||||
@ -15,6 +17,16 @@ final class CommonSchema extends OAuthSchema
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return $this->name ?? parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConfigKey(): string
|
||||||
|
{
|
||||||
|
return $this->configName ?? parent::getConfigKey();
|
||||||
|
}
|
||||||
|
|
||||||
public function getIcon(): ?string
|
public function getIcon(): ?string
|
||||||
{
|
{
|
||||||
return $this->icon;
|
return $this->icon;
|
||||||
|
|||||||
@ -76,6 +76,13 @@ abstract class OAuthSchema implements OAuthSchemaInterface
|
|||||||
return Str::title($this->getId());
|
return Str::title($this->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfigKey(): string
|
||||||
|
{
|
||||||
|
$id = Str::upper($this->getId());
|
||||||
|
|
||||||
|
return "OAUTH_{$id}_ENABLED";
|
||||||
|
}
|
||||||
|
|
||||||
public function getIcon(): ?string
|
public function getIcon(): ?string
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -180,7 +180,7 @@ class Settings extends Page implements HasForms
|
|||||||
Select::make('FILAMENT_AVATAR_PROVIDER')
|
Select::make('FILAMENT_AVATAR_PROVIDER')
|
||||||
->label(trans('admin/setting.general.avatar_provider'))
|
->label(trans('admin/setting.general.avatar_provider'))
|
||||||
->native(false)
|
->native(false)
|
||||||
->options(collect($this->avatarService->get())->mapWithKeys(fn ($schema) => [$schema->getId() => $schema->getName()]))
|
->options($this->avatarService->getMapping())
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->default(env('FILAMENT_AVATAR_PROVIDER', config('panel.filament.avatar-provider'))),
|
->default(env('FILAMENT_AVATAR_PROVIDER', config('panel.filament.avatar-provider'))),
|
||||||
Toggle::make('FILAMENT_UPLOADABLE_AVATARS')
|
Toggle::make('FILAMENT_UPLOADABLE_AVATARS')
|
||||||
@ -535,36 +535,34 @@ class Settings extends Page implements HasForms
|
|||||||
$oauthSchemas = $this->oauthService->get();
|
$oauthSchemas = $this->oauthService->get();
|
||||||
foreach ($oauthSchemas as $schema) {
|
foreach ($oauthSchemas as $schema) {
|
||||||
$id = Str::upper($schema->getId());
|
$id = Str::upper($schema->getId());
|
||||||
$name = Str::title($schema->getId());
|
$key = $schema->getConfigKey();
|
||||||
|
|
||||||
$formFields[] = Section::make($name)
|
$formFields[] = Section::make($schema->getName())
|
||||||
->columns(5)
|
->columns(5)
|
||||||
->icon($schema->getIcon() ?? 'tabler-brand-oauth')
|
->icon($schema->getIcon() ?? 'tabler-brand-oauth')
|
||||||
->collapsed(fn () => !env("OAUTH_{$id}_ENABLED", false))
|
->collapsed(fn () => !env($key, false))
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
Hidden::make("OAUTH_{$id}_ENABLED")
|
Hidden::make($key)
|
||||||
->live()
|
->live()
|
||||||
->default(env("OAUTH_{$id}_ENABLED")),
|
->default(env($key)),
|
||||||
Actions::make([
|
Actions::make([
|
||||||
FormAction::make("disable_oauth_$id")
|
FormAction::make("disable_oauth_$id")
|
||||||
->visible(fn (Get $get) => $get("OAUTH_{$id}_ENABLED"))
|
->visible(fn (Get $get) => $get($key))
|
||||||
->label(trans('admin/setting.oauth.disable'))
|
->label(trans('admin/setting.oauth.disable'))
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->action(function (Set $set) use ($id) {
|
->action(fn (Set $set) => $set($key, false)),
|
||||||
$set("OAUTH_{$id}_ENABLED", false);
|
|
||||||
}),
|
|
||||||
FormAction::make("enable_oauth_$id")
|
FormAction::make("enable_oauth_$id")
|
||||||
->visible(fn (Get $get) => !$get("OAUTH_{$id}_ENABLED"))
|
->visible(fn (Get $get) => !$get($key))
|
||||||
->label(trans('admin/setting.oauth.enable'))
|
->label(trans('admin/setting.oauth.enable'))
|
||||||
->color('success')
|
->color('success')
|
||||||
->steps($schema->getSetupSteps())
|
->steps($schema->getSetupSteps())
|
||||||
->modalHeading(trans('admin/setting.oauth.enable') . ' ' . $name)
|
->modalHeading(trans('admin/setting.oauth.enable') . ' ' . $schema->getName())
|
||||||
->modalSubmitActionLabel(trans('admin/setting.oauth.enable'))
|
->modalSubmitActionLabel(trans('admin/setting.oauth.enable'))
|
||||||
->modalCancelAction(false)
|
->modalCancelAction(false)
|
||||||
->action(function ($data, Set $set) use ($id) {
|
->action(function ($data, Set $set) use ($key) {
|
||||||
$data = array_merge([
|
$data = array_merge([
|
||||||
"OAUTH_{$id}_ENABLED" => 'true',
|
$key => 'true',
|
||||||
], $data);
|
], $data);
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
@ -573,7 +571,7 @@ class Settings extends Page implements HasForms
|
|||||||
}),
|
}),
|
||||||
])->columnSpan(1),
|
])->columnSpan(1),
|
||||||
Group::make($schema->getSettingsForm())
|
Group::make($schema->getSettingsForm())
|
||||||
->visible(fn (Get $get) => $get("OAUTH_{$id}_ENABLED"))
|
->visible(fn (Get $get) => $get($key))
|
||||||
->columns(4)
|
->columns(4)
|
||||||
->columnSpan(4),
|
->columnSpan(4),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -69,10 +69,11 @@ class Console extends Page
|
|||||||
public function mountFeature(string $data): void
|
public function mountFeature(string $data): void
|
||||||
{
|
{
|
||||||
$data = json_decode($data);
|
$data = json_decode($data);
|
||||||
$feature = data_get($data, 'key');
|
//$feature = data_get($data, 'key');
|
||||||
|
|
||||||
|
$feature = 'test';
|
||||||
$feature = $this->featureService->get($feature);
|
$feature = $this->featureService->get($feature);
|
||||||
if ($this->getMountedAction()) {
|
if (/*!$feature || */ $this->getMountedAction()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->mountAction($feature->getId());
|
$this->mountAction($feature->getId());
|
||||||
|
|||||||
@ -18,14 +18,14 @@ class OAuthServiceProvider extends ServiceProvider
|
|||||||
$this->app->singleton(OAuthService::class, function ($app) {
|
$this->app->singleton(OAuthService::class, function ($app) {
|
||||||
$service = new OAuthService();
|
$service = new OAuthService();
|
||||||
// Default OAuth providers included with Socialite
|
// Default OAuth providers included with Socialite
|
||||||
$service->register(new CommonSchema('facebook', 'tabler-brand-facebook-f', '#1877f2'));
|
$service->register(new CommonSchema('facebook', icon: 'tabler-brand-facebook-f', hexColor: '#1877f2'));
|
||||||
$service->register(new CommonSchema('x', 'tabler-brand-x-f', '#1da1f2'));
|
$service->register(new CommonSchema('x', icon: 'tabler-brand-x-f', hexColor: '#1da1f2'));
|
||||||
$service->register(new CommonSchema('linkedin', 'tabler-brand-linkedin-f', '#0a66c2'));
|
$service->register(new CommonSchema('linkedin', icon: 'tabler-brand-linkedin-f', hexColor: '#0a66c2'));
|
||||||
$service->register(new CommonSchema('google', 'tabler-brand-google-f', '#4285f4'));
|
$service->register(new CommonSchema('google', icon: 'tabler-brand-google-f', hexColor: '#4285f4'));
|
||||||
$service->register(new GithubSchema());
|
$service->register(new GithubSchema());
|
||||||
$service->register(new GitlabSchema());
|
$service->register(new GitlabSchema());
|
||||||
$service->register(new CommonSchema('bitbucket', 'tabler-brand-bitbucket-f', '#205081'));
|
$service->register(new CommonSchema('bitbucket', icon: 'tabler-brand-bitbucket-f', hexColor: '#205081'));
|
||||||
$service->register(new CommonSchema('slack', 'tabler-brand-slack', '#6ecadc'));
|
$service->register(new CommonSchema('slack', icon: 'tabler-brand-slack', hexColor: '#6ecadc'));
|
||||||
|
|
||||||
// Additional OAuth providers from socialiteproviders.com
|
// Additional OAuth providers from socialiteproviders.com
|
||||||
$service->register(new AuthentikSchema());
|
$service->register(new AuthentikSchema());
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
namespace App\Services\Servers;
|
namespace App\Services\Servers;
|
||||||
|
|
||||||
use App\Extensions\Features\FeatureService;
|
use App\Extensions\Features\FeatureService;
|
||||||
use App\Extensions\Features\FeatureSchemaInterface;
|
|
||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use App\Models\Mount;
|
use App\Models\Mount;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@ -61,7 +60,7 @@ class ServerConfigurationStructureService
|
|||||||
* default: array{ip: string, port: int},
|
* default: array{ip: string, port: int},
|
||||||
* mappings: array<int>,
|
* mappings: array<int>,
|
||||||
* },
|
* },
|
||||||
* egg: array{id: string, file_denylist: string[]},
|
* egg: array{id: string, file_denylist: string[], features: string[][]},
|
||||||
* labels?: string[],
|
* labels?: string[],
|
||||||
* mounts: array{source: string, target: string, read_only: bool},
|
* mounts: array{source: string, target: string, read_only: bool},
|
||||||
* }
|
* }
|
||||||
@ -104,9 +103,7 @@ class ServerConfigurationStructureService
|
|||||||
'egg' => [
|
'egg' => [
|
||||||
'id' => $server->egg->uuid,
|
'id' => $server->egg->uuid,
|
||||||
'file_denylist' => $server->egg->inherit_file_denylist,
|
'file_denylist' => $server->egg->inherit_file_denylist,
|
||||||
'features' => collect($this->featureService->get($server->egg->features))->mapWithKeys(fn (FeatureSchemaInterface $feature) => [
|
'features' => $this->featureService->getMappings($server),
|
||||||
$feature->getId() => $feature->getListeners(),
|
|
||||||
])->all(),
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -17,5 +17,6 @@
|
|||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"tailwindcss": "^3.4.13",
|
"tailwindcss": "^3.4.13",
|
||||||
"vite": "^6.0"
|
"vite": "^6.0"
|
||||||
}
|
},
|
||||||
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user