Skip to content

Commit 0c5537c

Browse files
authored
[dx] Add rule counter to /find-rule (#2721)
* add rule counters * remove play and learn from menu, make items more focusd
1 parent 0dd0066 commit 0c5537c

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

resources/views/_snippets/menu_items.blade.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ class="nav-link">Find Rule</a>
1818
@endif
1919
</li>
2020

21-
<li class="nav-item">
22-
<a href="{{ action(\App\Controller\InteractiveController::class) }}"
23-
class="nav-link">Play & Learn</a>
24-
@if (!isset($includeFooterLinks))
25-
<div class="badge text-white bg-danger"
26-
style="float:right; margin-top: -4.7em; margin-right: -.3em; font-size: .6em">NEW
27-
</div>
28-
@endif
29-
</li>
30-
3121
<li class="nav-item">
3222
<a href="{{ action(\App\Controller\ContactController::class) }}"
3323
class="nav-link">Contact</a>

resources/views/homepage/find_rule.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
@section('main')
88
<div id="filter" class="mt-4" style="min-height: 30em">
9-
<p class="mb-3">
10-
Find the best Rector rule to solve your problem
9+
<p class="mb-4">
10+
Find the best Rector rule to solve your problem. Searching through {{ $ruleCount }} rules.
1111
</p>
1212

1313
@livewire('find-rule-component')

resources/views/livewire/find-rule-component.blade.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,17 @@ class="form-select ms-3"
6868

6969
<div class="clearfix mb-2"></div>
7070

71-
<br>
72-
7371
@if ($isFilterActive)
72+
<p>
73+
@if ($filteredRules === 0)
74+
No rule found. Try changing group to more generic one, or use different query.
75+
@elseif (count($filteredRules) === 1)
76+
Found 1 rule. That's the one:
77+
@else
78+
Found <strong>{{ count($filteredRules) }} rules</strong>:
79+
@endif
80+
</p>
81+
7482
@foreach ($filteredRules as $filteredRule)
7583
<div style="--bs-border-opacity: .5;" class="mb-3 mt-2 card
7684
@if ($filteredRule->isConfigurable())
@@ -130,6 +138,8 @@ class="language-diff">{{ $filteredRule->getDiffCodeSample() }}</code></pre>
130138
<p>No rules found. Try different query.</p>
131139
@endif
132140
@else
141+
<br>
142+
133143
<p>Not sure how to search? Try one of these for a start:</p>
134144

135145
<ul>

src/Controller/FindRuleController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@
44

55
namespace App\Controller;
66

7+
use App\FileSystem\RectorFinder;
78
use Illuminate\Contracts\View\View;
89
use Illuminate\Routing\Controller;
910

1011
final class FindRuleController extends Controller
1112
{
13+
public function __construct(
14+
private RectorFinder $rectorFinder
15+
) {
16+
}
17+
1218
public function __invoke(): View
1319
{
1420
return \view('homepage/find_rule', [
1521
'page_title' => 'Find the best Rule',
22+
'ruleCount' => $this->rectorFinder->getRuleCount(),
1623
]);
1724
}
1825
}

src/FileSystem/RectorFinder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,9 @@ private function findInDirectoriesAndCreateRuleMetadatas(array $directories, arr
166166

167167
return $ruleMetadatas;
168168
}
169+
170+
public function getRuleCount(): int
171+
{
172+
return count($this->findCore()) + count($this->findCommunity());
173+
}
169174
}

0 commit comments

Comments
 (0)