diff --git a/app/assets/stylesheets/components/tick-cross.scss b/app/assets/stylesheets/components/tick-cross.scss index 3601b0ad4..4f80e08b3 100644 --- a/app/assets/stylesheets/components/tick-cross.scss +++ b/app/assets/stylesheets/components/tick-cross.scss @@ -42,12 +42,12 @@ &-list { @extend %grid-row; - margin-top: 5px; position: relative; &-permissions { @include grid-column(3/4); + margin-top: 5px; li { display: block; @@ -59,7 +59,7 @@ &-edit-link { text-align: right; position: absolute; - top: -1.6em; + top: -25px; right: -135px; } diff --git a/app/main/forms.py b/app/main/forms.py index a974a93ed..1cecfbe6a 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -463,7 +463,7 @@ class ProviderForm(Form): class ServiceReplyToEmailForm(Form): email_address = email_address(label='Email reply to address') - is_default = BooleanField("Make this address the default") + is_default = BooleanField("Make this email address the default") class ServiceSmsSender(Form): diff --git a/app/templates/components/api-key.html b/app/templates/components/api-key.html index 81e909d66..dc5e6c2ee 100644 --- a/app/templates/components/api-key.html +++ b/app/templates/components/api-key.html @@ -1,7 +1,9 @@ -{% macro api_key(key, name, thing="API key") %} -

- {{ name }} -

+{% macro api_key(key, name=None, thing="API key") %} + {% if name %} +

+ {{ name }} +

+ {% endif %}
{{ key }}
diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index ebce22710..cf3623752 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -44,8 +44,9 @@ {% if 'email' in current_service.permissions %} {% call row() %} - {{ text_field('Email reply to address') }} - {% call field() %} + {{ text_field('Email reply to addresses') }} + {% call field(status='default' if default_reply_to_email_address == "None" else '') %} + {{ default_reply_to_email_address }} {% if reply_to_email_address_count > 1 %}
@@ -53,7 +54,10 @@
{% endif %} {% endcall %} - {{ edit_field('Change', url_for('.service_email_reply_to', service_id=current_service.id)) }} + {{ edit_field( + 'Manage' if reply_to_email_address_count else 'Change', + url_for('.service_email_reply_to', service_id=current_service.id)) + }} {% endcall %} {% endif %} diff --git a/app/templates/views/service-settings/email-reply-to/add.html b/app/templates/views/service-settings/email-reply-to/add.html index d4fe351ce..98bd4966d 100644 --- a/app/templates/views/service-settings/email-reply-to/add.html +++ b/app/templates/views/service-settings/email-reply-to/add.html @@ -27,7 +27,7 @@ 'Add', back_link=url_for('.service_email_reply_to', service_id=current_service.id), back_link_text='Back' - ) }} + ) }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/views/service-settings/email-reply-to/edit.html b/app/templates/views/service-settings/email-reply-to/edit.html index 607171789..fb0fd6473 100644 --- a/app/templates/views/service-settings/email-reply-to/edit.html +++ b/app/templates/views/service-settings/email-reply-to/edit.html @@ -19,7 +19,9 @@ safe_error_message=True ) }} {% if form.is_default.data %} -

This email address is the default

+

+ This is the default reply to address for {{ current_service.name }} emails +

{% else %}
{{ checkbox(form.is_default) }} @@ -32,4 +34,4 @@ ) }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/views/service-settings/email_reply_to.html b/app/templates/views/service-settings/email_reply_to.html index baa3f035a..71ce4c627 100644 --- a/app/templates/views/service-settings/email_reply_to.html +++ b/app/templates/views/service-settings/email_reply_to.html @@ -1,5 +1,5 @@ {% extends "withnav_template.html" %} -{% from "components/textbox.html" import textbox %} +{% from "components/api-key.html" import api_key %} {% from "components/page-footer.html" import page_footer %} {% from "components/table.html" import row_group, row, text_field, edit_field, field, boolean_field, list_table %} @@ -19,27 +19,50 @@ Add email address
-
- {% call(item, row_number) list_table( - reply_to_email_addresses, - empty_message="You haven’t added any email addresses yet.", - caption="Reply to email addresses", - caption_visible=false, - field_headings=[ - 'Email addresses', - 'Action' - ], - field_headings_visible=False - ) %} - {% call field() %} - {{ item.email_address }} - {% if item.is_default %} - - {{ "(default)" }} - - {% endif %} - {% endcall %} - {{ edit_field('Change', url_for('.service_edit_email_reply_to', service_id =current_service.id, reply_to_email_id = item.id)) }} - {% endcall %} +
+ {% if not reply_to_email_addresses %} +
+ You haven’t added any email reply to addresses yet +
+ {% endif %} + {% for item in reply_to_email_addresses %} +
+

+ {{ item.email_address }} + {%- if item.is_default -%} + (default) + {% endif %} + +

+ + {% if reply_to_email_addresses|length > 1 %} + {{ api_key(item.id, thing="ID") }} + {% endif %} +
+ {% endfor %}
-{% endblock %} \ No newline at end of file +
+
+

+ Your emails will be sent from + {{ current_service.email_from }}@notifications.service.gov.uk +

+

+ This is so they have the best chance of being delivered. + This email address can’t receive replies. +

+

+ Set up separate email addresses to receive replies + from your users. + {% if current_service.restricted and not reply_to_email_addresses %} + Your service can’t go live until you’ve added at least one + reply to address. + {% endif %} +

+
+
+{% endblock %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 13811220a..628afc93e 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -31,7 +31,7 @@ from tests.conftest import ( 'Label Value Action', 'Send emails On Change', - 'Email reply to address None Change', + 'Email reply to addresses None Change', 'Label Value Action', 'Send text messages On Change', @@ -50,7 +50,7 @@ from tests.conftest import ( 'Label Value Action', 'Send emails On Change', - 'Email reply to address None Change', + 'Email reply to addresses None Change', 'Label Value Action', 'Send text messages On Change', @@ -102,7 +102,7 @@ def test_should_show_overview( 'Label Value Action', 'Send emails On Change', - 'Email reply to address test@example.com Change', + 'Email reply to addresses test@example.com Manage', 'Label Value Action', 'Send text messages On Change', @@ -121,7 +121,7 @@ def test_should_show_overview( 'Label Value Action', 'Send emails On Change', - 'Email reply to address test@example.com Change', + 'Email reply to addresses test@example.com Manage', 'Label Value Action', 'Send text messages On Change', @@ -692,35 +692,54 @@ def test_reply_to_hint_appears_when_service_has_multiple_reply_to_addresses( assert normalize_spaces( page.select('tbody tr')[2].text - ) == "Email reply to address test@example.com …and 2 more Change" + ) == "Email reply to addresses test@example.com …and 2 more Manage" + + +def test_single_reply_to_address_shows_default_but_without_id( + client_request, + single_reply_to_email_addresses +): + rows = client_request.get( + 'main.service_email_reply_to', + service_id=SERVICE_ONE_ID + ).select( + '.user-list-item' + ) + + assert normalize_spaces(rows[0].text) == "test@example.com (default) Change" + assert len(rows) == 1 def test_default_email_reply_to_address_has_default_hint( client_request, multiple_reply_to_email_addresses ): - page = client_request.get( + rows = client_request.get( 'main.service_email_reply_to', service_id=SERVICE_ONE_ID + ).select( + '.user-list-item' ) - assert normalize_spaces(page.select('tbody tr')[0].text) == "test@example.com (default) Change" - assert normalize_spaces(page.select('tbody tr')[1].text) == "test2@example.com Change" - assert normalize_spaces(page.select('tbody tr')[2].text) == "test3@example.com Change" - assert len(page.select('tbody tr')) == 3 + assert normalize_spaces(rows[0].text) == "test@example.com (default) Change 1234" + assert normalize_spaces(rows[1].text) == "test2@example.com Change 5678" + assert normalize_spaces(rows[2].text) == "test3@example.com Change 9457" + assert len(rows) == 3 def test_no_reply_to_email_addresses_message_shows( client_request, no_reply_to_email_addresses ): - page = client_request.get( + rows = client_request.get( 'main.service_email_reply_to', service_id=SERVICE_ONE_ID + ).select( + '.user-list-item' ) - assert normalize_spaces(page.select('tbody tr')[0].text) == "You haven’t added any email addresses yet." - assert len(page.select('tbody tr')) == 1 + assert normalize_spaces(rows[0].text) == "You haven’t added any email reply to addresses yet" + assert len(rows) == 1 @pytest.mark.parametrize('reply_to_input, expected_error', [ @@ -844,7 +863,9 @@ def test_default_box_shows_on_non_default_email_addresses_while_editing( if checkbox_present: assert page.select_one('[name=is_default]') else: - assert normalize_spaces(page.select_one('form p').text) == "This email address is the default" + assert normalize_spaces(page.select_one('form p').text) == ( + 'This is the default reply to address for service one emails' + ) def test_switch_service_to_research_mode(