A platform for community discussion. Free, open, simple.
UX: transition to edit URL when adding a category (#11634)
Penar Musaraj95df15bad960
diff --git a/app/assets/javascripts/discourse/app/controllers/edit-category-tabs.js b/app/assets/javascripts/discourse/app/controllers/edit-category-tabs.jsindex 6a3f6ea50a5..9b4aad25860 100644--- a/app/assets/javascripts/discourse/app/controllers/edit-category-tabs.js+++ b/app/assets/javascripts/discourse/app/controllers/edit-category-tabs.js@@ -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) => {diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.jsindex f02189ea475..e13661ce1bd 100644--- a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js@@ -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", {diff --git a/app/assets/javascripts/discourse/tests/fixtures/category-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/category-fixtures.jsindex c8625b03f4d..1ee9cf607eb 100644--- a/app/assets/javascripts/discourse/tests/fixtures/category-fixtures.js+++ b/app/assets/javascripts/discourse/tests/fixtures/category-fixtures.js@@ -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"+ }}};diff --git a/app/assets/javascripts/discourse/tests/helpers/create-pretender.js b/app/assets/javascripts/discourse/tests/helpers/create-pretender.jsindex 57fbd21eee7..cc267d9abce 100644--- a/app/assets/javascripts/discourse/tests/helpers/create-pretender.js+++ b/app/assets/javascripts/discourse/tests/helpers/create-pretender.js@@ -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") {