refactor: adress review
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4af80a8305
commit
942f2afd9e
8 changed files with 108 additions and 62 deletions
|
|
@ -54,11 +54,14 @@ defmodule MvWeb.GlobalSettingsLive do
|
|||
actor = MvWeb.LiveHelpers.current_actor(socket)
|
||||
custom_fields = load_custom_fields(actor)
|
||||
|
||||
environment = Application.get_env(:mv, :environment, :dev)
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> assign(:page_title, gettext("Settings"))
|
||||
|> assign(:settings, settings)
|
||||
|> assign(:locale, locale)
|
||||
|> assign(:environment, environment)
|
||||
|> assign(:vereinfacht_env_configured, Mv.Config.vereinfacht_env_configured?())
|
||||
|> assign(:vereinfacht_api_url_env_set, Mv.Config.vereinfacht_api_url_env_set?())
|
||||
|> assign(:vereinfacht_api_key_env_set, Mv.Config.vereinfacht_api_key_env_set?())
|
||||
|
|
@ -76,7 +79,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
|||
|> assign(:oidc_groups_claim_env_set, Mv.Config.oidc_groups_claim_env_set?())
|
||||
|> assign(:oidc_only_env_set, Mv.Config.oidc_only_env_set?())
|
||||
|> assign(:oidc_configured, Mv.Config.oidc_configured?())
|
||||
|> assign(:oidc_client_secret_set, present?(settings.oidc_client_secret))
|
||||
|> assign(:oidc_client_secret_set, Mv.Config.oidc_client_secret_set?())
|
||||
|> assign(:smtp_env_configured, Mv.Config.smtp_env_configured?())
|
||||
|> assign(:smtp_host_env_set, Mv.Config.smtp_host_env_set?())
|
||||
|> assign(:smtp_port_env_set, Mv.Config.smtp_port_env_set?())
|
||||
|
|
@ -274,7 +277,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
|||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= if Mix.env() == :prod and not @smtp_configured do %>
|
||||
<%= if @environment == :prod and not @smtp_configured do %>
|
||||
<div class="mb-4 flex items-start gap-2 p-3 rounded-lg border border-warning bg-warning/10 text-warning-aa text-sm">
|
||||
<.icon name="hero-exclamation-triangle" class="size-5 shrink-0 mt-0.5" />
|
||||
<span>
|
||||
|
|
@ -688,13 +691,10 @@ defmodule MvWeb.GlobalSettingsLive do
|
|||
assign(socket, form: AshPhoenix.Form.validate(socket.assigns.form, setting_params))}
|
||||
end
|
||||
|
||||
# phx-change can fire with only _target (e.g. when focusing a field); avoid FunctionClauseError
|
||||
def handle_event("validate", params, socket) when is_map(params) do
|
||||
setting_params =
|
||||
params["setting"] || Map.get(socket.assigns.form.params || %{}, "setting") || %{}
|
||||
|
||||
{:noreply,
|
||||
assign(socket, form: AshPhoenix.Form.validate(socket.assigns.form, setting_params))}
|
||||
# phx-change can fire without "setting" (e.g. only _target when focusing). Do not validate
|
||||
# with previous form params to avoid surprising behaviour; wait for the next event with setting data.
|
||||
def handle_event("validate", _params, socket) do
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
@ -777,7 +777,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
|||
socket
|
||||
|> assign(:settings, fresh_settings)
|
||||
|> assign(:vereinfacht_api_key_set, present?(fresh_settings.vereinfacht_api_key))
|
||||
|> assign(:oidc_client_secret_set, present?(fresh_settings.oidc_client_secret))
|
||||
|> assign(:oidc_client_secret_set, Mv.Config.oidc_client_secret_set?())
|
||||
|> assign(:oidc_configured, Mv.Config.oidc_configured?())
|
||||
|> assign(:smtp_configured, Mv.Config.smtp_configured?())
|
||||
|> assign(:smtp_password_set, present?(Mv.Config.smtp_password()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue