FEATURE: Move bootstrap mode indicator to header (#20663)

The information about bootstrap mode has been moved from the notice to
the README topic for admins.
This commit is contained in:
Bianca Nenciu 2023-03-24 15:59:03 +02:00 committed by GitHub
parent a39a7028ab
commit 142d2ab65e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 56 additions and 109 deletions

View File

@ -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>
<a class="btn btn-default bootstrap-mode" href={{this.href}}>
{{i18n "bootstrap_mode"}}
</a>

View File

@ -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}`;
}
}

View File

@ -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")
);
},
@discourseComputed
showFooterNav() {
return this.capabilities.isAppWebview || this.capabilities.isiOSPWA;

View File

@ -48,9 +48,6 @@
{{/if}}
<NotificationConsentBanner />
<PwaInstallBanner />
{{#if this.showBootstrapModeNotice}}
<BootstrapModeNotice />
{{/if}}
<GlobalNotice />
<CreateTopicsNotice />
<PluginOutlet

View File

@ -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 />`
);

View File

@ -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>

View File

@ -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"));
});
});

View File

@ -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;
}

View File

@ -5,11 +5,12 @@ module Jobs
sidekiq_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_enabled
user = User.find_by(id: args[:user_id])
return unless user.is_singular_admin?
return if !user.is_singular_admin?
# let's enable bootstrap mode settings
if SiteSetting.default_trust_level == TrustLevel[0]

View File

@ -5,21 +5,22 @@ module Jobs
every 1.day
def 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.default_email_digest_frequency == 1440
SiteSetting.set_and_log("default_email_digest_frequency", 10_080)
end
SiteSetting.set_and_log("bootstrap_mode_enabled", false)
if SiteSetting.bootstrap_mode_min_users != 0 &&
User.human_users.count <= SiteSetting.bootstrap_mode_min_users
return
end
if SiteSetting.default_trust_level == TrustLevel[1]
SiteSetting.set_and_log("default_trust_level", TrustLevel[0])
end
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)
end
end
end

View File

@ -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"

View File

@ -2482,6 +2482,7 @@ uncategorized:
admin_quick_start_topic_id:
default: -1
hidden: true
client: true
bootstrap_mode_min_users:
default: 50

View File

@ -4,6 +4,8 @@ Congratulations, you are now the proud owner of your very own [Civilized Discour
If 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 Dashboard
Exercise 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