Class: Primer::OpenProject::DangerDialog
- Defined in:
- app/components/primer/open_project/danger_dialog.rb,
app/components/primer/open_project/danger_dialog/form_wrapper.rb,
app/components/primer/open_project/danger_dialog/confirmation_check_box.rb
Overview
A pre-configured dialog for destructive/“potentially dangerous” actions
Defined Under Namespace
Classes: ConfirmationCheckBox, FormWrapper
Constant Summary
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Attribute Summary collapse
-
#dialog_id ⇒ Object
readonly
The dialog’s ID value.
Instance Method Summary collapse
-
#initialize(form_arguments: {}, id: self.class.generate_id, title:, confirm_button_text: nil, cancel_button_text: nil, **system_arguments) ⇒ DangerDialog
constructor
A new instance of DangerDialog.
- #render? ⇒ Boolean
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(form_arguments: {}, id: self.class.generate_id, title:, confirm_button_text: nil, cancel_button_text: nil, **system_arguments) ⇒ DangerDialog
Returns a new instance of DangerDialog.
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 |
# File 'app/components/primer/open_project/danger_dialog.rb', line 71 def initialize( form_arguments: {}, id: self.class.generate_id, title:, confirm_button_text: nil, cancel_button_text: nil, **system_arguments ) @check_box_name = form_arguments.delete(:name) || "confirm_dangerous_action" @form_wrapper = FormWrapper.new(**form_arguments) @dialog_id = id.to_s @confirm_button_text = @cancel_button_text = deny_single_argument(:role, "`role` will always be set to `alertdialog`.", **system_arguments) @system_arguments = system_arguments @system_arguments[:id] = @dialog_id @system_arguments[:classes] = class_names( system_arguments[:classes], "DangerDialog" ) @system_arguments[:role] = "alertdialog" @dialog = Primer::Alpha::Dialog.new(title: title, subtitle: nil, visually_hide_title: true, **@system_arguments) end |
Instance Attribute Details
#dialog_id ⇒ Object (readonly)
The dialog’s ID value.
11 12 13 |
# File 'app/components/primer/open_project/danger_dialog.rb', line 11 def dialog_id @dialog_id end |
Instance Method Details
#render? ⇒ Boolean
103 104 105 106 107 |
# File 'app/components/primer/open_project/danger_dialog.rb', line 103 def render? raise ArgumentError, "DangerDialog requires a confirmation_message" unless end |