From 9838c3908b6133ae66790220e8c497bc71a91b8c Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 12 Mar 2018 15:46:54 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Add=20line=20to=20template=20page=20if=20yo?= =?UTF-8?q?u=20can=E2=80=99t=20do=20anything?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If someone has no permissions but needs permissions the thing they’re probably going to need is to send a message or edit a template. The place they will probably come to is the place where the buttons would be – users with these permissions are finding the thing they need to do on this page. So this commit adds a line to this page which (hopefully) makes it clear they’re in the right place, but need to go and speak to someone. --- app/assets/stylesheets/_grids.scss | 5 ++++ app/templates/views/templates/_template.html | 8 +++++++ tests/app/main/views/test_templates.py | 24 ++++++++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/_grids.scss b/app/assets/stylesheets/_grids.scss index 818891e54..84cbbe94c 100644 --- a/app/assets/stylesheets/_grids.scss +++ b/app/assets/stylesheets/_grids.scss @@ -44,6 +44,11 @@ margin-top: $gutter-half; } +.top-gutter-1-3 { + @extend %top-gutter; + margin-top: $gutter / 3; +} + %bottom-gutter, .bottom-gutter { @extend %contain-floats; diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index 265597f68..f7a7d4d37 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -1,8 +1,16 @@ +{% from 'components/message-count-label.html' import message_count_label %} +
{% if template._template.archived %}

This template was deleted {{ template._template.updated_at|format_datetime_relative }}.

+ {% elif not current_user.has_permissions('send_messages', 'manage_api_keys', 'manage_templates', 'manage_service') %} +

+ If you need to send this + {{ message_count_label(1, template.template_type, suffix='') }} + or edit this template, contact your manager. +

{% else %}
diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index 6e7b04bed..3e1a30e57 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -110,22 +110,31 @@ def test_should_show_page_for_one_template( mock_get_service_template.assert_called_with(service_one['id'], template_id) -@pytest.mark.parametrize('permissions, links_to_be_shown', [ +@pytest.mark.parametrize('permissions, links_to_be_shown, permissions_warning_to_be_shown', [ ( ['view_activity'], - [] + [], + 'If you need to send this text message or edit this template, contact your manager.' + ), + ( + ['manage_api_keys'], + [], + None, ), ( ['manage_templates'], - ['.edit_service_template'] + ['.edit_service_template'], + None, ), ( ['send_messages'], - ['.send_messages', '.set_sender'] + ['.send_messages', '.set_sender'], + None, ), ( ['send_messages', 'manage_templates'], - ['.send_messages', '.set_sender', '.edit_service_template'] + ['.send_messages', '.set_sender', '.edit_service_template'], + None, ), ]) def test_should_be_able_to_view_a_template_with_links( @@ -138,6 +147,7 @@ def test_should_be_able_to_view_a_template_with_links( fake_uuid, permissions, links_to_be_shown, + permissions_warning_to_be_shown, ): active_user_with_permissions._permissions[service_one['id']] = permissions + ['view_activity'] client.login(active_user_with_permissions, mocker, service_one) @@ -161,6 +171,10 @@ def test_should_be_able_to_view_a_template_with_links( template_id=fake_uuid, ) + assert normalize_spaces(page.select_one('main p').text) == ( + permissions_warning_to_be_shown or 'To: phone number' + ) + def test_should_show_template_id_on_template_page( logged_in_client, From 9435f69a6e94cc3c20745ef6af19c81f385fde62 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 12 Mar 2018 15:49:52 +0000 Subject: [PATCH 2/2] Remove warning banner from dashboard (and app) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have teams who are using the dashboard every day, and being confronted with this alarming yellow banner. There’s no action they need to do since they’re only looking at the messages sent. So this commit removes that banner from the dashboard. It also removes the CSS and HTML for it from the app entirely because this is the last remaining place we were using this style of banner. --- app/assets/stylesheets/components/banner.scss | 27 ------------------- app/templates/views/dashboard/dashboard.html | 8 ++---- .../dashboard/no-permissions-banner.html | 6 ----- 3 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 app/templates/views/dashboard/no-permissions-banner.html diff --git a/app/assets/stylesheets/components/banner.scss b/app/assets/stylesheets/components/banner.scss index 610785e5a..54124afa6 100644 --- a/app/assets/stylesheets/components/banner.scss +++ b/app/assets/stylesheets/components/banner.scss @@ -153,30 +153,3 @@ } } - -.banner-warning { - - @extend %banner; - @include bold-19; - background: $yellow; - color: $text-colour; - border: 5px solid $text-colour; - margin: $gutter-half 0 $gutter 0; - text-align: left; - padding: 20px; - - .heading-medium { - @include bold-24; - margin: 0 0 $gutter-half 0; - } - - .list { - margin-bottom: 10px; - } - - a:link, - a:visited { - color: $text-colour; - } - -} diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index c347e86e0..dfabe6297 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -15,12 +15,8 @@

Dashboard

- {% if current_user.has_permissions('manage_templates') %} - {% if not templates %} - {% include 'views/dashboard/write-first-messages.html' %} - {% endif %} - {% elif not current_user.has_permissions('send_messages', 'manage_api_keys') %} - {% include 'views/dashboard/no-permissions-banner.html' %} + {% if current_user.has_permissions('manage_templates') and not templates %} + {% include 'views/dashboard/write-first-messages.html' %} {% endif %} {{ ajax_block(partials, updates_url, 'upcoming') }} diff --git a/app/templates/views/dashboard/no-permissions-banner.html b/app/templates/views/dashboard/no-permissions-banner.html deleted file mode 100644 index fdc8ad68c..000000000 --- a/app/templates/views/dashboard/no-permissions-banner.html +++ /dev/null @@ -1,6 +0,0 @@ -{% from "components/banner.html" import banner_wrapper %} - -{% call banner_wrapper(type="warning") %} - You only have permission to view this service. To send messages, edit - templates or manage team members, contact the person who invited you. -{% endcall %}