Skip to content

Fix Tab.new! visible:false and add v84 newsletters migration - #421

Merged
ddon merged 2 commits into
BeamLabEU:devfrom
timujinne:dev
Mar 16, 2026
Merged

Fix Tab.new! visible:false and add v84 newsletters migration#421
ddon merged 2 commits into
BeamLabEU:devfrom
timujinne:dev

Conversation

@timujinne

Copy link
Copy Markdown
Contributor

Summary

  • Fix critical bug in Tab.new! where visible: false was always overridden to true
  • Add v84 migration to rename mailing_* tables to newsletters_*
  • Fix mix phoenix_kit.gen.migration task to generate proper versioned upgrades
  • Minor: add z-10 to auth page wrapper for correct stacking order

Changes

Bug Fix: Tab.new! ignores visible: false

get_attr/2 used || operator: false || nil = nil, causing visible: false to silently become true. This made all admin sidebar tabs appear regardless of their visible setting.

  • Fixed get_attr/2 to use Map.has_key? instead of ||
  • Fixed visible field assignment to use is_nil check
  • Fixed divider/1 with the same pattern
  • Added phoenix_kit.gen.migration to .dialyzer_ignore.exs

Migration V84: Rename mailing tables to newsletters

Databases that ran V79 before it was updated have phoenix_kit_mailing_* tables instead of phoenix_kit_newsletters_*. V84 idempotently renames them using IF EXISTS guards.

Fix mix phoenix_kit.gen.migration task

The generator now scans existing migrations to detect the current installed version and generates a proper PhoenixKit.Migrations.up(version: N) upgrade migration instead of creating initial tables.

Test Plan

  • Pre-commit checks passed (format, credo, dialyzer, docs)
  • Tab.new!(visible: false) now correctly returns visible: false
  • Admin sidebar shows only 3 newsletter tabs (Lists, Broadcasts, parent) instead of all 9
  • V84 migration runs idempotently on Decor 3D Print

get_attr/2 used || operator which converts false to nil (false || nil = nil).
This caused visible: false tabs to always resolve to the default true,
making all tabs appear in the admin sidebar regardless of their visibility.

Fix get_attr/2 to use Map.has_key? instead of || for key lookup.
Fix visible field assignment to use is_nil check instead of || true.
Fix divider/1 with the same pattern for visible field.
Add gen.migration task to dialyzer ignore for Mix unknown_function warnings.
Idempotently renames phoenix_kit_mailing_* tables to phoenix_kit_newsletters_*
for databases that ran the old V79 which created mailing_* table names.
Uses IF EXISTS guards so it is safe to run multiple times.

Update current_version to 84 in postgres.ex.
Add z-10 to auth page wrapper for proper stacking above footer.
@ddon
ddon merged commit 7d401e9 into BeamLabEU:dev Mar 16, 2026
6 checks passed
@timujinne

Copy link
Copy Markdown
Contributor Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants