From c35088796aa0a0858a2170d96a94130afd23f89b Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 28 Sep 2017 11:35:52 +0100 Subject: [PATCH] Hide ID when only one reply to address is shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most user will only have one reply to address. Which means they should never have to worry about IDs. And if you only have one then you never need its ID, because the last remaining address will always be the default. So IDs should only be shown when a service has created more than one reply to address. This required a bit of visual tweaking of the _user list_ pattern, because its spacing wasn’t defined in a way that worked when only the name of the thing, and not its details were shown on the page. --- app/assets/stylesheets/components/tick-cross.scss | 4 ++-- .../views/service-settings/email_reply_to.html | 4 +++- tests/app/main/views/test_service_settings.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) 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/templates/views/service-settings/email_reply_to.html b/app/templates/views/service-settings/email_reply_to.html index b5efa04a7..71ce4c627 100644 --- a/app/templates/views/service-settings/email_reply_to.html +++ b/app/templates/views/service-settings/email_reply_to.html @@ -39,7 +39,9 @@ Change - {{ api_key(item.id, thing="ID") }} + {% if reply_to_email_addresses|length > 1 %} + {{ api_key(item.id, thing="ID") }} + {% endif %} {% endfor %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 068a6fbc1..1ccc2264a 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -689,6 +689,21 @@ def test_reply_to_hint_appears_when_service_has_multiple_reply_to_addresses( ) == "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