diff --git a/app/assets/javascripts/discourse/app/components/composer-container.gjs b/app/assets/javascripts/discourse/app/components/composer-container.gjs index a206ba502cd75..118b8db9834de 100644 --- a/app/assets/javascripts/discourse/app/components/composer-container.gjs +++ b/app/assets/javascripts/discourse/app/components/composer-container.gjs @@ -254,7 +254,6 @@ export default class ComposerContainer extends Component { disabled=this.composer.disableCategoryChooser scopedCategoryId=this.composer.scopedCategoryId prioritizedCategoryId=this.composer.prioritizedCategoryId - readOnlyCategoryId=this.composer.readOnlyCategoryId }} /> {{#if this.canCreateTopic}} - + + <:button> + + + <:tooltip> + {{#if @disabled}} + + {{/if}} + + {{#if @showDrafts}} diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.gjs b/app/assets/javascripts/discourse/app/components/d-navigation.gjs index 2257c9bdd0b7f..d1a785a599ce1 100644 --- a/app/assets/javascripts/discourse/app/components/d-navigation.gjs +++ b/app/assets/javascripts/discourse/app/components/d-navigation.gjs @@ -5,6 +5,7 @@ import { hash } from "@ember/helper"; import { action } from "@ember/object"; import { dependentKeyCompat } from "@ember/object/compat"; import { service } from "@ember/service"; +import { htmlSafe } from "@ember/template"; import { tagName } from "@ember-decorators/component"; import { and, gt } from "truth-helpers"; import BreadCrumbs from "discourse/components/bread-crumbs"; @@ -117,6 +118,35 @@ export default class DNavigation extends Component { } } + @discourseComputed( + "createTopicDisabled", + "categoryReadOnlyBanner", + "canCreateTopicOnTag", + "tag.id" + ) + createTopicButtonDisabled( + createTopicDisabled, + categoryReadOnlyBanner, + canCreateTopicOnTag, + tagId + ) { + if (tagId && !canCreateTopicOnTag) { + return true; + } else if (categoryReadOnlyBanner) { + return false; + } + return createTopicDisabled; + } + + @discourseComputed("categoryReadOnlyBanner") + createTopicClass(categoryReadOnlyBanner) { + let classNames = ["btn-default"]; + if (categoryReadOnlyBanner) { + classNames.push("disabled"); + } + return classNames.join(" "); + } + @discourseComputed("category.can_edit") showCategoryEdit(canEdit) { return canEdit; @@ -196,7 +226,11 @@ export default class DNavigation extends Component { @action clickCreateTopicButton() { - this.createTopic(); + if (this.categoryReadOnlyBanner) { + this.dialog.alert({ message: htmlSafe(this.categoryReadOnlyBanner) }); + } else { + this.createTopic(); + } }