mirror of
https://github.com/we-promise/sure.git
synced 2026-04-16 18:44:13 +00:00
* Add support for dynamic config UI
* Add support for section description
* Better dynamic class settings
Added dynamic_fields hash field - Stores all undeclared settings
[] method - Checks declared fields first, then falls back to dynamic hash
[]= method - Updates declared fields normally, stores others in hash
No runtime field declaration - Fields are never dynamically created on the class
* FIX proper lookup for provider keys
- Also validate configurable values properly.
- Change Provider factory to use Rails autoloading (Zeitwerk)
* Fix factory
The derive_adapter_name method relies on string manipulation ("PlaidAccount".sub(/Account$/, "") + "Adapter" → "PlaidAdapter"), but we already have explicit registration in place.
* Make updates atomic, field-aware, and handle blanks explicitly
* Small UX detail
* Add support for PlaidEU in UI also
- This looks like partial support atm
84 lines
2.9 KiB
Plaintext
84 lines
2.9 KiB
Plaintext
<%
|
|
# Parameters:
|
|
# - configuration: Provider::Configurable::Configuration object
|
|
%>
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<% if configuration.provider_description.present? %>
|
|
<div class="text-sm text-secondary mb-4 prose prose-sm">
|
|
<%= markdown(configuration.provider_description).html_safe %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% env_configured = configuration.fields.any? { |f| f.env_key && ENV[f.env_key].present? } %>
|
|
<% if env_configured %>
|
|
<p class="text-sm text-secondary">
|
|
Configuration can be set via environment variables or overridden below.
|
|
</p>
|
|
<% end %>
|
|
|
|
<% if configuration.fields.any? { |f| f.description.present? } %>
|
|
<p class="text-secondary text-sm mb-4">Field descriptions:</p>
|
|
<ul class="text-sm text-secondary mb-4 list-disc ml-6 space-y-2">
|
|
<% configuration.fields.each do |field| %>
|
|
<% if field.description.present? %>
|
|
<li><strong><%= field.label %>:</strong> <%= field.description %></li>
|
|
<% end %>
|
|
<% end %>
|
|
</ul>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= styled_form_with model: Setting.new,
|
|
url: settings_providers_path,
|
|
method: :patch,
|
|
data: {
|
|
controller: "auto-submit-form",
|
|
"auto-submit-form-trigger-event-value": "blur"
|
|
} do |form| %>
|
|
<div class="space-y-4">
|
|
<% configuration.fields.each do |field| %>
|
|
<%
|
|
env_value = ENV[field.env_key] if field.env_key
|
|
# Use dynamic hash-style access - works without explicit field declaration
|
|
setting_value = Setting[field.setting_key]
|
|
|
|
# Show the setting value if it exists, otherwise show ENV value
|
|
# This allows users to see what they've overridden
|
|
current_value = setting_value.presence || env_value
|
|
|
|
# Mask secret values if they exist
|
|
display_value = if field.secret && current_value.present?
|
|
"********"
|
|
else
|
|
current_value
|
|
end
|
|
|
|
# Determine input type
|
|
input_type = field.secret ? "password" : "text"
|
|
|
|
# Don't disable fields - allow overriding ENV variables
|
|
disabled = false
|
|
%>
|
|
|
|
<%= form.text_field field.setting_key,
|
|
label: field.label,
|
|
type: input_type,
|
|
placeholder: field.default || (field.required ? "" : "Optional"),
|
|
value: display_value,
|
|
disabled: disabled,
|
|
data: { "auto-submit-form-target": "auto" } %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% # Show configuration status %>
|
|
<% if configuration.configured? %>
|
|
<div class="flex items-center gap-2 mt-4">
|
|
<div class="w-2 h-2 bg-green-500 rounded-full"></div>
|
|
<p class="text-sm text-secondary">Configured and ready to use</p>
|
|
</div>
|
|
<% end %>
|
|
</div>
|