From aa8529b5bbeffbf3229aed6fc8ae4ef04e55844e Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Mon, 1 Jan 2024 10:34:59 -0500 Subject: [PATCH 1/5] Quick commit before pulling latest --- .../uswds/_uswds-theme-custom-styles.scss | 36 +++++++++-------- app/templates/admin_template.html | 40 ++++++++++++------- .../components/components/header/template.njk | 18 ++++----- app/templates/main_nav.html | 4 +- app/templates/settings_nav.html | 20 ++++++++++ 5 files changed, 77 insertions(+), 41 deletions(-) create mode 100644 app/templates/settings_nav.html diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index 516fa6c89..56771faed 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -22,16 +22,23 @@ i.e. @use "uswds-core" as *; -.usa-header--extended .usa-logo { - font-family: family("sans"); - margin: units(4) 0; - @include at-media-max('mobile-lg') { - margin: units(4) 0 units(4) units(2); +.usa-header--extended { + .usa-logo { + font-family: family("sans"); + margin: units(4) 0; + @include at-media-max('mobile-lg') { + margin: units(4) 0 units(4) units(2); + } + img { + @include at-media($theme-header-min-width) { + width: 80px; + height: 70px; + } + } } - img { - @include at-media($theme-header-min-width) { - width: 80px; - height: 70px; + .usa-nav__secondary { + .usa-nav__link { + padding: 0; } } } @@ -44,15 +51,12 @@ i.e. &> .usa-nav__primary-item > a { font-size: size("body", 4); } - &> .usa-nav__primary-item:last-child { - margin-left: auto; - @include u-margin-right(-4); - } + // &> .usa-nav__primary-item:last-child { + // margin-left: auto; + // @include u-margin-right(-4); + // } } -.usa-nav__primary - - h1 { font-weight: bold !important; } diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index 86482f829..0feae28e7 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -58,26 +58,32 @@ "text": "Features", "active": header_navigation.is_selected('features') }, - { - "href": url_for('main.user_profile'), - "text": current_user.name, - "active": header_navigation.is_selected('user-profile') - }, { "href": url_for('main.platform_admin_splash_page'), "text": "Platform admin", "active": header_navigation.is_selected('platform-admin') }, - { - "href": url_for('main.sign_out'), - "text": "Sign out" - }, { "href": url_for('main.support'), "text": "Contact us", "active": header_navigation.is_selected('support') } ] %} + {% set secondaryNavigation = [ + { + "href": url_for('main.user_profile'), + "text": current_user.name, + "active": header_navigation.is_selected('user-profile') + }, + { + "href": url_for('.service_settings', service_id=current_service.id), + "text": "Settings" + }, + { + "href": url_for('main.sign_out'), + "text": "Sign out" + } + ] %} {% else %} {% set navigation = [ { @@ -104,10 +110,17 @@ "href": url_for('main.user_profile'), "text": "User profile", "active": header_navigation.is_selected('user-profile') + } + ] %} + {% set secondaryNavigation = [ + { + "href": url_for('main.user_profile'), + "text": current_user.name, + "active": header_navigation.is_selected('user-profile') }, { - "href": url_for('main.sign_out'), - "text": "Sign out" + "href": url_for('main.sign_out'), + "text": "Sign out" } ] %} {% endif %} @@ -142,6 +155,7 @@ "productName": "Notify", "navigation": navigation, "navigationClasses": "govuk-header__navigation--end", + "secondaryNavigation": secondaryNavigation, "assetsPath": asset_path + "images" }) }} {% endblock %} @@ -236,7 +250,7 @@ Please choose to extend your session or sign out. Your session will expire in 5 minutes or less.
-

You have been inactive for too long. +

You have been inactive for too long. Your session will expire in .

@@ -273,5 +287,3 @@ {% endblock %} - - diff --git a/app/templates/components/components/header/template.njk b/app/templates/components/components/header/template.njk index 1c817ea1c..f32df0cd9 100644 --- a/app/templates/components/components/header/template.njk +++ b/app/templates/components/components/header/template.njk @@ -76,18 +76,18 @@ {% endif %} {% endfor %} -
+
+ +{% endif %} From 7d6a07efd7cb8d2fbbc1b73b048c4a5e03e90add Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 4 Jan 2024 10:02:31 -0500 Subject: [PATCH 2/5] Test update --- tests/app/main/test_permissions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/app/main/test_permissions.py b/tests/app/main/test_permissions.py index 2843407ba..3ad521ae2 100644 --- a/tests/app/main/test_permissions.py +++ b/tests/app/main/test_permissions.py @@ -125,7 +125,6 @@ def test_service_navigation_for_org_user( ( "Send messages", "Sent messages", - "Team members", ), 403, ), @@ -134,7 +133,7 @@ def test_service_navigation_for_org_user( ( "Send messages", "Sent messages", - "Team members", + "Usage", ), 200, ), From f1e678760b9c5a6f19ed996c64681ba03f5abb28 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 4 Jan 2024 15:23:01 -0500 Subject: [PATCH 3/5] Updating tests, but need to add a new one to test the new secondary navivation --- app/templates/admin_template.html | 33 ++++++++++++++++---------- app/templates/settings_nav.html | 4 ++-- tests/app/main/views/test_dashboard.py | 14 +++++------ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index c858fb59e..03e229236 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -117,18 +117,27 @@ "active": header_navigation.is_selected('user-profile') } ] %} - {% set secondaryNavigation = [ - { - "href": url_for('.service_settings', service_id=current_service.id), - "text": "Settings", - "active": secondary_navigation.is_selected('settings') - }, - { - "href": url_for('main.sign_out'), - "text": "Sign out" - } - ] %} - {% endif %} + {% if current_service %} + {% set secondaryNavigation = [ + { + "href": url_for('main.service_settings', service_id=current_service.id), + "text": "Settings", + "active": secondary_navigation.is_selected('settings') + }, + { + "href": url_for('main.sign_out'), + "text": "Sign out" + } + ] %} + {% else %} + {% set secondaryNavigation = [ + { + "href": url_for('main.sign_out'), + "text": "Sign out" + } + ] %} + {% endif %} + {% endif %} {% else %} {# {% set navigation = [ diff --git a/app/templates/settings_nav.html b/app/templates/settings_nav.html index e6fbbe437..d94c417e7 100644 --- a/app/templates/settings_nav.html +++ b/app/templates/settings_nav.html @@ -5,11 +5,11 @@
    {# {% if current_user.has_permissions() %} #}
  • General
  • + href="{{ url_for('main.service_settings', service_id=current_service.id) }}">General
  • User profile
  • Team members
  • + href="{{ url_for('main.manage_users', service_id=current_service.id) }}">Team members {# {% endif %} #}
diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 010b53d5d..95b67d3ad 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1052,9 +1052,9 @@ def test_menu_send_messages( in page ) # assert url_for('main.uploads', service_id=service_one['id']) in page - assert url_for("main.manage_users", service_id=service_one["id"]) in page + assert url_for("main.manage_users", service_id=service_one["id"]) not in page - assert url_for("main.service_settings", service_id=service_one["id"]) not in page + assert url_for("main.service_settings", service_id=service_one["id"]) in page # assert url_for('main.api_keys', service_id=service_one['id']) not in page @@ -1086,7 +1086,7 @@ def test_menu_manage_service( ) in page ) - assert url_for("main.manage_users", service_id=service_one["id"]) in page + # assert url_for("main.manage_users", service_id=service_one["id"]) in page assert url_for("main.service_settings", service_id=service_one["id"]) in page # assert url_for('main.api_keys', service_id=service_one['id']) not in page @@ -1122,8 +1122,8 @@ def test_menu_manage_api_keys( ) in page ) - assert url_for("main.manage_users", service_id=service_one["id"]) in page - assert url_for("main.service_settings", service_id=service_one["id"]) in page + # assert url_for("main.manage_users", service_id=service_one["id"]) not in page + # assert url_for("main.service_settings", service_id=service_one["id"]) not in page assert url_for("main.api_integration", service_id=service_one["id"]) in page @@ -1145,8 +1145,8 @@ def test_menu_all_services_for_platform_admin_user( ) page = str(page) assert url_for("main.choose_template", service_id=service_one["id"]) in page - assert url_for("main.manage_users", service_id=service_one["id"]) in page - assert url_for("main.service_settings", service_id=service_one["id"]) in page + # assert url_for("main.manage_users", service_id=service_one["id"]) in page + # assert url_for("main.service_settings", service_id=service_one["id"]) in page # assert url_for('main.view_notifications', service_id=service_one['id'], message_type='email') in page assert ( url_for( From 3a1d624d8fe41600aa58e8ec76bef276c864ca5c Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 4 Jan 2024 15:43:43 -0500 Subject: [PATCH 4/5] Missed a test --- tests/app/main/views/accounts/test_choose_accounts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index 8b94ebe64..dae5c712a 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -363,7 +363,7 @@ def test_should_show_back_to_service_if_user_belongs_to_service( ): mock_get_service.return_value = service_one expected_page_text = ( - "Test Service Switch service " "Send messages " "Dashboard " "Team members" + "Test Service Switch service " "Send messages " "Dashboard " "Usage" ) # TODO: set sidebar variables in common test module page = client_request.get( From 5a243904b6d0f5feb25e96d4e5cabf6592057e69 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Fri, 5 Jan 2024 12:07:20 -0500 Subject: [PATCH 5/5] Updated the tests to include the Settings page --- app/templates/admin_template.html | 2 +- tests/app/main/views/test_dashboard.py | 52 +++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index 03e229236..c48f768ce 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -72,7 +72,7 @@ {% if current_service %} {% set secondaryNavigation = [ { - "href": url_for('.service_settings', service_id=current_service.id), + "href": url_for('main.service_settings', service_id=current_service.id), "text": "Settings", "active": secondary_navigation.is_selected('settings') }, diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 95b67d3ad..1acd1f2de 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1020,6 +1020,20 @@ def _test_dashboard_menu(client_request, mocker, usr, service, permissions): return client_request.get("main.service_dashboard", service_id=service["id"]) +def _test_settings_menu(client_request, mocker, usr, service, permissions): + usr["permissions"][str(service["id"])] = permissions + usr["services"] = [service["id"]] + mocker.patch("app.user_api_client.check_verify_code", return_value=(True, "")) + mocker.patch( + "app.service_api_client.get_services", return_value={"data": [service]} + ) + mocker.patch("app.user_api_client.get_user", return_value=usr) + mocker.patch("app.user_api_client.get_user_by_email", return_value=usr) + mocker.patch("app.service_api_client.get_service", return_value={"data": service}) + client_request.login(usr) + return client_request.get("main.service_dashboard", service_id=service["id"]) + + def test_menu_send_messages( client_request, mocker, @@ -1051,11 +1065,8 @@ def test_menu_send_messages( ) in page ) - # assert url_for('main.uploads', service_id=service_one['id']) in page assert url_for("main.manage_users", service_id=service_one["id"]) not in page - assert url_for("main.service_settings", service_id=service_one["id"]) in page - # assert url_for('main.api_keys', service_id=service_one['id']) not in page def test_menu_manage_service( @@ -1086,10 +1097,39 @@ def test_menu_manage_service( ) in page ) - # assert url_for("main.manage_users", service_id=service_one["id"]) in page - assert url_for("main.service_settings", service_id=service_one["id"]) in page + assert url_for(".service_dashboard", service_id=service_one["id"]) in page + assert url_for(".choose_template", service_id=service_one["id"]) in page - # assert url_for('main.api_keys', service_id=service_one['id']) not in page + +def test_menu_main_settings( + client_request, + mocker, + api_user_active, + service_one, + mock_get_service_templates, + mock_has_no_jobs, + mock_get_template_statistics, + mock_get_service_statistics, + mock_get_annual_usage_for_service, + mock_get_inbound_sms_summary, + mock_get_free_sms_fragment_limit, +): + page = _test_settings_menu( + client_request, + mocker, + api_user_active, + service_one, + ["view_activity", "user_profile", "manage_users", "manage_settings"], + ) + page = str(page) + assert ( + url_for( + "main.service_settings", + service_id=service_one["id"], + ) + in page + ) + assert url_for("main.service_settings", service_id=service_one["id"]) in page def test_menu_manage_api_keys(