Merge pull request #2078 from GSA/2069-user-story-add-new-link-to-best-practices-page

Added link to new guidance page that enables navigating
This commit is contained in:
Alex Janousek
2024-11-14 16:52:52 -05:00
committed by GitHub
7 changed files with 115 additions and 70 deletions

View File

@@ -162,6 +162,17 @@ def _csp(config):
def create_app(application): def create_app(application):
application.config["FEATURE_BEST_PRACTICES_ENABLED"] = (
os.getenv("FEATURE_BEST_PRACTICES_ENABLED", "false").lower() == "true"
)
@application.context_processor
def inject_feature_flags():
feature_best_practices_enabled = application.config[
"FEATURE_BEST_PRACTICES_ENABLED"
]
return dict(FEATURE_BEST_PRACTICES_ENABLED=feature_best_practices_enabled)
notify_environment = os.environ["NOTIFY_ENVIRONMENT"] notify_environment = os.environ["NOTIFY_ENVIRONMENT"]
application.config.from_object(configs[notify_environment]) application.config.from_object(configs[notify_environment])

View File

@@ -21,10 +21,8 @@ from notifications_utils.url_safe_token import generate_token
# Hook to check for guidance routes # Hook to check for guidance routes
@main.before_request @main.before_request
def check_guidance_feature(): def check_guidance_feature():
current_app.logger.warning("best practices 1234")
current_app.logger.warning(current_app.config["FEATURE_BEST_PRACTICES_ENABLED"])
if ( if (
request.path.startswith("/best-practices") request.path.startswith("/guides/best-practices")
and not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"] and not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]
): ):
abort(404) abort(404)
@@ -207,7 +205,7 @@ def trial_mode_new():
) )
@main.route("/best-practices") @main.route("/guides/best-practices")
@user_is_logged_in @user_is_logged_in
def best_practices(): def best_practices():
return render_template( return render_template(
@@ -216,7 +214,7 @@ def best_practices():
) )
@main.route("/best-practices/clear-goals") @main.route("/guides/best-practices/clear-goals")
@user_is_logged_in @user_is_logged_in
def clear_goals(): def clear_goals():
return render_template( return render_template(
@@ -225,7 +223,7 @@ def clear_goals():
) )
@main.route("/best-practices/rules-and-regulations") @main.route("/guides/best-practices/rules-and-regulations")
@user_is_logged_in @user_is_logged_in
def rules_and_regulations(): def rules_and_regulations():
return render_template( return render_template(
@@ -234,7 +232,7 @@ def rules_and_regulations():
) )
@main.route("/best-practices/establish-trust") @main.route("/guides/best-practices/establish-trust")
@user_is_logged_in @user_is_logged_in
def establish_trust(): def establish_trust():
return render_template( return render_template(
@@ -243,7 +241,7 @@ def establish_trust():
) )
@main.route("/best-practices/write-for-action") @main.route("/guides/best-practices/write-for-action")
@user_is_logged_in @user_is_logged_in
def write_for_action(): def write_for_action():
return render_template( return render_template(
@@ -252,7 +250,7 @@ def write_for_action():
) )
@main.route("/best-practices/multiple-languages") @main.route("/guides/best-practices/multiple-languages")
@user_is_logged_in @user_is_logged_in
def multiple_languages(): def multiple_languages():
return render_template( return render_template(
@@ -261,7 +259,7 @@ def multiple_languages():
) )
@main.route("/best-practices/benchmark-performance") @main.route("/guides/best-practices/benchmark-performance")
@user_is_logged_in @user_is_logged_in
def benchmark_performance(): def benchmark_performance():
return render_template( return render_template(
@@ -270,7 +268,7 @@ def benchmark_performance():
) )
@main.route("/using-notify/guidance") @main.route("/guides/using-notify/guidance")
@user_is_logged_in @user_is_logged_in
def guidance_index(): def guidance_index():
return render_template( return render_template(

View File

@@ -27,6 +27,10 @@ def using_notify_nav():
"name": "Get started", "name": "Get started",
"link": "main.get_started", "link": "main.get_started",
}, },
{
"name": "Guides",
"link": "main.best_practices",
},
{ {
"name": "Trial mode", "name": "Trial mode",
"link": "main.trial_mode_new", "link": "main.trial_mode_new",

View File

@@ -46,6 +46,15 @@ class HeaderNavigation(Navigation):
"roadmap", "roadmap",
"security", "security",
}, },
"best_practices": {
"best_practices",
"clear_goals",
"rules_and_regulations",
"establish_trust",
"write_for_action",
"multiple_languages",
"benchmark_performance"
},
"using_notify": { "using_notify": {
"get_started", "get_started",
"using_notify", "using_notify",

View File

@@ -1,32 +1,43 @@
{% if current_user.is_authenticated %} {% if current_user.is_authenticated %}
{% set navigation = [ {% set navigation = [
{"href": url_for("main.show_accounts_or_dashboard"), "text": "Current service", "active": header_navigation.is_selected('accounts-or-dashboard')}, {"href": url_for("main.show_accounts_or_dashboard"), "text": "Current service", "active":
{"href": url_for('main.get_started'), "text": "Using Notify", "active": header_navigation.is_selected('using_notify')}, header_navigation.is_selected('accounts-or-dashboard')},
{"href": url_for('main.features'), "text": "Features", "active": header_navigation.is_selected('features')}, {"href": url_for('main.get_started'), "text": "Using Notify", "active": header_navigation.is_selected('using_notify')}
{"href": url_for('main.support'), "text": "Contact us", "active": header_navigation.is_selected('support')} ] %}
] %}
{% if current_user.platform_admin %} {% if FEATURE_BEST_PRACTICES_ENABLED %}
{% set navigation = navigation + [{"href": url_for('main.platform_admin_splash_page'), "text": "Platform admin", "active": header_navigation.is_selected('platform-admin')}] %} {% set navigation = navigation + [{"href": url_for('main.best_practices'), "text": "Guides", "active":
{% else %} header_navigation.is_selected('best_practices')}] %}
{% set navigation = navigation + [{"href": url_for('main.user_profile'), "text": "User profile", "active": header_navigation.is_selected('user-profile')}] %} {% endif %}
{% endif %}
{% if current_service %} {% set navigation = navigation + [
{% if current_user.has_permissions('manage_service') %} {"href": url_for('main.features'), "text": "Features", "active": header_navigation.is_selected('features')},
{% set secondaryNavigation = [ {"href": url_for('main.support'), "text": "Contact us", "active": header_navigation.is_selected('support')}
{"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 %} {% if current_user.platform_admin %}
{% else %} {% set navigation = navigation + [{"href": url_for('main.platform_admin_splash_page'), "text": "Platform admin",
{% set secondaryNavigation = [{"href": url_for('main.sign_out'), "text": "Sign out"}] %} "active": header_navigation.is_selected('platform-admin')}] %}
{% endif %} {% else %}
{% set navigation = navigation + [{"href": url_for('main.user_profile'), "text": "User profile", "active":
header_navigation.is_selected('user-profile')}] %}
{% endif %}
{% if current_service %}
{% if current_user.has_permissions('manage_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 %}
{% else %}
{% set secondaryNavigation = [{"href": url_for('main.sign_out'), "text": "Sign out"}] %}
{% endif %}
{% endif %} {% endif %}
<header class="usa-header usa-header--extended"> <header class="usa-header usa-header--extended">
@@ -36,12 +47,12 @@
<div class="logo-img display-flex"> <div class="logo-img display-flex">
<a href="/"> <a href="/">
<span class="usa-sr-only">Notify.gov logo</span> <span class="usa-sr-only">Notify.gov logo</span>
<img src="{{ (asset_path | default('/static')) + 'images/notify-logo.svg' }}" alt="Notify.gov logo" class="usa-flag-logo margin-right-1"> <img src="{{ (asset_path | default('/static')) + 'images/notify-logo.svg' }}" alt="Notify.gov logo"
class="usa-flag-logo margin-right-1">
</a> </a>
</div> </div>
{% if navigation %} {% if navigation %}
<button type="button" class="usa-menu-btn">Menu</button> <button type="button" class="usa-menu-btn">Menu</button>
{% endif %} {% endif %}
</div> </div>
</div> </div>
@@ -52,29 +63,29 @@
</button> </button>
<ul class="usa-nav__primary usa-accordion margin-right-1"> <ul class="usa-nav__primary usa-accordion margin-right-1">
{% for item in navigation %} {% for item in navigation %}
{% if item.href and item.text %} {% if item.href and item.text %}
<li class="usa-nav__primary-item{{ ' is-current' if item.active }}"> <li class="usa-nav__primary-item{{ ' is-current' if item.active }}">
<a class="usa-nav__link {{ ' usa-current' if item.active }}" href="{{ item.href }}" {% for attribute, value in <a class="usa-nav__link {{ ' usa-current' if item.active }}" href="{{ item.href }}" {% for attribute, value
item.attributes %} {{attribute}}="{{value}}" {% endfor %}> in item.attributes %} {{attribute}}="{{value}}" {% endfor %}>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
<div class="usa-nav__secondary margin-bottom-6"> <div class="usa-nav__secondary margin-bottom-6">
<ul class="usa-nav__secondary-links"> <ul class="usa-nav__secondary-links">
{% if secondaryNavigation %} {% if secondaryNavigation %}
{% for item in secondaryNavigation %} {% for item in secondaryNavigation %}
{% if item.href and item.text %} {% if item.href and item.text %}
<li class="usa-nav__secondary-item{{ ' is-current' if item.active }}"> <li class="usa-nav__secondary-item{{ ' is-current' if item.active }}">
<a class="usa-nav__link {{ ' usa-current' if item.active }}" href="{{ item.href }}" {% for attribute, value in <a class="usa-nav__link {{ ' usa-current' if item.active }}" href="{{ item.href }}" {% for attribute,
item.attributes %} {{attribute}}="{{value}}" {% endfor %}> value in item.attributes %} {{attribute}}="{{value}}" {% endfor %}>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
</a> </a>
</li> </li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</ul> </ul>
</div> </div>

View File

@@ -23,37 +23,37 @@ Best Practices
"svg_src": "goal", "svg_src": "goal",
"card_heading": "Establish clear goals", "card_heading": "Establish clear goals",
"p_text": "Start with a singular purpose. Make explicit what you want to achieve.", "p_text": "Start with a singular purpose. Make explicit what you want to achieve.",
"link": "/best-practices/clear-goals" "link": "/guides/best-practices/clear-goals"
}, },
{ {
"svg_src": "compliant", "svg_src": "compliant",
"card_heading": "Follow rules & regulations", "card_heading": "Follow rules & regulations",
"p_text": "Understand what is required when texting the public.", "p_text": "Understand what is required when texting the public.",
"link": "/best-practices/rules-and-regulations" "link": "/guides/best-practices/rules-and-regulations"
}, },
{ {
"svg_src": "trust", "svg_src": "trust",
"card_heading": "Establish trust", "card_heading": "Establish trust",
"p_text": "Help your audience anticipate and welcome your texts.", "p_text": "Help your audience anticipate and welcome your texts.",
"link": "/best-practices/establish-trust" "link": "/guides/best-practices/establish-trust"
}, },
{ {
"svg_src": "runner", "svg_src": "runner",
"card_heading": "Write texts that provoke action", "card_heading": "Write texts that provoke action",
"p_text": "Help your audience know what to do with the information you send.", "p_text": "Help your audience know what to do with the information you send.",
"link": "/best-practices/write-for-action" "link": "/guides/best-practices/write-for-action"
}, },
{ {
"svg_src": "language", "svg_src": "language",
"card_heading": "Send texts in multiple languages", "card_heading": "Send texts in multiple languages",
"p_text": "What to know as you plan translated texts.", "p_text": "What to know as you plan translated texts.",
"link": "/best-practices/multiple-languages" "link": "/guides/best-practices/multiple-languages"
}, },
{ {
"svg_src": "chart", "svg_src": "chart",
"card_heading": "Measure performance with benchmarking", "card_heading": "Measure performance with benchmarking",
"p_text": "Learn how effective your texting program can be.", "p_text": "Learn how effective your texting program can be.",
"link": "/best-practices/benchmark-performance" "link": "/guides/best-practices/benchmark-performance"
} }
] %} ] %}

26
urls.js
View File

@@ -13,13 +13,25 @@ const sublinks = [
{ label: 'Roadmap', path: '/features/roadmap' }, { label: 'Roadmap', path: '/features/roadmap' },
{ label: 'Security', path: '/features/security' }, { label: 'Security', path: '/features/security' },
{ label: 'Support', path: '/support' }, { label: 'Support', path: '/support' },
{ label: 'Best Practices', path: '/best-practices' }, { label: 'Best Practices', path: '/guides/best-practices' },
{ label: 'Clear Goals', path: '/best-practices/clear-goals' }, { label: 'Clear Goals', path: '/guides/best-practices/clear-goals' },
{ label: 'Rules And Regulations', path: '/best-practices/rules-and-regulations' }, {
{ label: 'Establish Trust', path: '/best-practices/establish-trust' }, label: 'Rules And Regulations',
{ label: 'Write For Action', path: '/best-practices/write-for-action' }, path: '/guides/best-practices/rules-and-regulations',
{ label: 'Multiple Languages', path: '/best-practices/multiple-languages' }, },
{ label: 'Benchmark Performance', path: '/best-practices/benchmark-performance' }, { label: 'Establish Trust', path: '/guides/best-practices/establish-trust' },
{
label: 'Write For Action',
path: '/guides/best-practices/write-for-action',
},
{
label: 'Multiple Languages',
path: '/guides/best-practices/multiple-languages',
},
{
label: 'Benchmark Performance',
path: '/guides/best-practices/benchmark-performance',
},
// Add more links here as needed // Add more links here as needed
]; ];