REFACTOR: Use the same structure as core does for topic-list-item in docs

This commit is contained in:
Jordan Vidrine 2023-06-09 14:08:13 -05:00
parent c2f27d1e3b
commit 0054539775
4 changed files with 42 additions and 16 deletions

View File

@ -0,0 +1,24 @@
import Component from "@ember/component";
import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers";
import { findRawTemplate } from "discourse-common/lib/raw-templates";
import { htmlSafe } from "@ember/template";
export default Component.extend({
tagName: "tr",
classNameBindings: [":topic-list-item"],
didInsertElement() {
this._super(...arguments);
this.renderTopicListItem();
},
renderTopicListItem() {
const template = findRawTemplate("list/topic-list-item");
if (template) {
this.set(
"topicListItemContents",
htmlSafe(template(this, RUNTIME_OPTIONS))
);
}
},
});

View File

@ -0,0 +1 @@
{{this.topicListItemContents}}

View File

@ -28,7 +28,7 @@
<tbody class="topic-list-body">
{{#each topics as |topic|}}
{{raw "docs-topic-list-item" topic=topic urlPath=urlPath}}
{{docs-topic-list-item topic=topic urlPath=urlPath}}
{{/each}}
</tbody>
</table>

View File

@ -1,15 +1,16 @@
<tr class="topic-list-item">
<td class="main-link topic-list-data">
<span class="link-top-line">
{{~raw "topic-status" topic=topic}}
{{~raw "docs-topic-link" topic=topic urlPath=urlPath}}
</span>
<span class="link-bottom-line">
{{category-link topic.category}}
{{discourse-tags topic mode="list"}}
</span>
</td>
<td class="topic-list-data">
{{format-date topic.bumped_at format="tiny" noTitle="true"}}
</td>
</tr>
{{~raw-plugin-outlet name="topic-list-before-columns"}}
<td class="main-link topic-list-data">
{{~raw-plugin-outlet name="topic-list-before-link"}}
<span class="link-top-line">
{{~raw "topic-status" topic=topic}}
{{~raw "docs-topic-link" topic=topic urlPath=urlPath}}
</span>
<span class="link-bottom-line">
{{category-link topic.category}}
{{discourse-tags topic mode="list"}}
</span>
</td>
<td class="topic-list-data">
{{format-date topic.bumped_at format="tiny" noTitle="true"}}
</td>