mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: correctly retrieve 'login required' setting value on wizard (#7355)
* FIX: correctly retrieve 'login required' setting value on wizard FEATURE: extract 'invite only' setting in a separate checkbox control * Update invite_only checkbox locale on wizard. Co-Authored-By: techAPJ <arpit@techapj.com>
This commit is contained in:
parent
9a428acce4
commit
7143572e0c
@ -0,0 +1,7 @@
|
|||||||
|
<label>
|
||||||
|
{{input type="checkbox"
|
||||||
|
class="wizard-checkbox"
|
||||||
|
checked=field.value}}
|
||||||
|
|
||||||
|
{{field.placeholder}}
|
||||||
|
</label>
|
@ -4261,10 +4261,12 @@ en:
|
|||||||
choices:
|
choices:
|
||||||
open:
|
open:
|
||||||
label: "Public"
|
label: "Public"
|
||||||
description: "Anyone can access this community and sign up for an account"
|
description: "Anyone can access this community"
|
||||||
restricted:
|
restricted:
|
||||||
label: "Private"
|
label: "Private"
|
||||||
description: "Only people I have invited or approved can access this community"
|
description: "Only logged in users can access this community"
|
||||||
|
invite_only:
|
||||||
|
placeholder: "People must be explicitly invited. Public registration is disabled."
|
||||||
|
|
||||||
contact:
|
contact:
|
||||||
title: "Contact"
|
title: "Contact"
|
||||||
|
@ -76,17 +76,22 @@ class Wizard
|
|||||||
end
|
end
|
||||||
|
|
||||||
@wizard.append_step('privacy') do |step|
|
@wizard.append_step('privacy') do |step|
|
||||||
locked = SiteSetting.login_required? && SiteSetting.invite_only?
|
|
||||||
privacy = step.add_field(id: 'privacy',
|
privacy = step.add_field(id: 'privacy',
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
required: true,
|
required: true,
|
||||||
value: locked ? 'restricted' : 'open')
|
value: SiteSetting.login_required? ? 'restricted' : 'open')
|
||||||
privacy.add_choice('open', icon: 'unlock')
|
privacy.add_choice('open', icon: 'unlock')
|
||||||
privacy.add_choice('restricted', icon: 'lock')
|
privacy.add_choice('restricted', icon: 'lock')
|
||||||
|
|
||||||
|
invite_only = step.add_field(id: 'invite_only',
|
||||||
|
type: 'checkbox',
|
||||||
|
required: false,
|
||||||
|
placeholder: 'wizard.invites.add_user',
|
||||||
|
value: SiteSetting.invite_only?)
|
||||||
|
|
||||||
step.on_update do |updater|
|
step.on_update do |updater|
|
||||||
updater.update_setting(:login_required, updater.fields[:privacy] == 'restricted')
|
updater.update_setting(:login_required, updater.fields[:privacy] == 'restricted')
|
||||||
updater.update_setting(:invite_only, updater.fields[:privacy] == 'restricted')
|
updater.update_setting(:invite_only, updater.fields[:invite_only])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ describe Wizard::StepUpdater do
|
|||||||
|
|
||||||
context "privacy settings" do
|
context "privacy settings" do
|
||||||
it "updates to open correctly" do
|
it "updates to open correctly" do
|
||||||
updater = wizard.create_updater('privacy', privacy: 'open')
|
updater = wizard.create_updater('privacy', privacy: 'open', invite_only: 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)
|
||||||
@ -72,7 +72,7 @@ describe Wizard::StepUpdater do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "updates to private correctly" do
|
it "updates to private correctly" do
|
||||||
updater = wizard.create_updater('privacy', privacy: 'restricted')
|
updater = wizard.create_updater('privacy', privacy: 'restricted', invite_only: 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)
|
||||||
|
@ -113,4 +113,22 @@ describe Wizard::Builder do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'privacy step' do
|
||||||
|
let(:privacy_step) { wizard.steps.find { |s| s.id == 'privacy' } }
|
||||||
|
|
||||||
|
it 'should set the right default value for the fields' do
|
||||||
|
SiteSetting.login_required = true
|
||||||
|
SiteSetting.invite_only = false
|
||||||
|
|
||||||
|
fields = privacy_step.fields
|
||||||
|
login_required_field = fields.first
|
||||||
|
invite_only_field = fields.last
|
||||||
|
|
||||||
|
expect(login_required_field.id).to eq('privacy')
|
||||||
|
expect(login_required_field.value).to eq("restricted")
|
||||||
|
expect(invite_only_field.id).to eq('invite_only')
|
||||||
|
expect(invite_only_field.value).to eq(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user