Skip to content

Commit

Permalink
Addons: normalize search filters (#10951)
Browse files Browse the repository at this point in the history
Currently, we have two filters on shown by default in the search modal.
However, they are not super useful to work together.

I changed this behavior (for now) to be:

* Default: search on the current project
* Include subprojects: also include results from subprojects

Note this will be configurable by the user once we expose the addons admin page
in readthedocs/ext-theme#211

Closes readthedocs/addons#209
  • Loading branch information
humitos authored Dec 12, 2023
1 parent b2add87 commit b2cdd97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 2 additions & 3 deletions readthedocs/proxito/tests/responses/v0.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@
"search": {
"enabled": true,
"api_endpoint": "/_/api/v3/search/",
"default_filter": "subprojects:project/latest",
"default_filter": "project:project/latest",
"filters": [
["Search only in this project", "project:project/latest"],
["Search subprojects", "subprojects:project/latest"]
["Include subprojects", "subprojects:project/latest"]
],
"project": "project",
"version": "latest"
Expand Down
8 changes: 2 additions & 6 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,13 @@ def _v0(self, project, version, build, filename, url, user):
# TODO: figure it out where this data comes from
"filters": [
[
"Search only in this project",
f"project:{project.slug}/{version.slug}",
],
[
"Search subprojects",
"Include subprojects",
f"subprojects:{project.slug}/{version.slug}",
],
]
if version
else [],
"default_filter": f"subprojects:{project.slug}/{version.slug}"
"default_filter": f"project:{project.slug}/{version.slug}"
if version
else None,
},
Expand Down

0 comments on commit b2cdd97

Please sign in to comment.