diff --git a/CHANGELOG.md b/CHANGELOG.md index 420312d..87b4223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # CHANGELOG -## v3.1.1 (2021.12-13) -- Removes an incorrect type hint +## v3.1.2 (2022-05-21) +- Fixes breadcrumbs for report names by preserving case + +## v3.1.1 (2021-12-13) +- Removes an incorrect type hint ## v3.1.0 (2021-12-13) - Fixes metric aggregation by customer, service, and owner (#12) diff --git a/VERSION b/VERSION index 94ff29c..ef538c2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.1 +3.1.2 diff --git a/phablytics/__init__.py b/phablytics/__init__.py index 726691b..f71b21a 100644 --- a/phablytics/__init__.py +++ b/phablytics/__init__.py @@ -1 +1 @@ -__version__ = '3.1.1' +__version__ = '3.1.2' diff --git a/phablytics/web/constants.py b/phablytics/web/constants.py index a0ec7d5..8e2e1e4 100644 --- a/phablytics/web/constants.py +++ b/phablytics/web/constants.py @@ -26,8 +26,8 @@ # Breadcrumbs are automatically inflected based on the final phrase of a URL path. -# Overrides can be set based on paths in the BREADCRUMBS dict. -BREADCRUMBS = { +# Overrides can be set based on paths in the BREADCRUMB_OVERRIDES dict. +BREADCRUMB_OVERRIDES = { '/' : 'Home', '/explore': 'Explore', '/metrics': 'Metrics', diff --git a/phablytics/web/utils.py b/phablytics/web/utils.py index debda15..6e853af 100644 --- a/phablytics/web/utils.py +++ b/phablytics/web/utils.py @@ -1,5 +1,6 @@ # Python Standard Library Imports import copy +import re # Third Party (PyPI) Imports from flask import ( @@ -18,12 +19,15 @@ PHABRICATOR_INSTANCE_BASE_URL, ) from phablytics.web.constants import ( - BREADCRUMBS, + BREADCRUMB_OVERRIDES, NAV_LINKS, SITE_NAME, ) +REPORT_PATH_REGEX = re.compile(r'^/reports/[^/]+$') + + def custom_render_template(template_name, context_data=None): if context_data is None: context_data = {} @@ -79,6 +83,11 @@ def _format_nav_link(nav_link): return nav_links +def is_report_name_path(path): + result = REPORT_PATH_REGEX.match(path) is not None + return result + + def get_breadcrumbs(): breadcrumbs = [] @@ -91,8 +100,26 @@ def get_breadcrumbs(): for i, path_part in enumerate(path_parts): path = '/'.join(path_parts[:i + 1]) or '/' + path_suffix = '/'.join(path_parts[i + 1:]) is_active = i + 1 == len(path_parts) - name = BREADCRUMBS.get(path, path_part.title()) + + default_breadcrumb_name = ( + path_part + if ( + # leave alone if any conditions are satisfied + is_report_name_path(path) + ) + # else format breadcrumb as Titlecase + else path_part.title() + ) + + name = BREADCRUMB_OVERRIDES.get( + path, # get breadcrumb by full path + BREADCRUMB_OVERRIDES.get( + path_suffix, # get breadcrumb by path_suffix + default_breadcrumb_name # fallback: generated breadcrumb based on path + ) + ) breadcrumb = { 'name': name, 'url': path,