This commit is contained in:
Jordan Vidrine
2025-03-05 20:20:30 -06:00
parent af4c0c540f
commit 8ebde81fda
8 changed files with 567 additions and 0 deletions
@@ -0,0 +1,14 @@
import Component from "@glimmer/component";
import avatar from "discourse/helpers/avatar";
export default class TopicAuthorColumn extends Component {
constructor() {
super(...arguments);
}
<template>
<span class="topic-author-avatar">
{{avatar @topic.creator imageSize="large"}}
</span>
</template>
}
@@ -0,0 +1,11 @@
import Component from "@glimmer/component";
export default class TopicAuthorColumn extends Component {
constructor() {
super(...arguments);
}
<template>
<span class="topic-author">@{{@topic.creator.username}}</span>
</template>
}
@@ -0,0 +1,12 @@
import Component from "@glimmer/component";
import { categoryLinkHTML } from "discourse/helpers/category-link";
export default class TopicAuthorColumn extends Component {
constructor() {
super(...arguments);
}
<template>
{{categoryLinkHTML @topic.category}}
</template>
}
@@ -0,0 +1,14 @@
import Component from "@glimmer/component";
import icon from "discourse/helpers/d-icon";
export default class TopicLikesColumn extends Component {
constructor() {
super(...arguments);
}
<template>
{{#if @topic.like_count}}
<span class="topic-likes">{{icon "heart"}}{{@topic.like_count}}</span>
{{/if}}
</template>
}
@@ -0,0 +1,14 @@
import Component from "@glimmer/component";
import icon from "discourse/helpers/d-icon";
export default class TopicRepliesColumn extends Component {
constructor() {
super(...arguments);
}
<template>
{{#if @topic.posts_count}}
<span class="topic-replies">{{icon "reply"}}{{@topic.posts_count}}</span>
{{/if}}
</template>
}
@@ -0,0 +1,96 @@
import Component from "@glimmer/component";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { and } from "truth-helpers";
import icon from "discourse/helpers/d-icon";
export default class TopicStatusColumn extends Component {
@service currentUser;
@service siteSettings;
get canAct() {
return this.currentUser && !this.args.disableActions;
}
get statusClass() {
let classes = ["topic-status-card"];
if (this.args.topic.bookmarked) {
classes.push("--bookmark");
} else if (this.args.topic.closed && this.args.topic.archived) {
classes.push("--locked --archived");
} else if (this.args.topic.closed) {
classes.push("--locked");
} else if (this.args.topic.archived) {
classes.push("--archived");
} else if (this.args.topic.is_warning) {
classes.push("--warning");
} else if (
this.args.showPrivateMessageIcon &&
this.args.topic.isPrivateMessage
) {
classes.push("--private-message");
} else if (this.args.topic.pinned) {
classes.push("--pinned");
} else if (this.args.topic.unpinned) {
classes.push("--unpinned");
}
return classes.join(" ");
}
get heatMap() {
return this.args.topic.views > this.siteSettings.topic_views_heat_medium;
}
@action
togglePinned(e) {
e.preventDefault();
this.args.topic.togglePinnedForUser();
}
<template>
{{#if @topic.bookmarked}}
<span class={{this.statusClass}}>{{icon "bookmark"}}Bookmarked</span>
{{/if}}
{{#if (and @topic.closed @topic.archived)~}}
<span class={{this.statusClass}}>Locked and Archived</span>
{{else if @topic.closed}}
<span class={{this.statusClass}}>Locked</span>
{{else if @topic.archived}}
<span class={{this.statusClass}}>Archived</span>
{{/if}}
{{#if @topic.is_warning}}
<span class={{this.statusClass}}>Warning</span>
{{else if (and @showPrivateMessageIcon @topic.isPrivateMessage)}}
<span class={{this.statusClass}}>Private Message</span>
{{/if}}
{{#if @topic.pinned}}
{{#if this.canAct}}
<button
type="button"
{{on "click" this.togglePinned}}
class={{this.statusClass}}
>{{icon "thumbtack"}}Pinned</button>
{{else}}
<span class={{this.statusClass}}>{{icon "thumbtack"}}Pinned</span>
{{/if}}
{{else if @topic.unpinned}}
{{#if this.canAct}}
<button
type="button"
{{on "click" this.togglePinned}}
class={{this.statusClass}}
>{{icon "thumbtack" class="unpinned"}}Unpinned</button>
{{else}}
<span class={{this.statusClass}}>{{icon
"thumbtack"
class="unpinned"
}}Unpinned</span>
{{/if}}
{{/if}}
{{#if this.heatMap}}
<span class="topic-status-card --hot">{{icon "fa-fire"}}Hot</span>
{{/if}}
</template>
}