MishkaCmsCore.Layouts.Nav (Mishka CMS Core v0.0.1)

Copy Markdown View Source

on_mount hook that records, for the admin chrome in MishkaCmsCore.Layouts: the current request path as @current_path (so the sidebar highlights the active item — updates on live navigation too), @notification_count (failed/retrying runtime jobs, shown as the topbar bell badge), and @current_user with its :permissions loaded. Attached to every admin page via MishkaCmsCore.ExtensionLiveView.

It also puts the page in the language its admin reads the dashboard in — MishkaCmsCore.Runtime.Languages.admin/1, chosen in the topbar's user menu — as Gettext's locale and as @admin_language, with the choices the menu offers as @admin_languages. The menu's Sign out is the site's sign-out page in the language its admin reads the site in, @sign_out_path (MishkaCmsCore.Runtime.Plugs.SiteLookupPlug.auth_address/3). And it names the page's @footer_credit: the name and address of the extension that owns the page, or nil on the core's own (MishkaCmsCore.Sidebar.credit/1).

The sidebar follows its settings live: the hook subscribes to MishkaCmsCore.Sidebar.changed/1 for the menu its viewer is shown and raises @sidebar_version, which MishkaCmsCore.Layouts.sidebar/1 redraws on. Changes that arrive together are drawn once.

Loading the permissions here rather than where they are used matters: MishkaCmsCore.Sidebar asks whether the viewer may see each nav entry, once per entry, through AccessPermissions.match?/3, which loads an unloaded actor — so without this the chrome would issue a query on every render.

Summary

Functions

on_mount(atom, params, session, socket)