mirror of
https://github.com/discourse/discourse.git
synced 2025-06-24 23:51:40 +08:00
FIX: tag transition only if tag name changed (#15149)
We need to change path only if tag name is changed. If a description is added, we don't need to reload.
This commit is contained in:

committed by
GitHub

parent
9a6ec1d0c6
commit
a616bc296a
@ -93,13 +93,17 @@ export default Component.extend({
|
||||
},
|
||||
|
||||
finishedEditing() {
|
||||
const oldTagName = this.tag.id;
|
||||
this.tag
|
||||
.update({ id: this.newTagName, description: this.newTagDescription })
|
||||
.then((result) => {
|
||||
this.set("editing", false);
|
||||
this.tagInfo.set("description", this.newTagDescription);
|
||||
if (result.payload) {
|
||||
this.router.transitionTo("tag.show", result.payload.id);
|
||||
if (
|
||||
result.responseJson.tag &&
|
||||
oldTagName !== result.responseJson.tag.id
|
||||
) {
|
||||
this.router.transitionTo("tag.show", result.responseJson.tag.id);
|
||||
}
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
queryAll,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Tags", function (needs) {
|
||||
@ -350,6 +350,10 @@ acceptance("Tag info", function (needs) {
|
||||
],
|
||||
});
|
||||
});
|
||||
server.put("/tag/happy-monkey", (request) => {
|
||||
const data = helper.parsePostData(request.requestBody);
|
||||
return helper.response({ tag: { id: data.tag.id } });
|
||||
});
|
||||
|
||||
server.get("/tag/happy-monkey/info", () => {
|
||||
return helper.response({
|
||||
@ -452,6 +456,23 @@ acceptance("Tag info", function (needs) {
|
||||
"happy monkey description",
|
||||
"it displays original tag description"
|
||||
);
|
||||
|
||||
await fillIn("#edit-description", "new description");
|
||||
await click(".submit-edit");
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/tag/happy-monkey",
|
||||
"it doesn't change URL"
|
||||
);
|
||||
|
||||
await click("#edit-tag");
|
||||
await fillIn("#edit-name", "happy-monkey2");
|
||||
await click(".submit-edit");
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/tag/happy-monkey2",
|
||||
"it changes URL to new tag path"
|
||||
);
|
||||
});
|
||||
|
||||
test("can filter tags page by category", async function (assert) {
|
||||
|
Reference in New Issue
Block a user