DEV: Modernise navigation controllers (#22982)

Converts to native class syntax, native getters, and removes unused properties
This commit is contained in:
David Taylor 2023-08-04 16:48:31 +01:00 committed by GitHub
parent ae95260645
commit f9361b9eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 22 deletions

View File

@ -1,6 +1,6 @@
import NavigationDefaultController from "discourse/controllers/navigation/default";
import { inject as controller } from "@ember/controller";
export default NavigationDefaultController.extend({
discoveryCategories: controller("discovery/categories"),
});
export default class NavigationCategoriesController extends NavigationDefaultController {
@controller("discovery/categories") discoveryCategories;
}

View File

@ -1,11 +1,6 @@
import { and, none } from "@ember/object/computed";
import FilterModeMixin from "discourse/mixins/filter-mode";
import NavigationDefaultController from "discourse/controllers/navigation/default";
export default NavigationDefaultController.extend(FilterModeMixin, {
showingParentCategory: none("category.parentCategory"),
showingSubcategoryList: and(
"category.show_subcategory_list",
"showingParentCategory"
),
});
export default class NavigationCategoryController extends NavigationDefaultController.extend(
FilterModeMixin
) {}

View File

@ -1,15 +1,15 @@
import { inject as service } from "@ember/service";
import Controller, { inject as controller } from "@ember/controller";
import FilterModeMixin from "discourse/mixins/filter-mode";
import discourseComputed from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";
import { TRACKED_QUERY_PARAM_VALUE } from "discourse/lib/topic-list-tracked-filter";
export default Controller.extend(FilterModeMixin, {
discovery: controller(),
router: service(),
export default class NavigationDefaultController extends Controller.extend(
FilterModeMixin
) {
@service router;
@controller discovery;
@discourseComputed("router.currentRoute.queryParams.f")
skipCategoriesNavItem(filterParamValue) {
return filterParamValue === TRACKED_QUERY_PARAM_VALUE;
},
});
get skipCategoriesNavItem() {
return this.router.currentRoute.queryParams.f === TRACKED_QUERY_PARAM_VALUE;
}
}

View File

@ -4,7 +4,7 @@ import { action } from "@ember/object";
import { bind } from "discourse-common/utils/decorators";
import discourseDebounce from "discourse-common/lib/debounce";
export default class extends Controller {
export default class NavigationFilterController extends Controller {
@controller("discovery/filter") discoveryFilter;
@tracked copyIcon = "link";