chatwoot/chatwoot

View on GitHub
app/views/super_admin/app_configs/show.html.erb

Summary

Maintainability
Test Coverage
<% content_for(:title) do %>
  Configure Settings - <%= @config.titleize %>
<% end %>
<header class="main-content__header" role="banner">
  <h1 class="main-content__page-title" id="page-title">
    <%= content_for(:title) %>
  </h1>
</header>
<section class="main-content__body">
  <%= form_with url: super_admin_app_config_url(config: @config) , method: :post do |form| %>
    <% @allowed_configs.each do |key| %>
      <div class="flex mb-8">
        <div class="field-unit__label">
          <%= form.label "app_config[#{key}]", @installation_configs[key]&.dig('display_title') || key %>
        </div>
        <div class="-mt-2 field-unit__field ">
          <% if @installation_configs[key]&.dig('type') == 'boolean' %>
            <%= form.select "app_config[#{key}]", 
              [["True", true], ["False", false]], 
              { selected: ActiveModel::Type::Boolean.new.cast(@app_config[key]) },
              class: "mt-2 border border-slate-100 p-1 rounded-md" 
            %>
          <% elsif @installation_configs[key]&.dig('type') == 'code' %>
            <%= form.text_area "app_config[#{key}]", 
                value: @app_config[key], 
                rows: 12,
                wrap: 'off',
                class: "mt-2 border font-mono text-xs border-slate-100 p-1 rounded-md overflow-scroll"
            %>
          <% else %>
            <%= form.text_field "app_config[#{key}]", value: @app_config[key] %>
          <% end %>
          <%if @installation_configs[key]&.dig('description').present? %>
            <p class="pt-2 text-xs italic text-slate-400">
              <%= @installation_configs[key]&.dig('description') %>
            </p>
          <% end %>
        </div>
      </div>
    <% end %>
    <div class="form-actions">
      <%= form.submit "Submit" %>
    </div>
  <% end %>
</section>