diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/categories.js b/app/assets/javascripts/discourse/app/controllers/preferences/categories.js deleted file mode 100644 index 9be58acd0c0..00000000000 --- a/app/assets/javascripts/discourse/app/controllers/preferences/categories.js +++ /dev/null @@ -1,68 +0,0 @@ -import Controller from "@ember/controller"; -import { or } from "@ember/object/computed"; -import { popupAjaxError } from "discourse/lib/ajax-error"; -import discourseComputed from "discourse-common/utils/decorators"; - -export default Controller.extend({ - @discourseComputed("siteSettings.mute_all_categories_by_default") - saveAttrNames(muteAllCategoriesByDefault) { - return [ - "watched_category_ids", - "tracked_category_ids", - "watched_first_post_category_ids", - muteAllCategoriesByDefault - ? "regular_category_ids" - : "muted_category_ids", - ]; - }, - - @discourseComputed( - "model.watchedCategories", - "model.watchedFirstPostCategories", - "model.trackedCategories", - "model.mutedCategories", - "model.regularCategories", - "siteSettings.mute_all_categories_by_default" - ) - selectedCategories( - watched, - watchedFirst, - tracked, - muted, - regular, - muteAllCategoriesByDefault - ) { - return [] - .concat( - watched, - watchedFirst, - tracked, - muteAllCategoriesByDefault ? regular : muted - ) - .filter(Boolean); - }, - - @discourseComputed - canSee() { - return this.get("currentUser.id") === this.get("model.id"); - }, - - @discourseComputed("siteSettings.remove_muted_tags_from_latest") - hideMutedTags() { - return this.siteSettings.remove_muted_tags_from_latest !== "never"; - }, - - canSave: or("canSee", "currentUser.admin"), - - actions: { - save() { - this.set("saved", false); - return this.model - .save(this.saveAttrNames) - .then(() => { - this.set("saved", true); - }) - .catch(popupAjaxError); - }, - }, -}); diff --git a/app/assets/javascripts/discourse/app/routes/app-route-map.js b/app/assets/javascripts/discourse/app/routes/app-route-map.js index 77dc9e1d20e..727026cade5 100644 --- a/app/assets/javascripts/discourse/app/routes/app-route-map.js +++ b/app/assets/javascripts/discourse/app/routes/app-route-map.js @@ -177,7 +177,6 @@ export default function () { this.route("emails"); this.route("notifications"); this.route("tracking"); - this.route("categories"); this.route("users"); this.route("tags"); this.route("interface"); diff --git a/app/assets/javascripts/discourse/app/routes/preferences-categories.js b/app/assets/javascripts/discourse/app/routes/preferences-categories.js deleted file mode 100644 index e68405a8da5..00000000000 --- a/app/assets/javascripts/discourse/app/routes/preferences-categories.js +++ /dev/null @@ -1,3 +0,0 @@ -import RestrictedUserRoute from "discourse/routes/restricted-user"; - -export default RestrictedUserRoute.extend({}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-categories-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-categories-test.js deleted file mode 100644 index 1eeb9da6481..00000000000 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-categories-test.js +++ /dev/null @@ -1,75 +0,0 @@ -import { click, visit } from "@ember/test-helpers"; -import { test } from "qunit"; -import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -import selectKit from "discourse/tests/helpers/select-kit-helper"; - -acceptance("User Preferences - Categories", function (needs) { - needs.user(); - - let putRequestData; - - needs.pretender((server, helper) => { - server.put("/u/eviltrout.json", (request) => { - putRequestData = helper.parsePostData(request.requestBody); - return helper.response({ user: {} }); - }); - }); - - needs.hooks.afterEach(() => { - putRequestData = null; - }); - - test("tracking category which is set to regular notification level for user when mute_all_categories_by_default site setting is enabled", async function (assert) { - this.siteSettings.mute_all_categories_by_default = true; - - await visit("/u/eviltrout/preferences/categories"); - - const trackedCategoriesSelector = selectKit( - ".tracking-controls__tracked-categories .category-selector" - ); - - await trackedCategoriesSelector.expand(); - - assert.notOk( - trackedCategoriesSelector.rowByValue("4").exists(), - "category that is set to regular is not available for selection" - ); - - const regularCategoriesSelector = selectKit( - ".tracking-controls__regular-categories .category-selector" - ); - - await regularCategoriesSelector.expand(); - await regularCategoriesSelector.deselectItemByValue("4"); - await trackedCategoriesSelector.expand(); - await trackedCategoriesSelector.selectRowByValue("4"); - await click(".save-changes"); - - assert.deepEqual(putRequestData, { - "regular_category_ids[]": ["-1"], - "tracked_category_ids[]": ["4"], - "watched_category_ids[]": ["3"], - "watched_first_post_category_ids[]": ["-1"], - }); - }); - - test("tracking category which is set to regular notification level for user when mute_all_categories_by_default site setting is disabled", async function (assert) { - await visit("/u/eviltrout/preferences/categories"); - - const categorySelector = selectKit( - ".tracking-controls__tracked-categories .category-selector" - ); - - await categorySelector.expand(); - // User has `regular_category_ids` set to [4] in fixtures - await categorySelector.selectRowByValue(4); - await click(".save-changes"); - - assert.deepEqual(putRequestData, { - "muted_category_ids[]": ["-1"], - "tracked_category_ids[]": ["4"], - "watched_category_ids[]": ["3"], - "watched_first_post_category_ids[]": ["-1"], - }); - }); -}); diff --git a/config/routes.rb b/config/routes.rb index a6b7a7eb66d..63c73ce2a87 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -667,10 +667,6 @@ Discourse::Application.routes.draw do :constraints => { username: RouteFormat.username, } - get "#{root_path}/:username/preferences/categories" => "users#preferences", - :constraints => { - username: RouteFormat.username, - } get "#{root_path}/:username/preferences/users" => "users#preferences", :constraints => { username: RouteFormat.username,