mirror of
https://github.com/discourse/discourse.git
synced 2025-06-11 13:16:04 +08:00
DEV: Use category ids in more URLs preferentially
This is a followup to 374534f0
This commit is contained in:
@ -107,7 +107,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||||||
slug: result.category.slug,
|
slug: result.category.slug,
|
||||||
id: result.category.id
|
id: result.category.id
|
||||||
});
|
});
|
||||||
DiscourseURL.redirectTo("/c/" + Category.slugFor(model));
|
DiscourseURL.redirectTo(`/c/${Category.slugFor(model)}/${model.id}`);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.flash(extractError(error), "error");
|
this.flash(extractError(error), "error");
|
||||||
|
@ -79,7 +79,7 @@ function defaultCategoryLinkRenderer(category, opts) {
|
|||||||
let restricted = get(category, "read_restricted");
|
let restricted = get(category, "read_restricted");
|
||||||
let url = opts.url
|
let url = opts.url
|
||||||
? opts.url
|
? opts.url
|
||||||
: Discourse.getURL("/c/") + Category.slugFor(category);
|
: Discourse.getURL(`/c/${Category.slugFor(category)}/${category.id}`);
|
||||||
let href = opts.link === false ? "" : url;
|
let href = opts.link === false ? "" : url;
|
||||||
let tagName = opts.link === false || opts.link === "false" ? "span" : "a";
|
let tagName = opts.link === false || opts.link === "false" ? "span" : "a";
|
||||||
let extraClasses = opts.extraClasses ? " " + opts.extraClasses : "";
|
let extraClasses = opts.extraClasses ? " " + opts.extraClasses : "";
|
||||||
|
@ -67,7 +67,7 @@ const Category = RestModel.extend({
|
|||||||
|
|
||||||
@discourseComputed("name")
|
@discourseComputed("name")
|
||||||
url() {
|
url() {
|
||||||
return Discourse.getURL("/c/") + Category.slugFor(this);
|
return Discourse.getURL(`/c/${Category.slugFor(this)}/${this.id}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
|
@ -36,7 +36,7 @@ QUnit.test("Editing the category", async assert => {
|
|||||||
assert.ok(!visible(".d-modal"), "it closes the modal");
|
assert.ok(!visible(".d-modal"), "it closes the modal");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
DiscourseURL.redirectedTo,
|
DiscourseURL.redirectedTo,
|
||||||
"/c/bug",
|
"/c/bug/1",
|
||||||
"it does one of the rare full page redirects"
|
"it does one of the rare full page redirects"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -265,6 +265,7 @@ export default function() {
|
|||||||
|
|
||||||
this.put("/categories/:category_id", request => {
|
this.put("/categories/:category_id", request => {
|
||||||
const category = parsePostData(request.requestBody);
|
const category = parsePostData(request.requestBody);
|
||||||
|
category.id = parseInt(request.params.category_id, 10);
|
||||||
|
|
||||||
if (category.email_in === "duplicate@example.com") {
|
if (category.email_in === "duplicate@example.com") {
|
||||||
return response(422, { errors: ["duplicate email"] });
|
return response(422, { errors: ["duplicate email"] });
|
||||||
|
Reference in New Issue
Block a user