PhoenixKit.Modules.Maintenance (phoenix_kit v1.6.16)
View SourceMaintenance Mode module for PhoenixKit.
This module provides a system-wide maintenance mode that shows a maintenance page to all non-admin users while allowing admins and owners to access the site normally.
Settings
The module uses the following settings stored in the database:
maintenance_module_enabled- Boolean to enable/disable the module settings page (default: false)maintenance_enabled- Boolean to enable/disable maintenance mode (default: false)maintenance_header- Main heading text (default: "Maintenance Mode")maintenance_subtext- Descriptive subtext (default: "We'll be back soon")
Usage
# Check if module is enabled (settings page accessible)
if PhoenixKit.Modules.Maintenance.module_enabled?() do
# Show settings page
end
# Check if maintenance mode is enabled
if PhoenixKit.Modules.Maintenance.enabled?() do
# Show maintenance page to non-admin users
end
# Enable module (makes settings page accessible)
PhoenixKit.Modules.Maintenance.enable_module()
# Enable maintenance mode (shows maintenance page to users)
PhoenixKit.Modules.Maintenance.enable_system()
# Get module configuration
config = PhoenixKit.Modules.Maintenance.get_config()
# => %{module_enabled: true, enabled: true, header: "...", subtext: "..."}
Summary
Functions
Disables the Maintenance module (hides settings page).
Disables the Maintenance mode.
Enables the Maintenance module (makes settings page accessible).
Enables the Maintenance mode.
Checks if Maintenance mode is enabled.
Gets the configuration for the Maintenance module.
Gets the header text for the maintenance page.
Gets the subtext for the maintenance page.
Checks if the Maintenance module is enabled (settings page accessible).
Updates the header text for the maintenance page.
Updates the subtext for the maintenance page.
Functions
Disables the Maintenance module (hides settings page).
Also automatically disables maintenance mode to prevent users from being locked out.
Disables the Maintenance mode.
When disabled, all users can access the site normally.
Enables the Maintenance module (makes settings page accessible).
Enables the Maintenance mode.
When enabled, all non-admin users will see the maintenance page.
Checks if Maintenance mode is enabled.
Examples
iex> PhoenixKit.Modules.Maintenance.enabled?()
false
Gets the configuration for the Maintenance module.
Returns a map with:
module_enabled- Boolean indicating if module settings page is accessibleenabled- Boolean indicating if maintenance mode is enabledheader- Main heading textsubtext- Descriptive subtext
Examples
iex> PhoenixKit.Modules.Maintenance.get_config()
%{
module_enabled: false,
enabled: false,
header: "Maintenance Mode",
subtext: "We'll be back soon..."
}
Gets the header text for the maintenance page.
Examples
iex> PhoenixKit.Modules.Maintenance.get_header()
"Maintenance Mode"
Gets the subtext for the maintenance page.
Examples
iex> PhoenixKit.Modules.Maintenance.get_subtext()
"We'll be back soon..."
Checks if the Maintenance module is enabled (settings page accessible).
Examples
iex> PhoenixKit.Modules.Maintenance.module_enabled?()
false
Updates the header text for the maintenance page.
Updates the subtext for the maintenance page.