DEV: Remove unused `/u/<:username>/preferences/categories` route (#26548)
This commmit removes the unused `/u/:username/preferences/categories`
route which was merged into the `/u/:username/preferences/tracking`
route in 2fc2d7d828
.
This commit is contained in:
parent
c0befe65d3
commit
fbfeb5d6d0
|
@ -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);
|
||||
},
|
||||
},
|
||||
});
|
|
@ -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");
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import RestrictedUserRoute from "discourse/routes/restricted-user";
|
||||
|
||||
export default RestrictedUserRoute.extend({});
|
|
@ -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"],
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue