UX: transition to edit URL when adding a category (#11634)
This commit is contained in:
parent
afebaf439f
commit
95df15bad9
|
@ -1,4 +1,5 @@
|
|||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
||||
import Category from "discourse/models/category";
|
||||
import Controller from "@ember/controller";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import I18n from "I18n";
|
||||
|
@ -106,6 +107,7 @@ export default Controller.extend({
|
|||
notification_level: NotificationLevels.REGULAR,
|
||||
});
|
||||
this.site.updateCategory(model);
|
||||
this.transitionToRoute("editCategory", Category.slugFor(model));
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import I18n from "I18n";
|
||||
import sinon from "sinon";
|
||||
|
@ -17,6 +17,12 @@ acceptance("Category New", function (needs) {
|
|||
|
||||
await click("#save-category");
|
||||
|
||||
assert.equal(
|
||||
currentURL(),
|
||||
"/c/testing/edit/general",
|
||||
"it transitions to the category edit route"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
queryAll(".edit-category-title h2").text(),
|
||||
I18n.t("category.edit_dialog_title", {
|
||||
|
|
|
@ -38,5 +38,14 @@ export default {
|
|||
allow_badges: true,
|
||||
custom_fields: {}
|
||||
}
|
||||
},
|
||||
"/c/11/show.json": {
|
||||
category: {
|
||||
id: 11,
|
||||
name: "testing",
|
||||
color: "0088CC",
|
||||
text_color: "FFFFFF",
|
||||
slug: "testing"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -312,17 +312,13 @@ export function applyDefaultHandlers(pretender) {
|
|||
return response({ category });
|
||||
});
|
||||
|
||||
pretender.post("/categories", () => {
|
||||
return response({
|
||||
category: {
|
||||
id: 11,
|
||||
name: "testing",
|
||||
color: "0088CC",
|
||||
text_color: "FFFFFF",
|
||||
slug: "testing",
|
||||
},
|
||||
});
|
||||
});
|
||||
pretender.post("/categories", () =>
|
||||
response(fixturesByUrl["/c/11/show.json"])
|
||||
);
|
||||
|
||||
pretender.get("/c/testing/find_by_slug.json", () =>
|
||||
response(fixturesByUrl["/c/11/show.json"])
|
||||
);
|
||||
|
||||
pretender.get("/draft.json", (request) => {
|
||||
if (request.queryParams.draft_key === "new_topic") {
|
||||
|
|
Loading…
Reference in New Issue