Improve display of folder path when deeply nested

It’s a bit rudimentary to only show the current place in the hierarchy
and the parent. You lose a sense of how deep you are.

But we can’t just show the full path, because it can be arbitrarily
long. So what this commit does is show the full path, but truncates the
display of any items. Further-up than the current folder or its parent.

This also helps disambiguate between folders and templates, because
folders are always shown with the folder icon.

This probably won’t affect many teams, because we don’t anticipate a lot
of deep nesting.
This commit is contained in:
Chris Hill-Scott
2019-01-30 10:09:04 +00:00
parent 02f7d7708a
commit 88ad982bf7
10 changed files with 125 additions and 50 deletions

View File

@@ -124,7 +124,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'Templates service one GOV.UK Notify',
'Templates',
None,
[],
{},
['Text message', 'Email', 'Letter'],
[
@@ -172,7 +172,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'Templates service one GOV.UK Notify',
'Templates',
None,
[],
{'template_type': 'sms'},
['All', 'Email', 'Letter'],
[
@@ -201,7 +201,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'folder_one Templates service one GOV.UK Notify',
'Templates / folder_one',
{'template_type': 'all'},
[{'template_type': 'all'}],
{'template_folder_id': PARENT_FOLDER_ID},
['Text message', 'Email', 'Letter'],
[
@@ -227,7 +227,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'folder_one Templates service one GOV.UK Notify',
'Templates / folder_one',
{'template_type': 'sms'},
[{'template_type': 'sms'}],
{'template_type': 'sms', 'template_folder_id': PARENT_FOLDER_ID},
['All', 'Email', 'Letter'],
[
@@ -248,7 +248,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'folder_one Templates service one GOV.UK Notify',
'Templates / folder_one',
{'template_type': 'email'},
[{'template_type': 'email'}],
{'template_type': 'email', 'template_folder_id': PARENT_FOLDER_ID},
['All', 'Text message', 'Letter'],
[],
@@ -257,9 +257,12 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
'There are no email templates in this folder',
),
(
'folder_one_one folder_one service one GOV.UK Notify',
'folder_one / folder_one_one',
{'template_type': 'all', 'template_folder_id': PARENT_FOLDER_ID},
'folder_one_one folder_one Templates service one GOV.UK Notify',
'Templates / folder_one / folder_one_one',
[
{'template_type': 'all'},
{'template_type': 'all', 'template_folder_id': PARENT_FOLDER_ID},
],
{'template_folder_id': CHILD_FOLDER_ID},
['Text message', 'Email', 'Letter'],
[
@@ -279,9 +282,13 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
None,
),
(
'folder_one_one_one folder_one_one service one GOV.UK Notify',
'folder_one_one / folder_one_one_one',
{'template_type': 'all', 'template_folder_id': CHILD_FOLDER_ID},
'folder_one_one_one folder_one_one folder_one Templates service one GOV.UK Notify',
'Templates / folder_one / folder_one_one / folder_one_one_one',
[
{'template_type': 'all'},
{'template_type': 'all', 'template_folder_id': PARENT_FOLDER_ID},
{'template_type': 'all', 'template_folder_id': CHILD_FOLDER_ID},
],
{'template_folder_id': GRANDCHILD_FOLDER_ID},
['Text message', 'Email', 'Letter'],
[
@@ -298,7 +305,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'folder_two Templates service one GOV.UK Notify',
'Templates / folder_two',
{'template_type': 'all'},
[{'template_type': 'all'}],
{'template_folder_id': FOLDER_TWO_ID},
['Text message', 'Email', 'Letter'],
[],
@@ -309,7 +316,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
(
'folder_two Templates service one GOV.UK Notify',
'Templates / folder_two',
{'template_type': 'sms'},
[{'template_type': 'sms'}],
{'template_folder_id': FOLDER_TWO_ID, 'template_type': 'sms'},
['All', 'Email', 'Letter'],
[],
@@ -368,15 +375,14 @@ def test_should_show_templates_folder_page(
assert normalize_spaces(page.select_one('title').text) == expected_title_tag
assert normalize_spaces(page.select_one('h1').text) == expected_page_title
if expected_parent_link_args:
assert len(page.select('h1 a')) == 1
assert page.select_one('h1 a')['href'] == url_for(
assert len(page.select('h1 a')) == len(expected_parent_link_args)
for index, parent_link in enumerate(page.select('h1 a')):
assert parent_link['href'] == url_for(
'main.choose_template',
service_id=SERVICE_ONE_ID,
**expected_parent_link_args
**expected_parent_link_args[index]
)
else:
assert page.select_one('h1 a') is None
links_in_page = page.select('.pill a')

View File

@@ -267,7 +267,7 @@ def test_should_show_live_search_if_service_has_lots_of_folders(
)
count_of_templates_and_folders = len(page.select('.message-name'))
count_of_folders = len(page.select('.template-list-folder'))
count_of_folders = len(page.select('.template-list-folder:first-child'))
count_of_templates = count_of_templates_and_folders - count_of_folders
assert len(page.select('.live-search')) == 1