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";
let path;
if (tagName === "a" && !params.noHref) {
if (params.isPrivateMessage && User.current()) {
if ((params.isPrivateMessage || params.pmOnly) && User.current()) {
const username = params.tagsForUser
? params.tagsForUser
: User.current().username;

View File

@ -9,7 +9,7 @@
{{/if}}
{{#each sortedTags as |tag|}}
<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>
{{/each}}
<div class="clearfix" />

View File

@ -25,7 +25,10 @@ QUnit.test("list the tags in groups", async assert => {
200,
{ "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: {
tag_groups: [
{
@ -91,6 +94,11 @@ QUnit.test("list the tags in groups", async assert => {
["/tags/focus", "/tags/escort"],
"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 => {