Closes #3137 - New email account expert view cannot be opened without filling in all fields
This commit is contained in:
parent
ab39b3a3f1
commit
0c80232a27
|
@ -410,6 +410,15 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
|
|||
{ name: 'options::keep_on_server', display: 'Keep messages on server', tag: 'boolean', null: true, options: { true: 'yes', false: 'no' }, translate: true, default: false, item_class: 'formGroup--halfSize' },
|
||||
]
|
||||
|
||||
if !@channel
|
||||
#Email Inbound form opened from new email wizard, show full settings
|
||||
configureAttributesInbound = [
|
||||
{ name: 'options::realname', display: 'Organization & Department Name', tag: 'input', type: 'text', limit: 160, null: false, placeholder: 'Organization Support', autocomplete: 'off' },
|
||||
{ name: 'options::email', display: 'Email', tag: 'input', type: 'email', limit: 120, null: false, placeholder: 'support@example.com', autocapitalize: false, autocomplete: 'off' },
|
||||
{ name: 'options::group_id', display: 'Destination Group', tag: 'select', null: false, relation: 'Group', nulloption: true },
|
||||
].concat(configureAttributesInbound)
|
||||
|
||||
|
||||
showHideFolder = (params, attribute, attributes, classname, form, ui) ->
|
||||
return if !params
|
||||
if params.adapter is 'imap'
|
||||
|
@ -424,7 +433,7 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
|
|||
return if !params.options
|
||||
currentPort = @$('[name="options::port"]').val()
|
||||
if params.options.ssl is true
|
||||
if !currentPort
|
||||
if !currentPort || currentPort is '143'
|
||||
@$('[name="options::port"]').val('993')
|
||||
return
|
||||
if params.options.ssl is false
|
||||
|
@ -484,18 +493,12 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
|
|||
params.channel_id = @channel.id
|
||||
|
||||
if $(e.currentTarget).hasClass('js-expert')
|
||||
|
||||
# validate form
|
||||
errors = @formMeta.validate(params)
|
||||
if errors
|
||||
delete errors.password
|
||||
if !_.isEmpty(errors)
|
||||
@formValidate(form: e.target, errors: errors)
|
||||
return
|
||||
|
||||
@showSlide('js-inbound')
|
||||
@$('.js-inbound [name="options::user"]').val(params.email)
|
||||
@$('.js-inbound [name="options::password"]').val(params.password)
|
||||
@$('.js-inbound [name="options::email"]').val(params.email)
|
||||
@$('.js-inbound [name="options::realname"]').val(params.realname)
|
||||
@$('.js-inbound [name="options::group_id"]').val(params.group_id)
|
||||
return
|
||||
|
||||
@disable(e)
|
||||
|
@ -528,6 +531,9 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
|
|||
@showAlert('js-inbound', 'Unable to detect your server settings. Manual configuration needed.')
|
||||
@$('.js-inbound [name="options::user"]').val(@account['meta']['email'])
|
||||
@$('.js-inbound [name="options::password"]').val(@account['meta']['password'])
|
||||
@$('.js-inbound [name="options::email"]').val(@account['meta']['email'])
|
||||
@$('.js-inbound [name="options::realname"]').val(@account['meta']['realname'])
|
||||
@$('.js-inbound [name="options::group_id"]').val(@account['meta']['group_id'])
|
||||
|
||||
@enable(e)
|
||||
error: =>
|
||||
|
@ -544,6 +550,11 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
|
|||
if params.options && params.options.password is @passwordPlaceholder
|
||||
params.options.password = @inboundPassword
|
||||
|
||||
# Update meta as the one from AttributesBase could be outdated
|
||||
@account.meta.realname = params.options.realname
|
||||
@account.meta.email = params.options.email
|
||||
@account.meta.group_id = params.options.group_id
|
||||
|
||||
# let backend know about the channel
|
||||
if @channel
|
||||
params.channel_id = @channel.id
|
||||
|
|
|
@ -21,4 +21,76 @@ RSpec.describe 'Manage > Channels > Email', type: :system do
|
|||
expect(page).to have_no_css('.js-editInbound, .js-editOutbound', text: 'Edit')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when adding an email' do
|
||||
before do
|
||||
visit '#channels/email'
|
||||
end
|
||||
|
||||
it 'one can switch between default and expert forms' do
|
||||
click '.js-channelNew'
|
||||
in_modal do
|
||||
click '.js-expert'
|
||||
expect(page).to have_text 'ORGANIZATION & DEPARTMENT NAME'
|
||||
expect(page).to have_text 'SSL/STARTTLS'
|
||||
expect(page).to have_text 'PORT'
|
||||
click '.js-close'
|
||||
end
|
||||
end
|
||||
|
||||
it 'in the expert form, the port for SSL/NoSSL is set automatically only when it is default' do
|
||||
click '.js-channelNew'
|
||||
in_modal do
|
||||
click '.js-expert'
|
||||
expect(find('input[name="options::port"]').value).to eq('993')
|
||||
field = find('select[name="options::ssl"]')
|
||||
option_yes = field.find(:option, 'yes')
|
||||
option_no = field.find(:option, 'no')
|
||||
option_no.select_option
|
||||
expect(find('input[name="options::port"]').value).to eq('143')
|
||||
option_yes.select_option
|
||||
expect(find('input[name="options::port"]').value).to eq('993')
|
||||
option_no.select_option
|
||||
expect(find('input[name="options::port"]').value).to eq('143')
|
||||
port = '4242'
|
||||
fill_in 'options::port', with: port
|
||||
expect(find('input[name="options::port"]').value).to eq(port)
|
||||
option_yes.select_option
|
||||
expect(find('input[name="options::port"]').value).to eq(port)
|
||||
click '.js-close'
|
||||
end
|
||||
end
|
||||
|
||||
it 'entered values on the default form are copied to the expert form' do
|
||||
click '.js-channelNew'
|
||||
in_modal do
|
||||
name = 'Area53'
|
||||
email = 'dont@ask.com'
|
||||
password = 'f34therRa!nSplash'
|
||||
fill_in 'realname', with: name
|
||||
fill_in 'email', with: email
|
||||
fill_in 'password', with: password
|
||||
click '.js-expert'
|
||||
expect(find('input[name="options::realname"]').value).to eq(name)
|
||||
expect(find('input[name="options::email"]').value).to eq(email)
|
||||
expect(find('input[name="options::user"]').value).to eq(email)
|
||||
expect(find('input[name="options::password"]').value).to eq(password)
|
||||
click '.js-close'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when editing inbound email settings' do
|
||||
it 'the expert form fields are not shown' do
|
||||
visit '#channels/email'
|
||||
click '.js-channelEnable'
|
||||
click '.js-editInbound'
|
||||
in_modal do
|
||||
expect(page).to have_no_text 'ORGANIZATION & DEPARTMENT NAME'
|
||||
expect(page).to have_no_text 'ORGANIZATION SUPPORT'
|
||||
expect(page).to have_no_text 'EMAIL'
|
||||
click '.js-close'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue