mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 15:34:44 +02:00
Fix EditProfile
This commit is contained in:
parent
cd88d23592
commit
779ee72ab5
@ -18,7 +18,6 @@ use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
@ -34,6 +33,8 @@ use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
@ -64,14 +65,12 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getForms(): array
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
$oauthProviders = collect(OAuthProvider::get())->filter(fn (OAuthProvider $provider) => $provider->isEnabled())->all();
|
||||
|
||||
return [
|
||||
'form' => $this->form(
|
||||
$this->makeForm()
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make()->persistTabInQueryString()
|
||||
->schema([
|
||||
Tab::make(trans('profile.tabs.account'))
|
||||
@ -131,20 +130,20 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
->options(fn (LanguageService $languageService) => $languageService->getAvailableLanguages())
|
||||
->native(false),
|
||||
FileUpload::make('avatar')
|
||||
->visible(fn () => config('panel.filament.uploadable-avatars'))
|
||||
->avatar()
|
||||
->acceptedFileTypes(['image/png'])
|
||||
->directory('avatars')
|
||||
->getUploadedFileNameForStorageUsing(fn () => $this->getUser()->id . '.png')
|
||||
->hintAction(function (FileUpload $fileUpload) {
|
||||
/* TODO ->hintAction(function (FileUpload $fileUpload) {
|
||||
$path = $fileUpload->getDirectory() . '/' . $this->getUser()->id . '.png';
|
||||
|
||||
return Action::make('remove_avatar')
|
||||
->icon('tabler-photo-minus')
|
||||
->iconButton()
|
||||
->hidden(fn () => !$fileUpload->getDisk()->exists($path))
|
||||
->action(fn () => $fileUpload->getDisk()->delete($path));
|
||||
}),
|
||||
->action(fn () => $fileUpload->getDisk()->delete($path))
|
||||
;
|
||||
}) */,
|
||||
]),
|
||||
|
||||
Tab::make(trans('profile.tabs.oauth'))
|
||||
@ -163,7 +162,7 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
$actions[] = Action::make("oauth_$id")
|
||||
->label(($unlink ? trans('profile.unlink') : trans('profile.link')) . $name)
|
||||
->icon($unlink ? 'tabler-unlink' : 'tabler-link')
|
||||
->color(Color::hex($oauthProvider->getHexColor()))
|
||||
// TODO ->color(Color::hex($oauthProvider->getHexColor()))
|
||||
->action(function (UserUpdateService $updateService) use ($id, $name, $unlink) {
|
||||
if ($unlink) {
|
||||
$oauth = auth()->user()->oauth;
|
||||
@ -247,7 +246,7 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
return [
|
||||
TextEntry::make('qr')
|
||||
->label(trans('profile.scan_qr'))
|
||||
->content(fn () => new HtmlString("
|
||||
->state(fn () => new HtmlString("
|
||||
<div style='width: 300px; background-color: rgb(24, 24, 27);'>$image</div>
|
||||
"))
|
||||
->helperText(trans('profile.setup_key') .': '. $secret),
|
||||
@ -266,7 +265,7 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
Tab::make(trans('profile.tabs.api_keys'))
|
||||
->icon('tabler-key')
|
||||
->schema([
|
||||
Grid::make('name')->columns(5)->schema([
|
||||
Grid::make(5)->schema([
|
||||
Section::make(trans('profile.create_key'))->columnSpan(3)->schema([
|
||||
TextInput::make('description')
|
||||
->label(trans('profile.description'))
|
||||
@ -323,7 +322,7 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
$component->callAfterStateUpdated();
|
||||
});
|
||||
})
|
||||
->schema(fn () => [
|
||||
->schema([
|
||||
TextEntry::make('adf')->label(fn (ApiKey $key) => $key->memo),
|
||||
]),
|
||||
]),
|
||||
@ -345,7 +344,7 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
$query->orderBy('timestamp', 'desc');
|
||||
})
|
||||
->schema([
|
||||
TextEntry::make('activity!')->label('')->content(fn (ActivityLog $log) => new HtmlString($log->htmlable())),
|
||||
TextEntry::make('activity!')->label('')->state(fn (ActivityLog $log) => new HtmlString($log->htmlable())),
|
||||
]),
|
||||
]),
|
||||
|
||||
@ -394,9 +393,7 @@ class EditProfile extends \Filament\Auth\Pages\EditProfile
|
||||
->operation('edit')
|
||||
->model($this->getUser())
|
||||
->statePath('data')
|
||||
->inlineLabel(!static::isSimple()),
|
||||
),
|
||||
];
|
||||
->inlineLabel(!static::isSimple());
|
||||
}
|
||||
|
||||
protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
|
Loading…
x
Reference in New Issue
Block a user