liberu-genealogy / genealogy-laravel

Full genealogy application using Laravel 11, PHP 8.3, Filament 3.2 and Livewire 3.5
https://www.liberu.net
MIT License
114 stars 59 forks source link

Sweep: copy files from #640

Closed curtisdelicata closed 3 months ago

curtisdelicata commented 3 months ago

Details

Copy files from https://github.com/stephenjude/filament-jetstream/tree/main/stubs%2FApp%2FFilament%2FPages into app/Filament/Pages

sweep-ai[bot] commented 3 months ago

🚀 Here's the PR! #649

💎 Sweep Pro: You have unlimited Sweep issues

Actions

Relevant files (click to expand). Mentioned files will always appear here. https://github.com/liberu-genealogy/genealogy-laravel/blob/22b887bc7aa9a7e7e1dd5dfd11fceb7e76502363/app/Filament/Pages/FanChartPage.php#L1-L31 https://github.com/liberu-genealogy/genealogy-laravel/blob/22b887bc7aa9a7e7e1dd5dfd11fceb7e76502363/app/Filament/Resources/SourceResource/Pages/CreateSource.php#L1-L10 https://github.com/liberu-genealogy/genealogy-laravel/blob/22b887bc7aa9a7e7e1dd5dfd11fceb7e76502363/app/Filament/Pages/FanChartPage.php#L1-L31

Step 2: ⌨️ Coding

app/Filament/Pages/ApiTokensPage.php

Copy the contents of https://github.com/stephenjude/filament-jetstream/blob/main/stubs/App/Filament/Pages/API/ApiTokensPage.php into this new file in the app/Filament/Pages directory.
<?php

namespace App\Filament\Pages;

use App\Models\User;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;

class ApiTokensPage extends Page
{
    protected static string $view = 'filament.pages.api.api-tokens';

    protected static ?string $navigationIcon = 'heroicon-o-key';

    protected static ?string $navigationGroup = 'Account';

    protected static ?int $navigationSort = 2;

    protected static string $title = 'API Tokens';

    public User $user;

    public function mount(): void
    {
        $this->user = Auth::user();
    }

    public function createApiToken(string $name, array $permissions): void
    {
        $this->user->createToken($name, $permissions);
    }

    public function deleteApiToken(string $name): void
    {
        $this->user->tokens()->where('name', $name)->first()->delete();
    }

    protected function getHeading(): string
    {
        return static::$title;
    }

    protected static function shouldRegisterNavigation(): bool
    {
        return config('filament-jetstream.show_api_token_page');
    }
}

app/Filament/Pages/PersonalAccessTokensPage.php

Copy the contents of https://github.com/stephenjude/filament-jetstream/blob/main/stubs/App/Filament/Pages/Profile/PersonalAccessTokensPage.php into this new file in the app/Filament/Pages directory.
<?php

namespace App\Filament\Pages;

use App\Models\User;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;

class PersonalAccessTokensPage extends Page
{
    protected static string $view = 'filament.pages.profile.personal-access-tokens';

    protected static ?string $navigationIcon = 'heroicon-o-key';

    protected static ?string $navigationGroup = 'Account';

    protected static ?int $navigationSort = 3;

    protected static string $title = 'Personal Access Tokens';

    public User $user;

    public function mount(): void
    {
        $this->user = Auth::user();
    }

    public function createApiToken(string $name): void
    {
        $this->user->createToken($name);
    }

    public function deleteApiToken(string $name): void
    {
        $this->user->tokens()->where('name', $name)->first()->delete();
    }

    protected function getHeading(): string
    {
        return static::$title;
    }

    protected static function shouldRegisterNavigation(): bool
    {
        return config('filament-jetstream.show_personal_access_tokens_page');
    }
}

app/Filament/Pages/TwoFactorAuthenticationPage.php

Copy the contents of https://github.com/stephenjude/filament-jetstream/blob/main/stubs/App/Filament/Pages/Profile/TwoFactorAuthenticationPage.php into this new file in the app/Filament/Pages directory.
<?php

namespace App\Filament\Pages;

use App\Models\User;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;

class TwoFactorAuthenticationPage extends Page
{
    protected static string $view = 'filament.pages.profile.two-factor-authentication';

    protected static ?string $navigationIcon = 'heroicon-o-key';

    protected static ?string $navigationGroup = 'Account';

    protected static ?int $navigationSort = 4;

    protected static string $title = 'Two Factor Authentication';

    public User $user;

    public function mount(): void
    {
        $this->user = Auth::user();
    }

    public function enableTwoFactorAuthentication(): void
    {
        $this->user->enableTwoFactorAuthentication();
    }

    public function disableTwoFactorAuthentication(): void
    {
        $this->user->disableTwoFactorAuthentication();
    }

    public function showRecoveryCodes(): void
    {
        $this->user->showRecoveryCodes();
    }

    public function regenerateRecoveryCodes(): void
    {
        $this->user->regenerateRecoveryCodes();
    }

    protected function getHeading(): string
    {
        return static::$title;
    }

    protected static function shouldRegisterNavigation(): bool
    {
        return config('filament-jetstream.show_two_factor_authentication_page');
    }
}

app/Filament/Pages/UpdatePasswordPage.php

Copy the contents of https://github.com/stephenjude/filament-jetstream/blob/main/stubs/App/Filament/Pages/Profile/UpdatePasswordPage.php into this new file in the app/Filament/Pages directory.
<?php

namespace App\Filament\Pages;

use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;

class UpdatePasswordPage extends Page
{
    protected static string $view = 'filament.pages.profile.update-password';

    protected static ?string $navigationIcon = 'heroicon-o-lock-closed';

    protected static ?string $navigationGroup = 'Account';

    protected static ?int $navigationSort = 1;

    protected static string $title = 'Update Password';

    public $current_password;

    public $new_password;

    public $new_password_confirmation;

    public function mount(): void
    {
        $this->form->fill();
    }

    protected function getFormSchema(): array
    {
        return [
            TextInput::make('current_password')
                ->label('Current Password')
                ->password()
                ->rules(['required', 'current_password'])
                ->required(),
            TextInput::make('new_password')
                ->label('New Password')
                ->password()
                ->rules(['required', Password::defaults(), 'confirmed'])
                ->required(),
            TextInput::make('new_password_confirmation')
                ->label('Confirm Password')
                ->password()
                ->rules(['required'])
                ->required(),
        ];
    }

    public function submit(): void
    {
        $this->form->getState();

        $state = array_filter([
            'password' => Hash::make($this->new_password),
        ]);

        $user = Auth::user();

        $user->forceFill($state)->save();

        session()->flash('status', 'Your password has been updated.');
    }

    protected function getHeading(): string
    {
        return static::$title;
    }

    protected static function shouldRegisterNavigation(): bool
    {
        return config('filament-jetstream.show_update_password_page');
    }
}

app/Filament/Pages/UpdateProfileInformationPage.php

Copy the contents of https://github.com/stephenjude/filament-jetstream/blob/main/stubs/App/Filament/Pages/Profile/UpdateProfileInformationPage.php into this new file in the app/Filament/Pages directory.
<?php

namespace App\Filament\Pages;

use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;

class UpdateProfileInformationPage extends Page
{
    protected static string $view = 'filament.pages.profile.update-profile-information';

    protected static ?string $navigationIcon = 'heroicon-o-user';

    protected static ?string $navigationGroup = 'Account';

    protected static ?int $navigationSort = 0;

    protected static string $title = 'Profile';

    public $name;

    public $email;

    public function mount(): void
    {
        $this->form->fill([
            'name' => Auth::user()->name,
            'email' => Auth::user()->email,
        ]);
    }

    protected function getFormSchema(): array
    {
        return [
            TextInput::make('name')
                ->label('Name')
                ->required(),
            TextInput::make('email')
                ->label('Email Address')
                ->required(),
        ];
    }

    public function submit(): void
    {
        $this->form->getState();

        $state = array_filter([
            'name' => $this->name,
            'email' => $this->email,
        ]);

        $user = Auth::user();

        $user->forceFill($state)->save();

        session()->flash('status', 'Your profile has been updated.');
    }

    protected function getHeading(): string
    {
        return static::$title;
    }

    protected static function shouldRegisterNavigation(): bool
    {
        return config('filament-jetstream.show_update_profile_information_page');
    }
}

app/Filament/Pages/FanChartPage.php

--- 
+++ 
@@ -7,26 +7,23 @@

 class FanChartPage extends Page
 {
-    protected static string $view = 'livewire.fan-chart';
-
-    protected static ?string $resource = null;
-
-    protected static ?string $title = ' Fan Charts';
+    protected static string $view = 'filament.pages.fan-chart';

     protected static ?string $navigationIcon = 'heroicon-o-chart-pie';

-    public function getTitle(): string
-    {
-        return static::$title;
-    }
+    protected static ?string $navigationGroup = 'Reports';

-    public static function getNavigationIcon(): string
-    {
-        return static::$navigationIcon;
-    }
+    protected static ?int $navigationSort = 0;
+
+    protected static string $title = 'Fan Chart';

     public function mount(): void
     {
         Livewire::mount(\App\Http\Livewire\FanChart::class);
     }
+
+    protected function getHeading(): string
+    {
+        return static::$title;
+    }
 }

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/copy_files_from. I have validated these changes using a syntax checker and a linter.


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.