Skip to content

add search to resource tree#2114

Open
aayushkdev wants to merge 3 commits intoaboutcode-org:mainfrom
aayushkdev:resource-tree-search
Open

add search to resource tree#2114
aayushkdev wants to merge 3 commits intoaboutcode-org:mainfrom
aayushkdev:resource-tree-search

Conversation

@aayushkdev
Copy link
Collaborator

@aayushkdev aayushkdev commented Mar 23, 2026

Issues

Changes

image

Checklist

  • I have read the contributing guidelines
  • I have linked an existing issue above
  • I have added unit tests covering the new code
  • I have reviewed and understood every line of this PR

Signed-off-by: Aayush Kumar <code@aayushk.dev>
@aayushkdev aayushkdev force-pushed the resource-tree-search branch from e1f1bb9 to f886bda Compare March 23, 2026 18:43
@aayushkdev aayushkdev requested a review from tdruez March 24, 2026 05:38
Copy link
Contributor

@tdruez tdruez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aayushkdev Looks good. See my various comment.
You want to inline most of the CSS with existing Bulma classes when possible.

Also, a small visual issue regarding the right side of the search box, no radius. But it appears once we start typing.

  • Squared
    Image

  • Rounded
    Image

Comment on lines +2 to +30
<div class="mb-3 search-container" id="resource-search-container">
<div class="field has-addons">
<div class="control has-icons-left is-expanded">
<input
id="file-search-input"
class="input is-small"
type="text"
placeholder="Go to file..."
autocomplete="off"
hx-get="{% url 'project_resource_tree_search' project.slug %}"
hx-target="#search-results"
hx-trigger="input changed delay:200ms"
hx-include="this"
name="search"
>
<span class="icon is-small is-left">
<i class="fas fa-search"></i>
</span>
</div>
<div class="control">
<button id="clear-search" class="button is-small is-hidden" type="button" aria-label="Clear search">
<span class="icon is-small">
<i class="fas fa-times"></i>
</span>
</button>
</div>
</div>
<div id="search-results" class="search-dropdown is-hidden"></div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dedicated template would make sense here.

def get_queryset(self):
search_query = self.request.GET.get("search", "").strip()
if not search_query:
return CodebaseResource.objects.none()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use self.model here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I’ve updated it to use super().get_queryset(), which should be better here.

return context


class ProjectResourceSearchView(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add basic unit testing for this function?

Comment on lines +578 to +580
#resource-tree-container .search-container .field {
margin-bottom: 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this CSS addition do not need dedicated classes.
For example, in place of

#resource-tree-container .search-results,
.search-dropdown.search-dropdown-portal .search-results {
  margin: 0;
}

Simply put m-0 on the HTML element, much easier to maintain and adapt.

Signed-off-by: Aayush Kumar <code@aayushk.dev>
Signed-off-by: Aayush Kumar <code@aayushk.dev>
@aayushkdev aayushkdev force-pushed the resource-tree-search branch from 5c4b5ea to 8f7e8b5 Compare March 24, 2026 18:58
@aayushkdev
Copy link
Collaborator Author

aayushkdev commented Mar 24, 2026

Ive changed the icon to this because the previous implementation was causing border issues
image

@aayushkdev aayushkdev requested a review from tdruez March 24, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resources tree view additional features

2 participants