-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ui): share User guest and RBAC section rendering and support selecting filtered tabs. #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PHPForge\Debug\Panel\User; | ||
|
|
||
| use PHPForge\Debug\Helper\EmptyState; | ||
| use UIAwesome\Html\Flow\P; | ||
|
|
||
| /** | ||
| * Renders the framework-neutral Guest state shared by User panels. | ||
| */ | ||
| final class UserGuestRenderer | ||
| { | ||
| /** | ||
| * Renders the complete Guest empty-state card. | ||
| */ | ||
| public static function render(): string | ||
| { | ||
| return EmptyState::card( | ||
| 'No user authenticated in this request', | ||
| P::tag() | ||
| ->content( | ||
| 'The request was served to a guest, so there are no identity attributes, roles, or permissions to inspect.', | ||
| ), | ||
| P::tag() | ||
| ->content( | ||
| 'Sign in and reload to inspect the identity. User switching remains unavailable to guests.', | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PHPForge\Debug\Panel\User; | ||
|
|
||
| use UIAwesome\Html\Heading\H2; | ||
|
|
||
| /** | ||
| * Composes the shared Roles and Permissions section around adapter-owned grid markup. | ||
| */ | ||
| final class UserRbacRenderer | ||
| { | ||
| /** | ||
| * Renders role and permission grids in their canonical order. | ||
| * | ||
| * A `null` grid means that RBAC category was not captured and omits its heading. An empty string means the category | ||
| * was captured with no rows and keeps the heading so the adapter grid may expose its native empty result state. | ||
| * | ||
| * @param string|null $rolesGrid Trusted adapter-rendered Roles grid markup. | ||
| * @param string|null $permissionsGrid Trusted adapter-rendered Permissions grid markup. | ||
| */ | ||
| public static function render(string|null $rolesGrid, string|null $permissionsGrid): string | ||
| { | ||
| $html = ''; | ||
|
|
||
| if ($rolesGrid !== null) { | ||
| $html .= H2::tag() | ||
| ->content('Roles') | ||
| ->render() . $rolesGrid; | ||
| } | ||
|
|
||
| if ($permissionsGrid !== null) { | ||
| $html .= H2::tag() | ||
| ->content('Permissions') | ||
| ->render() . $permissionsGrid; | ||
| } | ||
|
|
||
| return $html; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PHPForge\Debug\Tests\Panel\User; | ||
|
|
||
| use PHPForge\Debug\Panel\User\UserGuestRenderer; | ||
| use PHPUnit\Framework\Attributes\Group; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| /** | ||
| * Unit tests for {@see UserGuestRenderer} freezing the cross-adapter Guest semantics and exact empty-state markup. | ||
| */ | ||
| #[Group('panel')] | ||
| #[Group('user')] | ||
| final class UserGuestRendererTest extends TestCase | ||
| { | ||
| public function testRenderReturnsTheCompleteGuestState(): void | ||
| { | ||
| self::assertSame( | ||
| <<<HTML | ||
| <div class="yii-debug-empty-state"> | ||
| <h2> | ||
| No user authenticated in this request | ||
| </h2><p> | ||
| The request was served to a guest, so there are no identity attributes, roles, or permissions to inspect. | ||
| </p><p> | ||
| Sign in and reload to inspect the identity. User switching remains unavailable to guests. | ||
| </p> | ||
| </div> | ||
| HTML, | ||
| UserGuestRenderer::render(), | ||
| 'Guest rendering must remain identical across framework adapters.', | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PHPForge\Debug\Tests\Panel\User; | ||
|
|
||
| use PHPForge\Debug\Panel\User\UserRbacRenderer; | ||
| use PHPUnit\Framework\Attributes\Group; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| /** | ||
| * Unit tests for {@see UserRbacRenderer} freezing RBAC section ordering and missing-category behavior. | ||
| */ | ||
| #[Group('panel')] | ||
| #[Group('user')] | ||
| final class UserRbacRendererTest extends TestCase | ||
| { | ||
| public function testRenderOmitsOnlyUncapturedSections(): void | ||
| { | ||
| self::assertSame( | ||
| <<<HTML | ||
| <h2> | ||
| Permissions | ||
| </h2> | ||
| HTML, | ||
| UserRbacRenderer::render(null, ''), | ||
| 'A null category must be omitted while a captured empty category keeps its heading.', | ||
| ); | ||
| } | ||
| public function testRenderReturnsBothSectionsInCanonicalOrder(): void | ||
| { | ||
| self::assertSame( | ||
| <<<HTML | ||
| <h2> | ||
| Roles | ||
| </h2><table id="roles"></table><h2> | ||
| Permissions | ||
| </h2><table id="permissions"></table> | ||
| HTML, | ||
| UserRbacRenderer::render( | ||
| '<table id="roles"></table>', | ||
| '<table id="permissions"></table>', | ||
| ), | ||
| 'Roles must precede Permissions with the canonical headings.', | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.