Skip to content

A platform for community discussion. Free, open, simple.

Refactor: tags/show should use d-navigation (#10927)

Krisb9fb1cebcd8c
diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.js b/app/assets/javascripts/discourse/app/components/d-navigation.js
index 1a419f58c3e..b75ba8ee18b 100644
--- a/app/assets/javascripts/discourse/app/components/d-navigation.js
+++ b/app/assets/javascripts/discourse/app/components/d-navigation.js
@@ -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,
});
},
diff --git a/app/assets/javascripts/discourse/app/components/tag-heading.js b/app/assets/javascripts/discourse/app/components/tag-heading.js
new file mode 100644
index 00000000000..0e6d50b17d4
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/tag-heading.js
@@ -0,0 +1,4 @@
+import Component from "@ember/component";
+export default Component.extend({
+ tagName: "",
+});
diff --git a/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs b/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs
index d8c1ab13633..ace2de9b52b 100644
--- a/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs
@@ -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=""}}
diff --git a/app/assets/javascripts/discourse/app/templates/components/d-navigation.hbs b/app/assets/javascripts/discourse/app/templates/components/d-navigation.hbs
index 2ac52d5f71b..c9b4d4b345f 100644
--- a/app/assets/javascripts/discourse/app/templates/components/d-navigation.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/d-navigation.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/app/templates/components/tag-heading.hbs b/app/assets/javascripts/discourse/app/templates/components/tag-heading.hbs
new file mode 100644
index 00000000000..ec791283cc4
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/templates/components/tag-heading.hbs
@@ -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>&amp;</span>
+ {{discourse-tag tag style="simple"}}
+ {{/each}}
+</h2>
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/templates/tags/index.hbs b/app/assets/javascripts/discourse/app/templates/tags/index.hbs
index 3527823b289..be377466705 100644
--- a/app/assets/javascripts/discourse/app/templates/tags/index.hbs
+++ b/app/assets/javascripts/discourse/app/templates/tags/index.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/app/templates/tags/show.hbs b/app/assets/javascripts/discourse/app/templates/tags/show.hbs
index ca59b27c9bc..df6a757526c 100644
--- a/app/assets/javascripts/discourse/app/templates/tags/show.hbs
+++ b/app/assets/javascripts/discourse/app/templates/tags/show.hbs
@@ -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>&amp;</span>
- {{discourse-tag tag style="simple"}}
- {{/each}}
- </h2>
- {{/if}}
-
- {{#if tagNotification}}
- {{#unless additionalTags}}
- {{tag-notifications-button
- onChange=(action "changeTagNotificationLevel")
- value=tagNotification.notification_level
- }}
- {{/unless}}
+ {{tag-heading tag=tag additionalTags=additionalTags}}
{{/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>
diff --git a/app/assets/stylesheets/common/base/tagging.scss b/app/assets/stylesheets/common/base/tagging.scss
index 8222c0fa05a..d81201c5132 100644
--- a/app/assets/stylesheets/common/base/tagging.scss
+++ b/app/assets/stylesheets/common/base/tagging.scss
@@ -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;
}
}
diff --git a/app/assets/stylesheets/mobile/topic-list.scss b/app/assets/stylesheets/mobile/topic-list.scss
index a8293f0458d..6baaf05f585 100644
--- a/app/assets/stylesheets/mobile/topic-list.scss
+++ b/app/assets/stylesheets/mobile/topic-list.scss
@@ -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;
}