diff --git a/app/assets/stylesheets/components/forms.css b/app/assets/stylesheets/components/forms.css index 6c68083..61c7b1e 100644 --- a/app/assets/stylesheets/components/forms.css +++ b/app/assets/stylesheets/components/forms.css @@ -1,6 +1,6 @@ @layer components { input[type=text], input[type=email], input[type=password], - input[type=number], select { + input[type=number], select, textarea { @apply mt-1 rounded-md bg-gray-100 focus:bg-white border-transparent focus:border-transparent focus:ring-2 focus:ring-blue-600 focus:ring-opacity-75; diff --git a/app/controllers/admin/settings/registrations_controller.rb b/app/controllers/admin/settings/registrations_controller.rb new file mode 100644 index 0000000..1abca45 --- /dev/null +++ b/app/controllers/admin/settings/registrations_controller.rb @@ -0,0 +1,9 @@ +class Admin::Settings::RegistrationsController < Admin::SettingsController + + def index + end + + def update + end + +end diff --git a/app/controllers/admin/settings/services_controller.rb b/app/controllers/admin/settings/services_controller.rb new file mode 100644 index 0000000..ebdad4e --- /dev/null +++ b/app/controllers/admin/settings/services_controller.rb @@ -0,0 +1,9 @@ +class Admin::Settings::ServicesController < Admin::SettingsController + + def index + end + + def update + end + +end diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb new file mode 100644 index 0000000..8353f9b --- /dev/null +++ b/app/controllers/admin/settings_controller.rb @@ -0,0 +1,12 @@ +class Admin::SettingsController < Admin::BaseController + before_action :set_current_section + + def index + end + + private + + def set_current_section + @current_section = :settings + end +end diff --git a/app/models/setting.rb b/app/models/setting.rb index 2a80940..16a8590 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -2,6 +2,16 @@ class Setting < RailsSettings::Base cache_prefix { "v1" } + field :reserved_usernames, type: :array, default: %w[ + account + accounts + admin + donations + mail + webmaster + support + ] + field :lndhub_enabled, default: (ENV["LNDHUB_API_URL"].present?.to_s || "false"), type: :boolean field :lndhub_admin_enabled, default: (ENV["LNDHUB_ADMIN_UI"] || "false"), type: :boolean end diff --git a/app/views/admin/settings/registrations/index.html.erb b/app/views/admin/settings/registrations/index.html.erb new file mode 100644 index 0000000..2a327e1 --- /dev/null +++ b/app/views/admin/settings/registrations/index.html.erb @@ -0,0 +1,31 @@ +<%= render HeaderComponent.new(title: "Settings") %> + +<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_settings') do %> + + Registrations + <%= form_for(Setting.new, url: admin_settings_services_path) do |f| %> + <% if @errors && @errors.any? %> + + + <% @errors.full_messages.each do |msg| %> + <%= msg %> + <% end %> + + + <% end %> + + + Reserved usernames + + These usernames cannot be registered as accounts: + + <%= f.text_area :reserved_usernames, + value: Setting.reserved_usernames.join("\n"), + class: "h-44 mb-2" %> + + One username per line + + + <% end %> + +<% end %> diff --git a/app/views/admin/settings/services/index.html.erb b/app/views/admin/settings/services/index.html.erb new file mode 100644 index 0000000..c0dad64 --- /dev/null +++ b/app/views/admin/settings/services/index.html.erb @@ -0,0 +1,39 @@ +<%= render HeaderComponent.new(title: "Settings") %> + +<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_settings') do %> + + Lightning Network + <%= form_for(Setting.new, url: admin_settings_services_path) do |f| %> + <% if @errors && @errors.any? %> + + + <% @errors.full_messages.each do |msg| %> + <%= msg %> + <% end %> + + + <% end %> + + + + + Enable LNDHub integration + LNDHub configuration present and wallet features enabled + + <%= f.check_box :lndhub_enabled, checked: Setting.lndhub_enabled?, + disabled: true, + class: "relative ml-4 inline-flex flex-shrink-0" %> + + + + Enable LNDHub admin panel + LNDHub database configuration present and admin panel enabled + + <%= f.check_box :lndhub_admin_enabled, checked: Setting.lndhub_admin_enabled?, + disabled: true, + class: "relative ml-4 inline-flex flex-shrink-0" %> + + + <% end %> + +<% end %> diff --git a/app/views/icons/_grid.html.erb b/app/views/icons/_grid.html.erb index 8ef2e9d..57f9632 100644 --- a/app/views/icons/_grid.html.erb +++ b/app/views/icons/_grid.html.erb @@ -1 +1 @@ - \ No newline at end of file + diff --git a/app/views/shared/_admin_nav.html.erb b/app/views/shared/_admin_nav.html.erb index dfba699..dd8c8b8 100644 --- a/app/views/shared/_admin_nav.html.erb +++ b/app/views/shared/_admin_nav.html.erb @@ -10,3 +10,5 @@ <%= link_to "Lightning", admin_lightning_path, class: main_nav_class(@current_section, :lightning) %> <% end %> +<%= link_to "Settings", admin_settings_registrations_path, + class: main_nav_class(@current_section, :settings) %> diff --git a/app/views/shared/_admin_sidenav_settings.html.erb b/app/views/shared/_admin_sidenav_settings.html.erb new file mode 100644 index 0000000..d675242 --- /dev/null +++ b/app/views/shared/_admin_sidenav_settings.html.erb @@ -0,0 +1,11 @@ +<%= render SidenavLinkComponent.new( + name: "Registrations", path: admin_settings_registrations_path, icon: "user", + active: current_page?(admin_settings_registrations_path) +) %> +<%= render SidenavLinkComponent.new( + name: "Services", path: admin_settings_services_path, icon: "grid", + active: current_page?(admin_settings_services_path) +) %> +<%= render SidenavLinkComponent.new( + name: "Security", path: "#", icon: "shield", disabled: true +) %> diff --git a/config/routes.rb b/config/routes.rb index 00475c5..eb118cf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,6 +43,11 @@ Rails.application.routes.draw do get 'invitations', to: 'invitations#index' resources :donations get 'lightning', to: 'lightning#index' + + namespace :settings do + resources 'registrations', only: ['index', 'update'] + resources 'services', only: ['index', 'update'] + end end authenticate :user, ->(user) { user.is_admin? } do
Reserved usernames
+ These usernames cannot be registered as accounts: +
+ One username per line +
LNDHub configuration present and wallet features enabled
LNDHub database configuration present and admin panel enabled