-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LG-13665: Add option to change selected email shared with partner (#1…
…1196) * LG-13665: Add option to change selected email shared with partner changelog: Upcoming Features, Partner Shared Email, Add option to change selected email shared with partner * Use nil-safe access to email with fallback Co-authored-by: Zach Margolis <[email protected]> * Sort analytics methods * Update view spec to use revised constructor signature * Add failing regression spec for email language regression * Fix regression for email language preference label * Remove unnecessary footer condition See: #11196 (comment) * Sort analytics methods * Eager load email address on connected accounts * Add view spec for selected email * Add feature spec for changing selected email * Add ticket number * Restrict controller access based on feature flag --------- Co-authored-by: Zach Margolis <[email protected]>
- Loading branch information
1 parent
ae1454e
commit 76dee31
Showing
28 changed files
with
606 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ | |
<%= troubleshooting_options %> | ||
</div> | ||
<% end %> | ||
|
||
<%= footer %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/controllers/accounts/connected_accounts/selected_email_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
module Accounts | ||
module ConnectedAccounts | ||
class SelectedEmailController < ApplicationController | ||
include RenderConditionConcern | ||
|
||
check_or_render_not_found -> { IdentityConfig.store.feature_select_email_to_share_enabled } | ||
before_action :confirm_two_factor_authenticated | ||
before_action :validate_identity | ||
|
||
def edit | ||
@identity = identity | ||
@select_email_form = build_select_email_form | ||
analytics.sp_select_email_visited | ||
end | ||
|
||
def update | ||
@select_email_form = build_select_email_form | ||
|
||
result = @select_email_form.submit(form_params) | ||
|
||
analytics.sp_select_email_submitted(**result.to_h) | ||
|
||
if result.success? | ||
redirect_to account_connected_accounts_path | ||
else | ||
flash[:error] = result.first_error_message | ||
redirect_to edit_connected_account_selected_email_path(identity.id) | ||
end | ||
end | ||
|
||
private | ||
|
||
def form_params | ||
params.require(:select_email_form).permit(:selected_email_id) | ||
end | ||
|
||
def build_select_email_form | ||
SelectEmailForm.new(user: current_user, identity:) | ||
end | ||
|
||
def validate_identity | ||
render_not_found if identity.blank? | ||
end | ||
|
||
def identity | ||
return @identity if defined?(@identity) | ||
@identity = current_user.identities.find_by(id: params[:identity_id]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/views/accounts/connected_accounts/selected_email/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<% self.title = t('titles.select_email') %> | ||
|
||
<%= render StatusPageComponent.new(status: :info, icon: :question) do |c| %> | ||
<% c.with_header(id: 'select-email-heading') { t('titles.select_email') } %> | ||
|
||
<p id="select-email-intro"> | ||
<%= t('help_text.select_preferred_email', sp: @identity.display_name, app_name: APP_NAME) %> | ||
</p> | ||
|
||
<%= simple_form_for( | ||
@select_email_form, | ||
url: connected_account_selected_email_path(identity_id: @identity.id), | ||
method: :patch, | ||
) do |f| %> | ||
<%= f.input( | ||
:selected_email_id, | ||
as: :radio_buttons, | ||
label: false, | ||
wrapper_html: { | ||
aria: { | ||
labelledby: 'select-email-heading', | ||
describedby: 'select-email-intro', | ||
}, | ||
}, | ||
collection: current_user.confirmed_email_addresses.map do |email| | ||
[ | ||
email.email, | ||
email.id, | ||
checked: email.id == @identity.email_address_id, | ||
] | ||
end, | ||
) %> | ||
<%= f.submit(t('help_text.requested_attributes.change_email_link'), class: 'margin-top-1') %> | ||
<% end %> | ||
|
||
<%= render ButtonComponent.new( | ||
url: add_email_path, | ||
outline: true, | ||
big: true, | ||
wide: true, | ||
class: 'margin-top-2', | ||
).with_content(t('account.index.email_add')) %> | ||
|
||
<% c.with_footer { link_to t('forms.buttons.back'), account_connected_accounts_path } %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.