From 4973f0ccde7a766ac7e37060c3d2ac81cef13f31 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 8 Jun 2023 22:30:26 +0300 Subject: [PATCH] UX: Remove 'Create Topics' notice (#21958) We are looking at simplifying the new admin/user experience and the many notices bring unnecessary complexity. --- .../app/components/create-topics-notice.hbs | 7 -- .../app/components/create-topics-notice.js | 118 ------------------ .../discourse/app/templates/application.hbs | 1 - config/locales/client.en.yml | 36 ------ config/locales/server.en.yml | 1 - config/site_settings.yml | 4 - .../stylesheets/common/core-extensions.scss | 1 - spec/fixtures/onebox/discourse_topic.response | 2 +- .../onebox/discourse_topic_reply.response | 2 +- 9 files changed, 2 insertions(+), 170 deletions(-) delete mode 100644 app/assets/javascripts/discourse/app/components/create-topics-notice.hbs delete mode 100644 app/assets/javascripts/discourse/app/components/create-topics-notice.js diff --git a/app/assets/javascripts/discourse/app/components/create-topics-notice.hbs b/app/assets/javascripts/discourse/app/components/create-topics-notice.hbs deleted file mode 100644 index 4f6e388f54a..00000000000 --- a/app/assets/javascripts/discourse/app/components/create-topics-notice.hbs +++ /dev/null @@ -1,7 +0,0 @@ -{{#unless this.hidden}} -
-
- {{this.message}} -
-
-{{/unless}} \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/create-topics-notice.js b/app/assets/javascripts/discourse/app/components/create-topics-notice.js deleted file mode 100644 index da6f089ef6a..00000000000 --- a/app/assets/javascripts/discourse/app/components/create-topics-notice.js +++ /dev/null @@ -1,118 +0,0 @@ -import discourseComputed, { observes } from "discourse-common/utils/decorators"; -import Component from "@ember/component"; -import I18n from "I18n"; -import LivePostCounts from "discourse/models/live-post-counts"; -import { alias } from "@ember/object/computed"; -import { htmlSafe } from "@ember/template"; -import { inject as service } from "@ember/service"; - -export default Component.extend({ - classNameBindings: ["hidden:hidden", ":create-topics-notice"], - - enabled: false, - router: service(), - - publicTopicCount: null, - publicPostCount: null, - - requiredTopics: 5, - requiredPosts: alias("siteSettings.tl1_requires_read_posts"), - - init() { - this._super(...arguments); - if (this.shouldSee) { - let topicCount = 0, - postCount = 0; - - // Use data we already have before fetching live stats - this.site.get("categories").forEach((c) => { - if (!c.get("read_restricted")) { - topicCount += c.get("topic_count"); - postCount += c.get("post_count"); - } - }); - - if (topicCount < this.requiredTopics || postCount < this.requiredPosts) { - this.set("enabled", true); - this.fetchLiveStats(); - } - } - }, - - @discourseComputed( - "siteSettings.show_create_topics_notice", - "router.currentRouteName" - ) - shouldSee(showCreateTopicsNotice, currentRouteName) { - return ( - this.currentUser?.get("admin") && - showCreateTopicsNotice && - !this.site.get("wizard_required") && - !currentRouteName.startsWith("wizard") - ); - }, - - @discourseComputed( - "enabled", - "shouldSee", - "publicTopicCount", - "publicPostCount" - ) - hidden(enabled, shouldSee, publicTopicCount, publicPostCount) { - return ( - !enabled || - !shouldSee || - publicTopicCount == null || - publicPostCount == null - ); - }, - - @discourseComputed( - "publicTopicCount", - "publicPostCount", - "topicTrackingState.incomingCount" - ) - message(publicTopicCount, publicPostCount) { - let msg = null; - - if ( - publicTopicCount < this.requiredTopics && - publicPostCount < this.requiredPosts - ) { - msg = "too_few_topics_and_posts_notice_MF"; - } else if (publicTopicCount < this.requiredTopics) { - msg = "too_few_topics_notice_MF"; - } else { - msg = "too_few_posts_notice_MF"; - } - - return htmlSafe( - I18n.messageFormat(msg, { - requiredTopics: this.requiredTopics, - requiredPosts: this.requiredPosts, - currentTopics: publicTopicCount, - currentPosts: publicPostCount, - }) - ); - }, - - @observes("topicTrackingState.incomingCount") - fetchLiveStats() { - if (!this.enabled) { - return; - } - - LivePostCounts.find().then((stats) => { - if (stats) { - this.set("publicTopicCount", stats.get("public_topic_count")); - this.set("publicPostCount", stats.get("public_post_count")); - if ( - this.publicTopicCount >= this.requiredTopics && - this.publicPostCount >= this.requiredPosts - ) { - this.set("enabled", false); // No more checks - } - } - }); - }, -}); diff --git a/app/assets/javascripts/discourse/app/templates/application.hbs b/app/assets/javascripts/discourse/app/templates/application.hbs index 7c505749539..3501a48b0ce 100644 --- a/app/assets/javascripts/discourse/app/templates/application.hbs +++ b/app/assets/javascripts/discourse/app/templates/application.hbs @@ -53,7 +53,6 @@ - start the discussion! There { currentTopics, plural, - one {is # topic} - other {are # topics} - } and { currentPosts, plural, - one {# post} - other {# posts} - }. Visitors need more to read and reply to – we recommend at least { requiredTopics, plural, - one {# topic} - other {# topics} - } and { requiredPosts, plural, - one {# post} - other {# posts} - }. Only staff can see this message. - - # This string uses the ICU Message Format. See https://meta.discourse.org/t/7035 for translation guidelines. - too_few_topics_notice_MF: | - Let's start the discussion! There { currentTopics, plural, - one {is # topic} - other {are # topics} - }. Visitors need more to read and reply to – we recommend at least { requiredTopics, plural, - one {# topic} - other {# topics} - }. Only staff can see this message. - - # This string uses the ICU Message Format. See https://meta.discourse.org/t/7035 for translation guidelines. - too_few_posts_notice_MF: | - Let's start the discussion! There { currentPosts, plural, - one {is # post} - other {are # posts} - }. Visitors need more to read and reply to – we recommend at least { requiredPosts, plural, - one {# post} - other {# posts} - }. Only staff can see this message. - logs_error_rate_notice: # This string uses the ICU Message Format. See https://meta.discourse.org/t/7035 for translation guidelines. reached_hour_MF: | diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 84f00bcdce1..366981d9536 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2255,7 +2255,6 @@ en: embed_post_limit: "Maximum number of posts to embed." embed_username_required: "The username for topic creation is required." notify_about_reviewable_item_after: "If there are reviewable items that haven’t been handled after this many hours, send a personal message to moderators. Set to 0 to disable." - show_create_topics_notice: "If the site has fewer than 5 public topics, show a notice asking admins to create some topics." delete_drafts_older_than_n_days: "Delete drafts older than (n) days." delete_merged_stub_topics_after_days: "Number of days to wait before automatically deleting fully merged stub topics. Set to 0 to never delete stub topics." diff --git a/config/site_settings.yml b/config/site_settings.yml index 1e439d88403..b138e3f4edf 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -2446,10 +2446,6 @@ uncategorized: type: float default: 48 - show_create_topics_notice: - client: true - default: true - enable_system_avatars: hidden: true default: true diff --git a/plugins/chat/assets/stylesheets/common/core-extensions.scss b/plugins/chat/assets/stylesheets/common/core-extensions.scss index 98eb073ab37..e9f16af695c 100644 --- a/plugins/chat/assets/stylesheets/common/core-extensions.scss +++ b/plugins/chat/assets/stylesheets/common/core-extensions.scss @@ -1,6 +1,5 @@ .has-full-page-chat { .global-notice, - .create-topics-notice, .bootstrap-mode-notice { display: none; } diff --git a/spec/fixtures/onebox/discourse_topic.response b/spec/fixtures/onebox/discourse_topic.response index 647d98a1488..5842785be25 100644 --- a/spec/fixtures/onebox/discourse_topic.response +++ b/spec/fixtures/onebox/discourse_topic.response @@ -359,7 +359,7 @@ And that too in just over an year, way to go! [boom]"> - + diff --git a/spec/fixtures/onebox/discourse_topic_reply.response b/spec/fixtures/onebox/discourse_topic_reply.response index 84548d06ccf..8a9bbabf168 100644 --- a/spec/fixtures/onebox/discourse_topic_reply.response +++ b/spec/fixtures/onebox/discourse_topic_reply.response @@ -351,7 +351,7 @@ And that too in just over an year, way to go! [boom]"> - +