{# Plugin Configuration Partial - Server-side rendered form #} {# This template is loaded via HTMX when a plugin tab is clicked #} {# ===== MACROS FOR FORM FIELD GENERATION ===== #} {# Render a single form field based on schema type #} {% macro render_field(key, prop, value, prefix='', plugin_id='') %} {% set full_key = (prefix ~ '.' ~ key) if prefix else key %} {% set field_id = (plugin_id ~ '-' ~ full_key)|replace('.', '-')|replace('_', '-') %} {% set label = prop.title if prop.title else key|replace('_', ' ')|title %} {% set description = prop.description if prop.description else '' %} {% set field_type = prop.type if prop.type is string else (prop.type[0] if prop.type is iterable else 'string') %} {# Handle nested objects recursively #} {% if field_type == 'object' and prop.properties %} {{ render_nested_section(key, prop, value, prefix, plugin_id) }} {% else %}
{% if description %}

{{ description }}

{% endif %} {# Boolean checkbox #} {% if field_type == 'boolean' %} {# Enum dropdown #} {% elif prop.enum %} {# Number input #} {% elif field_type in ['number', 'integer'] %} {# Array of strings (comma-separated) #} {% elif field_type == 'array' %} {% set array_value = value if value is not none else (prop.default if prop.default is defined else []) %}

Separate multiple values with commas

{# Text input (default) #} {% else %} {% endif %}
{% endif %} {% endmacro %} {# Render a nested/collapsible section for object types #} {% macro render_nested_section(key, prop, value, prefix='', plugin_id='') %} {% set full_key = (prefix ~ '.' ~ key) if prefix else key %} {% set section_id = (plugin_id ~ '-section-' ~ full_key)|replace('.', '-')|replace('_', '-') %} {% set label = prop.title if prop.title else key|replace('_', ' ')|title %} {% set description = prop.description if prop.description else '' %} {% set nested_value = value if value else {} %}
{% endmacro %} {# ===== MAIN TEMPLATE ===== #}

{{ plugin.name or plugin.id }}

{{ plugin.description or 'Plugin configuration' }}

{# Plugin Information Panel #}

Plugin Information

Name
{{ plugin.name or plugin.id }}
Author
{{ plugin.author or 'Unknown' }}
{% if plugin.version %}
Version
{{ plugin.version }}
{% endif %} {% if plugin.last_commit %}
Commit
{{ plugin.last_commit[:7] if plugin.last_commit|length > 7 else plugin.last_commit }} {% if plugin.branch %} ({{ plugin.branch }}) {% endif %}
{% endif %} {% if plugin.category %}
Category
{{ plugin.category }}
{% endif %} {% if plugin.tags %}
Tags
{% for tag in plugin.tags %} {{ tag }} {% endfor %}
{% endif %}
{# On-Demand Controls #}
On-Demand Controls
{% if not plugin.enabled %}

Enable this plugin before launching on-demand.

{% endif %}
{# Configuration Form Panel #}

Configuration

{% if schema and schema.properties %} {# Use property order if defined, otherwise use natural order #} {# Skip 'enabled' field - it's handled by the header toggle #} {% set property_order = schema['x-propertyOrder'] if 'x-propertyOrder' in schema else schema.properties.keys()|list %} {% for key in property_order %} {% if key in schema.properties and key != 'enabled' %} {% set prop = schema.properties[key] %} {% set value = config[key] if key in config else none %} {{ render_field(key, prop, value, '', plugin.id) }} {% endif %} {% endfor %} {% else %} {# No schema - render simple form from config #} {% if config %} {% for key, value in config.items() %} {% if key not in ['enabled'] %}
{% if value is sameas true or value is sameas false %} {% elif value is number %} {% else %} {% endif %}
{% endif %} {% endfor %} {% else %}

No configuration options available for this plugin.

{% endif %} {% endif %}
{# Web UI Actions (if any) #} {% if web_ui_actions %}

Plugin Actions

{% if web_ui_actions[0].section_description %}

{{ web_ui_actions[0].section_description }}

{% endif %}
{% for action in web_ui_actions %} {% set action_id = "action-" ~ action.id ~ "-" ~ loop.index0 %} {% set status_id = "action-status-" ~ action.id ~ "-" ~ loop.index0 %} {% set bg_color = action.color or 'blue' %} {% if bg_color == 'green' %} {% set bg_class = 'bg-green-50' %} {% set border_class = 'border-green-200' %} {% set text_class = 'text-green-900' %} {% set text_light_class = 'text-green-700' %} {% set btn_class = 'bg-green-600 hover:bg-green-700' %} {% elif bg_color == 'red' %} {% set bg_class = 'bg-red-50' %} {% set border_class = 'border-red-200' %} {% set text_class = 'text-red-900' %} {% set text_light_class = 'text-red-700' %} {% set btn_class = 'bg-red-600 hover:bg-red-700' %} {% elif bg_color == 'yellow' %} {% set bg_class = 'bg-yellow-50' %} {% set border_class = 'border-yellow-200' %} {% set text_class = 'text-yellow-900' %} {% set text_light_class = 'text-yellow-700' %} {% set btn_class = 'bg-yellow-600 hover:bg-yellow-700' %} {% elif bg_color == 'purple' %} {% set bg_class = 'bg-purple-50' %} {% set border_class = 'border-purple-200' %} {% set text_class = 'text-purple-900' %} {% set text_light_class = 'text-purple-700' %} {% set btn_class = 'bg-purple-600 hover:bg-purple-700' %} {% else %} {% set bg_class = 'bg-blue-50' %} {% set border_class = 'border-blue-200' %} {% set text_class = 'text-blue-900' %} {% set text_light_class = 'text-blue-700' %} {% set btn_class = 'bg-blue-600 hover:bg-blue-700' %} {% endif %}

{% if action.icon %}{% endif %}{{ action.title or action.id }}

{{ action.description or '' }}

{% endfor %}
{% endif %} {# Action Buttons #}