{# F.X.fix #9 — capability-badge partial, HTMX-swappable. Rendered both (a) inline by manage.html on first page load and (b) as the response body of GET /api/sites/{id}/capabilities/badge when the Re-check button is clicked. Swapping this element with hx-swap= "outerHTML" avoids the full-page reload the legacy button triggered. F.X.fix-pass2 — wording corrected for WordPress: application passwords inherit ALL capabilities from the user account, so the "credential tier" framing is misleading. WP-specific branches reference the WP user's role instead. AI-provider availability is surfaced here too so removing a provider key gives visible feedback on Re-check. Required context: capability_probe — probe payload (with .fit, .granted, .reason, .ai_providers_configured, optionally .install_hint) site — site dict (for .plugin_type, .tool_scope) lang — "fa" | "en" companion_download_url — string, may be empty #} {% set fit_status = capability_probe.fit.status %} {% set is_wp = site.plugin_type == 'wordpress' %} {% set is_wc = site.plugin_type == 'woocommerce' %} {% set is_wp_like = is_wp or is_wc %} {% set ai_providers = capability_probe.ai_providers_configured or [] %} {% set ai_provider_missing = is_wp_like and (ai_providers | length == 0) %}
{% if fit_status == 'ok' %}
{% if lang == 'fa' %}✓ دسترسی credential برای سطح انتخاب‌شده کافی است{% else %}✓ Credential grants what this tier needs{% endif %}
{% if capability_probe.granted %}
{% if lang == 'fa' %}دسترسی‌های احراز شده:{% else %}Granted:{% endif %} {{ capability_probe.granted | join(', ') }}
{% endif %} {% elif fit_status == 'warning' %}
{% if is_wc %} {% if lang == 'fa' %} ⚠ سطح دسترسی Consumer Key ووکامرس برای سطح «{{ site.tool_scope }}» کافی نیست {% else %} ⚠ The WooCommerce REST API key permission is below the selected "{{ site.tool_scope }}" tier {% endif %} {% elif is_wp %} {% if lang == 'fa' %} ⚠ کاربر وردپرس این credential نقش لازم برای سطح «{{ site.tool_scope }}» را ندارد {% else %} ⚠ The WordPress user behind this application password lacks the role for the "{{ site.tool_scope }}" tier {% endif %} {% else %} {% if lang == 'fa' %} ⚠ credential ذخیره‌شده برای سطح «{{ site.tool_scope }}» کافی نیست {% else %} ⚠ Saved credential is below the selected "{{ site.tool_scope }}" tier {% endif %} {% endif %}
{% if lang == 'fa' %}دسترسی‌های ناموجود:{% else %}Missing:{% endif %} {{ capability_probe.fit.missing | join(', ') }}
{% if capability_probe.granted %}
{% if lang == 'fa' %}آنچه در دسترس است:{% else %}Currently granted:{% endif %} {{ capability_probe.granted | join(', ') }}
{% endif %}
{% if is_wc %} {% if lang == 'fa' %} کلید ووکامرس (Consumer Key + Secret) دارای فیلد permissions با مقادیر read یا read_write است. گزینه‌ها: (۱) سطح پایین‌تر انتخاب کنید؛ (۲) در WP Admin → WooCommerce → Settings → Advanced → REST API یک کلید جدید با Permission مناسب (Read / Write یا Read/Write) بسازید و در Connection Settings ذخیره کنید؛ (۳) ادامه — ابزارهای نیازمند این دسترسی هنگام فراخوانی ۴۰۳ می‌دهند. {% else %} WooCommerce REST API keys carry a permissions field (read / read_write). Options: (1) pick a lower access level; (2) regenerate the REST key with Read/Write permission in WP Admin → WooCommerce → Settings → Advanced → REST API and re-paste it in Connection Settings; (3) continue — tools needing missing caps will return 403 at call time. {% endif %} {% elif is_wp %} {% if lang == 'fa' %} application password در وردپرس همیشه تمام دسترسی‌های کاربر صاحب آن را می‌گیرد و قابل محدودکردن نیست. گزینه‌ها: (۱) سطح دسترسی پایین‌تری انتخاب کنید؛ (۲) application password را از کاربری با نقش بالاتر (مثلاً Administrator یا Editor) بسازید؛ (۳) ادامه — ابزارهای نیازمند این دسترسی هنگام فراخوانی ۴۰۳ می‌دهند. {% else %} WordPress application passwords inherit ALL capabilities of the user account and cannot be scoped down. Options: (1) pick a lower access level; (2) create the application password from a higher-role user (e.g. Administrator or Editor); (3) continue — tools needing missing caps will return 403 at call time. {% endif %} {% else %} {% if lang == 'fa' %} گزینه‌ها: (۱) انتخاب سطح پایین‌تر؛ (۲) استفاده از credential با دسترسی بالاتر؛ (۳) ادامه — ابزارهای نیازمند این دسترسی هنگام فراخوانی ۴۰۳ می‌دهند. {% else %} Options: (1) pick a lower tier; (2) use a higher-privileged credential; (3) continue — tools needing missing caps will return 403 at call time. {% endif %} {% endif %}
{% elif fit_status == 'probe_unavailable' %}
{% if lang == 'fa' %}ℹ امکان بررسی خودکار credential در این سایت وجود ندارد{% else %}ℹ Capability probe is unavailable for this site{% endif %}
{{ capability_probe.reason or 'probe_unavailable' }}
{% if site.plugin_type in ['wordpress', 'woocommerce'] and companion_download_url %}
{% if lang == 'fa' %} برای فعال‌سازی probe، افزونه Airano MCP Bridge را روی وردپرس نصب کنید. {% else %} Install the Airano MCP Bridge plugin on your WordPress to enable the probe. {% endif %}
{% endif %} {% elif fit_status == 'unknown_tier' %}
{% if lang == 'fa' %}ℹ probe برای این plugin + سطح پیاده‌سازی نشده{% else %}ℹ Probe not implemented for this plugin/tier combination{% endif %}
{% endif %} {# F.X.fix-pass2 — AI provider status line. Independent of the tier-fit state: even a perfectly-fit credential cannot run the AI image tool without an OpenRouter / OpenAI / … key. #} {% if ai_provider_missing %}
{% if lang == 'fa' %}⚠ هیچ کلید AI Provider تنظیم نشده{% else %}⚠ No AI provider key configured{% endif %} {% if lang == 'fa' %} — ابزار wordpress_generate_and_upload_image غیرفعال است. کلید را در بخش «تولید تصویر با هوش مصنوعی» بالا ذخیره کنید. {% else %} — wordpress_generate_and_upload_image is disabled. Add a key in the "AI Image Generation" section above. {% endif %}
{% elif is_wp_like and ai_providers %}
{% if lang == 'fa' %}کلیدهای AI Provider فعال:{% else %}Configured AI providers:{% endif %} {{ ai_providers | join(', ') }}
{% endif %}