UX: transition to edit URL when adding a category (#11634)

This commit is contained in:
Penar Musaraj 2021-01-05 08:34:35 -05:00 committed by GitHub
parent afebaf439f
commit 95df15bad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 12 deletions

View File

@ -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) => {

View File

@ -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", {

View File

@ -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"
}
}
};

View File

@ -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") {