FEATURE: Add chat and sidebar toggles to the setup wizard (#19347)
* FEATURE: Add chat and sidebar toggles to the setup wizard - Fix css alighnment - Add Enable Chat Toggle - Add Enable Sidebar Toggle * Check for the chat plugin * Account for new sidebar step * update chat and sidebar description * UI: add checkmark as a visual indicator that it is enabled * use new navigation_memu site setting for enabling the sidebar * fix tests * Add tests * Update lib/wizard/step_updater.rb Use HEADER_DROPDOWN instead of LEGACY Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com> * Fix spec. Use HEADER_DROPDOWN instead of LEGACY Co-authored-by: Ella <ella.estigoy@gmail.com> Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
parent
a03b2cd469
commit
de53cf7657
|
@ -618,15 +618,27 @@ body.wizard {
|
||||||
&__checkbox-slider:before,
|
&__checkbox-slider:before,
|
||||||
&__checkbox-slider:after {
|
&__checkbox-slider:after {
|
||||||
content: "";
|
content: "";
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__checkbox-slider:after {
|
||||||
|
content: "\2713"; // checkmark
|
||||||
|
color: var(--secondary);
|
||||||
|
top: 4px;
|
||||||
|
left: 10px;
|
||||||
|
@media only screen and (max-device-width: 568px) {
|
||||||
|
top: 3px;
|
||||||
|
left: 5px;
|
||||||
|
font-size: var(--font-down-3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__checkbox-slider:before {
|
&__checkbox-slider:before {
|
||||||
display: block;
|
|
||||||
background: var(--secondary);
|
background: var(--secondary);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
position: absolute;
|
|
||||||
top: 4px;
|
top: 4px;
|
||||||
left: 4px;
|
left: 4px;
|
||||||
transition: left 0.25s;
|
transition: left 0.25s;
|
||||||
|
@ -661,6 +673,10 @@ body.wizard {
|
||||||
top: 2px;
|
top: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label .svg-icon {
|
||||||
|
top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
.wizard-container__image-upload canvas {
|
.wizard-container__image-upload canvas {
|
||||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4957,6 +4957,12 @@ en:
|
||||||
must_approve_users:
|
must_approve_users:
|
||||||
placeholder: "Require Approval"
|
placeholder: "Require Approval"
|
||||||
extra_description: "Users must be approved by staff"
|
extra_description: "Users must be approved by staff"
|
||||||
|
chat_enabled:
|
||||||
|
placeholder: "Enable Chat"
|
||||||
|
extra_description: "Engage with your members in real time"
|
||||||
|
enable_sidebar:
|
||||||
|
placeholder: "Enable Sidebar"
|
||||||
|
extra_description: "Access your favorite spaces with ease"
|
||||||
|
|
||||||
ready:
|
ready:
|
||||||
title: "Your Discourse is Ready!"
|
title: "Your Discourse is Ready!"
|
||||||
|
|
|
@ -70,10 +70,28 @@ class Wizard
|
||||||
value: SiteSetting.must_approve_users
|
value: SiteSetting.must_approve_users
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if defined?(::Chat)
|
||||||
|
step.add_field(
|
||||||
|
id: 'chat_enabled',
|
||||||
|
type: 'checkbox',
|
||||||
|
icon: 'comment',
|
||||||
|
value: SiteSetting.chat_enabled
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
step.add_field(
|
||||||
|
id: 'enable_sidebar',
|
||||||
|
type: 'checkbox',
|
||||||
|
icon: 'bars',
|
||||||
|
value: SiteSetting.navigation_menu == NavigationMenuSiteSetting::SIDEBAR
|
||||||
|
)
|
||||||
|
|
||||||
step.on_update do |updater|
|
step.on_update do |updater|
|
||||||
updater.update_setting(:login_required, updater.fields[:login_required])
|
updater.update_setting(:login_required, updater.fields[:login_required])
|
||||||
updater.update_setting(:invite_only, updater.fields[:invite_only])
|
updater.update_setting(:invite_only, updater.fields[:invite_only])
|
||||||
updater.update_setting(:must_approve_users, updater.fields[:must_approve_users])
|
updater.update_setting(:must_approve_users, updater.fields[:must_approve_users])
|
||||||
|
updater.update_setting(:chat_enabled, updater.fields[:chat_enabled]) if defined?(::Chat)
|
||||||
|
updater.update_setting(:navigation_menu, updater.fields[:enable_sidebar])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ class Wizard
|
||||||
value = Upload.get_from_url(value) || ''
|
value = Upload.get_from_url(value) || ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if id == :navigation_menu
|
||||||
|
value = value.to_s == "true" ? NavigationMenuSiteSetting::SIDEBAR : NavigationMenuSiteSetting::HEADER_DROPDOWN
|
||||||
|
end
|
||||||
|
|
||||||
SiteSetting.set_and_log(id, value, @current_user) if SiteSetting.get(id) != value
|
SiteSetting.set_and_log(id, value, @current_user) if SiteSetting.get(id) != value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,22 +44,36 @@ RSpec.describe Wizard::StepUpdater do
|
||||||
|
|
||||||
describe "privacy" do
|
describe "privacy" do
|
||||||
it "updates to open correctly" do
|
it "updates to open correctly" do
|
||||||
updater = wizard.create_updater('privacy', login_required: false, invite_only: false, must_approve_users: false)
|
updater = wizard.create_updater(
|
||||||
|
'privacy',
|
||||||
|
login_required: false,
|
||||||
|
invite_only: false,
|
||||||
|
must_approve_users: false,
|
||||||
|
enable_sidebar: false
|
||||||
|
)
|
||||||
updater.update
|
updater.update
|
||||||
expect(updater.success?).to eq(true)
|
expect(updater.success?).to eq(true)
|
||||||
expect(SiteSetting.login_required?).to eq(false)
|
expect(SiteSetting.login_required?).to eq(false)
|
||||||
expect(SiteSetting.invite_only?).to eq(false)
|
expect(SiteSetting.invite_only?).to eq(false)
|
||||||
expect(SiteSetting.must_approve_users?).to eq(false)
|
expect(SiteSetting.must_approve_users?).to eq(false)
|
||||||
|
expect(SiteSetting.navigation_menu).to eq(NavigationMenuSiteSetting::HEADER_DROPDOWN)
|
||||||
expect(wizard.completed_steps?('privacy')).to eq(true)
|
expect(wizard.completed_steps?('privacy')).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates to private correctly" do
|
it "updates to private correctly" do
|
||||||
updater = wizard.create_updater('privacy', login_required: true, invite_only: true, must_approve_users: true)
|
updater = wizard.create_updater(
|
||||||
|
'privacy',
|
||||||
|
login_required: true,
|
||||||
|
invite_only: true,
|
||||||
|
must_approve_users: true,
|
||||||
|
enable_sidebar: true
|
||||||
|
)
|
||||||
updater.update
|
updater.update
|
||||||
expect(updater.success?).to eq(true)
|
expect(updater.success?).to eq(true)
|
||||||
expect(SiteSetting.login_required?).to eq(true)
|
expect(SiteSetting.login_required?).to eq(true)
|
||||||
expect(SiteSetting.invite_only?).to eq(true)
|
expect(SiteSetting.invite_only?).to eq(true)
|
||||||
expect(SiteSetting.must_approve_users?).to eq(true)
|
expect(SiteSetting.must_approve_users?).to eq(true)
|
||||||
|
expect(SiteSetting.navigation_menu).to eq(NavigationMenuSiteSetting::SIDEBAR)
|
||||||
expect(wizard.completed_steps?('privacy')).to eq(true)
|
expect(wizard.completed_steps?('privacy')).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,19 +75,30 @@ RSpec.describe Wizard::Builder do
|
||||||
SiteSetting.login_required = true
|
SiteSetting.login_required = true
|
||||||
SiteSetting.invite_only = false
|
SiteSetting.invite_only = false
|
||||||
SiteSetting.must_approve_users = true
|
SiteSetting.must_approve_users = true
|
||||||
|
SiteSetting.chat_enabled = true if defined?(::Chat)
|
||||||
|
SiteSetting.navigation_menu = NavigationMenuSiteSetting::SIDEBAR
|
||||||
|
|
||||||
fields = privacy_step.fields
|
fields = privacy_step.fields
|
||||||
login_required_field = fields.first
|
login_required_field = fields.first
|
||||||
invite_only_field = fields.second
|
invite_only_field = fields.second
|
||||||
must_approve_users_field = fields.last
|
must_approve_users_field = fields.third
|
||||||
|
chat_enabled_field = fields.second_to_last if defined?(::Chat)
|
||||||
|
navigation_menu_field = fields.last
|
||||||
|
|
||||||
expect(fields.length).to eq(3)
|
count = defined?(::Chat) ? 5 : 4
|
||||||
|
expect(fields.length).to eq(count)
|
||||||
expect(login_required_field.id).to eq('login_required')
|
expect(login_required_field.id).to eq('login_required')
|
||||||
expect(login_required_field.value).to eq(true)
|
expect(login_required_field.value).to eq(true)
|
||||||
expect(invite_only_field.id).to eq('invite_only')
|
expect(invite_only_field.id).to eq('invite_only')
|
||||||
expect(invite_only_field.value).to eq(false)
|
expect(invite_only_field.value).to eq(false)
|
||||||
expect(must_approve_users_field.id).to eq('must_approve_users')
|
expect(must_approve_users_field.id).to eq('must_approve_users')
|
||||||
expect(must_approve_users_field.value).to eq(true)
|
expect(must_approve_users_field.value).to eq(true)
|
||||||
|
if defined?(::Chat)
|
||||||
|
expect(chat_enabled_field.id).to eq('chat_enabled')
|
||||||
|
expect(chat_enabled_field.value).to eq(true)
|
||||||
|
end
|
||||||
|
expect(navigation_menu_field.id).to eq('enable_sidebar')
|
||||||
|
expect(navigation_menu_field.value).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue