FIX: Resolve computed property override when inviting to PM (#24823)
This was raising a deprecation under Ember 3, and an error under Ember 4+
This commit is contained in:
parent
dacb06842e
commit
b5fb8e89eb
|
@ -267,8 +267,11 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("isPM")
|
@discourseComputed("isPM", "ajaxError")
|
||||||
errorMessage(isPM) {
|
errorMessage(isPM, ajaxError) {
|
||||||
|
if (ajaxError) {
|
||||||
|
return ajaxError;
|
||||||
|
}
|
||||||
return isPM
|
return isPM
|
||||||
? I18n.t("topic.invite_private.error")
|
? I18n.t("topic.invite_private.error")
|
||||||
: I18n.t("topic.invite_reply.error");
|
: I18n.t("topic.invite_reply.error");
|
||||||
|
@ -326,14 +329,9 @@ export default Component.extend({
|
||||||
|
|
||||||
const onerror = (e) => {
|
const onerror = (e) => {
|
||||||
if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {
|
if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {
|
||||||
this.set("errorMessage", e.jqXHR.responseJSON.errors[0]);
|
this.set("ajaxError", e.jqXHR.responseJSON.errors[0]);
|
||||||
} else {
|
} else {
|
||||||
this.set(
|
this.set("ajaxError", null);
|
||||||
"errorMessage",
|
|
||||||
this.isPM
|
|
||||||
? I18n.t("topic.invite_private.error")
|
|
||||||
: I18n.t("topic.invite_reply.error")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
model.setProperties({ saving: false, error: true });
|
model.setProperties({ saving: false, error: true });
|
||||||
};
|
};
|
||||||
|
@ -397,14 +395,9 @@ export default Component.extend({
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {
|
if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {
|
||||||
this.set("errorMessage", e.jqXHR.responseJSON.errors[0]);
|
this.set("ajaxError", e.jqXHR.responseJSON.errors[0]);
|
||||||
} else {
|
} else {
|
||||||
this.set(
|
this.set("ajaxError", null);
|
||||||
"errorMessage",
|
|
||||||
this.isPM
|
|
||||||
? I18n.t("topic.invite_private.error")
|
|
||||||
: I18n.t("topic.invite_reply.error")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
model.setProperties({ saving: false, error: true });
|
model.setProperties({ saving: false, error: true });
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
query,
|
query,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
|
import selectKit from "../helpers/select-kit-helper";
|
||||||
|
|
||||||
acceptance("Personal Message", function (needs) {
|
acceptance("Personal Message", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
@ -75,8 +76,19 @@ acceptance("Personal Message (regular user)", function (needs) {
|
||||||
|
|
||||||
acceptance("Personal Message - invite", function (needs) {
|
acceptance("Personal Message - invite", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
needs.pretender((server, helper) => {
|
||||||
|
server.get("/u/search/users", () =>
|
||||||
|
helper.response({ users: [{ username: "example" }] })
|
||||||
|
);
|
||||||
|
|
||||||
test("suggested messages", async function (assert) {
|
server.post("/t/12/invite", () =>
|
||||||
|
helper.response(422, {
|
||||||
|
errors: ["Some validation error"],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("can open invite modal", async function (assert) {
|
||||||
await visit("/t/pm-for-testing/12");
|
await visit("/t/pm-for-testing/12");
|
||||||
await click(".add-remove-participant-btn");
|
await click(".add-remove-participant-btn");
|
||||||
await click(".private-message-map .controls .add-participant-btn");
|
await click(".private-message-map .controls .add-participant-btn");
|
||||||
|
@ -85,4 +97,23 @@ acceptance("Personal Message - invite", function (needs) {
|
||||||
.dom(".d-modal.add-pm-participants .invite-user-control")
|
.dom(".d-modal.add-pm-participants .invite-user-control")
|
||||||
.exists("invite modal is displayed");
|
.exists("invite modal is displayed");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("shows errors correctly", async function (assert) {
|
||||||
|
await visit("/t/pm-for-testing/12");
|
||||||
|
await click(".add-remove-participant-btn");
|
||||||
|
await click(".private-message-map .controls .add-participant-btn");
|
||||||
|
|
||||||
|
assert
|
||||||
|
.dom(".d-modal.add-pm-participants .invite-user-control")
|
||||||
|
.exists("invite modal is displayed");
|
||||||
|
|
||||||
|
const input = selectKit(".invite-user-input");
|
||||||
|
await input.expand();
|
||||||
|
await input.fillInFilter("example");
|
||||||
|
await input.selectRowByValue("example");
|
||||||
|
|
||||||
|
await click(".send-invite");
|
||||||
|
|
||||||
|
assert.dom(".d-modal.add-pm-participants .alert-error").exists();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue