FEATURE: Add plugin outlets to parent category row for desktop (#30002)

* FEATURE: Add plugin outlets to parent category row

Added 3 plugin outlets:

- `category-list-above-category-section` (above `td.category`)
- `category-list-above-topics-section` (above `td.topics`)
- `category-list-below-topics-section` (below `td.topics`)

* DEV: Add value transformer for changing classes in parent category row.

renamed connectors and added connector for mobile view

* DEV: order transformers by name
This commit is contained in:
Gabriel Grubba
2024-12-02 18:27:30 -03:00
committed by GitHub
parent 85691a7f31
commit 98ba5f2dfa
3 changed files with 40 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { tagName } from "@ember-decorators/component"; import { tagName } from "@ember-decorators/component";
import { applyValueTransformer } from "discourse/lib/transformer";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
const LIST_TYPE = { const LIST_TYPE = {
@@ -40,4 +41,8 @@ export default class CategoryListItem extends Component {
slugPath(categoryPath) { slugPath(categoryPath) {
return categoryPath.substring("/c/".length); return categoryPath.substring("/c/".length);
} }
applyValueTransformer(name, value, context) {
return applyValueTransformer(name, value, context);
}
} }

View File

@@ -5,6 +5,14 @@
/> />
{{#if this.site.mobileView}} {{#if this.site.mobileView}}
<PluginOutlet
@name="category-list-before-category-mobile"
@outletArgs={{hash
category=this.category
listType=this.listType
isMuted=this.isMuted
}}
/>
<div <div
data-category-id={{this.category.id}} data-category-id={{this.category.id}}
data-notification-level={{this.category.notificationLevelString}} data-notification-level={{this.category.notificationLevelString}}
@@ -80,8 +88,19 @@
'has-description' 'has-description'
'no-description' 'no-description'
}} }}
{{this.applyValueTransformer
'parent-category-row-class'
(array)
(hash category=this.category)
}}
{{if this.category.uploaded_logo.url 'has-logo' 'no-logo'}}" {{if this.category.uploaded_logo.url 'has-logo' 'no-logo'}}"
> >
<PluginOutlet
@name="category-list-before-category-section"
@outletArgs={{hash category=this.category listType=this.listType}}
/>
<td <td
class="category {{if this.isMuted 'muted'}}" class="category {{if this.isMuted 'muted'}}"
style={{category-color-variable this.category.color}} style={{category-color-variable this.category.color}}
@@ -141,6 +160,11 @@
{{/if}} {{/if}}
</td> </td>
<PluginOutlet
@name="category-list-before-topics-section"
@outletArgs={{hash category=this.category}}
/>
<td class="topics"> <td class="topics">
<div title={{this.category.statTitle}}>{{html-safe <div title={{this.category.statTitle}}>{{html-safe
this.category.stat this.category.stat
@@ -154,6 +178,11 @@
/> />
</td> </td>
<PluginOutlet
@name="category-list-after-topics-section"
@outletArgs={{hash category=this.category}}
/>
{{#unless this.isMuted}} {{#unless this.isMuted}}
{{#if this.showTopics}} {{#if this.showTopics}}
<td class="latest"> <td class="latest">
@@ -165,6 +194,10 @@
{{/if}} {{/if}}
{{/each}} {{/each}}
</td> </td>
<PluginOutlet
@name="category-list-after-latest-section"
@outletArgs={{hash category=this.category}}
/>
{{/if}} {{/if}}
{{/unless}} {{/unless}}
</tr> </tr>

View File

@@ -13,6 +13,8 @@ export const VALUE_TRANSFORMERS = Object.freeze([
"invite-simple-mode-topic", "invite-simple-mode-topic",
"mentions-class", "mentions-class",
"more-topics-tabs", "more-topics-tabs",
"parent-category-row-class-mobile",
"parent-category-row-class",
"post-menu-buttons", "post-menu-buttons",
"small-user-attrs", "small-user-attrs",
"topic-list-columns", "topic-list-columns",