Merge pull request #1952 from alphagov/no-no-permissions-banner

Replace ‘no permissions’ banner with a line on the template page
This commit is contained in:
Chris Hill-Scott
2018-03-13 09:48:54 +00:00
committed by GitHub
6 changed files with 34 additions and 44 deletions

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -15,12 +15,8 @@
<div class="dashboard">
<h1 class="visuallyhidden">Dashboard</h1>
{% 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') }}

View File

@@ -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 %}

View File

@@ -1,8 +1,16 @@
{% from 'components/message-count-label.html' import message_count_label %}
<div class="column-whole">
{% if template._template.archived %}
<p class="hint">
This template was deleted {{ template._template.updated_at|format_datetime_relative }}.
</p>
{% elif not current_user.has_permissions('send_messages', 'manage_api_keys', 'manage_templates', 'manage_service') %}
<p class="top-gutter-1-3 {% if template.template_type != 'sms' %}bottom-gutter{% endif %}">
If you need to send this
{{ message_count_label(1, template.template_type, suffix='') }}
or edit this template, contact your manager.
</p>
{% else %}
<div class="bottom-gutter-2-3">
<div class="grid-row">

View File

@@ -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,