feat: add new view and controller to display app configs together (#3563)
fixes: #3578
This commit is contained in:
21
app/controllers/super_admin/app_configs_controller.rb
Normal file
21
app/controllers/super_admin/app_configs_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
|
||||
def show
|
||||
@allowed_configs = %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET]
|
||||
# ref: https://github.com/rubocop/rubocop/issues/7767
|
||||
# rubocop:disable Style/HashTransformValues
|
||||
@fb_config = InstallationConfig.where(name: @allowed_configs)
|
||||
.pluck(:name, :serialized_value)
|
||||
.map { |name, serialized_value| [name, serialized_value['value']] }
|
||||
.to_h
|
||||
# rubocop:enable Style/HashTransformValues
|
||||
end
|
||||
|
||||
def create
|
||||
params['app_config'].each do |key, value|
|
||||
i = InstallationConfig.where(name: key).first_or_create(value: value, locked: false)
|
||||
i.value = value
|
||||
i.save!
|
||||
end
|
||||
redirect_to super_admin_app_config_url
|
||||
end
|
||||
end
|
||||
25
app/views/super_admin/app_configs/show.html.erb
Normal file
25
app/views/super_admin/app_configs/show.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<% content_for(:title) do %>
|
||||
App Config
|
||||
<% 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 , method: :post do |form| %>
|
||||
<% @allowed_configs.each do |c| %>
|
||||
<div class="field-unit">
|
||||
<div class="field-unit__label">
|
||||
<%= form.label "app_config[#{c}]", c %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= form.text_field "app_config[#{c}]", value: @fb_config[c] %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-actions">
|
||||
<%= form.submit "Submit" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -32,8 +32,14 @@ as defined by the routes in the `admin/` namespace
|
||||
<i class="ion ion-ios-keypad"></i>
|
||||
<%= link_to "Dashboard", super_admin_root_url %>
|
||||
</li>
|
||||
|
||||
<li class="navigation__link">
|
||||
<i class="ion ion-android-settings"></i>
|
||||
<%= link_to "App Config", super_admin_app_config_url %>
|
||||
</li>
|
||||
|
||||
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
|
||||
<% next if ["account_users", "agent_bots", "dashboard", "devise/sessions"].include? resource.resource %>
|
||||
<% next if ["account_users", "agent_bots", "dashboard", "devise/sessions", "app_configs" ].include? resource.resource %>
|
||||
<li class="navigation__link navigation__link--<%= nav_link_state(resource) %>">
|
||||
<i class="<%= sidebar_icons[resource.resource.to_sym] %>"></i>
|
||||
<%= link_to(
|
||||
|
||||
Reference in New Issue
Block a user