GithubHelp home page GithubHelp logo

Sweep: fix definition of class names in AdminPanelProvider.php of ApiTokenManager, CreateTeam, EditProfile as they attempted to load the Provider namespace and not Pages about genealogy-laravel HOT 1 CLOSED

curtisdelicata avatar curtisdelicata commented on August 26, 2024 2
Sweep: fix definition of class names in AdminPanelProvider.php of ApiTokenManager, CreateTeam, EditProfile as they attempted to load the Provider namespace and not Pages

from genealogy-laravel.

Comments (1)

sweep-ai avatar sweep-ai commented on August 26, 2024

🚀 Here's the PR! #696

💎 Sweep Pro: You have unlimited Sweep issues

Actions

  • ↻ Restart Sweep

Step 1: 🔎 Searching

Here are the code search results. I'm now analyzing these search results to write the PR.

Relevant files (click to expand). Mentioned files will always appear here.

<?php
namespace App\Providers\Filament;
use App\Filament\Pages\ApiTokens;
use App\Filament\Pages\CreateTeam;
use App\Filament\Pages\EditProfile;
use App\Filament\Pages\EditTeam;
use App\Listeners\CreatePersonalTeam;
use App\Listeners\SwitchTeam;
use App\Models\Team;
use Filament\Events\Auth\Registered;
use Filament\Events\TenantSet;
use Filament\Facades\Filament;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Navigation\MenuItem;
use Filament\Pages;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Event;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Laravel\Fortify\Fortify;
use Laravel\Jetstream\Features;
use Laravel\Jetstream\Jetstream;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
$panel
->default()
->id('admin')
->path('admin')
->login()
->registration()
->passwordReset()
->emailVerification()
->viteTheme('resources/css/app.css')
->colors([
'primary' => Color::Gray,
])
->userMenuItems([
MenuItem::make()
->label('Profile')
->icon('heroicon-o-user-circle')
->url(fn () => $this->shouldRegisterMenuItem()
? url(EditProfile::getUrl())
: url($panel->getPath())),
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
EditProfile::class,
ApiTokenManager::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
]);
if (Features::hasApiFeatures()) {
$panel->userMenuItems([
MenuItem::make()
->label('API Tokens')
->icon('heroicon-o-key')
->url(fn () => $this->shouldRegisterMenuItem()
? url(ApiTokenManager::getUrl())
: url($panel->getPath())),
]);
}
if (Features::hasTeamFeatures()) {
$panel
->tenant(Team::class)
->tenantRegistration(CreateTeam::class)
->tenantProfile(EditTeam::class)
->userMenuItems([
MenuItem::make()
->label('Team Settings')
->icon('heroicon-o-cog-6-tooth')
->url(fn () => $this->shouldRegisterMenuItem()
? url(EditTeam::getUrl())
: url($panel->getPath())),
]);
}
return $panel;
}
public function boot()
{
/**
* Disable Fortify routes
*/
Fortify::$registersRoutes = false;
/**
* Disable Jetstream routes
*/
Jetstream::$registersRoutes = false;
/**
* Listen and create personal team for new accounts
*/
Event::listen(
Registered::class,
CreatePersonalTeam::class,
);
/**
* Listen and switch team if tenant was changed
*/
Event::listen(
TenantSet::class,
SwitchTeam::class,
);
}
public function shouldRegisterMenuItem(): bool
{
return auth()->user()?->hasVerifiedEmail() && Filament::hasTenancy() && Filament::getTenant();
}

<?php
namespace App\Filament\Pages;
use App\Models\User;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;
class ApiTokenManagerPage extends Page
{
protected static string $view = 'filament.pages.api-token-manager';
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);
$this->notify('success', 'API token created successfully.');
}
public function deleteApiToken(string $name): void
{
$this->user->tokens()->where('name', $name)->first()->delete();
$this->notify('success', 'API token deleted successfully.');
}
public function getHeading(): string
{
return static::$title;
}
public static function shouldRegisterNavigation(): bool
{
return config('filament-jetstream.show_api_token_page');
}

<?php
namespace App\Filament\Pages;
use App\Models\Team;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class CreateTeam extends Page
{
protected static string $view = 'filament.pages.create-team';
public $name = '';
public function mount(): void
{
abort_unless(Filament::auth()->user()->canCreateTeams(), 403);
}
protected function getFormSchema(): array
{
return [
TextInput::make('name')
->label('Team Name')
->required()
->maxLength(255),
];
}
public function submit()
{
$this->validate();
$team = Team::forceCreate([
'user_id' => Filament::auth()->id(),
'name' => $this->name,
'personal_team' => false,
]);
Filament::auth()->user()->teams()->attach($team, ['role' => 'admin']);
Filament::auth()->user()->switchTeam($team);
return redirect()->route('filament.pages.edit-team', ['team' => $team]);
}
public function getBreadcrumbs(): array
{
return [
url()->current() => 'Create Team',
];
}

<?php
namespace App\Filament\Pages;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Hash;
class EditProfile extends Page
{
protected static string $view = 'filament.pages.edit-profile';
public User $user;
public $name = '';
public $email = '';
public function mount()
{
$this->user = Filament::auth()->user();
$this->form->fill([
'name' => $this->user->name,
'email' => $this->user->email,
]);
}
protected function getFormSchema(): array
{
return [
TextInput::make('name')
->label('Name')
->required()
->maxLength(255),
TextInput::make('email')
->label('Email Address')
->required()
->maxLength(255),
];
}
public function submit()
{
$this->validate();
$this->user->forceFill([
'name' => $this->name,
'email' => $this->email,
])->save();
Filament::notify('success', 'Your profile has been updated.');
}
public function getBreadcrumbs(): array
{
return [
url()->current() => 'Edit Profile',
];
}

<?php
namespace App\Filament\Pages;
use App\Models\User;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;
class ApiTokenManagerPage extends Page
{
protected static string $view = 'filament.pages.api-token-manager';
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);
$this->notify('success', 'API token created successfully.');
}
public function deleteApiToken(string $name): void
{
$this->user->tokens()->where('name', $name)->first()->delete();
$this->notify('success', 'API token deleted successfully.');
}
public function getHeading(): string
{
return static::$title;
}
public static function shouldRegisterNavigation(): bool
{
return config('filament-jetstream.show_api_token_page');
}

<?php
namespace App\Filament\Pages;
use App\Models\Team;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class CreateTeam extends Page
{
protected static string $view = 'filament.pages.create-team';
public $name = '';
public function mount(): void
{
abort_unless(Filament::auth()->user()->canCreateTeams(), 403);
}
protected function getFormSchema(): array
{
return [
TextInput::make('name')
->label('Team Name')
->required()
->maxLength(255),
];
}
public function submit()
{
$this->validate();
$team = Team::forceCreate([
'user_id' => Filament::auth()->id(),
'name' => $this->name,
'personal_team' => false,
]);
Filament::auth()->user()->teams()->attach($team, ['role' => 'admin']);
Filament::auth()->user()->switchTeam($team);
return redirect()->route('filament.pages.edit-team', ['team' => $team]);
}
public function getBreadcrumbs(): array
{
return [
url()->current() => 'Create Team',
];
}

<?php
namespace App\Filament\Pages;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Hash;
class EditProfile extends Page
{
protected static string $view = 'filament.pages.edit-profile';
public User $user;
public $name = '';
public $email = '';
public function mount()
{
$this->user = Filament::auth()->user();
$this->form->fill([
'name' => $this->user->name,
'email' => $this->user->email,
]);
}
protected function getFormSchema(): array
{
return [
TextInput::make('name')
->label('Name')
->required()
->maxLength(255),
TextInput::make('email')
->label('Email Address')
->required()
->maxLength(255),
];
}
public function submit()
{
$this->validate();
$this->user->forceFill([
'name' => $this->name,
'email' => $this->email,
])->save();
Filament::notify('success', 'Your profile has been updated.');
}
public function getBreadcrumbs(): array
{
return [
url()->current() => 'Edit Profile',
];
}

<?php
namespace App\Providers\Filament;
use App\Filament\Pages\ApiTokens;
use App\Filament\Pages\CreateTeam;
use App\Filament\Pages\EditProfile;
use App\Filament\Pages\EditTeam;
use App\Listeners\CreatePersonalTeam;
use App\Listeners\SwitchTeam;
use App\Models\Team;
use Filament\Events\Auth\Registered;
use Filament\Events\TenantSet;
use Filament\Facades\Filament;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Navigation\MenuItem;
use Filament\Pages;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Event;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Laravel\Fortify\Fortify;
use Laravel\Jetstream\Features;
use Laravel\Jetstream\Jetstream;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
$panel
->default()
->id('admin')
->path('admin')
->login()
->registration()
->passwordReset()
->emailVerification()
->viteTheme('resources/css/app.css')
->colors([
'primary' => Color::Gray,
])
->userMenuItems([
MenuItem::make()
->label('Profile')
->icon('heroicon-o-user-circle')
->url(fn () => $this->shouldRegisterMenuItem()
? url(EditProfile::getUrl())
: url($panel->getPath())),
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
EditProfile::class,
ApiTokenManager::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
]);
if (Features::hasApiFeatures()) {
$panel->userMenuItems([
MenuItem::make()
->label('API Tokens')
->icon('heroicon-o-key')
->url(fn () => $this->shouldRegisterMenuItem()
? url(ApiTokenManager::getUrl())
: url($panel->getPath())),
]);
}
if (Features::hasTeamFeatures()) {
$panel
->tenant(Team::class)
->tenantRegistration(CreateTeam::class)
->tenantProfile(EditTeam::class)
->userMenuItems([
MenuItem::make()
->label('Team Settings')
->icon('heroicon-o-cog-6-tooth')
->url(fn () => $this->shouldRegisterMenuItem()
? url(EditTeam::getUrl())
: url($panel->getPath())),
]);
}
return $panel;
}
public function boot()
{
/**
* Disable Fortify routes
*/
Fortify::$registersRoutes = false;
/**
* Disable Jetstream routes
*/
Jetstream::$registersRoutes = false;
/**
* Listen and create personal team for new accounts
*/
Event::listen(
Registered::class,
CreatePersonalTeam::class,
);
/**
* Listen and switch team if tenant was changed
*/
Event::listen(
TenantSet::class,
SwitchTeam::class,
);
}
public function shouldRegisterMenuItem(): bool
{
return auth()->user()?->hasVerifiedEmail() && Filament::hasTenancy() && Filament::getTenant();
}

Step 2: ⌨️ Coding

app/Providers/Filament/AdminPanelProvider.php

Update the `use` statements to import the correct classes from the `Pages` namespace.
--- 
+++ 
@@ -1,4 +1,4 @@
-use App\Filament\Pages\ApiTokens;
+use App\Filament\Pages\ApiTokenManagerPage;
 use App\Filament\Pages\CreateTeam;
 use App\Filament\Pages\EditProfile;
 use App\Filament\Pages\EditTeam;

app/Providers/Filament/AdminPanelProvider.php

Update the references to `ApiTokenManager`, `CreateTeam`, and `EditProfile` to use the correct class names from the `Pages` namespace.
--- 
+++ 
@@ -1,5 +1,5 @@
 ->pages([
     Pages\Dashboard::class,
-    EditProfile::class,
-    ApiTokenManager::class,
+    Pages\EditProfile::class,
+    Pages\ApiTokenManagerPage::class,
 ])

app/Providers/Filament/AdminPanelProvider.php

--- 
+++ 
@@ -4,7 +4,7 @@
             ->label('API Tokens')
             ->icon('heroicon-o-key')
             ->url(fn () => $this->shouldRegisterMenuItem()
-                ? url(ApiTokenManager::getUrl())
+                ? url(Pages\ApiTokenManagerPage::getUrl())
                 : url($panel->getPath())),
     ]);
 }

app/Providers/Filament/AdminPanelProvider.php

--- 
+++ 
@@ -1,14 +1,14 @@
 if (Features::hasTeamFeatures()) {
     $panel
         ->tenant(Team::class)
-        ->tenantRegistration(CreateTeam::class)
-        ->tenantProfile(EditTeam::class)
+        ->tenantRegistration(Pages\CreateTeam::class)
+        ->tenantProfile(Pages\EditTeam::class)
         ->userMenuItems([
             MenuItem::make()
                 ->label('Team Settings')
                 ->icon('heroicon-o-cog-6-tooth')
                 ->url(fn () => $this->shouldRegisterMenuItem()
-                    ? url(EditTeam::getUrl())
+                    ? url(Pages\EditTeam::getUrl())
                     : url($panel->getPath())),
         ]);
 }

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/fix_definition_of_class_names_in_adminpa_3c5f6. 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.

from genealogy-laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.