A platform for community discussion. Free, open, simple.
UX: Various improvements to welcome topic CTA (#21010)
Bianca Nenciub73a9a1faa78
diff --git a/app/assets/javascripts/discourse/app/components/user-tip.js b/app/assets/javascripts/discourse/app/components/user-tip.jsindex d85656f898d..791a95050bb 100644--- a/app/assets/javascripts/discourse/app/components/user-tip.js+++ b/app/assets/javascripts/discourse/app/components/user-tip.js@@ -1,4 +1,5 @@import { action } from "@ember/object";+import { schedule } from "@ember/runloop";import { inject as service } from "@ember/service";import Component from "@glimmer/component";import { hideUserTip } from "discourse/lib/user-tips";@@ -13,19 +14,22 @@ export default class UserTip extends Component {return;}- const { id, selector, content, placement } = this.args;- this.currentUser.showUserTip({- id,+ schedule("afterRender", () => {+ const { id, selector, content, placement } = this.args;+ this.currentUser.showUserTip({+ id,- titleText: I18n.t(`user_tips.${id}.title`),- contentText: content || I18n.t(`user_tips.${id}.content`),+ titleText: I18n.t(`user_tips.${id}.title`),+ contentText: content || I18n.t(`user_tips.${id}.content`),- reference: selector- ? element.parentElement.querySelector(selector) || element.parentElement- : element,- appendTo: element.parentElement,+ reference: selector+ ? element.parentElement.querySelector(selector) ||+ element.parentElement+ : element,+ appendTo: element.parentElement,- placement: placement || "top",+ placement: placement || "top",+ });});}diff --git a/app/assets/javascripts/discourse/app/components/welcome-topic-banner.hbs b/app/assets/javascripts/discourse/app/components/welcome-topic-banner.hbsdeleted file mode 100644index 32705dbafc8..00000000000--- a/app/assets/javascripts/discourse/app/components/welcome-topic-banner.hbs+++ /dev/null@@ -1,14 +0,0 @@-<div class="welcome-cta">- <div class="welcome-cta__content">- <h1 class="welcome-cta__title">{{i18n "welcome_topic_banner.title"}}</h1>- <p class="welcome-cta__description">{{i18n- "welcome_topic_banner.description"- }}</p>- </div>- <DButton- @class="btn-primary welcome-cta__button"- @action={{action "editWelcomeTopic"}}- @label="welcome_topic_banner.button_title"- @icon="pencil-alt"- />-</div>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/welcome-topic-banner.js b/app/assets/javascripts/discourse/app/components/welcome-topic-banner.jsdeleted file mode 100644index 205fc3538f1..00000000000--- a/app/assets/javascripts/discourse/app/components/welcome-topic-banner.js+++ /dev/null@@ -1,32 +0,0 @@-import Component from "@glimmer/component";-import { action } from "@ember/object";-import { getOwner } from "discourse-common/lib/get-owner";-import Topic from "discourse/models/topic";-import Composer from "discourse/models/composer";-import { inject as service } from "@ember/service";--export default class WelcomeTopicBanner extends Component {- @service siteSettings;- @service store;-- @action- editWelcomeTopic() {- const topicController = getOwner(this).lookup("controller:topic");-- Topic.find(this.siteSettings.welcome_topic_id, {}).then((topic) => {- this.store- .createRecord("topic", {- id: topic.id,- slug: topic.slug,- })- .postStream.loadPostByPostNumber(1)- .then((post) => {- post.topic.setProperties({- draft_key: Composer.EDIT,- "details.can_edit": true,- });- topicController.send("editPost", post);- });- });- }-}diff --git a/app/assets/javascripts/discourse/app/controllers/discovery.js b/app/assets/javascripts/discourse/app/controllers/discovery.jsindex 9a8d58b310d..ae0570b28bf 100644--- a/app/assets/javascripts/discourse/app/controllers/discovery.js+++ b/app/assets/javascripts/discourse/app/controllers/discovery.js@@ -2,7 +2,6 @@ import Controller, { inject as controller } from "@ember/controller";import { alias, equal, not } from "@ember/object/computed";import { action } from "@ember/object";import Category from "discourse/models/category";-import discourseComputed from "discourse-common/utils/decorators";import DiscourseURL from "discourse/lib/url";import { inject as service } from "@ember/service";@@ -22,24 +21,6 @@ export default Controller.extend({loadedAllItems: not("discoveryTopics.model.canLoadMore"),- @discourseComputed(- "router.currentRouteName",- "router.currentRoute.queryParams.f",- "site.show_welcome_topic_banner"- )- showEditWelcomeTopicBanner(- currentRouteName,- hasParams,- showWelcomeTopicBanner- ) {- return (- this.currentUser?.staff &&- currentRouteName === "discovery.latest" &&- showWelcomeTopicBanner &&- !hasParams- );- },-@actionloadingBegan() {this.set("loading", true);diff --git a/app/assets/javascripts/discourse/app/initializers/welcome-topic-banner.js b/app/assets/javascripts/discourse/app/initializers/welcome-topic-banner.jsdeleted file mode 100644index b00f24f83dc..00000000000--- a/app/assets/javascripts/discourse/app/initializers/welcome-topic-banner.js+++ /dev/null@@ -1,24 +0,0 @@-import { bind } from "discourse-common/utils/decorators";--export default {- name: "welcome-topic-banner",- after: "message-bus",-- initialize(container) {- this.site = container.lookup("service:site");- this.messageBus = container.lookup("service:message-bus");-- if (this.site.show_welcome_topic_banner) {- this.messageBus.subscribe("/site/welcome-topic-banner", this.onMessage);- }- },-- teardown() {- this.messageBus.unsubscribe("/site/welcome-topic-banner", this.onMessage);- },-- @bind- onMessage(disabled) {- this.site.set("show_welcome_topic_banner", disabled);- },-};diff --git a/app/assets/javascripts/discourse/app/lib/user-tips.js b/app/assets/javascripts/discourse/app/lib/user-tips.jsindex bc1ceea1758..546db13ec6e 100644--- a/app/assets/javascripts/discourse/app/lib/user-tips.js+++ b/app/assets/javascripts/discourse/app/lib/user-tips.js@@ -1,3 +1,4 @@+import { isTesting } from "discourse-common/config/environment";import { iconHTML } from "discourse-common/lib/icon-library";import I18n from "I18n";import { escape } from "pretty-text/sanitizer";@@ -25,6 +26,7 @@ export function showUserTip(options) {trigger: "manual",theme: "user-tips",zIndex: "",+ delay: isTesting() ? 0 : 100,// It must be interactive to make buttons work.interactive: true,diff --git a/app/assets/javascripts/discourse/app/templates/discovery.hbs b/app/assets/javascripts/discourse/app/templates/discovery.hbsindex 894678dadc7..39f859fbfd4 100644--- a/app/assets/javascripts/discourse/app/templates/discovery.hbs+++ b/app/assets/javascripts/discourse/app/templates/discovery.hbs@@ -28,10 +28,6 @@<PluginOutlet @name="discovery-above" @connectorTagName="div" /></span>-{{#if this.showEditWelcomeTopicBanner}}- <WelcomeTopicBanner />-{{/if}}-<div class="container list-container {{if this.loading 'hidden'}}"><div class="row"><div class="full-width">diff --git a/app/assets/javascripts/discourse/app/templates/topic.hbs b/app/assets/javascripts/discourse/app/templates/topic.hbsindex 1e817eb528e..c14399e29cc 100644--- a/app/assets/javascripts/discourse/app/templates/topic.hbs+++ b/app/assets/javascripts/discourse/app/templates/topic.hbs@@ -149,6 +149,14 @@class="edit-topic"title={{i18n "edit"}}>{{d-icon "pencil-alt"}}</a>++ {{#if (eq this.siteSettings.welcome_topic_id this.model.id)}}+ <UserTip+ @id="welcome_topic"+ @selector=".edit-topic"+ @placement="bottom"+ />+ {{/if}}{{/if}}<PluginOutletdiff --git a/app/assets/javascripts/discourse/tests/acceptance/welcome-topic-banner-test.js b/app/assets/javascripts/discourse/tests/acceptance/welcome-topic-banner-test.jsdeleted file mode 100644index b09dee87c3d..00000000000--- a/app/assets/javascripts/discourse/tests/acceptance/welcome-topic-banner-test.js+++ /dev/null@@ -1,66 +0,0 @@-import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";-import { test } from "qunit";-import { visit } from "@ember/test-helpers";-import Site from "discourse/models/site";--acceptance("Welcome Topic Banner", function (needs) {- needs.user({ admin: true });- needs.site({ show_welcome_topic_banner: true });-- test("Is shown on latest", async function (assert) {- await visit("/latest");- assert.ok(exists(".welcome-cta"), "has the welcome topic banner");- assert.ok(- exists("button.welcome-cta__button"),- "has the welcome topic edit button"- );- });-- test("Does not show if edited", async function (assert) {- const site = Site.current();- site.set("show_welcome_topic_banner", false);-- await visit("/latest");- assert.ok(!exists(".welcome-cta"), "has the welcome topic banner");- });-- test("Does not show on latest with query param tracked present", async function (assert) {- await visit("/latest?f=tracked");- assert.ok(- !exists(".welcome-cta"),- "does not have the welcome topic banner"- );- });-- test("Does not show on latest with query param watched present", async function (assert) {- await visit("/latest?f=watched");- assert.ok(- !exists(".welcome-cta"),- "does not have the welcome topic banner"- );- });-- test("Does not show on /categories page", async function (assert) {- await visit("/categories");- assert.ok(- !exists(".welcome-cta"),- "does not have the welcome topic banner"- );- });-- test("Does not show on /top page", async function (assert) {- await visit("/top");- assert.ok(- !exists(".welcome-cta"),- "does not have the welcome topic banner"- );- });-- test("Does not show on /unseen page", async function (assert) {- await visit("/unseen");- assert.ok(- !exists(".welcome-cta"),- "does not have the welcome topic banner"- );- });-});diff --git a/app/assets/stylesheets/common/base/user-tips.scss b/app/assets/stylesheets/common/base/user-tips.scssindex e1cea033358..e78534ccc15 100644--- a/app/assets/stylesheets/common/base/user-tips.scss+++ b/app/assets/stylesheets/common/base/user-tips.scss@@ -3,6 +3,7 @@}.user-tip-container {+ font-weight: normal;min-width: 300px;padding: 0.5em;text-align: left;diff --git a/app/assets/stylesheets/desktop/topic-list.scss b/app/assets/stylesheets/desktop/topic-list.scssindex 24f5ad46aa8..ed6382ba705 100644--- a/app/assets/stylesheets/desktop/topic-list.scss+++ b/app/assets/stylesheets/desktop/topic-list.scss@@ -249,21 +249,3 @@.container.list-container {position: relative;}--.welcome-cta {- background-color: var(--secondary);- border: 1px solid var(--primary-low);- box-shadow: shadow("menu-panel");- border-radius: 4px;- padding: 12px 20px;- display: flex;- flex-direction: row;- justify-content: space-between;- z-index: z("usercard");- &__content {- width: 70%;- }- &__button {- align-self: center;- }-}diff --git a/app/models/category.rb b/app/models/category.rbindex 0b0363f39bd..b962126319d 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -420,10 +420,7 @@ class Category < ActiveRecord::Baseenddef clear_related_site_settings- if self.id == SiteSetting.general_category_id- SiteSetting.general_category_id = -1- Site.clear_show_welcome_topic_cache- end+ SiteSetting.general_category_id = -1 if self.id == SiteSetting.general_category_idenddef topic_urldiff --git a/app/models/site.rb b/app/models/site.rbindex 8fc9042d5e4..70e466e82a9 100644--- a/app/models/site.rb+++ b/app/models/site.rb@@ -216,40 +216,4 @@ class Site# the cache is validated based on the sequenceMessageBus.publish(SITE_JSON_CHANNEL, "")end-- def self.welcome_topic_banner_cache_key(user_id)- "show_welcome_topic_banner:#{user_id}"- end-- def self.welcome_topic_exists_and_is_not_edited?- Post- .joins(:topic)- .where(- "topics.id = :topic_id AND topics.deleted_at IS NULL AND posts.post_number = 1 AND posts.version = 1 AND posts.created_at > :created_at",- topic_id: SiteSetting.welcome_topic_id,- created_at: 1.month.ago,- )- .exists?- end-- def self.clear_show_welcome_topic_cache- Discourse- .cache- .keys("show_welcome_topic_banner:*")- .each { |key| Discourse.cache.redis.del(key) }- end-- def self.show_welcome_topic_banner?(guardian)- return false if !guardian.is_admin?- return false if guardian.user.id != User.first_login_admin_id- user_id = guardian.user.id-- show_welcome_topic_banner = Discourse.cache.read(welcome_topic_banner_cache_key(user_id))- return show_welcome_topic_banner unless show_welcome_topic_banner.nil?-- show_welcome_topic_banner = welcome_topic_exists_and_is_not_edited?-- Discourse.cache.write(welcome_topic_banner_cache_key(user_id), show_welcome_topic_banner)- show_welcome_topic_banner- endenddiff --git a/app/models/user.rb b/app/models/user.rbindex ae589ce8569..45f3b0c47fb 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -355,6 +355,7 @@ class User < ActiveRecord::Basepost_menu: 3,topic_notification_levels: 4,suggested_topics: 5,+ welcome_topic: 6,)enddiff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rbindex 6af8623a3f7..7bafdb66976 100644--- a/app/serializers/site_serializer.rb+++ b/app/serializers/site_serializer.rb@@ -37,7 +37,6 @@ class SiteSerializer < ApplicationSerializer:hashtag_configurations,:hashtag_icons,:displayed_about_plugin_stat_groups,- :show_welcome_topic_banner,:anonymous_default_sidebar_tags,:anonymous_sidebar_sections,:whispers_allowed_groups_names,@@ -249,10 +248,6 @@ class SiteSerializer < ApplicationSerializerAbout.displayed_plugin_stat_groupsend- def show_welcome_topic_banner- Site.show_welcome_topic_banner?(scope)- end-def anonymous_default_sidebar_tagsSiteSetting.default_sidebar_tags.split("|") - DiscourseTagging.hidden_tag_names(scope)enddiff --git a/config/initializers/014-track-setting-changes.rb b/config/initializers/014-track-setting-changes.rbindex 6fa3a40b613..498123a5475 100644--- a/config/initializers/014-track-setting-changes.rb+++ b/config/initializers/014-track-setting-changes.rb@@ -65,4 +65,22 @@ DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|endEmoji.clear_cache && Discourse.request_refresh! if name == :emoji_deny_list++ if (name == :title || name == :site_description) &&+ topic = Topic.find_by(id: SiteSetting.welcome_topic_id)+ PostRevisor.new(topic.first_post, topic).revise!(+ Discourse.system_user,+ {+ title: I18n.t("discourse_welcome_topic.title", site_title: SiteSetting.title),+ raw:+ I18n.t(+ "discourse_welcome_topic.body",+ base_path: Discourse.base_path,+ site_title: SiteSetting.title,+ site_description: SiteSetting.site_description,+ ),+ },+ skip_revision: true,+ )+ endenddiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex bfb22501eea..103caac8c40 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -1930,6 +1930,10 @@ en:title: "Keep reading!"content: "Here are some topics we think you might like to read next."+ welcome_topic:+ title: "Edit the welcome topic"+ content: "Help new members feel at home by customizing this topic to suit your community's needs."+loading: "Loading..."errors:prev_page: "while trying to load"diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 9b8219c7d36..e9f3b33b165 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -678,21 +678,19 @@ en:staff_category_description: "Private category for staff discussions. Topics are only visible to admins and moderators."discourse_welcome_topic:- title: "Welcome to our community!"+ title: "Welcome to %{site_title}! :wave:"body: |+ We're so glad you've joined us. %{site_description}- The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!+ %{site_title} is powered by Discourse.org, the powerful, open platform for communities of all kinds. Here are some things you can do to get started:- **Edit this** into a brief description of your community:+ :speaking_head: **Introduce yourself** by adding your picture and information about yourself and your interests to [your profile](%{base_path}/my/profile). What is one thing you’d like to be asked about?- - Who is it for?- - What can they find here?- - Why should they come here?- - Where can they read more (links, resources, etc)?+ :open_book: **Get to know the community** by [browsing discussions](%{base_path}/top) that are already happening here. When you find a post interesting, informative, or entertaining, use the :heart: to show your appreciation or support!- <img src="%{base_path}/images/welcome/discourse-edit-post-animated.gif" width="508" height="106">+ :handshake: **Contribute** by commenting, sharing your own perspective, asking questions, or offering feedback in the discussion. Before replying or starting new topics, please review the [Community Guidelines](%{base_path}/faq).- You may want to close this topic via the admin :wrench: (at the upper right and bottom), so that replies don't pile up on an announcement.+ > If you need help or have a suggestion, feel free to ask in [#feedback](%{base_path}/c/site-feedback) or [contact the admins](%{base_path}/about).admin_quick_start_title: "READ ME FIRST: Admin Quick Start Guide"diff --git a/lib/post_revisor.rb b/lib/post_revisor.rbindex ca3c86bca60..7f9d55c1b60 100644--- a/lib/post_revisor.rb+++ b/lib/post_revisor.rb@@ -694,7 +694,6 @@ class PostRevisorupdate_topic_excerptupdate_category_description- hide_welcome_topic_bannerenddef update_topic_excerpt@@ -716,15 +715,6 @@ class PostRevisorendend- def hide_welcome_topic_banner- return unless guardian.is_admin?- return unless @topic.id == SiteSetting.welcome_topic_id- return unless Discourse.cache.read(Site.welcome_topic_banner_cache_key(@editor.id))-- Discourse.cache.write(Site.welcome_topic_banner_cache_key(@editor.id), false)- MessageBus.publish("/site/welcome-topic-banner", false)- end-def advance_draft_sequence@post.advance_draft_sequenceenddiff --git a/lib/seed_data/topics.rb b/lib/seed_data/topics.rbindex d98106579d9..ad4d15052f0 100644--- a/lib/seed_data/topics.rb+++ b/lib/seed_data/topics.rb@@ -84,8 +84,14 @@ module SeedDataif general_category = Category.find_by(id: SiteSetting.general_category_id)topics << {site_setting_name: "welcome_topic_id",- title: I18n.t("discourse_welcome_topic.title"),- raw: I18n.t("discourse_welcome_topic.body", base_path: Discourse.base_path),+ title: I18n.t("discourse_welcome_topic.title", site_title: SiteSetting.title),+ raw:+ I18n.t(+ "discourse_welcome_topic.body",+ base_path: Discourse.base_path,+ site_title: SiteSetting.title,+ site_description: SiteSetting.site_description,+ ),category: general_category,after_create: proc { |post| post.topic.update_pinned(true, true) },}diff --git a/lib/topic_query_params.rb b/lib/topic_query_params.rbindex 9e6d69395c2..4195c3709aa 100644--- a/lib/topic_query_params.rb+++ b/lib/topic_query_params.rb@@ -18,18 +18,6 @@ module TopicQueryParams:no_subcategories].present?- if hide_welcome_topic?- options[:except_topic_ids] ||= []- options[:except_topic_ids] << SiteSetting.welcome_topic_id- end-optionsend-- private-- def hide_welcome_topic?- return false if !SiteSetting.bootstrap_mode_enabled- Site.welcome_topic_exists_and_is_not_edited?- endenddiff --git a/public/images/welcome/discourse-edit-post-animated.gif b/public/images/welcome/discourse-edit-post-animated.gifdeleted file mode 100644index 1600beea327..00000000000Binary files a/public/images/welcome/discourse-edit-post-animated.gif and /dev/null differdiff --git a/spec/lib/post_revisor_spec.rb b/spec/lib/post_revisor_spec.rbindex ec13f74f4bb..1696471dcda 100644--- a/spec/lib/post_revisor_spec.rb+++ b/spec/lib/post_revisor_spec.rb@@ -879,26 +879,6 @@ RSpec.describe PostRevisor doendend- describe "welcome topic" do- before { SiteSetting.welcome_topic_id = topic.id }-- it "should publish welcome topic edit message" do- revisor = PostRevisor.new(post)- first_post = topic.first_post- UserAuthToken.generate!(user_id: admin.id)- Discourse.cache.write(Site.welcome_topic_banner_cache_key(admin.id), true)-- messages =- MessageBus.track_publish("/site/welcome-topic-banner") do- revisor.revise!(admin, { raw: "updated welcome topic body" })- end- welcome_topic_banner_message =- messages.find { |message| message.channel == "/site/welcome-topic-banner" }- expect(welcome_topic_banner_message).to be_present- expect(welcome_topic_banner_message.data).to eq(false)- end- end-it "doesn't strip starting whitespaces" dosubject.revise!(post.user, raw: " <-- whitespaces --> ")post.reloaddiff --git a/spec/lib/seed_data/topics_spec.rb b/spec/lib/seed_data/topics_spec.rbindex 581ecc10273..815d30ac314 100644--- a/spec/lib/seed_data/topics_spec.rb+++ b/spec/lib/seed_data/topics_spec.rb@@ -19,9 +19,16 @@ RSpec.describe SeedData::Topics doexpect { create_topic }.to change { Topic.count }.by(1).and change { Post.count }.by(1)topic = Topic.last- expect(topic.title).to eq(I18n.t("discourse_welcome_topic.title"))+ expect(topic.title).to eq(+ I18n.t("discourse_welcome_topic.title", site_title: SiteSetting.title),+ )expect(topic.first_post.raw).to eq(- I18n.t("discourse_welcome_topic.body", base_path: Discourse.base_path).rstrip,+ I18n.t(+ "discourse_welcome_topic.body",+ base_path: Discourse.base_path,+ site_title: SiteSetting.title,+ site_description: SiteSetting.site_description,+ ).rstrip,)expect(topic.category_id).to eq(SiteSetting.general_category_id)expect(topic.user_id).to eq(Discourse::SYSTEM_USER_ID)@@ -81,9 +88,16 @@ RSpec.describe SeedData::Topics doupdate_topictopic.reload- expect(topic.title).to eq(I18n.t("discourse_welcome_topic.title"))+ expect(topic.title).to eq(+ I18n.t("discourse_welcome_topic.title", site_title: SiteSetting.title),+ )expect(topic.first_post.raw).to eq(- I18n.t("discourse_welcome_topic.body", base_path: Discourse.base_path).rstrip,+ I18n.t(+ "discourse_welcome_topic.body",+ base_path: Discourse.base_path,+ site_title: SiteSetting.title,+ site_description: SiteSetting.site_description,+ ).rstrip,)enddiff --git a/spec/lib/topics_filter_spec.rb b/spec/lib/topics_filter_spec.rbindex aa82ad25fcd..9bcb38953e5 100644--- a/spec/lib/topics_filter_spec.rb+++ b/spec/lib/topics_filter_spec.rb@@ -1345,7 +1345,7 @@ RSpec.describe TopicsFilter do.new(guardian: Guardian.new).filter_from_query_string("order:category").pluck(:id),- ).to eq([topic2.id, topic.id, topic5.id, topic3.id, topic4.id])+ ).to eq([topic2.id, [topic.id, topic5.id].sort, [topic3.id, topic4.id].sort].flatten)endendenddiff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rbindex a8d67af563f..385e0993faf 100644--- a/spec/models/site_spec.rb+++ b/spec/models/site_spec.rb@@ -188,66 +188,4 @@ RSpec.describe Site dodata = JSON.parse(Site.json_for(Guardian.new))expect(data["auth_providers"].map { |a| a["name"] }).to contain_exactly("facebook", "twitter")end-- describe ".show_welcome_topic_banner?" do- it "returns false when the user is not admin" do- first_post = Fabricate(:post, created_at: 25.days.ago)- SiteSetting.welcome_topic_id = first_post.topic.id-- expect(Site.show_welcome_topic_banner?(Guardian.new(Fabricate(:user)))).to eq(false)- end-- it "returns false when the user is not first admin who logs in" do- admin = Fabricate(:admin)- first_post = Fabricate(:post, created_at: 25.days.ago)- SiteSetting.welcome_topic_id = first_post.topic.id-- expect(Site.show_welcome_topic_banner?(Guardian.new(admin))).to eq(false)- end-- it "returns true when welcome topic is less than month old" do- admin = Fabricate(:admin)- UserAuthToken.generate!(user_id: admin.id)-- first_post = Fabricate(:post, created_at: 25.days.ago)- SiteSetting.welcome_topic_id = first_post.topic.id-- expect(Site.show_welcome_topic_banner?(Guardian.new(admin))).to eq(true)- expect(Discourse.cache.read(Site.welcome_topic_banner_cache_key(admin.id))).to eq(true)- end-- it "returns false when welcome topic is more than month old" do- admin = Fabricate(:admin)- UserAuthToken.generate!(user_id: admin.id)-- first_post = Fabricate(:post, created_at: 35.days.ago)- SiteSetting.welcome_topic_id = first_post.topic.id-- expect(Site.show_welcome_topic_banner?(Guardian.new(admin))).to eq(false)- expect(Discourse.cache.read(Site.welcome_topic_banner_cache_key(admin.id))).to eq(false)- end-- it "returns false when welcome topic has been edited" do- admin = Fabricate(:admin)- UserAuthToken.generate!(user_id: admin.id)-- first_post = Fabricate(:post, version: 2, created_at: 25.days.ago)- SiteSetting.welcome_topic_id = first_post.topic.id-- expect(Site.show_welcome_topic_banner?(Guardian.new(admin))).to eq(false)- expect(Discourse.cache.read(Site.welcome_topic_banner_cache_key(admin.id))).to eq(false)- end-- it "returns false when welcome topic has been deleted" do- admin = Fabricate(:admin)- UserAuthToken.generate!(user_id: admin.id)-- topic = Fabricate(:topic, deleted_at: 1.minute.ago)- first_post = Fabricate(:post, topic: topic, created_at: 25.days.ago)- SiteSetting.welcome_topic_id = topic.id-- expect(Site.show_welcome_topic_banner?(Guardian.new(admin))).to eq(false)- expect(Discourse.cache.read(Site.welcome_topic_banner_cache_key(admin.id))).to eq(false)- end- endenddiff --git a/spec/requests/api/schemas/json/site_response.json b/spec/requests/api/schemas/json/site_response.jsonindex 2830f20bfe3..3e215cc38f6 100644--- a/spec/requests/api/schemas/json/site_response.json+++ b/spec/requests/api/schemas/json/site_response.json@@ -241,6 +241,9 @@},"suggested_topics": {"type": "integer"+ },+ "welcome_topic": {+ "type": "integer"}},"required": [@@ -752,9 +755,6 @@]}},- "show_welcome_topic_banner": {- "type": "boolean"- },"archetypes": {"type": "array","items":diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rbindex 8eec0f2bcd4..8666391b98a 100644--- a/spec/requests/categories_controller_spec.rb+++ b/spec/requests/categories_controller_spec.rb@@ -261,74 +261,6 @@ RSpec.describe CategoriesController doendend- describe "welcome topic" do- fab!(:category) { Fabricate(:category) }- fab!(:topic1) do- Fabricate(- :topic,- category: category,- created_at: 5.days.ago,- updated_at: Time.now,- bumped_at: Time.now,- )- end- fab!(:topic2) do- Fabricate(:topic, category: category, created_at: 2.days.ago, bumped_at: 2.days.ago)- end- fab!(:topic3) do- Fabricate(:topic, category: category, created_at: 1.day.ago, bumped_at: 1.day.ago)- end- fab!(:welcome_topic) { Fabricate(:topic) }- fab!(:post) { Fabricate(:post, topic: welcome_topic) }-- before do- SiteSetting.desktop_category_page_style = "categories_and_latest_topics"- SiteSetting.welcome_topic_id = welcome_topic.id- SiteSetting.editing_grace_period = 1.minute.to_i- SiteSetting.bootstrap_mode_enabled = true- end-- it "is hidden for non-admins" do- get "/categories_and_latest.json"- expect(response.status).to eq(200)- expect(response.parsed_body["topic_list"]["topics"].map { |t| t["id"] }).not_to include(- welcome_topic.id,- )- end-- it "is shown to non-admins when there is an edit" do- post.revise(post.user, { raw: "#{post.raw}2" }, revised_at: post.updated_at + 2.minutes)- post.reload- expect(post.version).to eq(2)-- get "/categories_and_latest.json"- expect(response.status).to eq(200)- expect(response.parsed_body["topic_list"]["topics"].map { |t| t["id"] }).to include(- welcome_topic.id,- )- end-- it "is hidden to admins" do- sign_in(admin)-- get "/categories_and_latest.json"- expect(response.status).to eq(200)- expect(response.parsed_body["topic_list"]["topics"].map { |t| t["id"] }).not_to include(- welcome_topic.id,- )- end-- it "is shown to users when bootstrap mode is disabled" do- SiteSetting.bootstrap_mode_enabled = false-- get "/categories_and_latest.json"- expect(response.status).to eq(200)- expect(response.parsed_body["topic_list"]["topics"].map { |t| t["id"] }).to include(- welcome_topic.id,- )- end- end-it "includes subcategories and topics by default when view is subcategories_with_featured_topics" doSiteSetting.max_category_nesting = 3subcategory = Fabricate(:category, user: admin, parent_category: category)diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex da2eb313670..7a7682dc3ff 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -1078,57 +1078,6 @@ RSpec.describe ListController doendend- describe "welcome topic" do- fab!(:welcome_topic) { Fabricate(:topic) }- fab!(:post) { Fabricate(:post, topic: welcome_topic) }-- before do- SiteSetting.welcome_topic_id = welcome_topic.id- SiteSetting.editing_grace_period = 1.minute.to_i- SiteSetting.bootstrap_mode_enabled = true- end-- it "is hidden for non-admins" do- get "/latest.json"- expect(response.status).to eq(200)- parsed = response.parsed_body- expect(parsed["topic_list"]["topics"].length).to eq(1)- expect(parsed["topic_list"]["topics"].first["id"]).not_to eq(welcome_topic.id)- end-- it "is shown to non-admins when there is an edit" do- post.revise(post.user, { raw: "#{post.raw}2" }, revised_at: post.updated_at + 2.minutes)- post.reload- expect(post.version).to eq(2)-- get "/latest.json"- expect(response.status).to eq(200)- parsed = response.parsed_body- expect(parsed["topic_list"]["topics"].length).to eq(2)- expect(parsed["topic_list"]["topics"].first["id"]).to eq(welcome_topic.id)- end-- it "is hidden to admins" do- sign_in(admin)-- get "/latest.json"- expect(response.status).to eq(200)- parsed = response.parsed_body- expect(parsed["topic_list"]["topics"].length).to eq(1)- expect(parsed["topic_list"]["topics"].first["id"]).not_to eq(welcome_topic.id)- end-- it "is shown to users when bootstrap mode is disabled" do- SiteSetting.bootstrap_mode_enabled = false-- get "/latest.json"- expect(response.status).to eq(200)- parsed = response.parsed_body- expect(parsed["topic_list"]["topics"].length).to eq(2)- expect(parsed["topic_list"]["topics"].first["id"]).to eq(welcome_topic.id)- end- end-describe "#filter" dofab!(:category) { Fabricate(:category, slug: "category-slug") }fab!(:tag) { Fabricate(:tag, name: "tag1") }diff --git a/spec/serializers/site_serializer_spec.rb b/spec/serializers/site_serializer_spec.rbindex c3b0f7c988b..201b0fb325b 100644--- a/spec/serializers/site_serializer_spec.rb+++ b/spec/serializers/site_serializer_spec.rb@@ -131,19 +131,6 @@ RSpec.describe SiteSerializer doexpect(serialized[:shared_drafts_category_id]).to eq(nil)end- it "includes show_welcome_topic_banner" do- admin = Fabricate(:admin)- admin_guardian = Guardian.new(admin)- UserAuthToken.generate!(user_id: admin.id)-- first_post = Fabricate(:post, created_at: 25.days.ago)- SiteSetting.welcome_topic_id = first_post.topic.id-- serialized =- described_class.new(Site.new(admin_guardian), scope: admin_guardian, root: false).as_json- expect(serialized[:show_welcome_topic_banner]).to eq(true)- end-describe "#anonymous_default_sidebar_tags" dofab!(:user) { Fabricate(:user) }fab!(:tag) { Fabricate(:tag, name: "dev") }