Skip to content

Commit 5bc2bca

Browse files
authored
Merge pull request rails#54876 from the-spectator/tag_filter
Add support for filtering notes by tag in /rails/info/notes
2 parents a0e7c5a + d7ab087 commit 5bc2bca

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

railties/lib/rails/info_controller.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ def routes
3333
end
3434

3535
def notes
36-
@annotations = Rails::SourceAnnotationExtractor.new(
37-
Rails::SourceAnnotationExtractor::Annotation.tags.join("|")
38-
).find(
36+
tags = params[:tag].presence || Rails::SourceAnnotationExtractor::Annotation.tags.join("|")
37+
@annotations = Rails::SourceAnnotationExtractor.new(tags).find(
3938
Rails::SourceAnnotationExtractor::Annotation.directories
4039
)
4140
end

railties/lib/rails/templates/rails/info/notes.html.erb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,35 @@
3333
background: #282828;
3434
}
3535
}
36+
37+
.filter {
38+
display: flex;
39+
width: 100%;
40+
justify-content: flex-end;
41+
align-items: center;
42+
}
43+
44+
.filter label[for="tag"] {
45+
margin-right: 10px;
46+
}
47+
48+
.filter select[name="tag"] {
49+
border-radius: 8px;
50+
padding: 0.25em;
51+
}
3652
</style>
3753

3854
<h2>
3955
Notes
4056
</h2>
4157

58+
<div class="filter">
59+
<%= form_tag("/rails/info/notes", method: :get) do %>
60+
<%= label_tag :tag, "Filter by Tag:" %>
61+
<%= select_tag(:tag, options_for_select(Rails::SourceAnnotationExtractor::Annotation.tags, params[:tag]), { include_blank: "All", onchange: "this.form.submit();" }) %>
62+
<% end %>
63+
</div>
64+
4265
<table id="route_table" class="table">
4366
<thead>
4467
<th>File Name</th>

0 commit comments

Comments
 (0)