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 diff --git a/app/Livewire/ListIssues.php b/app/Livewire/ListIssues.php index d6cc235..425055a 100644 --- a/app/Livewire/ListIssues.php +++ b/app/Livewire/ListIssues.php @@ -79,6 +79,8 @@ final class ListIssues extends Component public ?string $sort = null; + public array $searchLabels = []; + public ?string $searchTerm = null; public bool $shouldDisplayFirstTimeNotice; @@ -106,6 +108,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()); @@ -139,6 +142,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): void + { + $key = array_search($label, $this->searchLabels, strict: true); + + 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 87a3d30..84883a1 100644 --- a/resources/views/components/side-bar.blade.php +++ b/resources/views/components/side-bar.blade.php @@ -64,10 +64,17 @@ class="w-full rounded-md border border-gray-300 shadow-sm px-2 py-2 bg-white tex @foreach($labels as $name => $count)
+
+