FIX: A pmOnly tag should link to messages (#8361)

isPrivateMessages represents that the tag list is shown in the context
of private messages and pmOnly represents that the tag is used only in
private messages.
This commit is contained in:
Dan Ungureanu
2019-11-18 07:44:08 +02:00
committed by Sam
parent 975165f25f
commit a9704da34c
3 changed files with 11 additions and 3 deletions

View File

@ -14,7 +14,7 @@ function defaultRenderTag(tag, params) {
const tagName = params.tagName || "a"; const tagName = params.tagName || "a";
let path; let path;
if (tagName === "a" && !params.noHref) { if (tagName === "a" && !params.noHref) {
if (params.isPrivateMessage && User.current()) { if ((params.isPrivateMessage || params.pmOnly) && User.current()) {
const username = params.tagsForUser const username = params.tagsForUser
? params.tagsForUser ? params.tagsForUser
: User.current().username; : User.current().username;

View File

@ -9,7 +9,7 @@
{{/if}} {{/if}}
{{#each sortedTags as |tag|}} {{#each sortedTags as |tag|}}
<div class='tag-box'> <div class='tag-box'>
{{discourse-tag tag.id isPrivateMessage=isPrivateMessage tagsForUser=tagsForUser}} {{#if tag.pmOnly}}{{d-icon "far-envelope"}}{{/if}}{{#if tag.totalCount}} <span class='tag-count'>x {{tag.totalCount}}</span>{{/if}} {{discourse-tag tag.id isPrivateMessage=isPrivateMessage pmOnly=tag.pmOnly tagsForUser=tagsForUser}} {{#if tag.pmOnly}}{{d-icon "far-envelope"}}{{/if}}{{#if tag.totalCount}} <span class='tag-count'>x {{tag.totalCount}}</span>{{/if}}
</div> </div>
{{/each}} {{/each}}
<div class="clearfix" /> <div class="clearfix" />

View File

@ -25,7 +25,10 @@ QUnit.test("list the tags in groups", async assert => {
200, 200,
{ "Content-Type": "application/json" }, { "Content-Type": "application/json" },
{ {
tags: [{ id: "planned", text: "planned", count: 7, pm_count: 0 }], tags: [
{ id: "planned", text: "planned", count: 7, pm_count: 0 },
{ id: "private", text: "private", count: 0, pm_count: 7 }
],
extras: { extras: {
tag_groups: [ tag_groups: [
{ {
@ -91,6 +94,11 @@ QUnit.test("list the tags in groups", async assert => {
["/tags/focus", "/tags/escort"], ["/tags/focus", "/tags/escort"],
"always uses lowercase URLs for mixed case tags" "always uses lowercase URLs for mixed case tags"
); );
assert.equal(
$("a[data-tag-name='private']").attr("href"),
"/u/eviltrout/messages/tags/private",
"links to private messages"
);
}); });
test("new topic button is not available for staff-only tags", async assert => { test("new topic button is not available for staff-only tags", async assert => {