PhoenixKit 1.7.106: DB module leaves core, custom roles reach module pages
PhoenixKit 1.7.106 moves the DB module out of core into its own package, phoenix_kit_db, and fixes custom roles being locked out of module admin pages.
A role given a module permission such as entities or billing still could not open that module’s admin pages, because core only recognised its own modules. It now finds the module for any registered package. Host routes shaped like /:locale/services/... are no longer swallowed by the Publishing module’s catch-all route.
Clicking a file in a media browser that is not in admin or select mode opens a preview with zoom, details, Download and arrows to the next file. Being sent to sign in from a LiveView page now returns you to that page afterwards. Microsoft 365 connections take a Tenant ID, so single-tenant accounts can connect. An OAuth callback without its saved state is now refused. The list of installable modules comes from Hex. Migration V111 adds the PDF library tables for the Catalogue module.
Upgrading
Run mix phoenix_kit.update for V111. A site that uses the DB module must add phoenix_kit_db to its dependencies.
Full release notes: PhoenixKit 1.7.106
1.7.106 · 8 May 2026
Added
- V111 migration: PDF library tables for the upcoming catalogue PDF subtab (PR #516)
phoenix_kit_cat_pdfs— thin per-upload row.file_uuidFK tophoenix_kit_files(uuid)ON DELETE RESTRICT (catalogue manages the file lifecycle; core prune can’t remove files referenced by a live catalogue row). Soft-delete viastatussentinel (active/trashed) +trashed_at. Two uploads of identical content (different filenames) → two rows sharing onephoenix_kit_filesrow + one extractionphoenix_kit_cat_pdf_extractions— keyed byfile_uuidPK. Worker state machine (pending → extracting → extracted | scanned_no_text | failed) +page_count+extracted_at+error_message. Cascades on file hard deletephoenix_kit_cat_pdf_page_contents— content-addressed dedup cache. PK oncontent_hash(SHA-256 hex of normalized page text). Same page text across multiple PDFs is stored once. GIN trigram index lives here so the search index doesn’t grow with cross-PDF duplicationphoenix_kit_cat_pdf_pages— composite PK(file_uuid, page_number);content_hashFK to the dedup cache (RESTRICT — orphaned content rows GC’d by a catalogue-side helper, not by FK cascade)- Enables
pg_trgmextension;@current_version110 → 111
PhoenixKit.KnownPackages— live catalog of known external PhoenixKit packages, replacing the previously hardcoded list inModuleRegistry.known_external_packages/0(PR #523)- Fetched on demand from
https://hex.pm/api/packages?search=phoenix_kit_&sort=nameand cached for 10 minutes in an ETS named table (:phoenix_kit_known_packages_cache) - Stale-while-revalidate with cap: on Hex failure, serves cached data up to
:max_stale_age_ms(default 24h); beyond that, drops the cache and falls back to:extra_known_packagesconfig entries only :warninglog on stale-served and empty-cache-extras-only;:errorlog when cache exceeds max stale age — operationally distinct alert levelsLink-header pagination with a 20-page cap (@max_pages) so a malformedLinkheader pointing back to the same page can’t loop foreverextra_known_packagesconfig knob — parent apps with private/forked packages declare them inline and they take precedence over Hex entries on thepackagededup key (source: "config"baked in)hex_docs_icon_name: hero-<name>convention — package authors append the marker to their Hex package description and the catalog UI picks it up; default ishero-puzzle-piece
- Fetched on demand from
- Per-module gettext support on Dashboard sidebar labels and tooltips (PR #522)
PhoenixKit.Dashboard.Tabgainsgettext_backend: module() | nil(defaultnil) andgettext_domain: String.t()(default"default") fields, pluslocalized_label/1andlocalized_tooltip/1resolvers that callGettext.dgettext/3when a backend is set and fall back to the raw label otherwisePhoenixKit.Dashboard.Groupgains the same two fields pluslocalized_label/1Tab.divider/1andTab.group_header/1accept the new opts;Tab.new/1round-trips both viaget_attr/2- 14 render sites in
Sidebar,AdminSidebar,TabItemswaptab.label→Tab.localized_label(tab)and equivalents — mechanically uniform, no shape changes - Hot-reload safety via
Map.get/2(not pattern matching) on the new fields — old-shape%Tab{}cached in ETS or:persistent_termfrom before the upgrade falls through as ifgettext_backendwerenilrather than raisingFunctionClauseError. Pinned by an explicitMap.delete(:gettext_backend)regression test guides/per-module-i18n.md— public guide for module developers (setup checklist,mix.exs/ backend /.poflow,dynamic_children/2locale handling, dividers and group headers, tooltips, greenfield template, retrofitting checklist, smoke test pattern, common pitfalls including the hot-reload safety contract)dev_docs/instructions/2026-05-08-per-module-i18n-procedure.md— internal operational procedure capturing every gotcha hit during the Newsletters pilot (skip-worktree on mix.exs, path-dep workflow during local dev, conditional CI skip pattern for graceful degradation)
:per_translation_urlsattr on the threeLanguageSwitchervariants —language_switcher_dropdown/1,language_switcher_buttons/1,language_switcher_inline/1(PR #525)- Each entry is
%{code: <display_code>, url: <full_url>}. Both atom-keyed and string-keyed entries accepted (useful when the list comes from JSON/JSONB rather than Elixir code) - Resolves each language’s
base_codeagainst the list viaDialectMapper.extract_base/1so"en-US"and"en"both resolve cleanly. Falls back to the locale-rewrite default when no entry matches OR the matched entry has anilURL (e.g. an unpublished draft) - Useful when a feature module has computed canonical URLs that the simple locale-rewrite default can’t reproduce — for example publishing’s per-language URL slugs where
/en/blog/my-postand/fr/blog/mon-articlearen’t related by segment swap. Passassigns[:phoenix_kit_publishing_translations]from the layout - 7 new tests in
test/phoenix_kit_web/components/core/language_switcher_test.exspin the contract (atom-keyed, string-keyed, full-dialect normalization, per-language fallback, nil/empty/missing-attr pass-through)
- Each entry is
- Drag-handle scoping + sortable feedback infrastructure (PR #525)
<.table_default>emitsdata-sortable-handle=".pk-drag-handle"when@on_reorderis set; only the.pk-drag-handleelement getscursor-grabstyling. Click-to-expand / button-press / text-selection on a card no longer fights with SortableJS drag detectionSortableGridJS hook: newsortable:flashLV→client event handler. The host LV pushes{uuid: "...", status: "ok" | "error"}after eachreorder_itemsattempt; the hook appliespk-sortable-flash-{ok,err}class for ~1.2s, idempotent via reflow trigger. Queries every[data-id]element so table-view + card-view both animate. Defensive status-validation guard — unknown values bail rather than falling into the err-class branch<tr>cell-width preservation viaonChoose/onUnchoose— SortableJS’sforceFallback: true+fallbackOnBody: trueclones the dragged<tr>todocument.body, where it loses its<table>ancestor and<td>s collapse to content width. The hook now snapshots computed widths and pins them inline before the drag preview renders;onUnchooserestores themdata-sortable-handleattr threads to SortableJS’shandleoption for any caller;moved_idalways included in thereorder_itemspayload (was only on cross-container moves) so the LV can push back asortable:flashkeyed to the just-moved row
- MediaBrowser modal viewer becomes the default click target for non-admin / non-select_mode browsers, with read-only image / video / PDF / icon preview, metadata sidebar, Download button, prev/next chevrons (and ←/→ keyboard shortcuts), and Esc / backdrop close (PR #519)
- Mobile-fullscreen layout via
position: fixed; inset: 0— bypasses daisyUI’s grid + iOS Safari’s 100vh/100dvh quirks. Desktop reverts to95vw × 90vhcentered modal with rounded corners. The!-prefix utility chain on.modal-boxis required because daisyUI v5’s defaults win the cascade over plain Tailwind utilities MediaImageZoomJS hook lazy-loads Panzoom 4.6.0 from jsDelivr when the modal opens; image supports wheel/pinch/double-tap zoom and drag-pan. Listener attaches to the parent so the cursor doesn’t have to land on the image;destroyedcleanup removes the wheel listener and destroys the Panzoom instance- Bulk-select still reachable — clicking the toolbar’s Select button flips
select_modeon, and from then on clicks toggle selection instead of opening the modal
- Mobile-fullscreen layout via
- LiveView login redirect now carries the original request path as
?return_to=(PR #519)- New
login_path_with_return_to/1private helper inPhoenixKitWeb.Users.AuthreadsPhoenix.LiveView.get_connect_info(socket, :uri), encodespath?queryviaURI.encode_www_form/1, and threads it into the redirect target. Wired into the fourredirect_require_loginpaths inon_mounthooks - Trailing-slash self-loop guard:
String.trim_trailing(path, "/")on both sides of the equality check, so/users/log-inand/users/log-in/are treated as the same path and no return-to round-trips back to itself - Pairs with the existing
?return_to=flow inlogin.ex(sanitize_return_to/1→:user_return_tosession →log_in_user/3)
- New
PhoenixKit.ModuleRegistry.get_module_key_for_namespace/1— symmetric with the existingget_by_key/1. Resolves a top-level Elixir namespace string (e.g."PhoenixKitEntities") to the registered plugin’smodule_key/0(PR #521)- Iterates
all_modules/0, matches onModule.split(mod) == [top_namespace](exact, single segment), returns the key string ornilfor unmatched - Reads from
:persistent_termso there’s no GenServer roundtrip on the hot path
- Iterates
- Microsoft 365 OAuth tenant override + generic
interpolate_url/3helper inPhoenixKit.Integrations.OAuth— providers can now substitute{key}placeholders inauth_url/token_urlfrom per-rowintegration_data, falling back to a provider-level:url_defaultsmap (PR #516)- Closes the previously hardcoded
/common/Microsoft tenant — single-tenant operators got AADSTS50194 errors. Newtenant_idsetup field withcommondefault; multi-tenant remains the default behavior. Three pinning tests intest/phoenix_kit/integrations/oauth_test.exs - Wired into
authorization_url/5,exchange_code/4,refresh_access_token/2. URLs without{pass through unchanged (zero impact on Google / OpenRouter / Mistral / DeepSeek)
- Closes the previously hardcoded
- “Resolve a LiveView module to its permission key” block-comment on
PhoenixKitWeb.Users.Auth.permission_key_for_admin_view/1documenting the four-step resolution order (static map → custom-tabs →PhoenixKit.Modules.<X>.Web.*namespace → registered-plugin namespace) and the fail-closed nil default
Changed
- DB module extracted from core into the standalone
phoenix_kit_dbHex package (PR #518)- Removed
lib/modules/db/(db.ex,listener.ex,web/{activity,index,show}.{ex,html.heex}) — ~2010 lines across 8 files module_registry.ex— droppedPhoenixKit.Modules.DBfrominternal_modules/0integration.ex— dropped the three hand-registeredlive "/admin/db…"declarations (auto-discovery viaadmin_tabs/0picks them up once the package is installed)modules.html.heex— dropped the hardcoded DB module card; auto-render via<.module_card>based onadmin_tabs/0discoverydev_docs/guides/2026-02-24-module-system-guide.md— movedlib/modules/db/db.exfrom the Internal examples section to External asphoenix_kit_db/, between hello_world and document_creator
- Removed
PhoenixKit.ModuleRegistry.not_installed_packages/0switches fromCode.ensure_loaded?(pkg.module)to OTP-app-name MapSet membership (PR #523) — the more correct semantics, since module-loading state and OTP-app-installed state aren’t the same: an extracted-but-not-yet-installed module fragment could passCode.ensure_loaded?but isn’t actually a depPhoenixKit.Integrations.OAuth.verify_oauth_state/2missing-state branch tightened from lenient:okto{:error, :state_mismatch}(PR #516, closes a CSRF-relevant gap from PR #511’s review NIT #10) — everyconnect_oauthevent saves state viasave_oauth_state/2before redirect post-2026-05, so a missing state at callback time means either bypass or row-mutated-mid-flow; both are CSRF-relevantIntegrationPickerdrops theconn.name == "default"substitution that contradicted PR #511’s own moduledoc (“Names are pure user-chosen labels with no system semantics”) — always renders the user-chosen name + provider badge (PR #516, closes PR #511 NIT #6)<.file_upload>full_upload/1variant entry-progress label readsUploading… {entry.progress}%instead of the bare percentage —entry.progressis always client→server upload progress per Phoenix LV convention, so the wording is universally accurate (PR #516)LanguageSwitcherresolves the per-language URL once per iteration via inline<% url = ... %>and reuses it forhrefandphx-value-url— halves the per-renderresolve_url/3cost and pins both call sites to the same URL (post-merge triage)KnownPackagesmoduledoc grew an “Operational signals” section enumerating the three log levels (:warningstale-served / no-cache /:errorexceeded max stale age) and what each signals operationally (post-merge triage)
Fixed
- Publishing routing-strategy collision: any host route shaped
/:locale/<literal>/...declared afterphoenix_kit_routes()was silently shadowed by publishing’s/:language/:group/*pathcatch-all (PR #524)phoenix_kit_routes/0now emits a publishing-specific dispatch shim whenPhoenixKitPublishing.RouterDispatchis loaded — internal-prefix scope at/<url_prefix>/__phoenix_kit_publishing_dispatchwith/localizedand/rootdiscriminator sub-scopes, plus adef call/2override that callsRouterDispatch.maybe_rewrite/1on every request and only rewrites publishing-bound URLs onto the internal prefix. Host routes get a fair shot at every URLrestore_path/2runs after route binding (via the new:phoenix_kit_publishing_internalpipeline) so canonical-URL generation reads the URL the client sent — without it, publishing’sdefault_language_no_prefixredirect would spin on the internal prefix forever- Compile-time gated on
Code.ensure_loaded?(PhoenixKitPublishing.RouterDispatch); installs without publishing in the dep tree getquote do end(no-op AST). The__mix_recompile__?/0mechanism injected byphoenix_kit_routes/0forces a host-router recompile when publishing is added or removed from deps — handles the dep-cache staleness case - Browser-smoke verified across 8 URL classes: localized + canonical publishing posts, host’s
/:locale/services/view/...routes (was 404 pre-fix), admin redirects, plain home, genuine 404s. HTML body sweep confirmed zero leakage of the internal prefix in canonical / og / links / JS / headers
- Custom-role users with explicit plugin permissions (
entities,billing,ai, …) were silently locked out of plugin admin pages becauseinfer_permission_key_from_module/1only resolved the corePhoenixKit.Modules.*namespace. External plugins (PhoenixKitEntities.*,PhoenixKitBilling.*, …) returnednilfrom all three resolution paths, collapsing onto the “no permission” branch inenforce_admin_view_permission/2(PR #521)- New
[top | _rest] -> ModuleRegistry.get_module_key_for_namespace(top)clause oninfer_permission_key_from_module/1. Old_ -> nilfallback removed (unreachable post-Module.split/1). Owner / Admin behaviour and the fail-closed default for genuinely unknown views are preserved - Initial implementation used
[^top_namespace | _]which matched any registered module whoseModule.splitstarts with the segment; live repro on a parent app showedget_module_key_for_namespace("PhoenixKit") => "db"becausePhoenixKit.Modules.DBhappened to be the first registered module beginning with"PhoenixKit". Tightened to[^top_namespace](exact, single segment) and pinned with a regression test permission_key_for_admin_view/1exposed as@doc false def(wasdefp) so 4 new unit tests intest/phoenix_kit_web/users/auth_test.exscan exercise the resolution layers without LiveView mounting machinery; 3 new tests intest/phoenix_kit/module_registry_test.exspinget_module_key_for_namespace/1(usesModule.create/3with explicit top-level fixture names to avoid test-module auto-nesting)
- New
PhoenixKitWeb.PagesHTMLremoved (PR #518) — the module had no controller, no routes, no callers. Theembed_templates "pages_html/*"directive pluspages_html/show.html.heexplus theintegration.exdocstring described a markdown-page-rendering feature that was never wired up. Publishing module covers actual CMS-page rendering.ast-grep --lang elixir --pattern 'PhoenixKitWeb.PagesHTML'confirms zero structural references remainMediaBrowserchevron-button positioning: daisyUI’s active-state CSS replacestransformwithscale(0.97)on click, which would clobber a-translate-y-1/2on the button itself and make it jump down 50% of its height. Chevron positioning now sits on a wrapper<div>, not the button (PR #519)media_browser.html.heexmodal-viewer leading comment referenced the now-removedviewer={true}attr; rewritten to describe the new default click behaviour (post-merge triage)- Dead
defaults[String.to_atom(key)]fallback inOAuth.interpolate_url/3— no provider inProviders.providers/0ships an atom-keyedurl_defaults, so the path was unreachable. Removed; comment documents that provider authors must use string keys (post-merge triage) KnownPackages.fetch_hex_page/3recursion grew an explicit@max_pages 20cap so a malformedLinkheader pointing back to the same page can no longer loop forever;ensure_table/0rescue now carries an explanatory comment about the:ets.whereis/1→:ets.new/2race window (post-merge triage)KnownPackagestest_helper.exs: theSystem.cmd("psql", ...)DB-existence check nowtry/rescue ErlangErrorso environments wherepsqlisn’t on PATH fall through to the connect-direct branch instead of crashing the test boot (PR #523)- Pre-existing credo
Refactor.Applyopportunities on the threeapply/3calls incompile_publishing_routing/1silenced with inline# credo:disable-for-next-lineannotations and an empirically-verified comment explaining why the variable-indirection alternative (mod = ModuleName; mod.fun()) doesn’t shield the compiler’s static-resolution warning either.mix credo --strictnow reports zero issues across the tree (post-merge triage)
Removed
PhoenixKit.Modules.DBand the entirelib/modules/db/directory — extracted to the standalonephoenix_kit_dbHex package; companion repo TBA (PR #518)PhoenixKitWeb.PagesHTMLand itspages_html/show.html.heextemplate — dead code, never wired up to a controller or route (PR #518)MediaBrowser‘s:viewerattr — the four-mode click handler collapsed to three modes (select_mode→admin→ modal viewer); pickers reachselect_modevia the toolbar’s Select button. The default click action is now the modal viewer, so callers that previously passedviewer={true}see no behaviour change. Callers that depended on the old picker-by-default (noadmin, noviewer→ click toggles selection) need to instruct users to click the toolbar’s Select button instead (PR #519)
PhoenixKit 1.7.106. Install or update: {:phoenix_kit, "~> 1.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.