A platform for community discussion. Free, open, simple.
FEATURE: Move bootstrap mode indicator to header (#20663)
Bianca Nenciu142d2ab65ecf
diff --git a/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.hbs b/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.hbsindex b61e3bcc321..c5fe4ff364f 100644--- a/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.hbs+++ b/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.hbs@@ -1,21 +1,3 @@-<div class="row bootstrap-mode-notice">- <div class="alert alert-info alert-bootstrap-mode">- <div class="col-text">- {{this.message}}- </div>- <div class="col-button">- <div class="alert--button"><DButton- @icon="user-plus"- @action={{this.inviteUsers}}- @class="btn-primary bootstrap-invite-button"- @label="bootstrap_invite_button_title"- /></div>- {{#if this.site.wizard_required}}- <div class="alert--link"><a- class="bootstrap-wizard-link"- href="/wizard"- >{{i18n "bootstrap_wizard_link_title"}}</a></div>- {{/if}}- </div>- </div>-</div>\ No newline at end of file+<a class="btn btn-default bootstrap-mode" href={{this.href}}>+ {{i18n "bootstrap_mode"}}+</a>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.js b/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.jsindex 69914cfa04a..a67d9551fff 100644--- a/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.js+++ b/app/assets/javascripts/discourse/app/components/bootstrap-mode-notice.js@@ -1,29 +1,11 @@-import Component from "@glimmer/component";-import { htmlSafe } from "@ember/template";-import I18n from "I18n";import { inject as service } from "@ember/service";-import { action } from "@ember/object";-import showModal from "discourse/lib/show-modal";+import Component from "@glimmer/component";export default class BootstrapModeNotice extends Component {@service siteSettings;- @service site;-- get message() {- let msg = null;- const bootstrapModeMinUsers = this.siteSettings.bootstrap_mode_min_users;-- if (bootstrapModeMinUsers > 0) {- msg = "bootstrap_mode_enabled";- } else {- msg = "bootstrap_mode_disabled";- }-- return htmlSafe(I18n.t(msg, { count: bootstrapModeMinUsers }));- }- @action- inviteUsers() {- showModal("create-invite");+ get href() {+ const topicId = this.siteSettings.admin_quick_start_topic_id;+ return `/t/-/${topicId}`;}}diff --git a/app/assets/javascripts/discourse/app/controllers/application.js b/app/assets/javascripts/discourse/app/controllers/application.jsindex 653b509415d..6ab68de881f 100644--- a/app/assets/javascripts/discourse/app/controllers/application.js+++ b/app/assets/javascripts/discourse/app/controllers/application.js@@ -41,18 +41,6 @@ export default Controller.extend({return this.siteSettings.login_required && !this.currentUser;},- @discourseComputed(- "siteSettings.bootstrap_mode_enabled",- "router.currentRouteName"- )- showBootstrapModeNotice(bootstrapModeEnabled, currentRouteName) {- return (- this.currentUser?.get("staff") &&- bootstrapModeEnabled &&- !currentRouteName.startsWith("wizard")- );- },-@discourseComputedshowFooterNav() {return this.capabilities.isAppWebview || this.capabilities.isiOSPWA;diff --git a/app/assets/javascripts/discourse/app/templates/application.hbs b/app/assets/javascripts/discourse/app/templates/application.hbsindex 1a552692380..70bbc6b683a 100644--- a/app/assets/javascripts/discourse/app/templates/application.hbs+++ b/app/assets/javascripts/discourse/app/templates/application.hbs@@ -48,9 +48,6 @@{{/if}}<NotificationConsentBanner /><PwaInstallBanner />- {{#if this.showBootstrapModeNotice}}- <BootstrapModeNotice />- {{/if}}<GlobalNotice /><CreateTopicsNotice /><PluginOutletdiff --git a/app/assets/javascripts/discourse/app/widgets/header-bootstrap-mode.js b/app/assets/javascripts/discourse/app/widgets/header-bootstrap-mode.jsnew file mode 100644index 00000000000..0f11aeed11c--- /dev/null+++ b/app/assets/javascripts/discourse/app/widgets/header-bootstrap-mode.js@@ -0,0 +1,8 @@+import { hbs } from "ember-cli-htmlbars";+import { registerWidgetShim } from "discourse/widgets/render-glimmer";++registerWidgetShim(+ "header-bootstrap-mode",+ "div.d-header-mode",+ hbs`<BootstrapModeNotice />`+);diff --git a/app/assets/javascripts/discourse/app/widgets/header-contents.js b/app/assets/javascripts/discourse/app/widgets/header-contents.jsindex ba579498dad..cdaa2f134da 100644--- a/app/assets/javascripts/discourse/app/widgets/header-contents.js+++ b/app/assets/javascripts/discourse/app/widgets/header-contents.js@@ -14,6 +14,10 @@ createWidget("header-contents", {{{#if attrs.topic}}{{header-topic-info attrs=attrs}}+ {{else if this.siteSettings.bootstrap_mode_enabled}}+ {{#if this.currentUser.staff}}+ {{header-bootstrap-mode attrs=attrs}}+ {{/if}}{{/if}}<div class="panel clearfix" role="navigation">{{yield}}</div>diff --git a/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js b/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.jsindex de3c793294d..03be08812c9 100644--- a/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js@@ -1,6 +1,6 @@import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";-import { click, currentURL, settled, visit } from "@ember/test-helpers";+import { visit } from "@ember/test-helpers";acceptance("Bootstrap Mode Notice", function (needs) {needs.user({ admin: true });@@ -10,37 +10,15 @@ acceptance("Bootstrap Mode Notice", function (needs) {bootstrap_mode_min_users: 50,});- test("Navigation", async function (assert) {+ test("is displayed if bootstrap mode is enabled", async function (assert) {+ this.siteSettings.bootstrap_mode_enabled = true;await visit("/");- assert.ok(- exists(".bootstrap-mode-notice"),- "has the bootstrap mode notice"- );- assert.ok(- exists(".bootstrap-invite-button"),- "bootstrap notice has invite button"- );- assert.ok(- exists(".bootstrap-wizard-link"),- "bootstrap notice has wizard link"- );-- await click(".bootstrap-invite-button");- assert.ok(exists(".create-invite-modal"), "opens create invite modal");-- await click(".bootstrap-wizard-link");- assert.strictEqual(- currentURL(),- "/wizard/steps/hello-world",- "it transitions to the wizard page"- );+ assert.ok(exists(".bootstrap-mode"));+ });+ test("is hidden if bootstrap mode is disabled", async function (assert) {this.siteSettings.bootstrap_mode_enabled = false;await visit("/");- await settled();- assert.ok(- !exists(".bootstrap-mode-notice"),- "removes the notice when bootstrap mode is disabled"- );+ assert.ok(!exists(".bootstrap-mode"));});});diff --git a/app/assets/stylesheets/common/base/header.scss b/app/assets/stylesheets/common/base/header.scssindex 8af17ba1fd0..169e7784895 100644--- a/app/assets/stylesheets/common/base/header.scss+++ b/app/assets/stylesheets/common/base/header.scss@@ -445,3 +445,11 @@ $mobile-avatar-height: 1.532em;margin-left: 5px;}}++.d-header-mode .bootstrap-mode {+ border-radius: 2em;+ color: var(--primary-medium);+ font-size: var(--font-down-1);+ margin-left: 0.5em;+ padding: 0.25em 0.5em;+}diff --git a/app/jobs/regular/enable_bootstrap_mode.rb b/app/jobs/regular/enable_bootstrap_mode.rbindex 8b7d456f4cc..811eee8475c 100644--- a/app/jobs/regular/enable_bootstrap_mode.rb+++ b/app/jobs/regular/enable_bootstrap_mode.rb@@ -5,11 +5,12 @@ module Jobssidekiq_options queue: "critical"def execute(args)- raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present?+ raise Discourse::InvalidParameters.new(:user_id) if !args[:user_id].present?+return if SiteSetting.bootstrap_mode_enableduser = User.find_by(id: args[:user_id])- return unless user.is_singular_admin?+ return if !user.is_singular_admin?# let's enable bootstrap mode settingsif SiteSetting.default_trust_level == TrustLevel[0]diff --git a/app/jobs/scheduled/disable_bootstrap_mode.rb b/app/jobs/scheduled/disable_bootstrap_mode.rbindex e9d1db42881..67812c1f7a5 100644--- a/app/jobs/scheduled/disable_bootstrap_mode.rb+++ b/app/jobs/scheduled/disable_bootstrap_mode.rb@@ -5,21 +5,22 @@ module Jobsevery 1.daydef execute(args)- return unless SiteSetting.bootstrap_mode_enabled- total_users = User.human_users.count+ return if !SiteSetting.bootstrap_mode_enabled- if SiteSetting.bootstrap_mode_min_users == 0 ||- total_users > SiteSetting.bootstrap_mode_min_users- if SiteSetting.default_trust_level == TrustLevel[1]- SiteSetting.set_and_log("default_trust_level", TrustLevel[0])- end+ if SiteSetting.bootstrap_mode_min_users != 0 &&+ User.human_users.count <= SiteSetting.bootstrap_mode_min_users+ return+ end- if SiteSetting.default_email_digest_frequency == 1440- SiteSetting.set_and_log("default_email_digest_frequency", 10_080)- end+ if SiteSetting.default_trust_level == TrustLevel[1]+ SiteSetting.set_and_log("default_trust_level", TrustLevel[0])+ end- SiteSetting.set_and_log("bootstrap_mode_enabled", false)+ if SiteSetting.default_email_digest_frequency == 1440+ SiteSetting.set_and_log("default_email_digest_frequency", 10_080)end++ SiteSetting.set_and_log("bootstrap_mode_enabled", false)endendenddiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex b57d8f73774..6ebeb2322cb 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -209,12 +209,7 @@ en:message: "We've updated this site, <span>please refresh</span>, or you may experience unexpected behavior."dismiss: "Dismiss"- bootstrap_mode_enabled:- one: "To make launching your new site easier, you are in bootstrap mode. All new users will be granted trust level 1 and have daily email summary emails enabled. This will be automatically turned off when %{count} user has joined."- other: "To make launching your new site easier, you are in bootstrap mode. All new users will be granted trust level 1 and have daily email summary emails enabled. This will be automatically turned off when %{count} users have joined."- bootstrap_mode_disabled: "Bootstrap mode will be disabled within 24 hours."- bootstrap_invite_button_title: "Send Invites"- bootstrap_wizard_link_title: "Finish setup wizard"+ bootstrap_mode: "Bootstrap mode"themes:default_description: "Default"diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 245a8c0c793..08e85af2317 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -2482,6 +2482,7 @@ uncategorized:admin_quick_start_topic_id:default: -1hidden: true+ client: truebootstrap_mode_min_users:default: 50diff --git a/docs/ADMIN-QUICK-START-GUIDE.md b/docs/ADMIN-QUICK-START-GUIDE.mdindex 4a157b94288..b6d8a2742cd 100644--- a/docs/ADMIN-QUICK-START-GUIDE.md+++ b/docs/ADMIN-QUICK-START-GUIDE.md@@ -4,6 +4,8 @@ Congratulations, you are now the proud owner of your very own [Civilized DiscourIf you haven't already, launch the [setup wizard](/wizard) and go through the steps to configure your site. You can run the wizard as many times as you want, it's completely safe!+> Note: To make launching your new site easier, all new members will have daily email summary emails enabled (instead of the usual weekly) and be given a higher level of trust. See below to learn more about the trust system and bootstrap mode.+### Admin DashboardExercise your admin superpowers any time via the admin dashboard at@@ -91,7 +93,7 @@ All new users start out in a sandbox with restrictions for everyone's safety. **Every action a user can take is rate limited for safety, and especially so for new users. But don't worry, new users can [transition to trust level 1](https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/) in about 10 minutes of reading.-These defaults are safe, but note that while in "bootstrap mode" after you set up your site, all new users will be granted trust level 1 until you reach 50 users.+To make launching your new site easier, all new users will have daily email summary emails enabled (instead of the usual weekly) and be given a higher level of trust that allows them to bypass new user restrictions. Once you've reached a certain number of users (adjustable via the [Bootstrap mode admin setting](/admin/site_settings/category/all_results?filter=bootstrap)) new users will have to spend 15 minutes reading to remove new user restrictions, or be invited by another trusted user.### Building Your Community