refactor: Pages ビューを責務ごとにパーシャル分割 - #188
Merged
Merged
Conversation
resources/views/livewire/pages.blade.php に「フィルタUI」「検索結果一覧」 「ページネーション」の3つの責務が同居しており、ページネーションリンクの マークアップも2箇所(一覧の上下)に丸ごと重複していた。 - pages-filter.blade.php: キーワード入力・pak/siteチェックボックス・ 検索/リセットボタン - pages-results.blade.php: 検索結果一覧 - pages-pagination.blade.php: ページネーションリンク(上下で@includeし 重複を解消) Livewireのネストコンポーネント化・Islands化も検討したが、 - ネストコンポーネント化: LengthAwarePaginatorをpropとして安全に渡す 組み込みSynthesizerが無く、シリアライズ周りのリスクが増える割に、 ページ規模的に恩恵が薄い - Islands化: このページでは検索条件を変えると結果自体が必ず変わるため 再描画範囲を絞る効果がほぼ無く、目的に合わない と判断し、PHPクラス(Pages.php)の状態管理・#[Computed]等は一切変更せず、 Bladeテンプレートの整理のみに留めた。既存のPagesTest 8件を含む全テストが そのまま通ることを確認済み($this->pagesが@includeパーシャル内でも 問題なく解決されることも実地確認)。
Owner
Author
|
セルフレビュー実施(前回同様、並列調査エージェントは月間API利用上限で使えなかったため自分で直接検証)。パーシャル分割前後でBladeマークアップが完全に一致していること、 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
resources/views/livewire/pages.blade.phpに「フィルタUI」「検索結果一覧」「ページネーション」の3つの責務が同居しており、ページネーションリンクのマークアップも一覧の上下2箇所に丸ごと重複していた。resources/views/livewire/partials/配下にpages-filter.blade.php(フィルタUI)・pages-results.blade.php(検索結果一覧)・pages-pagination.blade.php(ページネーションリンク、上下で@includeし重複を解消)を切り出し、pages.blade.phpはそれらを@includeするだけの構成に整理した。LengthAwarePaginatorを安全にpropとして渡す組み込みSynthesizerが無く(Eloquent Model/Collectionにはあるが、Paginatorには無いことをvendorソースで確認済み)、シリアライズ周りのリスクが増える割に、このページの規模では恩恵が薄い。onConditionUpdateが実行されると常に一覧も更新される)ため、再描画範囲を絞る効果がほぼ無く、目的に合わない。Pages.php(PHPクラス側の状態管理・#[Computed]・バリデーション等)は一切変更せず、Bladeテンプレートの整理のみに留めた。E:\chore\best_practice\livewire.md のアンチパターンチェックリスト(3)に基づく対応。
Test plan
./vendor/bin/pint --test./vendor/bin/phpstan analyse(level 9, 全体, エラーなし)./vendor/bin/rector process --dry-run(変更対象ファイルに提案なし)php artisan test(65件全て通過。$this->pagesが@includeパーシャル内でも問題なく解決されることを含め、既存のPagesTest 8件がそのまま通ることを確認)🤖 Generated with Claude Code