Class: Panda::Core::Admin::DeleteButtonComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/delete_button_component.rb

Overview

Renders a right-aligned delete button using button_to with DELETE method and a Turbo confirmation dialog.

Lives in panda-core because every admin app needs destructive action buttons, and the existing ButtonComponent renders <a> tags rather than <form>-based button_to elements required for safe DELETE requests (CSRF + method override).

Examples:

Basic usage

render Panda::Core::Admin::DeleteButtonComponent.new(
  text: "Delete Person",
  path: person_path(@person),
  confirm: "Are you sure you want to delete this person?"
)

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, path:, confirm:, **attrs) ⇒ DeleteButtonComponent

Returns a new instance of DeleteButtonComponent.



22
23
24
25
26
27
# File 'app/components/panda/core/admin/delete_button_component.rb', line 22

def initialize(text:, path:, confirm:, **attrs)
  @text = text
  @path = path
  @confirm = confirm
  super(**attrs)
end

Instance Attribute Details

#confirmObject (readonly)

Returns the value of attribute confirm.



20
21
22
# File 'app/components/panda/core/admin/delete_button_component.rb', line 20

def confirm
  @confirm
end

#pathObject (readonly)

Returns the value of attribute path.



20
21
22
# File 'app/components/panda/core/admin/delete_button_component.rb', line 20

def path
  @path
end

#textObject (readonly)

Returns the value of attribute text.



20
21
22
# File 'app/components/panda/core/admin/delete_button_component.rb', line 20

def text
  @text
end