Merge pull request 'Allow editing and resetting of all admin setting strings' (#137) from feature/admin_settings into master
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			Reviewed-on: #137 Reviewed-by: greg <greg@noreply.kosmos.org>
This commit is contained in:
		
						commit
						83e3e2ecd8
					
				@ -1,4 +1,6 @@
 | 
				
			|||||||
<%= tag.public_send(@tag, class: "mb-6 last:mb-0") do %>
 | 
					<%= tag.public_send(@tag, class: "mb-6 last:mb-0", data: {
 | 
				
			||||||
 | 
					      :'field-name' => @field_name
 | 
				
			||||||
 | 
					    }) do %>
 | 
				
			||||||
  <% if @positioning == :vertical %>
 | 
					  <% if @positioning == :vertical %>
 | 
				
			||||||
  <label class="block">
 | 
					  <label class="block">
 | 
				
			||||||
    <p class="font-bold <%= @descripton.present? ? "mb-1" : "mb-2" %>">
 | 
					    <p class="font-bold <%= @descripton.present? ? "mb-1" : "mb-2" %>">
 | 
				
			||||||
@ -9,7 +11,21 @@
 | 
				
			|||||||
      <%= @descripton %>
 | 
					      <%= @descripton %>
 | 
				
			||||||
    </p>
 | 
					    </p>
 | 
				
			||||||
    <% end %>
 | 
					    <% end %>
 | 
				
			||||||
    <%= content %>
 | 
					
 | 
				
			||||||
 | 
					    <%= tag.p class: "flex gap-x-1", data: {
 | 
				
			||||||
 | 
					                controller: @resettable ? "settings--resettable-field" : nil,
 | 
				
			||||||
 | 
					              } do %>
 | 
				
			||||||
 | 
					      <%= content %>
 | 
				
			||||||
 | 
					      <% if @resettable %>
 | 
				
			||||||
 | 
					        <button type="button"
 | 
				
			||||||
 | 
					                class="relative grow-0 shrink-0 btn-md btn-outline text-red-700"
 | 
				
			||||||
 | 
					                title="Reset to default value"
 | 
				
			||||||
 | 
					                data-settings--resettable-field-target="resetButton"
 | 
				
			||||||
 | 
					                data-action="settings--resettable-field#resetField">
 | 
				
			||||||
 | 
					          Reset
 | 
				
			||||||
 | 
					        </button>
 | 
				
			||||||
 | 
					      <% end %>
 | 
				
			||||||
 | 
					    <% end %>
 | 
				
			||||||
  </label>
 | 
					  </label>
 | 
				
			||||||
  <% elsif @positioning == :horizontal %>
 | 
					  <% elsif @positioning == :horizontal %>
 | 
				
			||||||
  <label class="block flex items-center justify-between">
 | 
					  <label class="block flex items-center justify-between">
 | 
				
			||||||
 | 
				
			|||||||
@ -2,11 +2,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
module FormElements
 | 
					module FormElements
 | 
				
			||||||
  class FieldsetComponent < ViewComponent::Base
 | 
					  class FieldsetComponent < ViewComponent::Base
 | 
				
			||||||
    def initialize(tag: "li", positioning: :vertical, title:, description: nil)
 | 
					    def initialize(tag: "li", positioning: :vertical,
 | 
				
			||||||
 | 
					                   title:, description: nil,
 | 
				
			||||||
 | 
					                   field_name: nil, resettable: false)
 | 
				
			||||||
      @tag         = tag
 | 
					      @tag         = tag
 | 
				
			||||||
      @positioning = positioning
 | 
					      @positioning = positioning
 | 
				
			||||||
      @title       = title
 | 
					      @title       = title
 | 
				
			||||||
      @descripton  = description
 | 
					      @descripton  = description
 | 
				
			||||||
 | 
					      @field_name  = field_name
 | 
				
			||||||
 | 
					      @resettable  = resettable
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					<%= render FormElements::FieldsetComponent.new(
 | 
				
			||||||
 | 
					      title: @title,
 | 
				
			||||||
 | 
					      description: @description,
 | 
				
			||||||
 | 
					      field_name: "setting_#{@key.to_s}",
 | 
				
			||||||
 | 
					      resettable: @resettable
 | 
				
			||||||
 | 
					    ) do %>
 | 
				
			||||||
 | 
					  <%= method("#{@type}_field").call :setting, @key,
 | 
				
			||||||
 | 
					    value: Setting.public_send(@key),
 | 
				
			||||||
 | 
					    data: {
 | 
				
			||||||
 | 
					      :'default-value' => Setting.get_field(@key)[:default]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    class: "w-full" %>
 | 
				
			||||||
 | 
					<% end %>
 | 
				
			||||||
@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module FormElements
 | 
				
			||||||
 | 
					  class FieldsetResettableSettingComponent < ViewComponent::Base
 | 
				
			||||||
 | 
					    def initialize(tag: "li", key:, type: :text, title:, description: nil)
 | 
				
			||||||
 | 
					      @tag         = tag
 | 
				
			||||||
 | 
					      @positioning = :vertical
 | 
				
			||||||
 | 
					      @title       = title
 | 
				
			||||||
 | 
					      @descripton  = description
 | 
				
			||||||
 | 
					      @key         = key.to_sym
 | 
				
			||||||
 | 
					      @type        = type
 | 
				
			||||||
 | 
					      @resettable  = is_resettable?(@key)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def is_resettable?(key)
 | 
				
			||||||
 | 
					      default_value = Setting.get_field(key)[:default]
 | 
				
			||||||
 | 
					      default_value.present? && (default_value != Setting.send(key))
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					import { Controller } from "@hotwired/stimulus"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default class extends Controller {
 | 
				
			||||||
 | 
					  static targets = [ "resetButton" ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  resetField () {
 | 
				
			||||||
 | 
					    const inputEl = this.element.querySelector('input')
 | 
				
			||||||
 | 
					    inputEl.value = inputEl.dataset.defaultValue
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -29,6 +29,7 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  field :xmpp_default_rooms, type: :array, default: []
 | 
					  field :xmpp_default_rooms, type: :array, default: []
 | 
				
			||||||
  field :xmpp_autojoin_default_rooms, type: :boolean, default: false
 | 
					  field :xmpp_autojoin_default_rooms, type: :boolean, default: false
 | 
				
			||||||
 | 
					  field :xmpp_notifications_from_address, type: :string, default: primary_domain
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
  # Sentry
 | 
					  # Sentry
 | 
				
			||||||
@ -41,13 +42,13 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  # Discourse
 | 
					  # Discourse
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :discourse_public_url, type: :string, readonly: true,
 | 
					  field :discourse_public_url, type: :string,
 | 
				
			||||||
    default: ENV["DISCOURSE_PUBLIC_URL"].presence
 | 
					    default: ENV["DISCOURSE_PUBLIC_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :discourse_enabled, type: :boolean,
 | 
					  field :discourse_enabled, type: :boolean,
 | 
				
			||||||
    default: (ENV["DISCOURSE_PUBLIC_URL"].present?.to_s || false)
 | 
					    default: (ENV["DISCOURSE_PUBLIC_URL"].present?.to_s || false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :discourse_connect_secret, type: :string, readonly: true,
 | 
					  field :discourse_connect_secret, type: :string,
 | 
				
			||||||
    default: ENV["DISCOURSE_CONNECT_SECRET"].presence
 | 
					    default: ENV["DISCOURSE_CONNECT_SECRET"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
@ -57,10 +58,10 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  field :ejabberd_enabled, type: :boolean,
 | 
					  field :ejabberd_enabled, type: :boolean,
 | 
				
			||||||
    default: (ENV["EJABBERD_API_URL"].present?.to_s || false)
 | 
					    default: (ENV["EJABBERD_API_URL"].present?.to_s || false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :ejabberd_api_url, type: :string, readonly: true,
 | 
					  field :ejabberd_api_url, type: :string,
 | 
				
			||||||
    default: ENV["EJABBERD_API_URL"].presence
 | 
					    default: ENV["EJABBERD_API_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :ejabberd_admin_url, type: :string, readonly: true,
 | 
					  field :ejabberd_admin_url, type: :string,
 | 
				
			||||||
    default: ENV["EJABBERD_ADMIN_URL"].presence
 | 
					    default: ENV["EJABBERD_ADMIN_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :ejabberd_buddy_roster, type: :string,
 | 
					  field :ejabberd_buddy_roster, type: :string,
 | 
				
			||||||
@ -70,7 +71,7 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  # Gitea
 | 
					  # Gitea
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :gitea_public_url, type: :string, readonly: true,
 | 
					  field :gitea_public_url, type: :string,
 | 
				
			||||||
    default: ENV["GITEA_PUBLIC_URL"].presence
 | 
					    default: ENV["GITEA_PUBLIC_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :gitea_enabled, type: :boolean,
 | 
					  field :gitea_enabled, type: :boolean,
 | 
				
			||||||
@ -80,7 +81,7 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  # Lightning Network
 | 
					  # Lightning Network
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :lndhub_api_url, type: :string, readonly: true,
 | 
					  field :lndhub_api_url, type: :string,
 | 
				
			||||||
    default: ENV["LNDHUB_API_URL"].presence
 | 
					    default: ENV["LNDHUB_API_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :lndhub_enabled, type: :boolean,
 | 
					  field :lndhub_enabled, type: :boolean,
 | 
				
			||||||
@ -89,7 +90,7 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  field :lndhub_admin_enabled, type: :boolean,
 | 
					  field :lndhub_admin_enabled, type: :boolean,
 | 
				
			||||||
    default: (ENV["LNDHUB_ADMIN_UI"] || false)
 | 
					    default: (ENV["LNDHUB_ADMIN_UI"] || false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :lndhub_public_key, type: :string, readonly: true,
 | 
					  field :lndhub_public_key, type: :string,
 | 
				
			||||||
    default: (ENV["LNDHUB_PUBLIC_KEY"] || "")
 | 
					    default: (ENV["LNDHUB_PUBLIC_KEY"] || "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :lndhub_keysend_enabled, type: :boolean,
 | 
					  field :lndhub_keysend_enabled, type: :boolean,
 | 
				
			||||||
@ -99,7 +100,7 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  # Mastodon
 | 
					  # Mastodon
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :mastodon_public_url, type: :string, readonly: true,
 | 
					  field :mastodon_public_url, type: :string,
 | 
				
			||||||
    default: ENV["MASTODON_PUBLIC_URL"].presence
 | 
					    default: ENV["MASTODON_PUBLIC_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :mastodon_enabled, type: :boolean,
 | 
					  field :mastodon_enabled, type: :boolean,
 | 
				
			||||||
@ -109,7 +110,7 @@ class Setting < RailsSettings::Base
 | 
				
			|||||||
  # MediaWiki
 | 
					  # MediaWiki
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :mediawiki_public_url, type: :string, readonly: true,
 | 
					  field :mediawiki_public_url, type: :string,
 | 
				
			||||||
    default: ENV["MEDIAWIKI_PUBLIC_URL"].presence
 | 
					    default: ENV["MEDIAWIKI_PUBLIC_URL"].presence
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  field :mediawiki_enabled, type: :boolean,
 | 
					  field :mediawiki_enabled, type: :boolean,
 | 
				
			||||||
 | 
				
			|||||||
@ -8,16 +8,15 @@
 | 
				
			|||||||
    description: "Discourse configuration present and features enabled"
 | 
					    description: "Discourse configuration present and features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
<% if Setting.discourse_enabled? %>
 | 
					<% if Setting.discourse_enabled? %>
 | 
				
			||||||
  <%= render FormElements::FieldsetComponent.new(title: "Public URL") do %>
 | 
					  <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
    <%= f.text_field :discourse_public_url,
 | 
					        key: :discourse_public_url,
 | 
				
			||||||
      value: Setting.discourse_public_url,
 | 
					        title: "Public URL"
 | 
				
			||||||
      class: "w-full", disabled: true %>
 | 
					      ) %>
 | 
				
			||||||
  <% end %>
 | 
					  <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
  <%= render FormElements::FieldsetComponent.new(title: "Connect secret") do %>
 | 
					        key: :discourse_connect_secret,
 | 
				
			||||||
    <%= f.password_field :discourse_connect_secret,
 | 
					        type: :password,
 | 
				
			||||||
      value: Setting.discourse_connect_secret,
 | 
					        title: "Connect secret"
 | 
				
			||||||
      class: "w-full", disabled: true %>
 | 
					      ) %>
 | 
				
			||||||
  <% end %>
 | 
					 | 
				
			||||||
<% end %>
 | 
					<% end %>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
<% if Setting.discourse_enabled? %>
 | 
					<% if Setting.discourse_enabled? %>
 | 
				
			||||||
 | 
				
			|||||||
@ -8,16 +8,14 @@
 | 
				
			|||||||
    description: "ejabberd configuration present and features enabled"
 | 
					    description: "ejabberd configuration present and features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
<% if Setting.ejabberd_enabled? %>
 | 
					<% if Setting.ejabberd_enabled? %>
 | 
				
			||||||
  <%= render FormElements::FieldsetComponent.new(title: "API URL") do %>
 | 
					  <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
    <%= f.text_field :ejabberd_api_url,
 | 
					        key: :ejabberd_api_url,
 | 
				
			||||||
      value: Setting.ejabberd_api_url,
 | 
					        title: "API URL"
 | 
				
			||||||
      class: "w-full", disabled: true %>
 | 
					      ) %>
 | 
				
			||||||
  <% end %>
 | 
					  <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
  <%= render FormElements::FieldsetComponent.new(title: "Admin URL") do %>
 | 
					        key: :ejabberd_admin_url,
 | 
				
			||||||
    <%= f.text_field :ejabberd_admin_url,
 | 
					        title: "Admin URL"
 | 
				
			||||||
      value: Setting.ejabberd_admin_url,
 | 
					      ) %>
 | 
				
			||||||
      class: "w-full", disabled: true %>
 | 
					 | 
				
			||||||
  <% end %>
 | 
					 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
<h3 class="mt-10">User default settings</h3>
 | 
					<h3 class="mt-10">User default settings</h3>
 | 
				
			||||||
<ul role="list">
 | 
					<ul role="list">
 | 
				
			||||||
@ -37,12 +35,24 @@
 | 
				
			|||||||
    title: "Auto-join default rooms",
 | 
					    title: "Auto-join default rooms",
 | 
				
			||||||
    description: "Automatically join above default rooms in chat clients"
 | 
					    description: "Automatically join above default rooms in chat clients"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <%= render FormElements::FieldsetComponent.new(
 | 
					  <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
 | 
					        key: :ejabberd_buddy_roster,
 | 
				
			||||||
        title: "Contact roster name",
 | 
					        title: "Contact roster name",
 | 
				
			||||||
        description: "Used when exchanging contacts after signup from invitation"
 | 
					        description: "Used when exchanging contacts after signup from invitation"
 | 
				
			||||||
 | 
					      ) %>
 | 
				
			||||||
 | 
					</ul>
 | 
				
			||||||
 | 
					<h3 class="mt-10">Notifications</h3>
 | 
				
			||||||
 | 
					<ul role="list">
 | 
				
			||||||
 | 
					  <%= render FormElements::FieldsetComponent.new(
 | 
				
			||||||
 | 
					        title: "From address",
 | 
				
			||||||
 | 
					        description: "Address (JID) of the account notifications are sent from",
 | 
				
			||||||
 | 
					        resettable: Setting.get_field(:xmpp_notifications_from_address)[:default] != Setting.xmpp_notifications_from_address
 | 
				
			||||||
      ) do %>
 | 
					      ) do %>
 | 
				
			||||||
    <%= f.text_field :ejabberd_buddy_roster,
 | 
					    <%= f.text_field :xmpp_notifications_from_address,
 | 
				
			||||||
      value: Setting.ejabberd_buddy_roster,
 | 
					      value: Setting.xmpp_notifications_from_address,
 | 
				
			||||||
 | 
					      data: {
 | 
				
			||||||
 | 
					        :'default-value' => Setting.get_field(:xmpp_notifications_from_address)[:default]
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      class: "w-full" %>
 | 
					      class: "w-full" %>
 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
<% end %>
 | 
					<% end %>
 | 
				
			||||||
 | 
				
			|||||||
@ -8,10 +8,9 @@
 | 
				
			|||||||
    description: "Gitea configuration present and features enabled"
 | 
					    description: "Gitea configuration present and features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <% if Setting.gitea_enabled? %>
 | 
					  <% if Setting.gitea_enabled? %>
 | 
				
			||||||
    <%= render FormElements::FieldsetComponent.new(title: "Public URL") do %>
 | 
					    <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
      <%= f.text_field :gitea_public_url,
 | 
					          key: :gitea_public_url,
 | 
				
			||||||
        value: Setting.gitea_public_url,
 | 
					          title: "Public URL"
 | 
				
			||||||
        class: "w-full", disabled: true %>
 | 
					        ) %>
 | 
				
			||||||
    <% end %>
 | 
					 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 | 
				
			|||||||
@ -8,11 +8,10 @@
 | 
				
			|||||||
    description: "LNDHub configuration present and wallet features enabled"
 | 
					    description: "LNDHub configuration present and wallet features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <% if Setting.lndhub_enabled? %>
 | 
					  <% if Setting.lndhub_enabled? %>
 | 
				
			||||||
    <%= render FormElements::FieldsetComponent.new(title: "API URL") do %>
 | 
					    <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
      <%= f.text_field :lndhub_api_url,
 | 
					          key: :lndhub_api_url,
 | 
				
			||||||
        value: Setting.lndhub_api_url,
 | 
					          title: "API URL"
 | 
				
			||||||
        class: "w-full", disabled: true %>
 | 
					        ) %>
 | 
				
			||||||
    <% end %>
 | 
					 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
  <%= render FormElements::FieldsetToggleComponent.new(
 | 
					  <%= render FormElements::FieldsetToggleComponent.new(
 | 
				
			||||||
    form: f,
 | 
					    form: f,
 | 
				
			||||||
@ -29,10 +28,10 @@
 | 
				
			|||||||
    description: "Allow users to receive invoice-less payments to their Lightning Address"
 | 
					    description: "Allow users to receive invoice-less payments to their Lightning Address"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <% if Setting.lndhub_keysend_enabled? %>
 | 
					  <% if Setting.lndhub_keysend_enabled? %>
 | 
				
			||||||
    <%= render FormElements::FieldsetComponent.new(title: "Public key", description: "The public key of the Lightning node used by LNDHub") do %>
 | 
					    <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
      <%= f.text_field :lndhub_public_key,
 | 
					          key: :lndhub_public_key,
 | 
				
			||||||
        value: Setting.lndhub_public_key,
 | 
					          title: "Public key",
 | 
				
			||||||
        class: "w-full", disabled: true %>
 | 
					          description: "The public key of the Lightning node used by LNDHub"
 | 
				
			||||||
    <% end %>
 | 
					        ) %>
 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 | 
				
			|||||||
@ -8,10 +8,9 @@
 | 
				
			|||||||
    description: "Mastodon configuration present and features enabled"
 | 
					    description: "Mastodon configuration present and features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <% if Setting.mastodon_enabled? %>
 | 
					  <% if Setting.mastodon_enabled? %>
 | 
				
			||||||
    <%= render FormElements::FieldsetComponent.new(title: "Public URL") do %>
 | 
					    <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
      <%= f.text_field :mastodon_public_url,
 | 
					          key: :mastodon_public_url,
 | 
				
			||||||
        value: Setting.mastodon_public_url,
 | 
					          title: "Public URL"
 | 
				
			||||||
        class: "w-full", disabled: true %>
 | 
					        ) %>
 | 
				
			||||||
    <% end %>
 | 
					 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 | 
				
			|||||||
@ -8,10 +8,9 @@
 | 
				
			|||||||
    description: "MediaWiki configuration present and features enabled"
 | 
					    description: "MediaWiki configuration present and features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <% if Setting.mediawiki_enabled? %>
 | 
					  <% if Setting.mediawiki_enabled? %>
 | 
				
			||||||
    <%= render FormElements::FieldsetComponent.new(title: "Public URL") do %>
 | 
					    <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
      <%= f.text_field :mediawiki_public_url,
 | 
					          key: :mediawiki_public_url,
 | 
				
			||||||
        value: Setting.mediawiki_public_url,
 | 
					          title: "Public URL"
 | 
				
			||||||
        class: "w-full", disabled: true %>
 | 
					        ) %>
 | 
				
			||||||
    <% end %>
 | 
					 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
<h3>RemoteStorage</h3>
 | 
					<h3>RemoteStorage</h3>
 | 
				
			||||||
 | 
					<p class="text-red-600 mb-8">Feature currently in development.</p>
 | 
				
			||||||
<ul role="list">
 | 
					<ul role="list">
 | 
				
			||||||
  <%= render FormElements::FieldsetToggleComponent.new(
 | 
					  <%= render FormElements::FieldsetToggleComponent.new(
 | 
				
			||||||
    form: f,
 | 
					    form: f,
 | 
				
			||||||
@ -8,10 +9,9 @@
 | 
				
			|||||||
    description: "RemoteStorage configuration present and features enabled"
 | 
					    description: "RemoteStorage configuration present and features enabled"
 | 
				
			||||||
  ) %>
 | 
					  ) %>
 | 
				
			||||||
  <% if Setting.remotestorage_enabled? %>
 | 
					  <% if Setting.remotestorage_enabled? %>
 | 
				
			||||||
    <%= render FormElements::FieldsetComponent.new(title: "Storage URL") do %>
 | 
					    <%= render FormElements::FieldsetResettableSettingComponent.new(
 | 
				
			||||||
      <%= f.text_field :rs_storage_url,
 | 
					          key: :rs_storage_url,
 | 
				
			||||||
        value: Setting.rs_storage_url,
 | 
					          title: "Storage URL"
 | 
				
			||||||
        class: "w-full", disabled: true %>
 | 
					        ) %>
 | 
				
			||||||
    <% end %>
 | 
					 | 
				
			||||||
  <% end %>
 | 
					  <% end %>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 | 
				
			|||||||
@ -26,16 +26,14 @@ RSpec.describe 'Admin/global settings', type: :feature do
 | 
				
			|||||||
      expect(current_url).to eq(admin_settings_services_url(params: { s: "discourse" }))
 | 
					      expect(current_url).to eq(admin_settings_services_url(params: { s: "discourse" }))
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    scenario "View ejabberd settings" do
 | 
					    scenario "View service settings" do
 | 
				
			||||||
      visit admin_settings_services_path(params: { s: "ejabberd" })
 | 
					      visit admin_settings_services_path(params: { s: "ejabberd" })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      expect(page).to have_content("Enable ejabberd integration")
 | 
					      expect(page).to have_content("Enable ejabberd integration")
 | 
				
			||||||
      expect(page).to have_field("API URL",
 | 
					      expect(page).to have_field("API URL", with: "http://xmpp.example.com/api")
 | 
				
			||||||
        with: "http://xmpp.example.com/api",
 | 
					 | 
				
			||||||
        disabled: true)
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    scenario "Disable ejabberd integration" do
 | 
					    scenario "Disable a service integration" do
 | 
				
			||||||
      visit admin_settings_services_path(params: { s: "ejabberd" })
 | 
					      visit admin_settings_services_path(params: { s: "ejabberd" })
 | 
				
			||||||
      expect(page).to have_checked_field("setting[ejabberd_enabled]")
 | 
					      expect(page).to have_checked_field("setting[ejabberd_enabled]")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -47,25 +45,15 @@ RSpec.describe 'Admin/global settings', type: :feature do
 | 
				
			|||||||
      expect(page).to_not have_field("API URL", disabled: true)
 | 
					      expect(page).to_not have_field("API URL", disabled: true)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    scenario "View remoteStorage settings" do
 | 
					    scenario "Resettable fields" do
 | 
				
			||||||
      visit admin_settings_services_path(params: { s: "remotestorage" })
 | 
					      visit admin_settings_services_path(params: { s: "ejabberd" })
 | 
				
			||||||
 | 
					      expect(page).to have_field("API URL", with: "http://xmpp.example.com/api")
 | 
				
			||||||
 | 
					      expect(page).to_not have_css('input#setting_ejabberd_api_url+button')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      expect(page).to have_content("Enable RemoteStorage integration")
 | 
					      Setting.ejabberd_api_url = "http://example.com/foo"
 | 
				
			||||||
      expect(page).to have_field("Storage URL",
 | 
					      visit admin_settings_services_path(params: { s: "ejabberd" })
 | 
				
			||||||
        with: "https://storage.kosmos.org",
 | 
					      expect(page).to have_field("API URL", with: "http://example.com/foo")
 | 
				
			||||||
        disabled: true)
 | 
					      expect(page).to have_css('input#setting_ejabberd_api_url+button')
 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    scenario "Disable remoteStorage integration" do
 | 
					 | 
				
			||||||
      visit admin_settings_services_path(params: { s: "remotestorage" })
 | 
					 | 
				
			||||||
      expect(page).to have_checked_field("setting[remotestorage_enabled]")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      uncheck "setting[remotestorage_enabled]"
 | 
					 | 
				
			||||||
      click_button "Save"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      expect(current_url).to eq(admin_settings_services_url(params: { s: "remotestorage" }))
 | 
					 | 
				
			||||||
      expect(page).to_not have_checked_field("setting[remotestorage_enabled]")
 | 
					 | 
				
			||||||
      expect(page).to_not have_field("Storage URL", disabled: true)
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user