diff --git a/app/assets/javascripts/admin/addon/templates/config-about.hbs b/app/assets/javascripts/admin/addon/templates/config-about.hbs index f90e5b11b3e..266f64240f1 100644 --- a/app/assets/javascripts/admin/addon/templates/config-about.hbs +++ b/app/assets/javascripts/admin/addon/templates/config-about.hbs @@ -5,6 +5,7 @@ (hash basePath=(base-path)) }} @hideTabs={{true}} + @learnMoreUrl="https://meta.discourse.org/t/understanding-and-customizing-the-about-page/332161" > <:breadcrumbs> ${url}`, - }); - } else if (email) { - return I18n.t("about.contact_info", { - contact_info: email, - }); - } else { - return null; - } - } - - @discourseComputed( - "model.stats.visitors_30_days", - "model.stats.eu_visitors_30_days" - ) - statsTableFooter(all, eu) { - return I18n.messageFormat("about.traffic_info_footer_MF", { - total_visitors: all, - eu_visitors: eu, - }); - } - - @discourseComputed("site.displayed_about_plugin_stat_groups") - statGroups() { - const set = new Set(customStats); - for (const name of this.site.displayed_about_plugin_stat_groups || []) { - set.add(name); - } - return Array.from(set); - } - - @discourseComputed( - "model.stats.visitors_7_days", - "model.stats.eu_visitors_7_days", - "siteSettings.display_eu_visitor_stats" - ) - displayVisitorStats(visitors, euVisitors, displayEuVisitorStats) { - return ( - displayEuVisitorStats && - typeof euVisitors === "number" && - typeof visitors === "number" - ); - } } diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs index 9b91c2fcce8..336fb5b6059 100644 --- a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs +++ b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs @@ -43,7 +43,6 @@ import { setDesktopScrollAreaHeight } from "discourse/components/topic-timeline/ import { addTopicTitleDecorator } from "discourse/components/topic-title"; import { setNotificationsLimit as setUserMenuNotificationsLimit } from "discourse/components/user-menu/notifications-list"; import { addUserMenuProfileTabItem } from "discourse/components/user-menu/profile-tab-content"; -import { addLegacyStat as addLegacyAboutPageStat } from "discourse/controllers/about"; import { addDiscoveryQueryParam } from "discourse/controllers/discovery/list"; import { registerFullPageSearchType } from "discourse/controllers/full-page-search"; import { registerCustomPostMessageCallback as registerCustomPostMessageCallback1 } from "discourse/controllers/topic"; @@ -3267,7 +3266,6 @@ class PluginApi { */ addAboutPageActivity(name, func) { addAboutPageActivity(name, func); - addLegacyAboutPageStat(name); } /** diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js b/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js index 79ff51cbaae..bddb7e0ac8c 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js @@ -40,9 +40,7 @@ export const ADMIN_NAV_MAP = [ links: [ { name: "admin_about_your_site", - route: "adminSiteSettingsCategory", - routeModels: ["required"], - query: { filter: "" }, + route: "adminConfig.about", label: "admin.community.sidebar_link.about_your_site", icon: "gear", }, diff --git a/app/assets/javascripts/discourse/app/templates/about.hbs b/app/assets/javascripts/discourse/app/templates/about.hbs index ac7b68c4661..2dd5df16d41 100644 --- a/app/assets/javascripts/discourse/app/templates/about.hbs +++ b/app/assets/javascripts/discourse/app/templates/about.hbs @@ -35,168 +35,7 @@ }} {{/if}} - {{#if this.currentUser.render_experimental_about_page}} - - {{else}} -
-

{{i18n "about.title" title=this.model.title}}

-

{{this.model.description}}

-
- - - - {{#if this.model.admins}} -
-

{{d-icon "users"}} {{i18n "about.our_admins"}}

-
- -
-
- {{/if}} - - - - - - {{#if this.model.moderators}} -
-

{{d-icon "users"}} {{i18n "about.our_moderators"}}

-
- -
-
- {{/if}} - - - - - - {{#if this.model.category_moderators.length}} - {{#each this.model.category_moderators as |cm|}} -
-

{{category-link cm.category}}{{i18n "about.moderators"}}

-
- -
-
-
- {{/each}} - {{/if}} - {{#if this.model.can_see_about_stats}} -
-

{{d-icon "far-chart-bar"}} {{i18n "about.stats"}}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if this.displayVisitorStats}} - - - - - - - - - - - - - - - {{/if}} - - - - - - - - {{#each this.statGroups as |statGroupName|}} - - - - - - - - {{/each}} - -
- {{i18n "about.stat.last_day"}}{{i18n "about.stat.last_7_days"}}{{i18n "about.stat.last_30_days"}}{{i18n "about.stat.all_time"}}
{{i18n "about.topic_count"}}{{number this.model.stats.topics_last_day}}{{number this.model.stats.topics_7_days}}{{number this.model.stats.topics_30_days}}{{number this.model.stats.topics_count}}
{{i18n "about.post_count"}}{{number this.model.stats.posts_last_day}}{{number this.model.stats.posts_7_days}}{{number this.model.stats.posts_30_days}}{{number this.model.stats.posts_count}}
{{i18n "about.user_count"}}{{number this.model.stats.users_last_day}}{{number this.model.stats.users_7_days}}{{number this.model.stats.users_30_days}}{{number this.model.stats.users_count}}
{{i18n "about.active_user_count"}}{{number this.model.stats.active_users_last_day}}{{number this.model.stats.active_users_7_days}}{{number this.model.stats.active_users_30_days}}
{{i18n "about.visitor_count"}}{{number this.model.stats.visitors_last_day}}{{number this.model.stats.visitors_7_days}}{{number this.model.stats.visitors_30_days}}
{{i18n "about.eu_visitor_count"}}{{number this.model.stats.eu_visitors_last_day}}{{number this.model.stats.eu_visitors_7_days}}{{number this.model.stats.eu_visitors_30_days}}
{{i18n "about.like_count"}}{{number this.model.stats.likes_last_day}}{{number this.model.stats.likes_7_days}}{{number this.model.stats.likes_30_days}}{{number this.model.stats.likes_count}}
{{i18n (concat "about." statGroupName "_count")}}{{number - (get - this.model.stats (concat statGroupName "_last_day") - ) - }}{{number - (get this.model.stats (concat statGroupName "_7_days")) - }}{{number - (get this.model.stats (concat statGroupName "_30_days")) - }}{{number - (get this.model.stats (concat statGroupName "_count")) - }}
- {{#if this.displayVisitorStats}} - - {{/if}} -
- {{/if}} - - {{#if this.contactInfo}} -
-

{{d-icon "envelope"}} {{i18n "about.contact"}}

-

{{html-safe this.contactInfo}}

-
- {{/if}} - {{/if}} + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/tests/acceptance/about-test.js b/app/assets/javascripts/discourse/tests/acceptance/about-test.js deleted file mode 100644 index f3f7042550a..00000000000 --- a/app/assets/javascripts/discourse/tests/acceptance/about-test.js +++ /dev/null @@ -1,28 +0,0 @@ -import { visit } from "@ember/test-helpers"; -import { test } from "qunit"; -import { acceptance } from "discourse/tests/helpers/qunit-helpers"; - -acceptance("About", function () { - test("viewing", async function (assert) { - await visit("/about"); - - assert.dom(document.body).hasClass("about-page", "has body class"); - assert.dom(".about.admins .user-info").exists("has admins"); - assert.dom(".about.moderators .user-info").exists("has moderators"); - assert - .dom(".about.stats tr.about-topic-count td") - .exists("has topic stats"); - assert.dom(".about.stats tr.about-post-count td").exists("has post stats"); - assert.dom(".about.stats tr.about-user-count td").exists("has user stats"); - assert - .dom(".about.stats tr.about-active-user-count td") - .exists("has active user stats"); - assert.dom(".about.stats tr.about-like-count td").exists("has like stats"); - assert - .dom(".about.stats tr.about-chat_messages-count td") - .exists("has plugin stats"); - assert - .dom(".about.stats tr.about-chat_users-count td") - .doesNotExist("does not show hidden plugin stats"); - }); -}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js index 1a136175d6a..db8e736225b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js @@ -108,7 +108,7 @@ acceptance("Admin Sidebar - Sections", function (needs) { assert.strictEqual(count(".admin-reports-list__report"), 0); await click( - ".sidebar-section-link[data-link-name='admin_about_your_site']" + ".sidebar-section-link[data-link-name='admin_login_and_authentication']" ); await click(".sidebar-section-link[data-link-name='admin_all_reports']"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/loading-indicator-test.js b/app/assets/javascripts/discourse/tests/acceptance/loading-indicator-test.js index 45702a857d1..7d35925d24f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/loading-indicator-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/loading-indicator-test.js @@ -66,7 +66,7 @@ acceptance("Page Loading Indicator", function (needs) { assert.strictEqual(currentRouteName(), "about"); assert.dom(SPINNER_SELECTOR).doesNotExist(); - assert.dom("#main-outlet section.about").exists(); + assert.dom("#main-outlet .about__main-content").exists(); }); test("it works in 'slider' mode", async function (assert) { @@ -98,7 +98,7 @@ acceptance("Page Loading Indicator", function (needs) { await settled(); assert.strictEqual(currentRouteName(), "about"); - assert.dom("#main-outlet section.about").exists(); + assert.dom("#main-outlet .about__main-content").exists(); }); test("it only performs one slide during nested loading events", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js index 3bc16c5544d..c7cf310ac55 100644 --- a/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js +++ b/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js @@ -724,7 +724,6 @@ export default { can_revoke: true, }, ], - displayed_about_plugin_stat_groups: ["chat_messages"], hashtag_configurations: { "topic-composer": ["category", "tag"] }, hashtag_icons: { "category": "folder", "tag": "tag" }, anonymous_sidebar_sections: [ diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index 1019af2d4d2..fd202a39aad 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -29,7 +29,6 @@ import { resetQuickSearchRandomTips } from "discourse/components/search-menu/res import { resetOnKeyUpCallbacks } from "discourse/components/search-menu/search-term"; import { resetTopicTitleDecorators } from "discourse/components/topic-title"; import { resetUserMenuProfileTabItems } from "discourse/components/user-menu/profile-tab-content"; -import { clearCustomStats as clearLegacyAboutPageStats } from "discourse/controllers/about"; import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic"; import { clearHTMLCache } from "discourse/helpers/custom-html"; import { resetUsernameDecorators } from "discourse/helpers/decorate-username-selector"; @@ -252,7 +251,6 @@ export function testCleanup(container, app) { resetTransformers(); rollbackAllPrepends(); clearAboutPageActivities(); - clearLegacyAboutPageStats(); resetWidgetCleanCallbacks(); clearPluginHeaderActionComponents(); } diff --git a/app/assets/stylesheets/common/base/about.scss b/app/assets/stylesheets/common/base/about.scss index fb61666a5d9..7086dd0f714 100644 --- a/app/assets/stylesheets/common/base/about.scss +++ b/app/assets/stylesheets/common/base/about.scss @@ -96,46 +96,3 @@ width: 100%; } } - -section.about { - margin-bottom: 3em; - - .users { - display: grid; - gap: 1em; - grid-template-columns: repeat(auto-fit, minmax(20em, 1fr)); - } - - h3 { - margin-bottom: 1em; - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 0 0.35em; - - .d-icon { - color: var(--primary-high); - } - - .badge-category__wrapper { - font-size: var(--font-0); - align-self: baseline; - } - } - - &.stats { - table { - td { - padding: 0.67em; - - &:not(:first-child) { - text-align: center; - } - } - } - - .stats-table-footer { - max-width: 30em; - } - } -} diff --git a/app/models/about.rb b/app/models/about.rb index bdfb447f86e..c11476aa45a 100644 --- a/app/models/about.rb +++ b/app/models/about.rb @@ -1,10 +1,6 @@ # frozen_string_literal: true class About - def self.displayed_plugin_stat_groups - DiscoursePluginRegistry.stats.select { |stat| stat.show_in_ui }.map { |stat| stat.name } - end - class CategoryMods include ActiveModel::Serialization attr_reader :category, :moderators diff --git a/app/models/stat.rb b/app/models/stat.rb index 0ab2a5c09d2..02eebbba64e 100644 --- a/app/models/stat.rb +++ b/app/models/stat.rb @@ -1,14 +1,13 @@ # frozen_string_literal: true class Stat - def initialize(name, show_in_ui: false, expose_via_api: false, &block) + def initialize(name, expose_via_api: false, &block) @name = name - @show_in_ui = show_in_ui @expose_via_api = expose_via_api @block = block end - attr_reader :name, :expose_via_api, :show_in_ui + attr_reader :name, :expose_via_api def calculate @block.call.transform_keys { |key| build_key(key) } @@ -41,23 +40,19 @@ class Stat def self.core_stats list = [ - Stat.new("topics", show_in_ui: true, expose_via_api: true) { Statistics.topics }, - Stat.new("posts", show_in_ui: true, expose_via_api: true) { Statistics.posts }, - Stat.new("users", show_in_ui: true, expose_via_api: true) { Statistics.users }, - Stat.new("active_users", show_in_ui: true, expose_via_api: true) { Statistics.active_users }, - Stat.new("likes", show_in_ui: true, expose_via_api: true) { Statistics.likes }, - Stat.new("participating_users", show_in_ui: false, expose_via_api: true) do - Statistics.participating_users - end, + Stat.new("topics", expose_via_api: true) { Statistics.topics }, + Stat.new("posts", expose_via_api: true) { Statistics.posts }, + Stat.new("users", expose_via_api: true) { Statistics.users }, + Stat.new("active_users", expose_via_api: true) { Statistics.active_users }, + Stat.new("likes", expose_via_api: true) { Statistics.likes }, + Stat.new("participating_users", expose_via_api: true) { Statistics.participating_users }, ] if SiteSetting.display_eu_visitor_stats list.concat( [ - Stat.new("visitors", show_in_ui: true, expose_via_api: true) { Statistics.visitors }, - Stat.new("eu_visitors", show_in_ui: true, expose_via_api: true) do - Statistics.eu_visitors - end, + Stat.new("visitors", expose_via_api: true) { Statistics.visitors }, + Stat.new("eu_visitors", expose_via_api: true) { Statistics.eu_visitors }, ], ) end diff --git a/app/serializers/about_serializer.rb b/app/serializers/about_serializer.rb index 30f82d05010..17c4ce3a969 100644 --- a/app/serializers/about_serializer.rb +++ b/app/serializers/about_serializer.rb @@ -55,18 +55,6 @@ class AboutSerializer < ApplicationSerializer SiteSetting.contact_email end - def include_extended_site_description? - render_redesigned_about_page? - end - - def include_banner_image? - render_redesigned_about_page? - end - - def include_site_creation_date? - render_redesigned_about_page? - end - private def can_see_about_stats @@ -76,10 +64,4 @@ class AboutSerializer < ApplicationSerializer def can_see_site_contact_details scope.can_see_site_contact_details? end - - def render_redesigned_about_page? - return false if scope.anonymous? - - scope.user.in_any_groups?(SiteSetting.experimental_redesigned_about_page_groups_map) - end end diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb index 421e52bd297..419dbcf7e23 100644 --- a/app/serializers/current_user_serializer.rb +++ b/app/serializers/current_user_serializer.rb @@ -77,7 +77,6 @@ class CurrentUserSerializer < BasicUserSerializer :can_view_raw_email, :use_glimmer_topic_list?, :login_method, - :render_experimental_about_page, :has_unseen_features delegate :user_stat, to: :object, private: true @@ -151,10 +150,6 @@ class CurrentUserSerializer < BasicUserSerializer object.staff? end - def render_experimental_about_page - object.in_any_groups?(SiteSetting.experimental_redesigned_about_page_groups_map) - end - def can_post_anonymously SiteSetting.allow_anonymous_posting && (is_anonymous || object.in_any_groups?(SiteSetting.anonymous_posting_allowed_groups_map)) diff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rb index 5c4515b29f9..87089538b93 100644 --- a/app/serializers/site_serializer.rb +++ b/app/serializers/site_serializer.rb @@ -39,7 +39,6 @@ class SiteSerializer < ApplicationSerializer :markdown_additional_options, :hashtag_configurations, :hashtag_icons, - :displayed_about_plugin_stat_groups, :anonymous_default_navigation_menu_tags, :anonymous_sidebar_sections, :whispers_allowed_groups_names, @@ -287,10 +286,6 @@ class SiteSerializer < ApplicationSerializer HashtagAutocompleteService.data_source_icon_map end - def displayed_about_plugin_stat_groups - About.displayed_plugin_stat_groups - end - SIDEBAR_TOP_TAGS_TO_SHOW = 5 def navigation_menu_site_top_tags diff --git a/app/views/about/index.html.erb b/app/views/about/index.html.erb index a9219b05e4f..98bfc49f279 100644 --- a/app/views/about/index.html.erb +++ b/app/views/about/index.html.erb @@ -100,15 +100,6 @@ <%= stats["likes_7_days"] %> <%= stats["likes_30_days"] %> - <% About.displayed_plugin_stat_groups.each do |stat_group_name| %> - - <%=t "js.about.#{stat_group_name}_count" %> - <%= stats["#{stat_group_name}_count"] %> - <%= stats["#{stat_group_name}_last_day"] %> - <%= stats["#{stat_group_name}_7_days"] %> - <%= stats["#{stat_group_name}_30_days"] %> - - <% end %> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index e03cda120ed..b88ea25c5de 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2725,7 +2725,6 @@ en: experimental_topics_filter: "EXPERIMENTAL: Enables the experimental topics filter route at /filter" enable_experimental_lightbox: "EXPERIMENTAL: Replace the default image lightbox with the revamped design." enable_experimental_bookmark_redesign_groups: "EXPERIMENTAL: Show a quick access menu for bookmarks on posts and a new redesigned modal" - experimental_redesigned_about_page_groups: "EXPERIMENTAL: Enable the redesigned /about page for specific groups." experimental_glimmer_topic_list_groups: "EXPERIMENTAL: Enable the new 'glimmer' topic list implementation. This implementation is under active development, and is not intended for production use. Do not develop themes/plugins against it until the implementation is finalized and announced." experimental_form_templates: "EXPERIMENTAL: Enable the form templates feature. After enabled, manage the templates at Customize / Templates." admin_sidebar_enabled_groups: "Enable sidebar navigation for the admin UI for the specified groups, which replaces the top-level admin navigation buttons." diff --git a/config/site_settings.yml b/config/site_settings.yml index 44f4b2f3d2c..449f1bc15ba 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -2465,10 +2465,6 @@ developer: default: "" client: true hidden: true - experimental_redesigned_about_page_groups: - default: "" - type: group_list - allow_any: false custom_flags_limit: default: 50 hidden: true diff --git a/db/migrate/20241024102733_remove_experimental_redesigned_about_page_groups_setting.rb b/db/migrate/20241024102733_remove_experimental_redesigned_about_page_groups_setting.rb new file mode 100644 index 00000000000..5b945403b80 --- /dev/null +++ b/db/migrate/20241024102733_remove_experimental_redesigned_about_page_groups_setting.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class RemoveExperimentalRedesignedAboutPageGroupsSetting < ActiveRecord::Migration[7.1] + def up + execute(<<~SQL) + DELETE FROM site_settings + WHERE name = 'experimental_redesigned_about_page_groups' + SQL + end + + def down + raise IrreversibleMigration.new + end +end diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 01ba645f128..61c58803ae8 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -1126,34 +1126,11 @@ class Plugin::Instance # "chat_messages_30_days": 100, # "chat_messages_count": 1000, # } - # - # The show_in_ui option (default false) is used to determine whether the - # group of stats is shown on the site About page in the Site Statistics - # table. Some stats may be needed purely for reporting purposes and thus - # do not need to be shown in the UI to admins/users. - # - # TODO(osama): remove show_in_ui when experimental_redesigned_about_page_groups is removed - def register_stat( - name, - show_in_ui: ( - not_using_deprecated_arg = true - false - ), - expose_via_api: false, - &block - ) - if !not_using_deprecated_arg - Discourse.deprecate( - "`show_in_ui` argument of the `register_stat` API is deprecated. Please use the `addAboutPageActivity` JS API instead if you want your custom stat to be shown on the about page.", - since: "3.4.0.beta2", - drop_from: "3.5.0.beta1", - ) - end - + def register_stat(name, expose_via_api: false, &block) # We do not want to register and display the same group multiple times. return if DiscoursePluginRegistry.stats.any? { |stat| stat.name == name } - stat = Stat.new(name, show_in_ui: show_in_ui, expose_via_api: expose_via_api, &block) + stat = Stat.new(name, expose_via_api: expose_via_api, &block) DiscoursePluginRegistry.register_stat(stat, self) end diff --git a/plugins/chat/spec/system/about_page_site_acitivity_spec.rb b/plugins/chat/spec/system/about_page_site_acitivity_spec.rb index 64485803da3..f0ac4d3fd58 100644 --- a/plugins/chat/spec/system/about_page_site_acitivity_spec.rb +++ b/plugins/chat/spec/system/about_page_site_acitivity_spec.rb @@ -1,15 +1,10 @@ # frozen_string_literal: true describe "Chat messages site activity in the about page", type: :system do - fab!(:current_user) { Fabricate(:user) } - fab!(:group) { Fabricate(:group, users: [current_user]) } - let(:about_page) { PageObjects::Pages::About.new } before do chat_system_bootstrap - SiteSetting.experimental_redesigned_about_page_groups = group.id.to_s - sign_in(current_user) Fabricate(:chat_message, created_at: 5.hours.ago) Fabricate(:chat_message, created_at: 2.days.ago) diff --git a/spec/lib/plugin/instance_spec.rb b/spec/lib/plugin/instance_spec.rb index f294cb285bc..37e93b1cb4a 100644 --- a/spec/lib/plugin/instance_spec.rb +++ b/spec/lib/plugin/instance_spec.rb @@ -928,7 +928,7 @@ TEXT it "registers an about stat group correctly" do stats = { :last_day => 1, "7_days" => 10, "30_days" => 100, :count => 1000 } - plugin.register_stat("some_group", show_in_ui: true) { stats } + plugin.register_stat("some_group") { stats } expect(Stat.all_stats.with_indifferent_access).to match( hash_including( some_group_last_day: 1, @@ -939,12 +939,6 @@ TEXT ) end - it "hides the stat group from the UI by default" do - stats = { :last_day => 1, "7_days" => 10, "30_days" => 100, :count => 1000 } - plugin.register_stat("some_group") { stats } - expect(About.displayed_plugin_stat_groups).to eq([]) - end - it "does not allow duplicate named stat groups" do stats = { :last_day => 1, "7_days" => 10, "30_days" => 100, :count => 1000 } plugin.register_stat("some_group") { stats } diff --git a/spec/models/about_spec.rb b/spec/models/about_spec.rb index dba52ed924a..759d38c0917 100644 --- a/spec/models/about_spec.rb +++ b/spec/models/about_spec.rb @@ -7,7 +7,7 @@ RSpec.describe About do def register_stat(name, stats_block) DiscoursePluginRegistry.register_stat( - Stat.new(name, show_in_ui: true, expose_via_api: true, &stats_block), + Stat.new(name, expose_via_api: true, &stats_block), stub(enabled?: true), ) end diff --git a/spec/system/about_page_spec.rb b/spec/system/about_page_spec.rb index f2df13294bf..ccd7decf4c7 100644 --- a/spec/system/about_page_spec.rb +++ b/spec/system/about_page_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true describe "About page", type: :system do - fab!(:current_user) { Fabricate(:user) } fab!(:image_upload) fab!(:admin) { Fabricate(:admin, last_seen_at: 1.hour.ago) } fab!(:moderator) { Fabricate(:moderator, last_seen_at: 1.hour.ago) } - fab!(:group) { Fabricate(:group, users: [current_user, admin, moderator]) } before do SiteSetting.title = "title for my forum" @@ -22,411 +20,382 @@ describe "About page", type: :system do SiteSetting.contact_url = "http://some-contact-url.discourse.org" end - describe "legacy version" do - it "renders successfully for a logged-in user" do - sign_in(current_user) + let(:about_page) { PageObjects::Pages::About.new } - visit("/about") + it "renders successfully" do + about_page.visit - expect(page).to have_css(".about.admins") - expect(page).to have_css(".about.moderators") - expect(page).to have_css(".about.stats") - expect(page).to have_css(".about.contact") + expect(about_page).to have_banner_image(image_upload) + expect(about_page).to have_header_title(SiteSetting.title) + expect(about_page).to have_short_description(SiteSetting.site_description) + + expect(about_page).to have_members_count(3, "3") + expect(about_page).to have_admins_count(1, "1") + expect(about_page).to have_moderators_count(1, "1") + end + + it "doesn't render banner image when it's not set" do + SiteSetting.about_banner_image = nil + + about_page.visit + expect(about_page).to have_no_banner_image + end + + describe "displayed site age" do + it "says less than 1 month if the site is less than 1 month old" do + Discourse.stubs(:site_creation_date).returns(1.week.ago) + + about_page.visit + + expect(about_page).to have_site_created_less_than_1_month_ago end - it "renders successfully for an anonymous user" do - visit("/about") + it "says how many months old the site is if the site is less than 1 year old" do + Discourse.stubs(:site_creation_date).returns(2.months.ago) - expect(page).to have_css(".about.admins") - expect(page).to have_css(".about.moderators") - expect(page).to have_css(".about.stats") - expect(page).to have_css(".about.contact") + about_page.visit + + expect(about_page).to have_site_created_in_months_ago(2) + end + + it "says how many years old the site is if the site is more than 1 year old" do + Discourse.stubs(:site_creation_date).returns(5.years.ago) + + about_page.visit + + expect(about_page).to have_site_created_in_years_ago(5) end end - describe "redesigned version" do - let(:about_page) { PageObjects::Pages::About.new } + describe "the site activity section" do + describe "topics" do + before do + Fabricate(:topic, created_at: 2.days.ago) + Fabricate(:topic, created_at: 3.days.ago) + Fabricate(:topic, created_at: 8.days.ago) + end - before do - SiteSetting.experimental_redesigned_about_page_groups = group.id.to_s - sign_in(current_user) + it "shows the count of topics created in the last 7 days" do + about_page.visit + expect(about_page.site_activities.topics).to have_count(2, "2") + expect(about_page.site_activities.topics).to have_7_days_period + end end - it "renders successfully for a logged in user" do - about_page.visit + describe "posts" do + before do + Fabricate(:post, created_at: 2.days.ago) + Fabricate(:post, created_at: 1.hour.ago) + Fabricate(:post, created_at: 3.hours.ago) + Fabricate(:post, created_at: 23.hours.ago) + end - expect(about_page).to have_banner_image(image_upload) - expect(about_page).to have_header_title(SiteSetting.title) - expect(about_page).to have_short_description(SiteSetting.site_description) - - expect(about_page).to have_members_count(4, "4") - expect(about_page).to have_admins_count(1, "1") - expect(about_page).to have_moderators_count(1, "1") + it "shows the count of topics created in the last day" do + about_page.visit + expect(about_page.site_activities.posts).to have_count(3, "3") + expect(about_page.site_activities.posts).to have_1_day_period + end end - it "doesn't render banner image when it's not set" do - SiteSetting.about_banner_image = nil + describe "visitors" do + context "when the display_eu_visitor_stats setting is disabled" do + before { SiteSetting.display_eu_visitor_stats = false } + + it "doesn't show the row" do + about_page.visit + + expect(about_page.site_activities).to have_no_activity_item("visitors") + end + end + + context "when the display_eu_visitor_stats setting is enabled" do + before { SiteSetting.display_eu_visitor_stats = true } + + it "shows the row" do + about_page.visit + + expect(about_page.site_activities).to have_activity_item("visitors") + expect(about_page.site_activities.visitors).to have_text( + "0 visitors, about 0 from the EU", + ) + end + end + end + + describe "active users" do + before do + User.update_all(last_seen_at: 1.month.ago) + + Fabricate(:user, last_seen_at: 1.hour.ago) + Fabricate(:user, last_seen_at: 1.day.ago) + Fabricate(:user, last_seen_at: 3.days.ago) + Fabricate(:user, last_seen_at: 6.days.ago) + Fabricate(:user, last_seen_at: 8.days.ago) + end + + it "shows the count of active users in the last 7 days" do + about_page.visit + expect(about_page.site_activities.active_users).to have_count(4, "4") # 4 fabricated above + expect(about_page.site_activities.active_users).to have_7_days_period + end + end + + describe "sign ups" do + before do + User.update_all(created_at: 1.month.ago) + + Fabricate(:user, created_at: 3.hours.ago) + Fabricate(:user, created_at: 3.days.ago) + Fabricate(:user, created_at: 8.days.ago) + end + + it "shows the count of signups in the last 7 days" do + about_page.visit + expect(about_page.site_activities.sign_ups).to have_count(2, "2") + expect(about_page.site_activities.sign_ups).to have_7_days_period + end + end + + describe "likes" do + before do + UserAction.destroy_all + + Fabricate(:user_action, created_at: 1.hour.ago, action_type: UserAction::LIKE) + Fabricate(:user_action, created_at: 1.day.ago, action_type: UserAction::LIKE) + Fabricate(:user_action, created_at: 1.month.ago, action_type: UserAction::LIKE) + Fabricate(:user_action, created_at: 10.years.ago, action_type: UserAction::LIKE) + end + + it "shows the count of likes of all time" do + about_page.visit + expect(about_page.site_activities.likes).to have_count(4, "4") + expect(about_page.site_activities.likes).to have_all_time_period + end + end + + describe "traffic info footer" do + it "is displayed when the display_eu_visitor_stats setting is true" do + SiteSetting.display_eu_visitor_stats = true + + about_page.visit + + expect(about_page).to have_traffic_info_footer + end + + it "is not displayed when the display_eu_visitor_stats setting is false" do + SiteSetting.display_eu_visitor_stats = false + + about_page.visit + + expect(about_page).to have_no_traffic_info_footer + end + end + end + + describe "our admins section" do + before { User.update_all(last_seen_at: 1.month.ago) } + + fab!(:admins) { Fabricate.times(8, :admin) } + + it "displays only the 6 most recently seen admins when there are more than 6 admins" do + admins[0].update!(last_seen_at: 4.minutes.ago) + admins[1].update!(last_seen_at: 1.minutes.ago) + admins[2].update!(last_seen_at: 10.minutes.ago) about_page.visit - expect(about_page).to have_no_banner_image + expect(about_page.admins_list).to have_expand_button + + displayed_admins = about_page.admins_list.users + expect(displayed_admins.size).to eq(6) + expect(displayed_admins.map { |u| u[:username] }.first(3)).to eq( + [admins[1].username, admins[0].username, admins[2].username], + ) end - describe "displayed site age" do - it "says less than 1 month if the site is less than 1 month old" do - Discourse.stubs(:site_creation_date).returns(1.week.ago) + it "allows expanding and collapsing the list of admins" do + about_page.visit - about_page.visit + displayed_admins = about_page.admins_list.users + expect(displayed_admins.size).to eq(6) - expect(about_page).to have_site_created_less_than_1_month_ago - end + expect(about_page.admins_list).to be_expandable - it "says how many months old the site is if the site is less than 1 year old" do - Discourse.stubs(:site_creation_date).returns(2.months.ago) + about_page.admins_list.expand - about_page.visit + expect(about_page.admins_list).to be_collapsible - expect(about_page).to have_site_created_in_months_ago(2) - end + displayed_admins = about_page.admins_list.users + expect(displayed_admins.size).to eq(9) # 8 fabricated for this spec group and 1 global - it "says how many years old the site is if the site is more than 1 year old" do - Discourse.stubs(:site_creation_date).returns(5.years.ago) + about_page.admins_list.collapse - about_page.visit + expect(about_page.admins_list).to be_expandable - expect(about_page).to have_site_created_in_years_ago(5) - end + displayed_admins = about_page.admins_list.users + expect(displayed_admins.size).to eq(6) end - describe "the site activity section" do - describe "topics" do - before do - Fabricate(:topic, created_at: 2.days.ago) - Fabricate(:topic, created_at: 3.days.ago) - Fabricate(:topic, created_at: 8.days.ago) - end + it "doesn't show an expand/collapse button when there are fewer than 6 admins" do + User.where(id: admins.first(4).map(&:id)).destroy_all - it "shows the count of topics created in the last 7 days" do - about_page.visit - expect(about_page.site_activities.topics).to have_count(2, "2") - expect(about_page.site_activities.topics).to have_7_days_period - end - end + about_page.visit - describe "posts" do - before do - Fabricate(:post, created_at: 2.days.ago) - Fabricate(:post, created_at: 1.hour.ago) - Fabricate(:post, created_at: 3.hours.ago) - Fabricate(:post, created_at: 23.hours.ago) - end - - it "shows the count of topics created in the last day" do - about_page.visit - expect(about_page.site_activities.posts).to have_count(3, "3") - expect(about_page.site_activities.posts).to have_1_day_period - end - end - - describe "visitors" do - context "when the display_eu_visitor_stats setting is disabled" do - before { SiteSetting.display_eu_visitor_stats = false } - - it "doesn't show the row" do - about_page.visit - - expect(about_page.site_activities).to have_no_activity_item("visitors") - end - end - - context "when the display_eu_visitor_stats setting is enabled" do - before { SiteSetting.display_eu_visitor_stats = true } - - it "shows the row" do - about_page.visit - - expect(about_page.site_activities).to have_activity_item("visitors") - expect(about_page.site_activities.visitors).to have_text( - "1 visitor, about 0 from the EU", - ) - end - end - end - - describe "active users" do - before do - User.update_all(last_seen_at: 1.month.ago) - - Fabricate(:user, last_seen_at: 1.hour.ago) - Fabricate(:user, last_seen_at: 1.day.ago) - Fabricate(:user, last_seen_at: 3.days.ago) - Fabricate(:user, last_seen_at: 6.days.ago) - Fabricate(:user, last_seen_at: 8.days.ago) - end - - it "shows the count of active users in the last 7 days" do - about_page.visit - expect(about_page.site_activities.active_users).to have_count(5, "5") # 4 fabricated above + 1 for the current user - expect(about_page.site_activities.active_users).to have_7_days_period - end - end - - describe "sign ups" do - before do - User.update_all(created_at: 1.month.ago) - - Fabricate(:user, created_at: 3.hours.ago) - Fabricate(:user, created_at: 3.days.ago) - Fabricate(:user, created_at: 8.days.ago) - end - - it "shows the count of signups in the last 7 days" do - about_page.visit - expect(about_page.site_activities.sign_ups).to have_count(2, "2") - expect(about_page.site_activities.sign_ups).to have_7_days_period - end - end - - describe "likes" do - before do - UserAction.destroy_all - - Fabricate(:user_action, created_at: 1.hour.ago, action_type: UserAction::LIKE) - Fabricate(:user_action, created_at: 1.day.ago, action_type: UserAction::LIKE) - Fabricate(:user_action, created_at: 1.month.ago, action_type: UserAction::LIKE) - Fabricate(:user_action, created_at: 10.years.ago, action_type: UserAction::LIKE) - end - - it "shows the count of likes of all time" do - about_page.visit - expect(about_page.site_activities.likes).to have_count(4, "4") - expect(about_page.site_activities.likes).to have_all_time_period - end - end - - describe "traffic info footer" do - it "is displayed when the display_eu_visitor_stats setting is true" do - SiteSetting.display_eu_visitor_stats = true - - about_page.visit - - expect(about_page).to have_traffic_info_footer - end - - it "is not displayed when the display_eu_visitor_stats setting is false" do - SiteSetting.display_eu_visitor_stats = false - - about_page.visit - - expect(about_page).to have_no_traffic_info_footer - end - end + displayed_admins = about_page.admins_list.users + expect(displayed_admins.size).to eq(5) + expect(about_page.admins_list).to have_no_expand_button end - describe "our admins section" do - before { User.update_all(last_seen_at: 1.month.ago) } + it "prioritizes names when prioritize_username_in_ux is false" do + SiteSetting.prioritize_username_in_ux = false - fab!(:admins) { Fabricate.times(8, :admin) } + about_page.visit - it "displays only the 6 most recently seen admins when there are more than 6 admins" do - admins[0].update!(last_seen_at: 4.minutes.ago) - admins[1].update!(last_seen_at: 1.minutes.ago) - admins[2].update!(last_seen_at: 10.minutes.ago) - - about_page.visit - expect(about_page.admins_list).to have_expand_button - - displayed_admins = about_page.admins_list.users - expect(displayed_admins.size).to eq(6) - expect(displayed_admins.map { |u| u[:username] }.first(3)).to eq( - [admins[1].username, admins[0].username, admins[2].username], - ) - end - - it "allows expanding and collapsing the list of admins" do - about_page.visit - - displayed_admins = about_page.admins_list.users - expect(displayed_admins.size).to eq(6) - - expect(about_page.admins_list).to be_expandable - - about_page.admins_list.expand - - expect(about_page.admins_list).to be_collapsible - - displayed_admins = about_page.admins_list.users - expect(displayed_admins.size).to eq(9) # 8 fabricated for this spec group and 1 global - - about_page.admins_list.collapse - - expect(about_page.admins_list).to be_expandable - - displayed_admins = about_page.admins_list.users - expect(displayed_admins.size).to eq(6) - end - - it "doesn't show an expand/collapse button when there are fewer than 6 admins" do - User.where(id: admins.first(4).map(&:id)).destroy_all - - about_page.visit - - displayed_admins = about_page.admins_list.users - expect(displayed_admins.size).to eq(5) - expect(about_page.admins_list).to have_no_expand_button - end - - it "prioritizes names when prioritize_username_in_ux is false" do - SiteSetting.prioritize_username_in_ux = false - - about_page.visit - - displayed_admins = about_page.admins_list.users - admins = User.where(username: displayed_admins.map { |u| u[:username] }) - expect(displayed_admins.map { |u| u[:displayed_username] }).to contain_exactly( - *admins.pluck(:name), - ) - expect(displayed_admins.map { |u| u[:displayed_name] }).to contain_exactly( - *admins.pluck(:username), - ) - end - - it "prioritizes usernames when prioritize_username_in_ux is true" do - SiteSetting.prioritize_username_in_ux = true - - about_page.visit - - displayed_admins = about_page.admins_list.users - admins = User.where(username: displayed_admins.map { |u| u[:username] }) - expect(displayed_admins.map { |u| u[:displayed_username] }).to contain_exactly( - *admins.pluck(:username), - ) - expect(displayed_admins.map { |u| u[:displayed_name] }).to contain_exactly( - *admins.pluck(:name), - ) - end - - it "opens the user card when a user is clicked" do - about_page.visit - - about_page.admins_list.users.first[:node].click - expect(about_page).to have_css("#user-card") - end + displayed_admins = about_page.admins_list.users + admins = User.where(username: displayed_admins.map { |u| u[:username] }) + expect(displayed_admins.map { |u| u[:displayed_username] }).to contain_exactly( + *admins.pluck(:name), + ) + expect(displayed_admins.map { |u| u[:displayed_name] }).to contain_exactly( + *admins.pluck(:username), + ) end - describe "our moderators section" do - before { User.update_all(last_seen_at: 1.month.ago) } + it "prioritizes usernames when prioritize_username_in_ux is true" do + SiteSetting.prioritize_username_in_ux = true - fab!(:moderators) { Fabricate.times(9, :moderator) } + about_page.visit - it "displays only the 6 most recently seen moderators when there are more than 6 moderators" do - moderators[5].update!(last_seen_at: 5.hours.ago) - moderators[4].update!(last_seen_at: 2.hours.ago) - moderators[1].update!(last_seen_at: 13.hours.ago) - - about_page.visit - expect(about_page.moderators_list).to have_expand_button - - displayed_mods = about_page.moderators_list.users - expect(displayed_mods.size).to eq(6) - expect(displayed_mods.map { |u| u[:username] }.first(3)).to eq( - [moderators[4].username, moderators[5].username, moderators[1].username], - ) - end - - it "allows expanding and collapsing the list of moderators" do - about_page.visit - - displayed_mods = about_page.moderators_list.users - expect(displayed_mods.size).to eq(6) - - expect(about_page.moderators_list).to be_expandable - - about_page.moderators_list.expand - - expect(about_page.moderators_list).to be_collapsible - - displayed_mods = about_page.moderators_list.users - expect(displayed_mods.size).to eq(10) # 9 fabricated for this spec group and 1 global - - about_page.moderators_list.collapse - - expect(about_page.moderators_list).to be_expandable - - displayed_mods = about_page.moderators_list.users - expect(displayed_mods.size).to eq(6) - end - - it "doesn't show an expand/collapse button when there are fewer than 6 moderators" do - User.where(id: moderators.first(4).map(&:id)).destroy_all - - about_page.visit - - displayed_mods = about_page.moderators_list.users - expect(displayed_mods.size).to eq(6) - expect(about_page.moderators_list).to have_no_expand_button - end - - it "prioritizes names when prioritize_username_in_ux is false" do - SiteSetting.prioritize_username_in_ux = false - - about_page.visit - - displayed_mods = about_page.moderators_list.users - moderators = User.where(username: displayed_mods.map { |u| u[:username] }) - expect(displayed_mods.map { |u| u[:displayed_username] }).to contain_exactly( - *moderators.pluck(:name), - ) - expect(displayed_mods.map { |u| u[:displayed_name] }).to contain_exactly( - *moderators.pluck(:username), - ) - end - - it "prioritizes usernames when prioritize_username_in_ux is true" do - SiteSetting.prioritize_username_in_ux = true - - about_page.visit - - displayed_mods = about_page.moderators_list.users - moderators = User.where(username: displayed_mods.map { |u| u[:username] }) - expect(displayed_mods.map { |u| u[:displayed_username] }).to contain_exactly( - *moderators.pluck(:username), - ) - expect(displayed_mods.map { |u| u[:displayed_name] }).to contain_exactly( - *moderators.pluck(:name), - ) - end - - it "opens the user card when a user is clicked" do - about_page.visit - - about_page.moderators_list.users.last[:node].click - expect(about_page).to have_css("#user-card") - end + displayed_admins = about_page.admins_list.users + admins = User.where(username: displayed_admins.map { |u| u[:username] }) + expect(displayed_admins.map { |u| u[:displayed_username] }).to contain_exactly( + *admins.pluck(:username), + ) + expect(displayed_admins.map { |u| u[:displayed_name] }).to contain_exactly( + *admins.pluck(:name), + ) end - describe "the edit link" do - it "appears for admins" do - sign_in(admin) + it "opens the user card when a user is clicked" do + about_page.visit - about_page.visit - expect(about_page).to have_edit_link + about_page.admins_list.users.first[:node].click + expect(about_page).to have_css("#user-card") + end + end - about_page.edit_link.click + describe "our moderators section" do + before { User.update_all(last_seen_at: 1.month.ago) } - try_until_success { expect(current_url).to end_with("/admin/config/about") } - end + fab!(:moderators) { Fabricate.times(9, :moderator) } - it "doesn't appear for moderators" do - sign_in(moderator) + it "displays only the 6 most recently seen moderators when there are more than 6 moderators" do + moderators[5].update!(last_seen_at: 5.hours.ago) + moderators[4].update!(last_seen_at: 2.hours.ago) + moderators[1].update!(last_seen_at: 13.hours.ago) - about_page.visit - expect(about_page).to have_no_edit_link - end + about_page.visit + expect(about_page.moderators_list).to have_expand_button - it "doesn't appear for normal users" do - about_page.visit - expect(about_page).to have_no_edit_link - end + displayed_mods = about_page.moderators_list.users + expect(displayed_mods.size).to eq(6) + expect(displayed_mods.map { |u| u[:username] }.first(3)).to eq( + [moderators[4].username, moderators[5].username, moderators[1].username], + ) + end + + it "allows expanding and collapsing the list of moderators" do + about_page.visit + + displayed_mods = about_page.moderators_list.users + expect(displayed_mods.size).to eq(6) + + expect(about_page.moderators_list).to be_expandable + + about_page.moderators_list.expand + + expect(about_page.moderators_list).to be_collapsible + + displayed_mods = about_page.moderators_list.users + expect(displayed_mods.size).to eq(10) # 9 fabricated for this spec group and 1 global + + about_page.moderators_list.collapse + + expect(about_page.moderators_list).to be_expandable + + displayed_mods = about_page.moderators_list.users + expect(displayed_mods.size).to eq(6) + end + + it "doesn't show an expand/collapse button when there are fewer than 6 moderators" do + User.where(id: moderators.first(4).map(&:id)).destroy_all + + about_page.visit + + displayed_mods = about_page.moderators_list.users + expect(displayed_mods.size).to eq(6) + expect(about_page.moderators_list).to have_no_expand_button + end + + it "prioritizes names when prioritize_username_in_ux is false" do + SiteSetting.prioritize_username_in_ux = false + + about_page.visit + + displayed_mods = about_page.moderators_list.users + moderators = User.where(username: displayed_mods.map { |u| u[:username] }) + expect(displayed_mods.map { |u| u[:displayed_username] }).to contain_exactly( + *moderators.pluck(:name), + ) + expect(displayed_mods.map { |u| u[:displayed_name] }).to contain_exactly( + *moderators.pluck(:username), + ) + end + + it "prioritizes usernames when prioritize_username_in_ux is true" do + SiteSetting.prioritize_username_in_ux = true + + about_page.visit + + displayed_mods = about_page.moderators_list.users + moderators = User.where(username: displayed_mods.map { |u| u[:username] }) + expect(displayed_mods.map { |u| u[:displayed_username] }).to contain_exactly( + *moderators.pluck(:username), + ) + expect(displayed_mods.map { |u| u[:displayed_name] }).to contain_exactly( + *moderators.pluck(:name), + ) + end + + it "opens the user card when a user is clicked" do + about_page.visit + + about_page.moderators_list.users.last[:node].click + expect(about_page).to have_css("#user-card") + end + end + + describe "the edit link" do + it "appears for admins" do + sign_in(admin) + + about_page.visit + expect(about_page).to have_edit_link + + about_page.edit_link.click + + try_until_success { expect(current_url).to end_with("/admin/config/about") } + end + + it "doesn't appear for moderators" do + sign_in(moderator) + + about_page.visit + expect(about_page).to have_no_edit_link + end + + it "doesn't appear for normal users" do + about_page.visit + expect(about_page).to have_no_edit_link end end end