UX: Do not render solved filter on categories page (#100)

There is no topic list to filter on the categories page, so we should not be rendering the solved filter there.

This also addresses a few deprecations in the code.
This commit is contained in:
tshenry 2020-11-11 10:08:09 -08:00 committed by GitHub
parent 77edb4ae29
commit 02981fe1d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -3,7 +3,7 @@
class="solved-status-filter" class="solved-status-filter"
content=statuses content=statuses
value=status value=status
valueAttribute="value" valueProperty="value"
onSelect=(action "changeStatus") onChange=(action "changeStatus")
}} }}
{{/if}} {{/if}}

View File

@ -1,17 +1,22 @@
import I18n from "I18n"; import I18n from "I18n";
import DiscourseUrl from "discourse/lib/url"; import DiscourseUrl from "discourse/lib/url";
import { getOwner } from "discourse-common/lib/get-owner";
export default { export default {
shouldRender(args, component) { shouldRender(args, component) {
if (!component.siteSettings.show_filter_by_solved_status) { const router = getOwner(this).lookup("router:main");
if (
!component.siteSettings.show_filter_by_solved_status ||
router.currentPath === "discovery.categories"
) {
return false; return false;
} else if (component.siteSettings.allow_solved_on_all_topics) { } else if (component.siteSettings.allow_solved_on_all_topics) {
return true; return true;
} else { } else {
const controller = Discourse.__container__.lookup( const controller = getOwner(this).lookup(
"controller:navigation/category" "controller:navigation/category"
); );
return controller && controller.get("category.enable_accepted_answers"); return controller && controller.get("category.enable_accepted_answers");
} }
}, },