diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c8032c..c17ea39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.2.0] - 2026-05-08 +## [Unreleased] ### Changed -- **Clickable table row highlights** – The new hover/focus-visible row highlight behavior is now the CoreComponents default across clickable tables. Sticky-first-column tables keep zebra striping and show selection through the sticky-column accent stripe (checkboxes keep their default style). -- **Members overview scrolling** – The members table scrollbar now scrolls inside the table container instead of moving with the full page. - **Join request display and settings workflow** – Improved join request rendering and related settings behavior in one cohesive update: - Join request fields now respect their configured field types in the details view. - Custom field labels in join request views were standardized. @@ -19,10 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - **Runtime ENV handling** – Empty or invalid environment variables (e.g. `SMTP_PORT=`, `PORT=`, `POOL_SIZE=`, `DATABASE_PORT=`) no longer cause `ArgumentError` at boot. Instead raises clear errors for required vars set but empty (e.g. DATABASE_HOST, PHX_HOST/DOMAIN, SECRET_KEY_BASE). - **PostgreSQL 18 Docker volume path** – Corrected the database volume path to match PostgreSQL 18 expectations. -- **Association name ENV handling** – `ASSOCIATION_NAME` is now treated as source of truth; the field is read-only in Global Settings when managed via ENV. -- **Association name consistency after updates** – Layout now prefers explicitly assigned `club_name` values to avoid stale cached values right after settings changes. -- **SMTP ENV/UI source selection** – SMTP now follows a strict single-source policy: ENV-only when `SMTP_HOST` is set, otherwise Settings-only. -- **SMTP settings UI in ENV mode** – SMTP fields are read-only, save action is hidden, and missing required ENV keys are shown as a warning. ### Dependency updates - Mix dependencies were updated. diff --git a/CODE_GUIDELINES.md b/CODE_GUIDELINES.md index 2b378ef..0d478f9 100644 --- a/CODE_GUIDELINES.md +++ b/CODE_GUIDELINES.md @@ -1277,8 +1277,7 @@ mix hex.outdated **SMTP configuration:** -- SMTP can be configured via **ENV variables** (`SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_PASSWORD_FILE`, `SMTP_SSL`) or via **Admin Settings** (database: `smtp_host`, `smtp_port`, `smtp_username`, `smtp_password`, `smtp_ssl`). -- **ENV-only policy:** If `SMTP_HOST` is set, SMTP is treated as environment-managed only. All SMTP fields in Settings are read-only, SMTP save action is hidden, and the UI shows a warning when required ENV values are missing (`SMTP_USERNAME`, and `SMTP_PASSWORD` or `SMTP_PASSWORD_FILE`). This keeps one source of truth for transport credentials and avoids mixed ENV/DB SMTP states. +- SMTP can be configured via **ENV variables** (`SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_PASSWORD_FILE`, `SMTP_SSL`) or via **Admin Settings** (database: `smtp_host`, `smtp_port`, `smtp_username`, `smtp_password`, `smtp_ssl`). ENV takes priority (same pattern as OIDC/Vereinfacht). - **Sensitive settings in DB:** `smtp_password` and `oidc_client_secret` are excluded from the default read of the Setting resource; they are loaded only via explicit select when needed (e.g. `Mv.Config.smtp_password/0`, `Mv.Config.oidc_client_secret/0`). This avoids exposing secrets through `get_settings()`. - **Settings cache:** `Mv.Membership.get_settings/0` uses `Mv.Membership.SettingsCache` when the cache process is running (not in test). Cache has a short TTL and is invalidated on every settings update. This avoids repeated DB reads on hot paths (e.g. `RegistrationEnabled` validation, `Layouts.public_page`). In test, the cache is not started so all callers use `get_settings_uncached/0` in the test process (Ecto Sandbox). - **Join emails (domain → web):** The domain calls `Mv.Membership.JoinNotifier` (config `:join_notifier`, default `MvWeb.JoinNotifierImpl`) for sending join confirmation, already-member, and already-pending emails. This keeps the domain independent of the web layer; tests can override the notifier. diff --git a/DESIGN_GUIDELINES.md b/DESIGN_GUIDELINES.md index 34c71b8..0ad562e 100644 --- a/DESIGN_GUIDELINES.md +++ b/DESIGN_GUIDELINES.md @@ -247,13 +247,11 @@ If these cannot be met, use `secondary`/`outline` instead of `ghost`. ### 8.1 Default behavior: row click opens details - **DEFAULT:** Clicking a row navigates to the details page. - **EXCEPTIONS:** Highly interactive rows may disable row-click (document why). -- **Row highlight (CoreComponents):** When `row_click` is set, rows use a neutral background highlight on `hover` and `tr:has(:focus-visible)` (see `assets/css/app.css`), so keyboard focus is visible while mouse-only focus does not appear "stuck". For non-sticky tables, `selected_row_id` can still add a stronger selected ring. For sticky-first-column tables, selection emphasis is handled by the sticky-column accent stripe. +- **Row outline (CoreComponents):** When `row_click` is set, rows get a subtle hover and focus-within ring (theme-friendly). Use `selected_row_id` to show a stronger selected outline (e.g. from URL `?highlight=id` or last selection); the Back link from detail can use `?highlight=id` so the row is visually selected when returning to the index. **IMPORTANT (correctness with our `<.table>` CoreComponent):** Our table implementation attaches the `phx-click` to the **``** when `row_click` is set. That means click events bubble from inner elements up to the cell unless we stop propagation. -**LiveStream rows:** Do not enumerate `@rows` with `Enum.with_index` in the table template; streams must be consumed only through `:for`. Sticky-first-column zebra striping for those tables is handled in CSS (`nth-child` under `data-sticky-first-col-rows`), not by assigning odd/even classes from an index. - So, for interactive elements inside a clickable row, you must **stop propagation using `Phoenix.LiveView.JS.stop_propagation/1`**, not a custom attribute. ✅ Correct pattern (one click handler that both stops propagation and triggers an event): diff --git a/assets/css/app.css b/assets/css/app.css index 611e9ad..d7f873c 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -708,68 +708,3 @@ background-color: transparent !important; color: inherit; } - -/* - * Default interactive table rows: neutral hover/focus-visible fill for clickable rows. - * Uses :has(:focus-visible) so keyboard navigation highlights the row without sticky mouse-focus artifacts. - */ -.table.table-zebra tbody tr[data-row-interactive="true"]:is(:hover, :has(:focus-visible)) > td { - background-color: var(--color-base-300); -} - -/* - * Sticky first column in zebra tables: opaque backgrounds per row. - * Use nth-child (not HEEx row index) so LiveStream rows stay iterable only via :for (Phoenix LV requirement). - */ -[data-sticky-first-col-rows="true"] .table.table-zebra tbody tr:nth-child(odd) > td.sticky-first-col-cell { - background-color: var(--color-base-100); -} - -[data-sticky-first-col-rows="true"] .table.table-zebra tbody tr:nth-child(even) > td.sticky-first-col-cell { - background-color: var(--color-base-200); -} - -/* - * Checkbox-selected rows: keep zebra backgrounds; only accent the sticky checkbox column. - */ -[data-sticky-first-col-rows="true"] - .table.table-zebra - tbody - tr[data-selected="true"] - > td.sticky-first-col-cell { - box-shadow: inset 2px 0 0 var(--color-primary); -} - -[data-sticky-first-col-rows="true"] - .table.table-zebra - tbody - tr[data-row-interactive="true"]:is(:hover, :has(:focus-visible)) - > td.sticky-first-col-cell { - background-color: var(--color-base-300); - /* Left accent only; keep the familiar orange primary accent. */ - box-shadow: inset 2px 0 0 var(--color-primary); -} - -/* - * Sticky member selection table: drop mouse-only focus outlines that read like a thin frame around the row; - * keyboard :focus-visible keeps DaisyUI control outlines (checkbox / tabindex cell). - */ -[data-sticky-first-col-rows="true"] .table.table-zebra tbody tr { - outline: none; -} - -[data-sticky-first-col-rows="true"] - .table.table-zebra - tbody - tr[data-row-interactive="true"]:is(:hover, :has(:focus-visible)):not(:last-child) { - /* DaisyUI draws a bottom border on each row; hiding it while highlighted avoids a boxy “frame”. */ - border-bottom-color: transparent; -} - -[data-sticky-first-col-rows="true"] .table.table-zebra tbody tr td:focus:not(:focus-visible) { - outline: none; -} - -[data-sticky-first-col-rows="true"] .table.table-zebra tbody tr input.checkbox:focus:not(:focus-visible) { - outline: none; -} diff --git a/docs/database-schema-readme.md b/docs/database-schema-readme.md index fa6ea55..f58cbea 100644 --- a/docs/database-schema-readme.md +++ b/docs/database-schema-readme.md @@ -188,6 +188,7 @@ Settings (1) → MembershipFeeType (0..1) ### Member Constraints - First name and last name required (min 1 char) - Email unique, validated format (5-254 chars) +- Join date cannot be in future - Exit date must be after join date - Phone: `+?[0-9\- ]{6,20}` - Postal code: optional (no format validation) diff --git a/docs/database_schema.dbml b/docs/database_schema.dbml index 16c9723..61da063 100644 --- a/docs/database_schema.dbml +++ b/docs/database_schema.dbml @@ -124,7 +124,7 @@ Table members { first_name text [null, note: 'Member first name (min length: 1 if present)'] last_name text [null, note: 'Member last name (min length: 1 if present)'] email text [not null, unique, note: 'Member email address (5-254 chars, validated)'] - join_date date [null, note: 'Date when member joined club'] + join_date date [null, note: 'Date when member joined club (cannot be in future)'] exit_date date [null, note: 'Date when member left club (must be after join_date)'] notes text [null, note: 'Additional notes about member'] city text [null, note: 'City of residence'] @@ -187,6 +187,7 @@ Table members { **Validation Rules:** - first_name, last_name: optional, but if present min 1 character - email: 5-254 characters, valid email format (required) + - join_date: cannot be in future - exit_date: must be after join_date (if both present) - postal_code: optional (no format validation) - country: optional diff --git a/docs/smtp-configuration-concept.md b/docs/smtp-configuration-concept.md index b19f6e4..4ae7760 100644 --- a/docs/smtp-configuration-concept.md +++ b/docs/smtp-configuration-concept.md @@ -25,11 +25,7 @@ Enable configurable SMTP for sending transactional emails (join confirmation, us | ENV | 1 | Production, Docker, 12-factor | | Settings | 2 | Admin UI, dev without ENV | -When `SMTP_HOST` is set, SMTP runs in **ENV-only mode**: -- all SMTP fields in Settings are read-only, -- saving SMTP settings in the UI is disabled, -- and the UI shows a warning block if required SMTP ENV values are missing. -- the UI displays the effective ENV-driven SMTP values in disabled fields so admins can verify what is active. +When an ENV variable is set, the corresponding Settings field is read-only in the UI (with hint "Set by environment"). --- @@ -67,14 +63,6 @@ Support **SMTP_PASSWORD_FILE** (path to file containing the password), same patt - Show a warning in the Settings UI. - Delivery attempts silently fall back to the Local adapter (no crash). -### 6.1 Behaviour in ENV-only mode (`SMTP_HOST` set) - -- The SMTP source of truth is environment variables only. -- The UI does not allow editing SMTP fields in this mode. -- The Settings page shows a warning block when required values are missing: - - `SMTP_USERNAME` - - `SMTP_PASSWORD` or `SMTP_PASSWORD_FILE` - --- ## 7. Test Email (Settings UI) diff --git a/lib/membership/member.ex b/lib/membership/member.ex index 85f5562..4e85fa8 100644 --- a/lib/membership/member.ex +++ b/lib/membership/member.ex @@ -22,7 +22,7 @@ defmodule Mv.Membership.Member do ## Validations - Required: email (all other fields are optional) - Email format validation (using EctoCommons.EmailValidator) - - Date validations: exit_date after join_date + - Date validations: join_date not in future, exit_date after join_date - Email uniqueness: prevents conflicts with unlinked users - Linked member email change: only admins or the linked user may change a linked member's email (see `Mv.Membership.Member.Validations.EmailChangePermission`) @@ -473,6 +473,11 @@ defmodule Mv.Membership.Member do end end + # Join date not in future + validate compare(:join_date, less_than_or_equal_to: &Date.utc_today/0), + where: [present(:join_date)], + message: "cannot be in the future" + # Exit date not before join date validate compare(:exit_date, greater_than: :join_date), where: [present([:join_date, :exit_date])], diff --git a/lib/mv/config.ex b/lib/mv/config.ex index 870d1d3..3494937 100644 --- a/lib/mv/config.ex +++ b/lib/mv/config.ex @@ -470,77 +470,56 @@ defmodule Mv.Config do # --------------------------------------------------------------------------- @doc """ - Returns SMTP host. - - Policy: - - ENV-only mode (`SMTP_HOST` set): read from ENV `SMTP_HOST` - - Settings mode: read from Settings only + Returns SMTP host. ENV `SMTP_HOST` overrides Settings. """ @spec smtp_host() :: String.t() | nil def smtp_host do - if smtp_env_mode?() do - System.get_env("SMTP_HOST") |> trim_nil() - else - get_from_settings(:smtp_host) - end + smtp_env_or_setting("SMTP_HOST", :smtp_host) end @doc """ - Returns SMTP port as integer. - - Policy: - - ENV-only mode (`SMTP_HOST` set): read from ENV `SMTP_PORT` - - Settings mode: read from Settings only + Returns SMTP port as integer. ENV `SMTP_PORT` (parsed) overrides Settings. + Returns nil when neither ENV nor Settings provide a valid port. """ @spec smtp_port() :: non_neg_integer() | nil def smtp_port do - if smtp_env_mode?() do - parse_smtp_port_env(System.get_env("SMTP_PORT")) - else - get_from_settings_integer(:smtp_port) + case System.get_env("SMTP_PORT") do + nil -> + get_from_settings_integer(:smtp_port) + + value when is_binary(value) -> + case Integer.parse(String.trim(value)) do + {port, _} when port > 0 -> port + _ -> nil + end end end @doc """ - Returns SMTP username. - - Policy: - - ENV-only mode (`SMTP_HOST` set): read from ENV `SMTP_USERNAME` - - Settings mode: read from Settings only + Returns SMTP username. ENV `SMTP_USERNAME` overrides Settings. """ @spec smtp_username() :: String.t() | nil def smtp_username do - if smtp_env_mode?() do - System.get_env("SMTP_USERNAME") |> trim_nil() - else - get_from_settings(:smtp_username) - end + smtp_env_or_setting("SMTP_USERNAME", :smtp_username) end @doc """ Returns SMTP password. - Policy: - - ENV-only mode (`SMTP_HOST` set): `SMTP_PASSWORD` > `SMTP_PASSWORD_FILE` - - Settings mode: read from Settings only - + Priority: `SMTP_PASSWORD` ENV > `SMTP_PASSWORD_FILE` (file contents) > Settings. Strips trailing whitespace/newlines from file contents. """ @spec smtp_password() :: String.t() | nil def smtp_password do - if smtp_env_mode?() do - case System.get_env("SMTP_PASSWORD") do - nil -> smtp_password_from_file() - value -> trim_nil(value) - end - else - get_smtp_password_from_settings() + case System.get_env("SMTP_PASSWORD") do + nil -> smtp_password_from_file_or_settings() + value -> trim_nil(value) end end - defp smtp_password_from_file do + defp smtp_password_from_file_or_settings do case System.get_env("SMTP_PASSWORD_FILE") do - nil -> nil + nil -> get_smtp_password_from_settings() path -> read_smtp_password_file(path) end end @@ -554,18 +533,11 @@ defmodule Mv.Config do @doc """ Returns SMTP TLS/SSL mode string (e.g. 'tls', 'ssl', 'none'). - - Policy: - - ENV-only mode (`SMTP_HOST` set): read from ENV `SMTP_SSL` - - Settings mode: read from Settings only + ENV `SMTP_SSL` overrides Settings. """ @spec smtp_ssl() :: String.t() | nil def smtp_ssl do - if smtp_env_mode?() do - System.get_env("SMTP_SSL") |> trim_nil() - else - get_from_settings(:smtp_ssl) - end + smtp_env_or_setting("SMTP_SSL", :smtp_ssl) end @doc """ @@ -577,32 +549,12 @@ defmodule Mv.Config do end @doc """ - Returns true when SMTP is managed by environment variables. - - Policy: if `SMTP_HOST` is set, SMTP is treated as ENV-only. + Returns true when any SMTP ENV variable is set (used in Settings UI for hints). """ - @spec smtp_env_mode?() :: boolean() - def smtp_env_mode? do - smtp_host_env_set?() - end - - @doc """ - Returns missing required SMTP ENV keys for ENV-only mode warnings. - - Required in ENV-only mode: - - `SMTP_USERNAME` - - one of `SMTP_PASSWORD` or `SMTP_PASSWORD_FILE` - """ - @spec smtp_missing_required_env_keys() :: [String.t()] - def smtp_missing_required_env_keys do - if smtp_env_mode?() do - [] - |> maybe_add_missing("SMTP_USERNAME", smtp_username_env_set?()) - |> maybe_add_missing("SMTP_PASSWORD/SMTP_PASSWORD_FILE", smtp_password_env_set?()) - |> Enum.reverse() - else - [] - end + @spec smtp_env_configured?() :: boolean() + def smtp_env_configured? do + smtp_host_env_set?() or smtp_port_env_set?() or smtp_username_env_set?() or + smtp_password_env_set?() or smtp_ssl_env_set?() end @doc "Returns true if SMTP_HOST ENV is set." @@ -666,18 +618,14 @@ defmodule Mv.Config do @spec mail_from_email_env_set?() :: boolean() def mail_from_email_env_set?, do: env_set?("MAIL_FROM_EMAIL") - defp parse_smtp_port_env(value) when is_binary(value) do - case Integer.parse(String.trim(value)) do - {port, _} when port > 0 -> port - _ -> nil + # Reads a plain string SMTP setting: ENV first, then Settings. + defp smtp_env_or_setting(env_key, setting_key) do + case System.get_env(env_key) do + nil -> get_from_settings(setting_key) + value -> trim_nil(value) end end - defp parse_smtp_port_env(_), do: nil - - defp maybe_add_missing(acc, _label, true), do: acc - defp maybe_add_missing(acc, label, false), do: [label | acc] - # Reads an integer setting attribute from Settings. defp get_from_settings_integer(key) do case Mv.Membership.get_settings() do diff --git a/lib/mv_web/components/core_components.ex b/lib/mv_web/components/core_components.ex index 465d41a..b5bd763 100644 --- a/lib/mv_web/components/core_components.ex +++ b/lib/mv_web/components/core_components.ex @@ -938,16 +938,6 @@ defmodule MvWeb.CoreComponents do doc: "when true, thead th get lg:sticky lg:top-0 bg-base-100 z-10 for use inside a scroll container on desktop" - attr :wrapper_overflow_class, :string, - default: "overflow-x-auto", - doc: - "overflow class for the table wrapper; set to overflow-visible when outer container owns scrolling" - - attr :sticky_first_col, :boolean, - default: false, - doc: - "when true, first header/body column gets sticky left positioning to keep selection controls visible" - slot :col, required: true do attr :label, :string attr :class, :string @@ -984,19 +974,15 @@ defmodule MvWeb.CoreComponents do ~H"""
@@ -1046,13 +1026,6 @@ defmodule MvWeb.CoreComponents do has_click = col[:col_click] || @row_click classes = ["max-w-xs"] - classes = - if @sticky_first_col && col_idx == 0 do - ["sticky-first-col-cell sticky left-0 z-20" | classes] - else - classes - end - classes = if col_class == nil || (col_class && !String.contains?(col_class, "text-center")) do ["truncate" | classes] @@ -1067,7 +1040,7 @@ defmodule MvWeb.CoreComponents do classes end - # WCAG: no focus ring on the cell itself; sticky zebra rows show keyboard focus via CSS :has(:focus-visible) + # WCAG: no focus ring on the cell itself; row shows focus via focus-within classes = if @row_click && @first_row_click_col_idx == col_idx do [ @@ -1138,11 +1111,30 @@ defmodule MvWeb.CoreComponents do end end - # Returns CSS classes for table row selection styles. - # Hover/focus row highlighting is CSS-driven via [data-row-interactive] selectors in app.css. - # Sticky-first-column zebra tables use CSS accents and omit selected row ring classes. - defp table_row_tr_class(true, false), do: "ring-2 ring-inset ring-primary" - defp table_row_tr_class(_, _), do: "" + # Returns CSS classes for table row: hover/focus-within outline when row_click is set, + # and stronger selected outline when selected (WCAG: not color-only). + # Hover/focus-within are omitted for the selected row so the selected ring stays visible. + defp table_row_tr_class(row_click, selected?) do + has_row_click? = not is_nil(row_click) + base = [] + + base = + if has_row_click? and not selected?, + do: + base ++ + [ + "hover:ring-2", + "hover:ring-inset", + "hover:ring-base-content/10", + "focus-within:ring-2", + "focus-within:ring-inset", + "focus-within:ring-base-content/10" + ], + else: base + + base = if selected?, do: base ++ ["ring-2", "ring-inset", "ring-primary"], else: base + Enum.join(base, " ") + end defp table_th_aria_sort(col, sort_field, sort_order) do col_sort = Map.get(col, :sort_field) diff --git a/lib/mv_web/live/global_settings_live.ex b/lib/mv_web/live/global_settings_live.ex index 6a1c926..43851db 100644 --- a/lib/mv_web/live/global_settings_live.ex +++ b/lib/mv_web/live/global_settings_live.ex @@ -85,8 +85,14 @@ defmodule MvWeb.GlobalSettingsLive do |> assign(:oidc_configured, Mv.Config.oidc_configured?()) |> assign(:oidc_client_secret_set, Mv.Config.oidc_client_secret_set?()) |> assign(:registration_enabled, settings.registration_enabled != false) - |> assign(:smtp_env_mode, Mv.Config.smtp_env_mode?()) - |> assign(:smtp_missing_required_env_keys, Mv.Config.smtp_missing_required_env_keys()) + |> 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?()) + |> assign(:smtp_username_env_set, Mv.Config.smtp_username_env_set?()) + |> assign(:smtp_password_env_set, Mv.Config.smtp_password_env_set?()) + |> assign(:smtp_ssl_env_set, Mv.Config.smtp_ssl_env_set?()) + |> assign(:smtp_from_name_env_set, Mv.Config.mail_from_name_env_set?()) + |> assign(:smtp_from_email_env_set, Mv.Config.mail_from_email_env_set?()) |> assign(:smtp_password_set, present?(Mv.Config.smtp_password())) |> assign(:smtp_configured, Mv.Config.smtp_configured?()) |> assign(:smtp_test_result, nil) @@ -315,25 +321,12 @@ defmodule MvWeb.GlobalSettingsLive do <%!-- SMTP / E-Mail Section --%> <.form_section title={gettext("SMTP / E-Mail")}> - <%= if @smtp_env_mode do %> + <%= if @smtp_env_configured do %>

- {gettext( - "SMTP is fully managed via environment variables. All SMTP fields are read-only." - )} + {gettext("Some values are set via environment variables. Those fields are read-only.")}

<% end %> - <%= if @smtp_env_mode and @smtp_missing_required_env_keys != [] do %> -
- <.icon name="hero-exclamation-triangle" class="size-5 shrink-0 mt-0.5" /> - - {gettext("SMTP environment configuration appears incomplete. Missing: %{keys}", - keys: Enum.join(@smtp_missing_required_env_keys, ", ") - )} - -
- <% end %> - <%= if @environment == :prod and not @smtp_configured do %>
<.icon name="hero-exclamation-triangle" class="size-5 shrink-0 mt-0.5" /> @@ -352,26 +345,32 @@ defmodule MvWeb.GlobalSettingsLive do field={@form[:smtp_host]} type="text" label={gettext("Host")} - disabled={@smtp_env_mode} - placeholder="smtp.example.com" + disabled={@smtp_host_env_set} + placeholder={ + if(@smtp_host_env_set, + do: gettext("From SMTP_HOST"), + else: "smtp.example.com" + ) + } /> <.input field={@form[:smtp_port]} type="number" label={gettext("Port")} - disabled={@smtp_env_mode} - placeholder="587" + disabled={@smtp_port_env_set} + placeholder={if(@smtp_port_env_set, do: gettext("From SMTP_PORT"), else: "587")} /> <.input field={@form[:smtp_ssl]} type="select" label={gettext("TLS/SSL")} - disabled={@smtp_env_mode} + disabled={@smtp_ssl_env_set} options={[ {gettext("TLS (port 587, recommended)"), "tls"}, {gettext("SSL (port 465)"), "ssl"}, {gettext("None (port 25, insecure)"), "none"} ]} + placeholder={if(@smtp_ssl_env_set, do: gettext("From SMTP_SSL"), else: nil)} />
@@ -380,20 +379,28 @@ defmodule MvWeb.GlobalSettingsLive do field={@form[:smtp_username]} type="text" label={gettext("Username")} - disabled={@smtp_env_mode} - placeholder="user@example.com" + disabled={@smtp_username_env_set} + placeholder={ + if(@smtp_username_env_set, + do: gettext("From SMTP_USERNAME"), + else: "user@example.com" + ) + } /> <.input field={@form[:smtp_password]} type="password" label={gettext("Password")} - disabled={@smtp_env_mode} + disabled={@smtp_password_env_set} placeholder={ - if @smtp_env_mode do - gettext("From SMTP_PASSWORD") - else - if @smtp_password_set, do: gettext("Leave blank to keep current"), else: nil - end + if(@smtp_password_env_set, + do: gettext("From SMTP_PASSWORD"), + else: + if(@smtp_password_set, + do: gettext("Leave blank to keep current"), + else: nil + ) + ) } /> @@ -403,15 +410,22 @@ defmodule MvWeb.GlobalSettingsLive do field={@form[:smtp_from_email]} type="email" label={gettext("Sender email (From)")} - disabled={@smtp_env_mode} - placeholder="noreply@example.com" + disabled={@smtp_from_email_env_set} + placeholder={ + if(@smtp_from_email_env_set, + do: gettext("From MAIL_FROM_EMAIL"), + else: "noreply@example.com" + ) + } /> <.input field={@form[:smtp_from_name]} type="text" label={gettext("Sender name (From)")} - disabled={@smtp_env_mode} - placeholder="Mila" + disabled={@smtp_from_name_env_set} + placeholder={ + if(@smtp_from_name_env_set, do: gettext("From MAIL_FROM_NAME"), else: "Mila") + } /> @@ -421,7 +435,11 @@ defmodule MvWeb.GlobalSettingsLive do )}

<.button - :if={not @smtp_env_mode} + :if={ + not (@smtp_host_env_set and @smtp_port_env_set and @smtp_username_env_set and + @smtp_password_env_set and @smtp_ssl_env_set and @smtp_from_email_env_set and + @smtp_from_name_env_set) + } phx-disable-with={gettext("Saving...")} variant="primary" class="mt-2" @@ -907,9 +925,9 @@ defmodule MvWeb.GlobalSettingsLive do |> assign(:oidc_only, Mv.Config.oidc_only?()) |> assign(:oidc_configured, Mv.Config.oidc_configured?()) |> assign(:smtp_configured, Mv.Config.smtp_configured?()) - |> assign(:smtp_env_mode, Mv.Config.smtp_env_mode?()) - |> assign(:smtp_missing_required_env_keys, Mv.Config.smtp_missing_required_env_keys()) |> assign(:smtp_password_set, present?(Mv.Config.smtp_password())) + |> assign(:smtp_from_name_env_set, Mv.Config.mail_from_name_env_set?()) + |> assign(:smtp_from_email_env_set, Mv.Config.mail_from_email_env_set?()) |> assign(:vereinfacht_test_result, test_result) |> put_flash(:success, gettext("Settings updated successfully")) |> assign_form() @@ -1249,17 +1267,25 @@ defmodule MvWeb.GlobalSettingsLive do end defp merge_smtp_env_values(s) do - if Mv.Config.smtp_env_mode?() do - s - |> Map.put(:smtp_host, Mv.Config.smtp_host()) - |> Map.put(:smtp_port, Mv.Config.smtp_port()) - |> Map.put(:smtp_username, Mv.Config.smtp_username()) - |> Map.put(:smtp_ssl, Mv.Config.smtp_ssl()) - |> Map.put(:smtp_from_email, Mv.Config.mail_from_email()) - |> Map.put(:smtp_from_name, Mv.Config.mail_from_name()) - else - s - end + s + |> put_if_env_set(:smtp_host, Mv.Config.smtp_host_env_set?(), Mv.Config.smtp_host()) + |> put_if_env_set(:smtp_port, Mv.Config.smtp_port_env_set?(), Mv.Config.smtp_port()) + |> put_if_env_set( + :smtp_username, + Mv.Config.smtp_username_env_set?(), + Mv.Config.smtp_username() + ) + |> put_if_env_set(:smtp_ssl, Mv.Config.smtp_ssl_env_set?(), Mv.Config.smtp_ssl()) + |> put_if_env_set( + :smtp_from_email, + Mv.Config.mail_from_email_env_set?(), + Mv.Config.mail_from_email() + ) + |> put_if_env_set( + :smtp_from_name, + Mv.Config.mail_from_name_env_set?(), + Mv.Config.mail_from_name() + ) end defp enrich_sync_errors([]), do: [] diff --git a/lib/mv_web/live/member_live/index.html.heex b/lib/mv_web/live/member_live/index.html.heex index efc1eb7..4d86a62 100644 --- a/lib/mv_web/live/member_live/index.html.heex +++ b/lib/mv_web/live/member_live/index.html.heex @@ -105,9 +105,7 @@ <.table id="members" rows={@members} - wrapper_overflow_class="overflow-visible" sticky_header={true} - sticky_first_col={true} row_id={fn member -> "row-#{member.id}" end} row_click={fn member -> JS.push("select_row_and_navigate", value: %{id: member.id}) end} row_tooltip={gettext("Click for member details")} diff --git a/mix.lock b/mix.lock index 212ea44..41d49b8 100644 --- a/mix.lock +++ b/mix.lock @@ -16,13 +16,13 @@ "cinder": {:hex, :cinder, "0.13.0", "5ed447df76ee1da7a61fbb5c1069b2baa5a46972e499acc9c971c6deab8a68e1", [:mix], [{:ash, "~> 3.0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_phoenix, "~> 2.3", [hex: :ash_phoenix, repo: "hexpm", optional: false]}, {:gettext, "~> 1.0.0", [hex: :gettext, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "82f902eeb41bcbb084b34b7ba9add1c7eabed1d06eccb856d1e83977954abe93"}, "circular_buffer": {:hex, :circular_buffer, "1.0.0", "25c004da0cba7bd8bc1bdabded4f9a902d095e20600fd15faf1f2ffbaea18a07", [:mix], [], "hexpm", "c829ec31c13c7bafd1f546677263dff5bfb006e929f25635878ac3cfba8749e5"}, "comeonin": {:hex, :comeonin, "5.5.1", "5113e5f3800799787de08a6e0db307133850e635d34e9fab23c70b6501669510", [:mix], [], "hexpm", "65aac8f19938145377cee73973f192c5645873dcf550a8a6b18187d17c13ccdb"}, - "cowboy": {:hex, :cowboy, "2.15.0", "9cfe86ed7117bf045e10adbedb0170af7be57f2a3637e7be143433d8dd267396", [], [{:cowlib, ">= 2.16.0 and < 3.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, ">= 1.8.0 and < 3.0.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "179fb65140fb440a17b767ad53b755081506f9596c4db5c49c0396d8c8643668"}, + "cowboy": {:hex, :cowboy, "2.14.2", "4008be1df6ade45e4f2a4e9e2d22b36d0b5aba4e20b0a0d7049e28d124e34847", [:make, :rebar3], [{:cowlib, ">= 2.16.0 and < 3.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, ">= 1.8.0 and < 3.0.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "569081da046e7b41b5df36aa359be71a0c8874e5b9cff6f747073fc57baf1ab9"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, - "cowlib": {:hex, :cowlib, "2.16.1", "318d385d55f657e9a5005838c4e426e13dcd724a691438384b6165a69687e531", [], [], "hexpm", "58f1e425a9e04176f1d30e20116f57c4e90ef0e187552e9741c465bdf4044f70"}, + "cowlib": {:hex, :cowlib, "2.16.0", "54592074ebbbb92ee4746c8a8846e5605052f29309d3a873468d76cdf932076f", [:make, :rebar3], [], "hexpm", "7f478d80d66b747344f0ea7708c187645cfcc08b11aa424632f78e25bf05db51"}, "credo": {:hex, :credo, "1.7.18", "5c5596bf7aedf9c8c227f13272ac499fe8eae6237bd326f2f07dfc173786f042", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a189d164685fd945809e862fe76a7420c4398fa288d76257662aecb909d6b3e5"}, "crux": {:hex, :crux, "0.1.2", "4441c9e3a34f1e340954ce96b9ad5a2de13ceb4f97b3f910211227bb92e2ca90", [:mix], [{:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: true]}], "hexpm", "563ea3748ebfba9cc078e6d198a1d6a06015a8fae503f0b721363139f0ddb350"}, "db_connection": {:hex, :db_connection, "2.10.0", "8ff756471e41765bd5563b633f73e9a94bbc138816e8644bb17d0d91bf260a95", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02cdd01b45efb1b550e68edbbea41be32de9b24bb07e1ea0e9cbc522ac377e54"}, - "decimal": {:hex, :decimal, "3.1.0", "9ede268cff827e6f0c4fb1b34747c82630dce5d7b877dfb22ec8f0cb25855fce", [:mix], [], "hexpm", "e8b3efb3bb3a13cb5e4268ffe128569067b1972e9dee013537c71a5b073168f9"}, + "decimal": {:hex, :decimal, "3.0.0", "ce2befbd7218427e4a57d1c6efa6bf50cfc7d0c480c422e70f4fb533074a5f33", [], [], "hexpm", "7a6ab3f806f09738991fc951b2fd2390b3377113feec605a540121aaf772a87b"}, "dns_cluster": {:hex, :dns_cluster, "0.2.0", "aa8eb46e3bd0326bd67b84790c561733b25c5ba2fe3c7e36f28e88f384ebcb33", [:mix], [], "hexpm", "ba6f1893411c69c01b9e8e8f772062535a4cf70f3f35bcc964a324078d8c8240"}, "ecto": {:hex, :ecto, "3.13.6", "352135b474f91d1ab99a1b502171d207e9db60421c9e3d0ecab4c7ab96b24d14", [:mix], [{:decimal, "~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "8afa059bc16cd2c94739ec0a11e3e5df69d828125119109bef35f20a21a76af2"}, "ecto_commons": {:hex, :ecto_commons, "0.3.7", "f33c162a6f63695d5939af02c65a0e76aa6e7278b82c7bfc357ffbfea353bf0f", [:mix], [{:burnex, "~> 3.0", [hex: :burnex, repo: "hexpm", optional: true]}, {:ecto, "~> 3.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:ex_phone_number, "~> 0.4", [hex: :ex_phone_number, repo: "hexpm", optional: false]}, {:luhn, "~> 0.3.0", [hex: :luhn, repo: "hexpm", optional: false]}], "hexpm", "9c33771ebd38cd83d3f90fab6069826ba9d4f7580f1481b3c0913f8b9795c5fd"}, @@ -30,11 +30,10 @@ "elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"}, "esbuild": {:hex, :esbuild, "0.10.0", "b0aa3388a1c23e727c5a3e7427c932d89ee791746b0081bbe56103e9ef3d291f", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "468489cda427b974a7cc9f03ace55368a83e1a7be12fba7e30969af78e5f8c70"}, "ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"}, - "ex_ast": {:hex, :ex_ast, "0.11.2", "8a0330e7b2bc664b52d7b60b8d5faa2628cd6e02fe80f89e726ff20328411dbf", [:mix], [{:sourceror, "~> 1.7", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "df343260bd443306ca5da232615f1534a4aa740960055a4699e493fad8b4bd66"}, "ex_phone_number": {:hex, :ex_phone_number, "0.4.10", "11809f6600b2ecb0a2e75d496c2ec2f273d49d1e2f58b2be2667decb0aabfb43", [:mix], [{:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: false]}], "hexpm", "eefccf58d8149d64af658721bff0edcb9e9b8943f74000ede151948ef03046c1"}, "expo": {:hex, :expo, "1.1.1", "4202e1d2ca6e2b3b63e02f69cfe0a404f77702b041d02b58597c00992b601db5", [:mix], [], "hexpm", "5fb308b9cb359ae200b7e23d37c76978673aa1b06e2b3075d814ce12c5811640"}, "file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"}, - "finch": {:hex, :finch, "0.22.0", "5c48fa6f9706a78eb9036cacb67b8b996b4e66d111c543f4c29bb0f879a6806b", [], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.8", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b94e83c47780fc6813f746a1f1a34ee65cda42da4c5ea26a68f0acc4498e23dc"}, + "finch": {:hex, :finch, "0.21.0", "b1c3b2d48af02d0c66d2a9ebfb5622be5c5ecd62937cf79a88a7f98d48a8290c", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "87dc6e169794cb2570f75841a19da99cfde834249568f2a5b121b809588a4377"}, "fine": {:hex, :fine, "0.1.6", "4bf7151493443c454aac9f2fa2f34f5fefd0346a83fb5586a016c4a135c63247", [:mix], [], "hexpm", "5638eb4495488e885ebec167fa57973e5c35e1a50c344eb7666c90ec1c4e3b12"}, "gen_smtp": {:hex, :gen_smtp, "1.3.0", "62c3d91f0dcf6ce9db71bcb6881d7ad0d1d834c7f38c13fa8e952f4104a8442e", [:rebar3], [{:ranch, ">= 1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "0b73fbf069864ecbce02fe653b16d3f35fd889d0fdd4e14527675565c39d84e6"}, "gettext": {:hex, :gettext, "1.0.2", "5457e1fd3f4abe47b0e13ff85086aabae760497a3497909b8473e0acee57673b", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "eab805501886802071ad290714515c8c4a17196ea76e5afc9d06ca85fb1bfeb3"}, @@ -43,7 +42,7 @@ "heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "0435d4ca364a608cc75e2f8683d374e55abbae26", [tag: "v2.2.0", sparse: "optimized", depth: 1]}, "hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, - "igniter": {:hex, :igniter, "0.8.0", "c7cab589440e5f20ff68e00f60eb094378114dab3105c0784ce8140f8dfdd2c0", [:mix], [{:ex_ast, "~> 0.5", [hex: :ex_ast, repo: "hexpm", optional: false]}, {:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:phx_new, "~> 1.7", [hex: :phx_new, repo: "hexpm", optional: true]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:rewrite, ">= 1.1.1 and < 2.0.0-0", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "fcd99096fde4797f7b48bebddcfc58785569acd696346a3eb385bf813f47a7cc"}, + "igniter": {:hex, :igniter, "0.7.9", "8c573440b8127fd80be8220fb197e7422317a81072054fcc0b336029f035a416", [:mix], [{:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:phx_new, "~> 1.7", [hex: :phx_new, repo: "hexpm", optional: true]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:rewrite, ">= 1.1.1 and < 2.0.0-0", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "123513d09f3af149db851aad8492b5b49f861d2c466a72031b2a0cbd9f45526f"}, "imprintor": {:hex, :imprintor, "0.6.0", "c6dfeb3c47d15cfb7e8491cf0a40548b3b9e37d0fc33940ca6dd283d36c4bada", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:rustler, ">= 0.0.0", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.8", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "9c26b0e665c0ab183860e77c450e0b0a4e390249e8322328dbe1be70d0fbca36"}, "iterex": {:hex, :iterex, "0.1.2", "58f9b9b9a22a55cbfc7b5234a9c9c63eaac26d276b3db80936c0e1c60355a5a6", [:mix], [], "hexpm", "2e103b8bcc81757a9af121f6dc0df312c9a17220f302b1193ef720460d03029d"}, "jason": {:hex, :jason, "1.4.5", "2e3a008590b0b8d7388c20293e9dcc9cf3e5d642fd2a114e4cbbb52e595d940a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b0c823996102bcd0239b3c2444eb00409b72f6a140c1950bc8b457d836b30684"}, @@ -54,7 +53,7 @@ "live_debugger": {:hex, :live_debugger, "1.0.0", "0bbcbdcb3b40b6862b6dfbb76579e7832e2787fee643031e5958f597def6fb32", [:mix], [{:file_system, "~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:igniter, ">= 0.5.40 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_live_view, ">= 1.1.7 and < 2.0.0-0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "b80f5d9db874d3270eb534738a10982b2b4ce55d58f94544e43b4a36111585fc"}, "luhn": {:hex, :luhn, "0.3.3", "5aa0c6a32c2db4b9db9f9b883ba8301c1ae169d57199b9e6cb1ba2707bc51d96", [:mix], [], "hexpm", "3e823a913a25aab51352c727f135278d22954874d5f0835be81ed4fec3daf78d"}, "mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"}, - "mint": {:hex, :mint, "1.8.0", "b964eaf4416f2dee2ba88968d52239fca5621b0402b9c95f55a08eb9d74803e9", [], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "f3c572c11355eccf00f22275e9b42463bc17bd28db13be1e28f8e0bb4adbc849"}, + "mint": {:hex, :mint, "1.7.1", "113fdb2b2f3b59e47c7955971854641c61f378549d73e829e1768de90fc1abf1", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "fceba0a4d0f24301ddee3024ae116df1c3f4bb7a563a731f45fdfeb9d39a231b"}, "mix_audit": {:hex, :mix_audit, "2.1.5", "c0f77cee6b4ef9d97e37772359a187a166c7a1e0e08b50edf5bf6959dfe5a016", [:make, :mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.11", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "87f9298e21da32f697af535475860dc1d3617a010e0b418d2ec6142bc8b42d69"}, "nimble_csv": {:hex, :nimble_csv, "1.3.0", "b7f998dc62b222bce9596e46f028c7a5af04cb5dde6df2ea197c583227c54971", [:mix], [], "hexpm", "41ccdc18f7c8f8bb06e84164fc51635321e80d5a3b450761c4997d620925d619"}, "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, @@ -91,7 +90,7 @@ "sweet_xml": {:hex, :sweet_xml, "0.7.5", "803a563113981aaac202a1dbd39771562d0ad31004ddbfc9b5090bdcd5605277", [:mix], [], "hexpm", "193b28a9b12891cae351d81a0cead165ffe67df1b73fe5866d10629f4faefb12"}, "swoosh": {:hex, :swoosh, "1.25.1", "569fcff34817da8a03f28775146b3c8b71b4c9b14f8f78d37ff3ef422862a18b", [:mix], [{:bandit, ">= 1.0.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:ex_aws, "~> 2.1", [hex: :ex_aws, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:idna, "~> 6.0", [hex: :idna, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mua, "~> 0.2.3", [hex: :mua, repo: "hexpm", optional: true]}, {:multipart, "~> 0.4", [hex: :multipart, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:req, "~> 0.5.10 or ~> 0.6 or ~> 1.0", [hex: :req, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "58b3e8db6406fe417a89b5042358d2e8f15d32a3317d4f8581d7a3ae501e410b"}, "tailwind": {:hex, :tailwind, "0.4.1", "e7bcc222fe96a1e55f948e76d13dd84a1a7653fb051d2a167135db3b4b08d3e9", [:mix], [], "hexpm", "6249d4f9819052911120dbdbe9e532e6bd64ea23476056adb7f730aa25c220d1"}, - "telemetry": {:hex, :telemetry, "1.4.2", "a0cb522801dffb1c49fe6e30561badffc7b6d0e180db1300df759faa22062855", [:rebar3], [], "hexpm", "928f6495066506077862c0d1646609eed891a4326bee3126ba54b60af61febb1"}, + "telemetry": {:hex, :telemetry, "1.4.1", "ab6de178e2b29b58e8256b92b382ea3f590a47152ca3651ea857a6cae05ac423", [:rebar3], [], "hexpm", "2172e05a27531d3d31dd9782841065c50dd5c3c7699d95266b2edd54c2dafa1c"}, "telemetry_metrics": {:hex, :telemetry_metrics, "1.1.0", "5bd5f3b5637e0abea0426b947e3ce5dd304f8b3bc6617039e2b5a008adc02f8f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e7b79e8ddfde70adb6db8a6623d1778ec66401f366e9a8f5dd0955c56bc8ce67"}, "telemetry_poller": {:hex, :telemetry_poller, "1.3.0", "d5c46420126b5ac2d72bc6580fb4f537d35e851cc0f8dbd571acf6d6e10f5ec7", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "51f18bed7128544a50f75897db9974436ea9bfba560420b646af27a9a9b35211"}, "text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"}, diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index a85b4cf..52270cc 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -1384,6 +1384,16 @@ msgstr "Festgelegt nach der Erstellung. Mitglieder können nur zwischen Beitrags msgid "From %{first} to %{last} (relevant years with membership data)" msgstr "Von %{first} bis %{last} (Jahre mit Mitgliederdaten)" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From MAIL_FROM_EMAIL" +msgstr "Aus MAIL_FROM_EMAIL" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From MAIL_FROM_NAME" +msgstr "Aus MAIL_FROM_NAME" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From OIDC_ADMIN_GROUP_NAME" @@ -1419,11 +1429,31 @@ msgstr "Aus OIDC_ONLY" msgid "From OIDC_REDIRECT_URI" msgstr "Aus OIDC_REDIRECT_URI" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_HOST" +msgstr "Von SMTP_HOST" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From SMTP_PASSWORD" msgstr "Von SMTP_PASSWORD" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_PORT" +msgstr "Von SMTP_PORT" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_SSL" +msgstr "Von SMTP_SSL" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_USERNAME" +msgstr "Von SMTP_USERNAME" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From VEREINFACHT_API_KEY" @@ -3887,13 +3917,3 @@ msgstr "Offen" #, elixir-autogen, elixir-format msgid "join page URL in a new tab" msgstr "Beitrittslink in einem neuen Tab" - -#: lib/mv_web/live/global_settings_live.ex -#, elixir-autogen, elixir-format -msgid "SMTP environment configuration appears incomplete. Missing: %{keys}" -msgstr "Die SMTP-Umgebungs-Konfiguration ist unvollständig. Fehlend: %{keys}" - -#: lib/mv_web/live/global_settings_live.ex -#, elixir-autogen, elixir-format -msgid "SMTP is fully managed via environment variables. All SMTP fields are read-only." -msgstr "SMTP wird vollständig über Umgebungsvariablen verwaltet. Alle SMTP-Felder sind schreibgeschützt." diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index b995b1a..5d48691 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -1385,6 +1385,16 @@ msgstr "" msgid "From %{first} to %{last} (relevant years with membership data)" msgstr "" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From MAIL_FROM_EMAIL" +msgstr "" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From MAIL_FROM_NAME" +msgstr "" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From OIDC_ADMIN_GROUP_NAME" @@ -1420,11 +1430,31 @@ msgstr "" msgid "From OIDC_REDIRECT_URI" msgstr "" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_HOST" +msgstr "" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From SMTP_PASSWORD" msgstr "" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_PORT" +msgstr "" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_SSL" +msgstr "" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_USERNAME" +msgstr "" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From VEREINFACHT_API_KEY" @@ -3887,13 +3917,3 @@ msgstr "" #, elixir-autogen, elixir-format msgid "join page URL in a new tab" msgstr "" - -#: lib/mv_web/live/global_settings_live.ex -#, elixir-autogen, elixir-format -msgid "SMTP environment configuration appears incomplete. Missing: %{keys}" -msgstr "" - -#: lib/mv_web/live/global_settings_live.ex -#, elixir-autogen, elixir-format -msgid "SMTP is fully managed via environment variables. All SMTP fields are read-only." -msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index f4526d1..ec6f305 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -1385,6 +1385,16 @@ msgstr "" msgid "From %{first} to %{last} (relevant years with membership data)" msgstr "" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From MAIL_FROM_EMAIL" +msgstr "" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From MAIL_FROM_NAME" +msgstr "" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From OIDC_ADMIN_GROUP_NAME" @@ -1420,11 +1430,31 @@ msgstr "" msgid "From OIDC_REDIRECT_URI" msgstr "" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_HOST" +msgstr "" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From SMTP_PASSWORD" msgstr "" +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_PORT" +msgstr "" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_SSL" +msgstr "" + +#: lib/mv_web/live/global_settings_live.ex +#, elixir-autogen, elixir-format +msgid "From SMTP_USERNAME" +msgstr "" + #: lib/mv_web/live/global_settings_live.ex #, elixir-autogen, elixir-format msgid "From VEREINFACHT_API_KEY" @@ -3887,13 +3917,3 @@ msgstr "Open" #, elixir-autogen, elixir-format msgid "join page URL in a new tab" msgstr "join page URL in a new tab" - -#: lib/mv_web/live/global_settings_live.ex -#, elixir-autogen, elixir-format -msgid "SMTP environment configuration appears incomplete. Missing: %{keys}" -msgstr "" - -#: lib/mv_web/live/global_settings_live.ex -#, elixir-autogen, elixir-format -msgid "SMTP is fully managed via environment variables. All SMTP fields are read-only." -msgstr "SMTP is fully managed via environment variables. All SMTP fields are read-only." diff --git a/test/membership/member_test.exs b/test/membership/member_test.exs index 5e30da6..ca4d022 100644 --- a/test/membership/member_test.exs +++ b/test/membership/member_test.exs @@ -49,43 +49,12 @@ defmodule Mv.Membership.MemberTest do assert error_message(errors, :email) =~ "is not a valid email" end - test "Join date can be in the future", %{actor: actor} do + test "Join date cannot be in the future", %{actor: actor} do attrs = Map.put(@valid_attrs, :join_date, Date.utc_today() |> Date.add(1)) - assert {:ok, _member} = Membership.create_member(attrs, actor: actor) - end - - test "Join date far in the future (2099) is accepted", %{actor: actor} do - attrs = Map.put(@valid_attrs, :join_date, ~D[2099-12-31]) - - assert {:ok, _member} = Membership.create_member(attrs, actor: actor) - end - - test "Join date today is accepted", %{actor: actor} do - attrs = Map.put(@valid_attrs, :join_date, Date.utc_today()) - - assert {:ok, _member} = Membership.create_member(attrs, actor: actor) - end - - test "Join date in the future is accepted on update", %{actor: actor} do - {:ok, member} = Membership.create_member(@valid_attrs, actor: actor) - - assert {:ok, _updated} = - Membership.update_member(member, %{join_date: Date.utc_today() |> Date.add(30)}, - actor: actor - ) - end - - test "Exit date before future join date is rejected", %{actor: actor} do - attrs = - @valid_attrs - |> Map.put(:join_date, Date.utc_today() |> Date.add(10)) - |> Map.put(:exit_date, Date.utc_today() |> Date.add(5)) - - assert {:error, %Ash.Error.Invalid{errors: errors}} = + assert {:error, + %Ash.Error.Invalid{errors: [%Ash.Error.Changes.InvalidAttribute{field: :join_date}]}} = Membership.create_member(attrs, actor: actor) - - assert error_message(errors, :exit_date) =~ "cannot be before join date" end test "Exit date is optional but must not be before join date if both are specified", %{ diff --git a/test/mv/config_smtp_test.exs b/test/mv/config_smtp_test.exs index ebf2b83..5359366 100644 --- a/test/mv/config_smtp_test.exs +++ b/test/mv/config_smtp_test.exs @@ -2,7 +2,7 @@ defmodule Mv.ConfigSmtpTest do @moduledoc """ Unit tests for Mv.Config SMTP-related helpers. - SMTP uses ENV-only mode when SMTP_HOST is set. Uses real ENV and + ENV overrides Settings (same pattern as OIDC/Vereinfacht). Uses real ENV and Settings; no mocking so we test the actual precedence. async: false because we mutate ENV. """ @@ -23,8 +23,7 @@ defmodule Mv.ConfigSmtpTest do end describe "smtp_port/0" do - test "returns parsed integer when SMTP_PORT ENV is set in ENV-only mode" do - set_smtp_env("SMTP_HOST", "smtp.example.com") + test "returns parsed integer when SMTP_PORT ENV is set" do set_smtp_env("SMTP_PORT", "587") assert Mv.Config.smtp_port() == 587 after @@ -52,40 +51,30 @@ defmodule Mv.ConfigSmtpTest do end end - describe "smtp_env_mode?/0" do - test "returns true when SMTP_HOST is set" do + describe "smtp_env_configured?/0" do + test "returns true when any SMTP ENV variable is set" do set_smtp_env("SMTP_HOST", "smtp.example.com") - assert Mv.Config.smtp_env_mode?() == true - after - clear_smtp_env() - end - - test "returns false when SMTP_HOST is not set even if other SMTP ENV variables are set" do - set_smtp_env("SMTP_USERNAME", "user@example.com") - set_smtp_env("SMTP_PASSWORD", "secret") - refute Mv.Config.smtp_env_mode?() + assert Mv.Config.smtp_env_configured?() == true after clear_smtp_env() end test "returns false when no SMTP ENV variables are set" do clear_smtp_env() - refute Mv.Config.smtp_env_mode?() + refute Mv.Config.smtp_env_configured?() end end describe "smtp_password/0 and SMTP_PASSWORD_FILE" do - test "returns value from SMTP_PASSWORD when set in ENV-only mode" do - set_smtp_env("SMTP_HOST", "smtp.example.com") + test "returns value from SMTP_PASSWORD when set" do set_smtp_env("SMTP_PASSWORD", "env-secret") assert Mv.Config.smtp_password() == "env-secret" after clear_smtp_env() end - test "returns content of file when SMTP_PASSWORD_FILE is set in ENV-only mode and SMTP_PASSWORD is not" do + test "returns content of file when SMTP_PASSWORD_FILE is set and SMTP_PASSWORD is not" do clear_smtp_env() - set_smtp_env("SMTP_HOST", "smtp.example.com") path = Path.join(System.tmp_dir!(), "mv_smtp_test_#{System.unique_integer([:positive])}") File.write!(path, "file-secret\n") Process.put(:smtp_password_file_path, path) @@ -96,8 +85,7 @@ defmodule Mv.ConfigSmtpTest do if path = Process.get(:smtp_password_file_path), do: File.rm(path) end - test "SMTP_PASSWORD overrides SMTP_PASSWORD_FILE in ENV-only mode when both are set" do - set_smtp_env("SMTP_HOST", "smtp.example.com") + test "SMTP_PASSWORD overrides SMTP_PASSWORD_FILE when both are set" do path = Path.join(System.tmp_dir!(), "mv_smtp_test_#{System.unique_integer([:positive])}") File.write!(path, "file-secret") Process.put(:smtp_password_file_path, path) diff --git a/test/mv_web/components/core_components_table_test.exs b/test/mv_web/components/core_components_table_test.exs index 03f1f71..931b42a 100644 --- a/test/mv_web/components/core_components_table_test.exs +++ b/test/mv_web/components/core_components_table_test.exs @@ -9,7 +9,7 @@ defmodule MvWeb.Components.CoreComponentsTableTest do alias MvWeb.CoreComponents describe "table row_click styling" do - test "when row_click is set, rows are marked interactive and omit ring hover classes" do + test "when row_click is set, table rows have hover and focus-within ring classes" do rows = [%{id: "1", name: "Alice"}, %{id: "2", name: "Bob"}] assigns = %{ @@ -31,12 +31,12 @@ defmodule MvWeb.Components.CoreComponentsTableTest do html = render_component(&CoreComponents.table/1, assigns) - assert html =~ ~s(data-row-interactive="true") - refute html =~ "hover:ring-2" - refute html =~ "focus-within:ring-2" + assert html =~ "hover:ring-2" + assert html =~ "focus-within:ring-2" + assert html =~ "hover:ring-base-content/10" end - test "when row_click is nil, rows are not marked interactive" do + test "when row_click is nil, table rows do not have hover ring classes" do rows = [%{id: "1", name: "Alice"}] assigns = %{ @@ -58,7 +58,8 @@ defmodule MvWeb.Components.CoreComponentsTableTest do html = render_component(&CoreComponents.table/1, assigns) - refute html =~ ~s(data-row-interactive="true") + refute html =~ "hover:ring-2" + refute html =~ "focus-within:ring-2" end end @@ -150,183 +151,4 @@ defmodule MvWeb.Components.CoreComponentsTableTest do assert html =~ "ring-primary" end end - - describe "table scroll wrapper contract" do - test "sticky header table uses horizontal-only overflow wrapper" do - rows = [%{id: "1", name: "Alice"}] - - assigns = %{ - id: "test-table", - rows: rows, - row_id: fn r -> "row-#{r.id}" end, - row_click: nil, - sticky_header: true, - row_item: &Function.identity/1, - col: [ - %{ - __slot__: :col, - label: "Name", - inner_block: fn _socket, item -> [item[:name] || ""] end - } - ], - dynamic_cols: [], - action: [] - } - - html = render_component(&CoreComponents.table/1, assigns) - - assert html =~ ~s(class="overflow-x-auto") - refute html =~ ~s(class="overflow-auto") - end - - test "table wrapper does not enable vertical overflow by default" do - rows = [%{id: "1", name: "Alice"}] - - assigns = %{ - id: "test-table", - rows: rows, - row_id: fn r -> "row-#{r.id}" end, - row_click: nil, - row_item: &Function.identity/1, - col: [ - %{ - __slot__: :col, - label: "Name", - inner_block: fn _socket, item -> [item[:name] || ""] end - } - ], - dynamic_cols: [], - action: [] - } - - html = render_component(&CoreComponents.table/1, assigns) - - assert html =~ ~s(class="overflow-x-auto") - refute html =~ ~s(class="overflow-auto") - end - - test "table wrapper overflow class can be overridden by caller" do - rows = [%{id: "1", name: "Alice"}] - - assigns = %{ - id: "test-table", - rows: rows, - row_id: fn r -> "row-#{r.id}" end, - row_click: nil, - wrapper_overflow_class: "overflow-visible", - row_item: &Function.identity/1, - col: [ - %{ - __slot__: :col, - label: "Name", - inner_block: fn _socket, item -> [item[:name] || ""] end - } - ], - dynamic_cols: [], - action: [] - } - - html = render_component(&CoreComponents.table/1, assigns) - - assert html =~ ~s(class="overflow-visible") - refute html =~ ~s(class="overflow-x-auto") - end - end - - describe "sticky first column contract" do - test "when sticky_first_col is enabled, first header and body cells render sticky-left classes" do - rows = [%{id: "1", selected: true, name: "Alice"}] - - assigns = %{ - id: "test-table", - rows: rows, - row_id: fn r -> "row-#{r.id}" end, - row_click: nil, - sticky_first_col: true, - row_item: &Function.identity/1, - col: [ - %{ - __slot__: :col, - label: "Select", - inner_block: fn _socket, item -> [if(item[:selected], do: "x", else: "")] end - }, - %{ - __slot__: :col, - label: "Name", - inner_block: fn _socket, item -> [item[:name] || ""] end - } - ], - dynamic_cols: [], - action: [] - } - - html = render_component(&CoreComponents.table/1, assigns) - - assert html =~ "sticky" - assert html =~ "left-0" - assert html =~ "z-20" - assert html =~ "z-30" - end - - test "sticky first column marks wrapper and uses CSS row backgrounds instead of row ring classes" do - rows = [%{id: "1", name: "Alice"}] - - assigns = %{ - id: "test-table", - rows: rows, - row_id: fn r -> "row-#{r.id}" end, - row_click: fn _ -> nil end, - sticky_first_col: true, - row_item: &Function.identity/1, - col: [ - %{ - __slot__: :col, - label: "Select", - inner_block: fn _socket, _item -> ["x"] end - }, - %{ - __slot__: :col, - label: "Name", - inner_block: fn _socket, item -> [item[:name] || ""] end - } - ], - dynamic_cols: [], - action: [] - } - - html = render_component(&CoreComponents.table/1, assigns) - - assert html =~ ~s(data-sticky-first-col-rows="true") - assert html =~ "sticky-first-col-cell" - refute html =~ "hover:ring-2" - end - - test "sticky first column with selection sets data-selected without ring-primary" do - rows = [%{id: "one", name: "Alice"}, %{id: "two", name: "Bob"}] - - assigns = %{ - id: "test-table", - rows: rows, - row_id: fn r -> "row-#{r.id}" end, - row_click: fn _ -> nil end, - sticky_first_col: true, - selected_row_id: "two", - row_item: &Function.identity/1, - col: [ - %{ - __slot__: :col, - label: "Name", - inner_block: fn _socket, item -> [item[:name] || ""] end - } - ], - dynamic_cols: [], - action: [] - } - - html = render_component(&CoreComponents.table/1, assigns) - - assert html =~ ~s(data-selected="true") - refute html =~ "ring-primary" - end - end end diff --git a/test/mv_web/live/global_settings_live_test.exs b/test/mv_web/live/global_settings_live_test.exs index 9be12b9..2edaf74 100644 --- a/test/mv_web/live/global_settings_live_test.exs +++ b/test/mv_web/live/global_settings_live_test.exs @@ -1,22 +1,8 @@ defmodule MvWeb.GlobalSettingsLiveTest do - use MvWeb.ConnCase, async: false + use MvWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mv.Membership - defp clear_smtp_env do - [ - "SMTP_HOST", - "SMTP_PORT", - "SMTP_SSL", - "SMTP_USERNAME", - "SMTP_PASSWORD", - "SMTP_PASSWORD_FILE", - "MAIL_FROM_EMAIL", - "MAIL_FROM_NAME" - ] - |> Enum.each(&System.delete_env/1) - end - describe "Global Settings LiveView" do setup %{conn: conn} do user = create_test_user(%{email: "admin@example.com"}) @@ -138,85 +124,6 @@ defmodule MvWeb.GlobalSettingsLiveTest do {:ok, _view, html} = live(conn, ~p"/settings") assert html =~ "SMTP" or html =~ "E-Mail" or html =~ "Settings" end - - @tag :ui - test "disables all SMTP inputs when SMTP_HOST is set", %{conn: conn} do - clear_smtp_env() - System.put_env("SMTP_HOST", "smtp.env-only.example") - on_exit(fn -> clear_smtp_env() end) - - {:ok, view, _html} = live(conn, ~p"/settings") - - assert has_element?(view, "#setting_smtp_host[disabled]") - assert has_element?(view, "#setting_smtp_port[disabled]") - assert has_element?(view, "#setting_smtp_ssl[disabled]") - assert has_element?(view, "#setting_smtp_username[disabled]") - assert has_element?(view, "#setting_smtp_password[disabled]") - assert has_element?(view, "#setting_smtp_from_email[disabled]") - assert has_element?(view, "#setting_smtp_from_name[disabled]") - end - - @tag :ui - test "does not render SMTP save action when SMTP_HOST is set", %{conn: conn} do - clear_smtp_env() - System.put_env("SMTP_HOST", "smtp.env-only.example") - on_exit(fn -> clear_smtp_env() end) - - {:ok, view, _html} = live(conn, ~p"/settings") - refute has_element?(view, "#smtp-form button", "Save SMTP Settings") - end - - @tag :ui - test "shows explicit ENV-only mode hint when SMTP_HOST is set", %{conn: conn} do - clear_smtp_env() - System.put_env("SMTP_HOST", "smtp.env-only.example") - on_exit(fn -> clear_smtp_env() end) - - {:ok, _view, html} = live(conn, ~p"/settings") - assert html =~ "SMTP is fully managed via environment variables" - end - - @tag :ui - test "shows warning block for missing required SMTP ENV values in ENV-only mode", %{ - conn: conn - } do - clear_smtp_env() - System.put_env("SMTP_HOST", "smtp.env-only.example") - on_exit(fn -> clear_smtp_env() end) - - {:ok, _view, html} = live(conn, ~p"/settings") - assert html =~ "SMTP environment configuration appears incomplete" - assert html =~ "SMTP_USERNAME" - assert html =~ "SMTP_PASSWORD/SMTP_PASSWORD_FILE" - end - - @tag :ui - test "does not enter ENV-only mode when SMTP_HOST is not set", %{conn: conn} do - clear_smtp_env() - System.put_env("SMTP_USERNAME", "leftover@example.com") - on_exit(fn -> clear_smtp_env() end) - - {:ok, view, html} = live(conn, ~p"/settings") - - refute html =~ "SMTP is fully managed via environment variables" - refute html =~ "SMTP environment configuration appears incomplete" - refute has_element?(view, "#setting_smtp_host[disabled]") - refute has_element?(view, "#setting_smtp_username[disabled]") - end - - @tag :ui - test "shows effective ENV SMTP host value in disabled field", %{conn: conn} do - clear_smtp_env() - System.put_env("SMTP_HOST", "smtp.env-active.example") - on_exit(fn -> clear_smtp_env() end) - - {:ok, settings} = Membership.get_settings() - {:ok, _} = Membership.update_settings(settings, %{smtp_host: "smtp.db-legacy.example"}) - - {:ok, _view, html} = live(conn, ~p"/settings") - assert html =~ ~s(value="smtp.env-active.example") - refute html =~ ~s(value="smtp.db-legacy.example") - end end describe "Authentication section when OIDC-only is enabled" do diff --git a/test/mv_web/member_live/index_test.exs b/test/mv_web/member_live/index_test.exs index 85c3385..686a8e8 100644 --- a/test/mv_web/member_live/index_test.exs +++ b/test/mv_web/member_live/index_test.exs @@ -78,37 +78,6 @@ defmodule MvWeb.MemberLive.IndexTest do assert html =~ "lg:top-0" assert html =~ "bg-base-100" end - - test "members page does not nest a second overflow wrapper inside members-table-scroll", %{ - conn: conn - } do - conn = conn_with_oidc_user(conn) - {:ok, _view, html} = live(conn, ~p"/members") - - assert html =~ ~s(id="members-keyboard") - assert html =~ ~s(class="overflow-visible") - refute html =~ ~s(id="members-keyboard" class="overflow-x-auto") - refute html =~ ~s(id="members-keyboard" class="overflow-auto") - end - - test "members table keeps checkbox column sticky while horizontally scrolling", %{conn: conn} do - system_actor = SystemActor.get_system_actor() - - {:ok, _member} = - Membership.create_member( - %{first_name: "Sticky", last_name: "Column", email: "sticky-column@example.com"}, - actor: system_actor - ) - - conn = conn_with_oidc_user(conn) - {:ok, _view, html} = live(conn, ~p"/members") - - # Contract: first column (select-all header + row checkbox cells) is sticky on the left - assert html =~ "left-0" - assert html =~ "sticky" - assert html =~ "z-30" - assert html =~ "z-20" - end end describe "translations" do @@ -370,12 +339,10 @@ defmodule MvWeb.MemberLive.IndexTest do assert_redirect(view, ~p"/members/#{member}") end - describe "table row highlight (hover and selected)" do + describe "table row outline (hover and selected)" do @describetag :ui - test "clickable rows with sticky first column use hover/focus background highlight", %{ - conn: conn - } do + test "clickable rows have hover and focus-within ring classes", %{conn: conn} do system_actor = SystemActor.get_system_actor() {:ok, _member} = @@ -387,9 +354,10 @@ defmodule MvWeb.MemberLive.IndexTest do conn = conn_with_oidc_user(conn) {:ok, _view, html} = live(conn, "/members") - # Sticky-first-column tables: hover/focus fills live in CSS; wrapper is marked for tests. - assert html =~ ~s(data-sticky-first-col-rows="true") - refute html =~ "hover:ring-2" + # CoreComponents table adds hover and focus-within ring when row_click is set + assert html =~ "hover:ring-2" + assert html =~ "focus-within:ring-2" + assert html =~ "hover:ring-base-content/10" end test "selected outline only from checkbox selection, not from highlight param", %{conn: conn} do
{col[:label]} @@ -1020,13 +1006,7 @@ defmodule MvWeb.CoreComponents do