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"> <tbody class="topic-list-body">
{{#each topics as |topic|}} {{#each topics as |topic|}}
{{raw "docs-topic-list-item" topic=topic urlPath=urlPath}} {{docs-topic-list-item topic=topic urlPath=urlPath}}
{{/each}} {{/each}}
</tbody> </tbody>
</table> </table>

View File

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