FIX: Clicking on edited notification should open edit history modal (#21631)
This is a regression introduced when we redesigned the user menu
This commit is contained in:
parent
9951493129
commit
bc58ee5f85
|
@ -1,14 +0,0 @@
|
|||
import { setLastEditNotificationClick } from "discourse/models/post-stream";
|
||||
|
||||
export default {
|
||||
name: "edit-notification-clicks-tracker",
|
||||
|
||||
initialize(container) {
|
||||
const appEvents = container.lookup("service:app-events");
|
||||
appEvents.on("edit-notification:clicked", this.handleClick);
|
||||
},
|
||||
|
||||
handleClick({ topicId, postNumber, revisionNumber }) {
|
||||
setLastEditNotificationClick(topicId, postNumber, revisionNumber);
|
||||
},
|
||||
};
|
|
@ -14,10 +14,12 @@ import MembershipRequestConsolidated from "discourse/lib/notification-types/memb
|
|||
import NewFeatures from "discourse/lib/notification-types/new-features";
|
||||
import MovedPost from "discourse/lib/notification-types/moved-post";
|
||||
import WatchingFirstPost from "discourse/lib/notification-types/watching-first-post";
|
||||
import Edited from "discourse/lib/notification-types/edited";
|
||||
|
||||
const CLASS_FOR_TYPE = {
|
||||
bookmark_reminder: BookmarkReminder,
|
||||
custom: Custom,
|
||||
edited: Edited,
|
||||
granted_badge: GrantedBadge,
|
||||
group_mentioned: GroupMentioned,
|
||||
group_message_summary: GroupMessageSummary,
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import NotificationTypeBase from "discourse/lib/notification-types/base";
|
||||
import { setLastEditNotificationClick } from "discourse/models/post-stream";
|
||||
|
||||
export default class extends NotificationTypeBase {
|
||||
onClick() {
|
||||
setLastEditNotificationClick(
|
||||
this.notification.topic_id,
|
||||
this.notification.post_number,
|
||||
this.notification.data.revision_number
|
||||
);
|
||||
}
|
||||
}
|
|
@ -63,6 +63,7 @@ export default class UserMenuNotificationItem extends UserMenuBaseItem {
|
|||
}
|
||||
|
||||
onClick() {
|
||||
this.renderDirector.onClick?.();
|
||||
this.appEvents.trigger("user-menu:notification-click", this.notification);
|
||||
|
||||
if (!this.notification.read) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import { skip } from "qunit";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Edit Notification Click", function (needs) {
|
||||
needs.user();
|
||||
|
@ -38,17 +38,19 @@ acceptance("Edit Notification Click", function (needs) {
|
|||
});
|
||||
});
|
||||
|
||||
// TODO: Unskip failing test after fixing issue with new user menu and history modal
|
||||
skip("history modal is shown when navigating from a non-topic page", async function (assert) {
|
||||
test("history modal is shown when navigating from a non-topic page", async function (assert) {
|
||||
await visit("/");
|
||||
await click(".d-header-icons #current-user");
|
||||
await click("#quick-access-notifications .edited");
|
||||
await click(".header-dropdown-toggle.current-user");
|
||||
await click(".notification.edited a");
|
||||
|
||||
const [v1, v2] = queryAll(".history-modal .revision-content");
|
||||
|
||||
assert.strictEqual(
|
||||
v1.textContent.trim(),
|
||||
"Hello world this is a test",
|
||||
"history modal for the edited post is shown"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
v2.textContent.trim(),
|
||||
"Hello world this is a testThis is an edit!",
|
||||
|
|
Loading…
Reference in New Issue