The post widgets expect to receive a transformed post as argument and use the spread operator to pass attributes to the inner widget, however the Docs plugin was providing a post model instance as argument instead.
This used to work fine, but as we introduce tracked properties in the post model, the spread operator doesn't copy their values, which causes issues.
This PR changes the `DocsTopic` Component to provide a `transformedPost` as argument to the post widget instead.
The change is necessary due to upcoming changes in the post model for the Glimmer post stream.
Not all categories are preloaded when lazy_load_categories is enabled.
In this case, the category objects that are loaded through /docs.json
must be complete.
The `legacy` option has been removed from the `navigation_menu` site setting, so we can remove all the logic that's related to the `legacy` option from this plugin.
Internal topic: t/113137.
This makes docs search behavior consistent with the rest of Discourse. It also resolves a UX issue where the live search would cause the input to lose focus while typing.
* FEATURE: Optionally show topic excerpts in docs index
This commit adds a new docs_show_topic_excerpts site setting
which, when enabled and used in conjunction either with the
always_include_topic_excerpts site setting or the
serialize_topic_excerpts theme modifier.
For the theme modifier, this commit also fixes an issue
with the Docs::Query class. Since we were re-initializing
Guardian within the class (rather than using the guardian
passed down from the controller), we did not have the request
information needed to determine theme_id, which meant that
the theme modifier had no effect. We now pass down guardian
from the controller instead. In general guardian is almost
always better than a user object, since we can always just
call guardian.user.
Adds a simple system spec as well.
---
We now check both the serialize_topic_excerpts theme modifier
and the always_include_topic_excerpts site setting server-side
within Docs::Query, and use that on the client to determine
whether or not to show the excerpts for docs. This is because if
someone sets one of those values it's logical to think it will
apply everywhere there is a topic list.
Also include a system spec to test whether the theme modifier
works to show the excerpts.
---------
Co-authored-by: Martin Brennan <martin@discourse.org>
In some cases, when having multiple tag filters selected and results in the list, deselecting one of the filters would cause no results. This is clearly incorrect behavior, as fewer filters should lead to more (or at least the same number of) results.
This happens when you have a list of selected filters, e.g. `foo|bar|baz`, and you deselect the "middle" one. This will result in the following filter: `foo||baz`, which causes the back-end to try and filter on empty string as well, and in turn leads to no results.
The order of the filter list depends on the order they were selected, which caused this to seem a bit erratic.
In the code, there's a regular expression that tries to remove consecutive `|` characters, but this is anchored to the beginning of the string, so it doesn't work for this case.
Instead of relying on a regular expression, this change splits the string into an array, filters out the deselected tag, and joins it back together into the filter string. This avoids the issues that regular expressions have.
The PR also includes unit tests for the three code paths of the filter selection.
* FEATURE: add a global setting to support custom docs url path
This commit adds a GlobalSetting `docs_path` to support custom docs url
path for sites that do not want docs page to live at `/docs` and have a
customized path.
* Fixed the route declaration
* Test and linting
* Update server.en.yml
* Fixed doc test
* Fixed linting.
* Testing qunit test fix
* Fixed tests
* Prettified tests
* Changed the implementation from SiteSetting to GlobalSetting instead.
* Fixed tests
* Cleanup
* Using Site instead of .js.erb to pass GlobalSetting.docs_url to the front end.
Also fixed front end tests
* Remove references to obsolete site setting
* remove unused fixture file
* Rename `docs_url` to `docs_path` and use camelCase in JavaScript
* Add serializer tests
Co-authored-by: Arpit Jalan <er.ajalan@gmail.com>
We can rip out the `click` handler completely and just lean on the _logic_ we have in `docs-index`.
0cef82aec0/assets/javascripts/discourse/routes/docs-index.js (L12)
It will always refresh the `selectedTopic` so there will be no need to update it within the click handler. Which then nullifies the need for `setSelectedTopic`.
When a documentation topic is viewed, corresponding TopicViewItem and TopicUser should be created.
A method from a TopicController is called, however, specs should warn us if ever that core method would change.