FIX: ensures reports links are correct on subfolder installs
This commit is contained in:
parent
3c92202654
commit
398f98c568
|
@ -304,7 +304,7 @@ const Report = Discourse.Model.extend({
|
|||
avatar_template: row[properties.avatar]
|
||||
});
|
||||
|
||||
const href = `/admin/users/${userId}/${username}`;
|
||||
const href = Discourse.getURL(`/admin/users/${userId}/${username}`);
|
||||
|
||||
const avatarImg = renderAvatar(user, {
|
||||
imageSize: "tiny",
|
||||
|
@ -327,7 +327,7 @@ const Report = Discourse.Model.extend({
|
|||
|
||||
const formatedValue = () => {
|
||||
const topicId = row[properties.id];
|
||||
const href = `/t/-/${topicId}`;
|
||||
const href = Discourse.getURL(`/t/-/${topicId}`);
|
||||
return `<a href='${href}'>${topicTitle}</a>`;
|
||||
};
|
||||
|
||||
|
@ -341,7 +341,7 @@ const Report = Discourse.Model.extend({
|
|||
const postTitle = row[properties.truncated_raw];
|
||||
const postNumber = row[properties.number];
|
||||
const topicId = row[properties.topic_id];
|
||||
const href = `/t/-/${topicId}/${postNumber}`;
|
||||
const href = Discourse.getURL(`/t/-/${topicId}/${postNumber}`);
|
||||
|
||||
return {
|
||||
property: properties.title,
|
||||
|
@ -395,7 +395,7 @@ const Report = Discourse.Model.extend({
|
|||
|
||||
_linkLabel(properties, row) {
|
||||
const property = properties[0];
|
||||
const value = row[property];
|
||||
const value = Discourse.getURL(row[property]);
|
||||
const formatedValue = (href, anchor) => {
|
||||
return `<a href="${escapeExpression(href)}">${escapeExpression(
|
||||
anchor
|
||||
|
|
|
@ -515,4 +515,22 @@ QUnit.test("computed labels", assert => {
|
|||
"<a href='/t/-/2/3'>This is the beginning of</a>"
|
||||
);
|
||||
assert.equal(computedPostLabel.value, "This is the beginning of");
|
||||
|
||||
// subfolder support
|
||||
Discourse.BaseUri = "/forum";
|
||||
|
||||
const postLink = computedLabels[5].compute(row).formatedValue;
|
||||
assert.equal(
|
||||
postLink,
|
||||
"<a href='/forum/t/-/2/3'>This is the beginning of</a>"
|
||||
);
|
||||
|
||||
const topicLink = computedLabels[4].compute(row).formatedValue;
|
||||
assert.equal(topicLink, "<a href='/forum/t/-/2'>Test topic</a>");
|
||||
|
||||
const userLink = computedLabels[0].compute(row).formatedValue;
|
||||
assert.equal(
|
||||
userLink,
|
||||
"<a href='/forum/admin/users/1/joffrey'><img alt='' width='20' height='20' src='/forum/' class='avatar' title='joffrey'><span class='username'>joffrey</span></a>"
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue