{# Navigation macros for the dashboard #} {# Render tier badge based on tier name #} {% macro tier_badge(tier) %} {% if tier %} {{ tier }} {% endif %} {% endmacro %} {# Check if a feature is available for the current tier #} {% macro is_feature_available(feature, current_tier) %} {# Define feature availability by tier #} {% set feature_tiers = { 'basic_sync': ['free', 'starter', 'professional', 'enterprise'], 'schedules': ['starter', 'professional', 'enterprise'], 'favorites': ['starter', 'professional', 'enterprise'], 'api_keys': ['professional', 'enterprise'], 'webhooks': ['professional', 'enterprise'], 'multi_user': ['professional', 'enterprise'], 'sla_monitoring': ['enterprise'], 'audit_logs': ['enterprise'], } %} {% set available_tiers = feature_tiers.get(feature, []) %} {{ current_tier|lower in available_tiers }} {% endmacro %} {# Main navigation component with dropdown menus #} {% macro main_nav(current_path, current_user=None) %} {% set tier = current_user.tier|default('free') if current_user else 'free' %} {% endmacro %} {# Simplified navigation for error/minimal pages #} {% macro minimal_nav() %} {% endmacro %} {# Breadcrumb navigation - enhanced version with home icon and accessibility #} {% macro breadcrumb(items) %} {# Renders breadcrumb navigation. Args: items: List of dicts with 'label' and optional 'url' keys Example: [{'label': 'Configs', 'url': '/configs'}, {'label': 'Edit Sales'}] #} {% endmacro %} {# Legacy alias for backward compatibility #} {% macro breadcrumbs(items) %} {{ breadcrumb(items) }} {% endmacro %} {# Feature upgrade notice #} {% macro upgrade_notice(feature, required_tier) %}
{{ feature }} is available on the {{ required_tier }} plan and above.
Upgrade
{% endmacro %} {# Tier usage bar for dashboard #} {% macro tier_usage_bar(usage, limits, tier) %}
Configs: {% set config_pct = (usage.configs / limits.max_configs * 100) if limits.max_configs > 0 else 0 %} {{ usage.configs }}/{{ limits.max_configs }}
Syncs today: {% set sync_pct = (usage.syncs_today / limits.daily_syncs * 100) if limits.daily_syncs > 0 else 0 %} {{ usage.syncs_today }}/{{ limits.daily_syncs }}
{% if tier|lower == 'free' %}
Upgrade {% endif %}
{% endmacro %} {# Sidebar navigation with collapsible sections - Phase 5 Navigation #} {% macro sidebar_nav(current_path, current_user=None, super_admin_enabled=False) %} {# Renders a sidebar navigation with logical groupings and collapsible admin section. Args: current_path: Current request path for highlighting active items current_user: Current user object (optional, for role-based visibility) super_admin_enabled: Whether super admin features are enabled (from env) #} {% set tier = current_user.tier|default('free') if current_user else 'free' %} {% set role = current_user.role|default('viewer') if current_user else 'viewer' %} {% endmacro %}