openSUSE/open-build-service

View on GitHub
src/api/app/components/modal_component.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class ModalComponent < ApplicationComponent
  renders_one :header
  renders_one :footer

  def initialize(modal_id:, modal_button_data: {})
    super

    @modal_id = modal_id
    @modal_button_data = modal_button_data
  end

  def button
    return if @modal_button_data.empty?

    render(ButtonComponent.new(type: @modal_button_data[:type] || 'secondary',
                               text: @modal_button_data[:text],
                               icon_type: @modal_button_data[:icon],
                               button_data: { 'bs-toggle': 'modal',
                                              'bs-target': "##{@modal_id}-modal" }))
  end
end