Configuration
Configuration
You can configure LooposUi using an initializer file, usually located in config/initializers/loopos_ui.rb.
Example:
# config/initializers/loopos_ui.rbLooposUi.configure do |config| config.app_type = "..." # ... config.sidebar do |sidebar_config| sidebar_config.items = [] endendYou have the following options to configure:
app_type- The type of the application. Should be one of "core", "manager", "hubs", "handling", "impact", "submission" or "validation". Currently only used to decide what is the primary color.auto_breadcrumbs- Automatically generate breadcrumbs based on the current path. Default istrue.errors_controller- The controller to use for error pages. Default is the providedLooposUi::ErrorsController.sidebar- The sidebar configuration. You can set the items directly or use thesidebarblock to set the items. Check the sidebar component documentation on how to do so.image_default_accept_formats- The default accepted formats for images for the V2::Image component. Default is[:jpeg, :png, :webp].enable_loading_skeletons- Enable loading skeletons forMainLayoutcomponent. Default istrue.enable_main_layout_background- Enable the background for theMainLayoutcomponent. Default isfalse.infer_background_from_app_type- Infer the background color from the app type. Default istrue.logger- The logger to use. Default isRails.loggeror a new logger that outputs to stdout ifRails.loggeris not available.base_controller_class- The base class for the ApplicationController for all LooposUi controllers.
Errors
The default errors controller will match the following routes:
404- Not Found422- Unprocessable Entity500- Internal Server Error
It will try to inherit form your applications "::ApplicationController" if present, otherwise "ActionController::Base".
If the request was a turbo request (or turbo stream), it will stream the Error message, replace the contents of "lui-main-layout", and disable turbo.
For a normal request, it will render it's own AppLayout and sidebar. Note that while the sidebar is already configured, the header cannot be rendered from whitin LooposUi.
In this scenario, for consistency, the sidebar will also not be rendered.
If you want the turbo request and normal request to behave the same, you can override the errors_controller configuration to use your own controller.
A simple implementation would be:
# config/initializers/loopos_ui.rbLooposUi.configure do |config| # ... config.errors_controller = "MyErrorsController" # ...end# app/controllers/my_errors_controller.rbclass MyErrorsController < ApplicationController include LooposUi::ErrorsControllerConcern def header render_to_string(partial: "layouts/header") endendIf you want to some action before rendering the page, you can use a before_action in your controller.
You'll have access to @exeption and @status_code.