Show custom topic tracking message when the user 'never' automatically tracks topics and gets assigned (#249)
* Show more precise topic tracking message when the user never tracks any topics and gets assigned
This commit is contained in:
parent
f88c419a8c
commit
3d2a9d1e87
|
@ -506,6 +506,26 @@ function initialize(api) {
|
|||
},
|
||||
});
|
||||
|
||||
api.modifyClass("component:topic-notifications-button", {
|
||||
pluginId: PLUGIN_ID,
|
||||
|
||||
@discourseComputed(
|
||||
"topic",
|
||||
"topic.details.{notification_level,notifications_reason_id}"
|
||||
)
|
||||
notificationReasonText(topic) {
|
||||
if (
|
||||
this.currentUser.never_auto_track_topics &&
|
||||
topic.assigned_to_user &&
|
||||
topic.assigned_to_user.username === this.currentUser.username
|
||||
) {
|
||||
return I18n.t("notification_reason.user");
|
||||
}
|
||||
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
api.addPostSmallActionIcon("assigned", "user-plus");
|
||||
api.addPostSmallActionIcon("assigned_to_post", "user-plus");
|
||||
api.addPostSmallActionIcon("assigned_group", "group-plus");
|
||||
|
|
|
@ -119,3 +119,5 @@ en:
|
|||
label: Assigned Topic ID
|
||||
in_working_hours:
|
||||
label: Users in working hours
|
||||
notification_reason:
|
||||
user: "You will see a count of new replies because this topic was assigned to you."
|
||||
|
|
|
@ -133,6 +133,10 @@ after_initialize do
|
|||
@can_assign == :true
|
||||
end
|
||||
|
||||
add_to_serializer(:current_user, :never_auto_track_topics) do
|
||||
user.user_option.auto_track_topics_after_msecs < 0
|
||||
end
|
||||
|
||||
add_to_class(:group, :can_show_assigned_tab?) do
|
||||
allowed_group_ids = SiteSetting.assign_allowed_on_groups.split("|")
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
import { test } from "qunit";
|
||||
import {
|
||||
acceptance,
|
||||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import topicFixtures from "discourse/tests/fixtures/topic";
|
||||
|
||||
acceptance(
|
||||
"Discourse Assign | Never track topics assign reason",
|
||||
function (needs) {
|
||||
needs.user();
|
||||
needs.settings({
|
||||
assign_enabled: true,
|
||||
assigns_user_url_path: "/",
|
||||
});
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/t/44.json", () => {
|
||||
let topic = cloneJSON(topicFixtures["/t/130.json"]);
|
||||
topic.details.notifications_reason_id = 3;
|
||||
return helper.response(topic);
|
||||
});
|
||||
server.get("/t/45.json", () => {
|
||||
let topic = cloneJSON(topicFixtures["/t/28830/1.json"]);
|
||||
topic["assigned_to_user"] = {
|
||||
username: "eviltrout",
|
||||
name: "Robin Ward",
|
||||
avatar_template:
|
||||
"/letter_avatar/eviltrout/{size}/3_f9720745f5ce6dfc2b5641fca999d934.png",
|
||||
};
|
||||
return helper.response(topic);
|
||||
});
|
||||
server.get("/t/46.json", () => {
|
||||
let topic = cloneJSON(topicFixtures["/t/28830/1.json"]);
|
||||
topic["assigned_to_group"] = {
|
||||
id: 47,
|
||||
name: "discourse",
|
||||
};
|
||||
return helper.response(topic);
|
||||
});
|
||||
});
|
||||
|
||||
test("Show default assign reason when user tracks topics", async (assert) => {
|
||||
updateCurrentUser({ never_auto_track_topics: false });
|
||||
|
||||
await visit("/t/assignment-topic/44");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".topic-notifications-button .reason span.text").innerText,
|
||||
"You will receive notifications because you are watching this topic."
|
||||
);
|
||||
});
|
||||
|
||||
test("Show user assign reason when user never tracks topics", async (assert) => {
|
||||
updateCurrentUser({
|
||||
never_auto_track_topics: true,
|
||||
});
|
||||
|
||||
await visit("/t/assignment-topic/45");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".topic-notifications-button .reason span.text").innerText,
|
||||
"You will see a count of new replies because this topic was assigned to you."
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue