mirror of
https://github.com/discourse/discourse.git
synced 2025-06-25 18:41:33 +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() {
|
finishedEditing() {
|
||||||
|
const oldTagName = this.tag.id;
|
||||||
this.tag
|
this.tag
|
||||||
.update({ id: this.newTagName, description: this.newTagDescription })
|
.update({ id: this.newTagName, description: this.newTagDescription })
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.set("editing", false);
|
this.set("editing", false);
|
||||||
this.tagInfo.set("description", this.newTagDescription);
|
this.tagInfo.set("description", this.newTagDescription);
|
||||||
if (result.payload) {
|
if (
|
||||||
this.router.transitionTo("tag.show", result.payload.id);
|
result.responseJson.tag &&
|
||||||
|
oldTagName !== result.responseJson.tag.id
|
||||||
|
) {
|
||||||
|
this.router.transitionTo("tag.show", result.responseJson.tag.id);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
queryAll,
|
queryAll,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} 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";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Tags", function (needs) {
|
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", () => {
|
server.get("/tag/happy-monkey/info", () => {
|
||||||
return helper.response({
|
return helper.response({
|
||||||
@ -452,6 +456,23 @@ acceptance("Tag info", function (needs) {
|
|||||||
"happy monkey description",
|
"happy monkey description",
|
||||||
"it displays original tag 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) {
|
test("can filter tags page by category", async function (assert) {
|
||||||
|
Reference in New Issue
Block a user