Class: SolidusAdmin::Configuration
- Inherits:
-
Spree::Preferences::Configuration
- Object
- Spree::Preferences::Configuration
- SolidusAdmin::Configuration
- Defined in:
- lib/solidus_admin/configuration.rb
Overview
Configuration for the admin interface.
Ensure requiring this file after the Rails application has been created, as some defaults depend on the application context.
Constant Summary collapse
- ENGINE_ROOT =
File.("#{__dir__}/../..")
Instance Attribute Summary collapse
-
#dark_theme ⇒ String
Default admin theme name.
-
#enable_alpha_features?= ⇒ Boolean
Determines whether alpha features are enabled or disabled in the application.
-
#low_stock_value ⇒ Integer
The low stock value determines the threshold at which products are considered low in stock.
-
#theme ⇒ String
Default admin theme name.
-
#themes ⇒ Hash
A hash containing the themes that are available for the admin panel.
Instance Method Summary collapse
- #components ⇒ Object
- #import_menu_items_from_backend! ⇒ Object
-
#menu_items ⇒ Array<Hash>
Gives access to the main navigation configuration.
- #storefront_product_path(product) ⇒ Object
- #theme_path(user_theme) ⇒ Object
Instance Attribute Details
#dark_theme ⇒ String
Returns Default admin theme name.
213 |
# File 'lib/solidus_admin/configuration.rb', line 213 preference :dark_theme, :string, default: 'solidus_dark' |
#enable_alpha_features?=(value) ⇒ Boolean
Returns Determines whether alpha features are enabled or disabled in the application. Setting this to ‘true` enables access to alpha stage features that might still be in testing or development. Use with caution, as these features may not be fully stable or complete. Default: false.
47 |
# File 'lib/solidus_admin/configuration.rb', line 47 preference :enable_alpha_features, :boolean, default: false |
#low_stock_value ⇒ Integer
Returns The low stock value determines the threshold at which products are considered low in stock. Products with a count_on_hand less than or equal to this value will be considered low in stock. Default: 10.
40 |
# File 'lib/solidus_admin/configuration.rb', line 40 preference :low_stock_value, :integer, default: 10 |
#theme ⇒ String
Returns Default admin theme name.
209 |
# File 'lib/solidus_admin/configuration.rb', line 209 preference :theme, :string, default: 'solidus' |
#themes ⇒ Hash
Returns A hash containing the themes that are available for the admin panel.
201 202 203 204 205 |
# File 'lib/solidus_admin/configuration.rb', line 201 preference :themes, :hash, default: { solidus: 'solidus_admin/application', solidus_dark: 'solidus_admin/dark', solidus_dimmed: 'solidus_admin/dimmed', } |
Instance Method Details
#components ⇒ Object
182 183 184 |
# File 'lib/solidus_admin/configuration.rb', line 182 def components @components ||= ComponentRegistry.new end |
#import_menu_items_from_backend! ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/solidus_admin/configuration.rb', line 137 def = ->(item, index) do route = if item.url.is_a?(Symbol) -> { solidus_admin.public_send(item.url) } elsif item.url.is_a?(String) -> { item.url } elsif item.url.is_a?(Proc) item.url elsif item.url.nil? -> { spree.public_send(:"admin_#{item.label}_path") } else raise ArgumentError, "Unknown url type #{item.url.class}" end match_path = case item.match_path when Regexp then -> { _1 =~ item.match_path } when Proc then item.match_path when String then -> { _1.start_with?("/admin#{item.match_path}") } when nil then -> { _1.start_with?(route.call) } else raise ArgumentError, "Unknown match_path type #{item.match_path.class}" end icon = case item.icon when /^ri-/ item.icon.delete_prefix("ri-") when String 'record-circle-line' # fallback on a generic icon end { position: index, key: item.label, icon:, route:, children: item.children.map.with_index(&), match_path:, } end @menu_items = Spree::Backend::Config..map.with_index(&) end |
#menu_items ⇒ Array<Hash>
Gives access to the main navigation configuration
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/solidus_admin/configuration.rb', line 71 def @menu_items ||= [ { key: "orders", route: -> { spree.admin_orders_path }, icon: "inbox-line", position: 10 }, { key: "products", route: :products_path, icon: "price-tag-3-line", position: 20, children: [ { key: "products", route: -> { solidus_admin.products_path }, match_path: -> { _1.start_with?("/admin/products/") }, position: 0 }, { key: "option_types", route: -> { spree.admin_option_types_path }, position: 10 }, { key: "property_types", route: -> { spree.admin_properties_path }, position: 20 }, { key: "taxonomies", route: -> { spree.admin_taxonomies_path }, position: 30 }, { key: "taxons", route: -> { spree.admin_taxons_path }, position: 40 } ] }, { key: "stock", route: -> { spree.admin_stock_items_path }, icon: "stack-line", position: 40 }, { key: "users", route: -> { spree.admin_users_path }, icon: "user-line", position: 50 }, { key: "settings", route: -> { spree.admin_stores_path }, icon: "settings-line", position: 60, } ] end |
#storefront_product_path(product) ⇒ Object
55 56 57 |
# File 'lib/solidus_admin/configuration.rb', line 55 def storefront_product_path(product) storefront_product_path_proc.call(product) end |
#theme_path(user_theme) ⇒ Object
215 216 217 |
# File 'lib/solidus_admin/configuration.rb', line 215 def theme_path(user_theme) themes.fetch(user_theme&.to_sym, themes[theme.to_sym]) end |