Skip to content

Commit

Permalink
Merge pull request #291 from dissto/fix-get-resource-create-fields
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
CodeWithDennis authored Jul 17, 2024
2 parents 17df229 + d48a504 commit a48fc7b
Show file tree
Hide file tree
Showing 17 changed files with 12 additions and 240 deletions.
8 changes: 0 additions & 8 deletions src/Handlers/StubHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ public function getStubs(): Collection
$stubs = [
\CodeWithDennis\FilamentTests\Stubs\SetupStub::make($resource)->get(),

\CodeWithDennis\FilamentTests\Stubs\Page\Auth\Registration\Render::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Page\Auth\Registration\Register::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Page\Auth\PasswordReset\Render::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Page\Auth\PasswordReset\Reset::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Page\Auth\Login\Render::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Page\Auth\Login\Login::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Page\Auth\Logout\Logout::make($resource)->get(),

\CodeWithDennis\FilamentTests\Stubs\Resource\Page\Index\Render::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Resource\Page\Index\ListRecords::make($resource)->get(),
\CodeWithDennis\FilamentTests\Stubs\Resource\Page\Index\ListRecordsPaginated::make($resource)->get(),
Expand Down
46 changes: 10 additions & 36 deletions src/Stubs/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace CodeWithDennis\FilamentTests\Stubs;

use Closure;
use Filament\Facades\Filament;
use Filament\Forms\Form;
use Filament\Resources\Pages\CreateRecord;
use Filament\Resources\Pages\EditRecord;
Expand Down Expand Up @@ -274,6 +273,11 @@ public function getResourceCreateFormRequiredFields(Resource $resource): Collect
->filter(fn ($field) => $field->isRequired());
}

public function getResourceCreateFields(Resource $resource): Collection
{
return collect($this->getResourceCreateForm($resource)->getFlatFields(withHidden: true));
}

public function getResourceEditFormRequiredFields(Resource $resource): Collection
{
return collect($this->getResourceEditForm($resource)->getFlatFields())
Expand All @@ -285,6 +289,11 @@ public function getResourceCreateFormFields(Resource $resource): Collection
return collect($this->getResourceCreateForm($resource)->getFlatFields(withHidden: true));
}

public function getResourceEditFields(Resource $resource): Collection
{
return collect($this->getResourceEditForm($resource)->getFlatFields(withHidden: true));
}

public function getResourceCreateFormVisibleFields(Resource $resource): Collection
{
return collect($this->getResourceCreateForm($resource)->getFlatFields());
Expand Down Expand Up @@ -803,41 +812,6 @@ public function hasTableFilter(string $filter, Table $table): bool
return $this->getResourceTableFilters($table)->map(fn ($filter) => $filter->getName())->contains($filter);
}

public function getRegistrationRouteAction(): ?string
{
return Filament::getDefaultPanel()?->getRegistrationRouteAction();
}

public function hasRegistration(): bool
{
return Filament::hasRegistration();
}

public function getRequestPasswordResetRouteAction(): ?string
{
return Filament::getDefaultPanel()?->getRequestPasswordResetRouteAction();
}

public function hasPasswordReset(): bool
{
return Filament::hasPasswordReset();
}

public function getLoginRouteAction(): ?string
{
return Filament::getDefaultPanel()?->getLoginRouteAction();
}

public function getPanelPath(): ?string
{
return Filament::getDefaultPanel()?->getPath();
}

public function hasLogin(): bool
{
return Filament::hasLogin();
}

// TODO: implement
public function hasRelationManagers(): bool
{
Expand Down
21 changes: 0 additions & 21 deletions src/Stubs/Page/Auth/Login/Login.php

This file was deleted.

28 changes: 0 additions & 28 deletions src/Stubs/Page/Auth/Login/Render.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Stubs/Page/Auth/Logout/Logout.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Stubs/Page/Auth/PasswordReset/Render.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Stubs/Page/Auth/PasswordReset/Reset.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/Stubs/Page/Auth/Registration/Register.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Stubs/Page/Auth/Registration/Render.php

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/Page/Auth/Login/Login.stub

This file was deleted.

6 changes: 0 additions & 6 deletions stubs/Page/Auth/Login/Render.stub

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/Page/Auth/Logout/Logout.stub

This file was deleted.

6 changes: 0 additions & 6 deletions stubs/Page/Auth/PasswordReset/Render.stub

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/Page/Auth/PasswordReset/Reset.stub

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/Page/Auth/Registration/Register.stub

This file was deleted.

6 changes: 0 additions & 6 deletions stubs/Page/Auth/Registration/Render.stub

This file was deleted.

4 changes: 2 additions & 2 deletions stubs/Setup.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use Filament\Tables\Actions\{
ForceDeleteBulkAction
};

uses()->group('filament-tests');

use function Pest\Laravel\{actingAs};
use function Pest\Livewire\livewire;

uses()->group('filament-tests');

beforeEach(function () {
actingAs(User::factory()->create());
});

0 comments on commit a48fc7b

Please sign in to comment.