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