From 7a7f6a1871761a4c8afb9ba49364916e4bdb76d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20S=C3=B8rensen?= Date: Wed, 1 May 2024 19:21:06 +0200 Subject: [PATCH 1/7] README fix. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 193ba4c..714fa75 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This is the official repository for [Find A PR](https://findapr.io/). Find A PR The following tools are required in order to start the installation and run the project locally. -- PHP 8.1 +- PHP 8.2 - [Composer](https://getcomposer.org/download/) ## Installation From 1ca51fbe8e1340071ea06ee005e1b9613aade3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20S=C3=B8rensen?= Date: Wed, 1 May 2024 19:22:17 +0200 Subject: [PATCH 2/7] Making the labels in the sidebar clickable and using them as filters. --- app/Livewire/ListIssues.php | 29 +++++++++++++++++++ resources/views/components/side-bar.blade.php | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/Livewire/ListIssues.php b/app/Livewire/ListIssues.php index 1cf54c1..b1777ac 100644 --- a/app/Livewire/ListIssues.php +++ b/app/Livewire/ListIssues.php @@ -78,6 +78,8 @@ final class ListIssues extends Component public ?string $sort = null; + public array $searchLabels = []; + public ?string $searchTerm = null; public bool $shouldDisplayFirstTimeNotice; @@ -104,6 +106,7 @@ public function render(): View { $issues = $this->originalIssues ->filter(fn (Issue $issue): bool => $this->showIgnoredIssues === in_array($issue->url, $this->ignoredUrls, true)) + ->when($this->searchLabels, $this->applySearchLabel()) ->when($this->searchTerm, $this->applySearch()) ->when($this->sort, $this->applySort()); @@ -133,6 +136,32 @@ private function applySearch(): \Closure }; } + private function applySearchLabel(): \Closure + { + return static function (Collection $issues, array $searchLabels) : Collection { + return $issues->filter(function (Issue $issue) use ($searchLabels): bool { + foreach ($searchLabels as $searchLabel) + { + if (collect($issue->labels)->contains('name', $searchLabel)) + { + return true; + } + } + return false; + }); + }; + } + + public function toggleSearchLabel(string $label) + { + $key = array_search($label, $this->searchLabels); + if ($key !== false) { + unset($this->searchLabels[$key]); + } else { + $this->searchLabels[] = $label; + } + } + private function applySort(): \Closure { return function (Collection $issues): Collection { diff --git a/resources/views/components/side-bar.blade.php b/resources/views/components/side-bar.blade.php index 142014d..50e61fa 100644 --- a/resources/views/components/side-bar.blade.php +++ b/resources/views/components/side-bar.blade.php @@ -64,9 +64,9 @@ class="w-full rounded-md border border-gray-300 shadow-sm px-2 py-2 bg-white tex @foreach($labels as $label)
-

+

@endforeach From 5a3c820bf515f631c6046907c8fa0795b49eb6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20S=C3=B8rensen?= Date: Wed, 1 May 2024 19:31:45 +0200 Subject: [PATCH 3/7] styleci fix --- app/Livewire/ListIssues.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Livewire/ListIssues.php b/app/Livewire/ListIssues.php index b1777ac..0659588 100644 --- a/app/Livewire/ListIssues.php +++ b/app/Livewire/ListIssues.php @@ -138,12 +138,10 @@ private function applySearch(): \Closure private function applySearchLabel(): \Closure { - return static function (Collection $issues, array $searchLabels) : Collection { + return static function (Collection $issues, array $searchLabels): Collection { return $issues->filter(function (Issue $issue) use ($searchLabels): bool { - foreach ($searchLabels as $searchLabel) - { - if (collect($issue->labels)->contains('name', $searchLabel)) - { + foreach ($searchLabels as $searchLabel) { + if (collect($issue->labels)->contains('name', $searchLabel)) { return true; } } From c3df9df24d22b280e410428772f6049803d841a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20S=C3=B8rensen?= Date: Wed, 1 May 2024 19:32:50 +0200 Subject: [PATCH 4/7] styleci fix --- app/Livewire/ListIssues.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Livewire/ListIssues.php b/app/Livewire/ListIssues.php index 0659588..3446b93 100644 --- a/app/Livewire/ListIssues.php +++ b/app/Livewire/ListIssues.php @@ -145,6 +145,7 @@ private function applySearchLabel(): \Closure return true; } } + return false; }); }; From 68214db272b151e433a55dd5ed42543f35f38fc7 Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Wed, 21 Aug 2024 11:54:56 +0100 Subject: [PATCH 5/7] Fix naming that I broke when solving a merge conflict. --- resources/views/components/side-bar.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/components/side-bar.blade.php b/resources/views/components/side-bar.blade.php index 0bdc6de..f67c053 100644 --- a/resources/views/components/side-bar.blade.php +++ b/resources/views/components/side-bar.blade.php @@ -64,7 +64,7 @@ class="w-full rounded-md border border-gray-300 shadow-sm px-2 py-2 bg-white tex @foreach($labels as $name => $count)
- From 99254a26738951e74e7e520be41a35e97bf28478 Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Wed, 21 Aug 2024 11:58:26 +0100 Subject: [PATCH 6/7] Add "strict" argument and return type. --- app/Livewire/ListIssues.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Livewire/ListIssues.php b/app/Livewire/ListIssues.php index 0a05d57..425055a 100644 --- a/app/Livewire/ListIssues.php +++ b/app/Livewire/ListIssues.php @@ -157,9 +157,10 @@ private function applySearchLabel(): \Closure }; } - public function toggleSearchLabel(string $label) + public function toggleSearchLabel(string $label): void { - $key = array_search($label, $this->searchLabels); + $key = array_search($label, $this->searchLabels, strict: true); + if ($key !== false) { unset($this->searchLabels[$key]); } else { From bf4d4d09c6b8b9d0f4ba62ed71e26206fec8c761 Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Wed, 21 Aug 2024 12:00:11 +0100 Subject: [PATCH 7/7] Use the @class Blade directive. --- resources/views/components/side-bar.blade.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/views/components/side-bar.blade.php b/resources/views/components/side-bar.blade.php index f67c053..84883a1 100644 --- a/resources/views/components/side-bar.blade.php +++ b/resources/views/components/side-bar.blade.php @@ -64,7 +64,14 @@ class="w-full rounded-md border border-gray-300 shadow-sm px-2 py-2 bg-white tex @foreach($labels as $name => $count)
-