mirror of
https://github.com/discourse/discourse.git
synced 2025-04-17 09:51:30 +08:00
Refactor: tags/show should use d-navigation (#10927)
This commit is contained in:
parent
c5a4907800
commit
b9fb1cebcd
@ -25,14 +25,20 @@ export default Component.extend(FilterModeMixin, {
|
||||
@discourseComputed(
|
||||
"createTopicDisabled",
|
||||
"hasDraft",
|
||||
"categoryReadOnlyBanner"
|
||||
"categoryReadOnlyBanner",
|
||||
"canCreateTopicOnTag",
|
||||
"tag.id"
|
||||
)
|
||||
createTopicButtonDisabled(
|
||||
createTopicDisabled,
|
||||
hasDraft,
|
||||
categoryReadOnlyBanner
|
||||
categoryReadOnlyBanner,
|
||||
canCreateTopicOnTag,
|
||||
tagId
|
||||
) {
|
||||
if (categoryReadOnlyBanner && !hasDraft) {
|
||||
if (tagId && !canCreateTopicOnTag) {
|
||||
return true;
|
||||
} else if (categoryReadOnlyBanner && !hasDraft) {
|
||||
return false;
|
||||
}
|
||||
return createTopicDisabled;
|
||||
@ -60,14 +66,20 @@ export default Component.extend(FilterModeMixin, {
|
||||
@discourseComputed("category.can_edit")
|
||||
showCategoryEdit: (canEdit) => canEdit,
|
||||
|
||||
@discourseComputed("filterType", "category", "noSubcategories")
|
||||
navItems(filterType, category, noSubcategories) {
|
||||
@discourseComputed("additionalTags", "category", "tag.id")
|
||||
showToggleInfo(additionalTags, category, tagId) {
|
||||
return !additionalTags && !category && tagId !== "none";
|
||||
},
|
||||
|
||||
@discourseComputed("filterType", "category", "noSubcategories", "tag.id")
|
||||
navItems(filterType, category, noSubcategories, tagId) {
|
||||
const currentRouteQueryParams = this.get("router.currentRoute.queryParams");
|
||||
|
||||
return NavItem.buildList(category, {
|
||||
filterType,
|
||||
noSubcategories,
|
||||
currentRouteQueryParams,
|
||||
tagId,
|
||||
siteSettings: this.siteSettings,
|
||||
});
|
||||
},
|
||||
|
@ -0,0 +1,4 @@
|
||||
import Component from "@ember/component";
|
||||
export default Component.extend({
|
||||
tagName: "",
|
||||
});
|
@ -15,7 +15,12 @@
|
||||
{{/each}}
|
||||
|
||||
{{#if siteSettings.tagging_enabled}}
|
||||
{{tag-drop firstCategory=category tagId=tagId}}
|
||||
{{#unless additionalTags}}
|
||||
{{!-- the tag filter doesn't work with tag intersections, so hide it --}}
|
||||
{{#if siteSettings.show_filter_by_tag}}
|
||||
{{tag-drop firstCategory=category tagId=tag.id}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="bread-crumbs-right" connectorTagName="li" tagName=""}}
|
||||
|
@ -1,4 +1,9 @@
|
||||
{{bread-crumbs categories=categories category=category noSubcategories=noSubcategories}}
|
||||
{{bread-crumbs categories=categories category=category noSubcategories=noSubcategories tag=tag additionalTags=additionalTags}}
|
||||
|
||||
{{#unless additionalTags}}
|
||||
{{!-- nav bar doesn't work with tag intersections --}}
|
||||
{{navigation-bar navItems=navItems filterMode=filterMode category=category}}
|
||||
{{/unless}}
|
||||
|
||||
{{#if showCategoryAdmin}}
|
||||
{{categories-admin-dropdown
|
||||
@ -9,14 +14,29 @@
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{navigation-bar navItems=navItems filterMode=filterMode category=category}}
|
||||
{{#if category}}
|
||||
{{#unless tag}}
|
||||
{{!-- don't show category notification menu on tag pages --}}
|
||||
{{#if showCategoryNotifications}}
|
||||
{{category-notifications-button
|
||||
value=category.notification_level
|
||||
category=category
|
||||
onChange=(action "changeCategoryNotificationLevel")
|
||||
}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
{{#if showCategoryNotifications}}
|
||||
{{category-notifications-button
|
||||
value=category.notification_level
|
||||
category=category
|
||||
onChange=(action "changeCategoryNotificationLevel")
|
||||
}}
|
||||
{{#if tag}}
|
||||
{{#if tagNotification}}
|
||||
{{#unless additionalTags}}
|
||||
{{!-- don't show tag notification menu on tag intersections --}}
|
||||
{{tag-notifications-button
|
||||
onChange=changeTagNotificationLevel
|
||||
value=tagNotification.notification_level
|
||||
}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="before-create-topic-button"
|
||||
@ -32,12 +52,24 @@
|
||||
disabled=createTopicButtonDisabled
|
||||
label=createTopicLabel
|
||||
btnClass=createTopicClass
|
||||
canCreateTopicOnTag=canCreateTopicOnTag
|
||||
}}
|
||||
|
||||
{{#if showCategoryEdit}}
|
||||
{{d-button
|
||||
class="btn-default edit-category"
|
||||
action=editCategory
|
||||
icon="wrench"
|
||||
label="category.edit"}}
|
||||
{{#if category}}
|
||||
{{#unless tag}}
|
||||
{{!-- don't show category edit button on tag pages --}}
|
||||
{{#if showCategoryEdit}}
|
||||
{{d-button
|
||||
class="btn-default edit-category"
|
||||
action=editCategory
|
||||
icon="wrench"
|
||||
label="category.edit"}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
{{#if tag}}
|
||||
{{#if showToggleInfo}}
|
||||
{{d-button icon="tag" class="btn-default" label="tagging.info" action=toggleInfo id="show-tag-info"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
@ -0,0 +1,11 @@
|
||||
<h2 class="tag-show-heading">
|
||||
{{#link-to "tags"}}
|
||||
{{i18n "tagging.tags"}}
|
||||
{{/link-to}}
|
||||
{{d-icon "angle-right"}}
|
||||
{{discourse-tag-bound tagRecord=tag style="simple"}}
|
||||
{{#each additionalTags as |tag|}}
|
||||
<span>&</span>
|
||||
{{discourse-tag tag style="simple"}}
|
||||
{{/each}}
|
||||
</h2>
|
@ -3,7 +3,7 @@
|
||||
</div>
|
||||
|
||||
<div class="list-controls">
|
||||
<div class="container">
|
||||
<div class="container tags-controls">
|
||||
{{#if canAdminTags}}
|
||||
{{tags-admin-dropdown actionsMapping=actionsMapping}}
|
||||
{{/if}}
|
||||
|
@ -5,53 +5,34 @@
|
||||
|
||||
<div class="list-controls">
|
||||
<div class="container">
|
||||
<section class="navigation-container">
|
||||
<section class="navigation-container tag-navigation">
|
||||
|
||||
{{#if showTagFilter}}
|
||||
{{bread-crumbs
|
||||
categories=categories
|
||||
category=category
|
||||
tagId=tag.id
|
||||
noSubcategories=noSubcategories
|
||||
}}
|
||||
{{navigation-bar navItems=navItems filterMode=filterMode}}
|
||||
{{#if additionalTags}}
|
||||
{{!-- Tag intersections don't work with the tag filter, so show the tag heading instead --}}
|
||||
{{tag-heading tag=tag additionalTags=additionalTags}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<h2 class="tag-show-heading">
|
||||
{{#link-to "tags"}}{{i18n "tagging.tags"}}{{/link-to}}
|
||||
{{d-icon "angle-right"}}
|
||||
{{discourse-tag-bound tagRecord=tag style="simple"}}
|
||||
{{#each additionalTags as |tag|}}
|
||||
<span>&</span>
|
||||
{{discourse-tag tag style="simple"}}
|
||||
{{/each}}
|
||||
</h2>
|
||||
{{tag-heading tag=tag additionalTags=additionalTags}}
|
||||
{{/if}}
|
||||
|
||||
{{#if tagNotification}}
|
||||
{{#unless additionalTags}}
|
||||
{{tag-notifications-button
|
||||
onChange=(action "changeTagNotificationLevel")
|
||||
value=tagNotification.notification_level
|
||||
}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="before-create-topic-button"
|
||||
args=(hash
|
||||
canCreateTopic=canCreateTopic
|
||||
createTopicDisabled=createTopicDisabled
|
||||
createTopicLabel=createTopicLabel)
|
||||
}}
|
||||
|
||||
{{create-topic-button
|
||||
{{d-navigation
|
||||
filterMode=filterMode
|
||||
canCreateTopic=canCreateTopic
|
||||
disabled=createTopicDisabled
|
||||
label=createTopicLabel
|
||||
action=(route-action "createTopic")
|
||||
}}
|
||||
|
||||
{{#if showToggleInfo}}
|
||||
{{d-button icon="tag" class="btn-default" label="tagging.info" action=(action "toggleInfo") id="show-tag-info"}}
|
||||
{{/if}}
|
||||
hasDraft=draft
|
||||
createTopic=(route-action "createTopic")
|
||||
categories=categories
|
||||
category=category
|
||||
tag=tag
|
||||
noSubcategories=noSubcategories
|
||||
showToggleInfo=showToggleInfo
|
||||
tagNotification=tagNotification
|
||||
additionalTags=additionalTags
|
||||
showInfo=showInfo
|
||||
canCreateTopicOnTag=canCreateTopicOnTag
|
||||
changeTagNotificationLevel=(action "changeTagNotificationLevel")
|
||||
toggleInfo=(action "toggleInfo")
|
||||
}}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -38,10 +38,9 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: hidden;
|
||||
@include breakpoint(mobile-large) {
|
||||
width: 100%;
|
||||
}
|
||||
.d-icon {
|
||||
width: 100%;
|
||||
.d-icon,
|
||||
span {
|
||||
margin: 0 0.25em;
|
||||
}
|
||||
}
|
||||
|
@ -480,6 +480,14 @@ ol.category-breadcrumb {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tags-controls {
|
||||
display: flex;
|
||||
h2 {
|
||||
order: -1;
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.staff.tags-page #create-topic {
|
||||
clear: right;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user