Class: Primer::OpenProject::DangerConfirmationDialog
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::OpenProject::DangerConfirmationDialog
- Defined in:
- app/components/primer/open_project/danger_confirmation_dialog.rb,
app/components/primer/open_project/danger_confirmation_dialog/form_wrapper.rb,
app/components/primer/open_project/danger_confirmation_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, **system_arguments) ⇒ DangerConfirmationDialog
constructor
to reuse an existing Rails form, or ‘action:` if you prefer the component to render the form tag itself.
- #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, **system_arguments) ⇒ DangerConfirmationDialog
to reuse an existing Rails form, or ‘action:` if you prefer the component to render the form tag itself. `builder:` should be an instance of `ActionView::Helpers::FormBuilder`, which is created by the standard Rails `#form_with` and `#form_for` helpers. The `name:` option is the desired name of the field that will be included in the params sent to the server on form submission.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/components/primer/open_project/danger_confirmation_dialog.rb', line 67 def initialize( form_arguments: {}, id: self.class.generate_id, **system_arguments ) @check_box_name = form_arguments.delete(:name) || "confirm_dangerous_action" @form_wrapper = FormWrapper.new(**form_arguments) @dialog_id = id.to_s @system_arguments = system_arguments @system_arguments[:id] = @dialog_id @system_arguments[:classes] = class_names( system_arguments[:classes], "DangerConfirmationDialog" ) @dialog = Primer::Alpha::Dialog.new(title: @system_arguments[: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_confirmation_dialog.rb', line 11 def dialog_id @dialog_id end |
Instance Method Details
#render? ⇒ Boolean
90 91 92 93 94 95 |
# File 'app/components/primer/open_project/danger_confirmation_dialog.rb', line 90 def render? raise ArgumentError, "DangerConfirmationDialog requires a confirmation_message" unless raise ArgumentError, "DangerConfirmationDialog requires a confirmation_check_box" unless confirmation_check_box? && confirmation_check_box? end |