forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.rb
More file actions
19 lines (16 loc) 路 707 Bytes
/
Copy pathcomponent.rb
File metadata and controls
19 lines (16 loc) 路 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true
class SolidusAdmin::Layout::Flashes::Alerts::Component < SolidusAdmin::BaseComponent
attr_reader :alerts
# Construct alert flashes like:
# flash[:alert] = { <alert_type>: { title: "", message: "" } }
# See +SolidusAdmin::UI::Alert::Component::SCHEMES+ for available alert types.
#
# If a string is passed to flash[:alert], we treat it is a body of the alert message and fall back to +danger+ type
# and default title (see +SolidusAdmin::UI::Alert::Component+).
def initialize(alerts:)
if alerts.is_a?(String)
alerts = { danger: { message: alerts } }
end
@alerts = alerts.slice(*SolidusAdmin::UI::Alert::Component::SCHEMES.keys)
end
end