Sha256: eb2ec05b29f022e933ac94b4228bd80b2f28efb843225c039ed8aad72b145100

Contents?: true

Size: 1.19 KB

Versions: 49

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Primer
  module OpenProject
    class PageHeader
      # A Helper class to create ActionMenus inside the PageHeader action slot
      # Do not use standalone
      class Dialog < Primer::Component
        status :open_project

        # @param dialog_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Alpha::Dialog) %>.
        # @param button_arguments [Hash] The arguments accepted by <%= link_to_component(Primer::Beta::Button) %> or <%= link_to_component(Primer::Beta::IconButton) %>, depending on the value of the `icon:` argument.
        def initialize(dialog_arguments: {}, button_arguments: {})
          callback = button_arguments.delete(:button_block)

          @dialog = Primer::Alpha::Dialog.new(**dialog_arguments)
          @button = @dialog.with_show_button(**button_arguments) do |button|
            callback&.call(button)
          end
        end

        def render_in(view_context, &block)
          super(view_context) do
            block&.call(@dialog, @button)
          end
        end

        def before_render
          content
        end

        def call
          render(@dialog)
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.33.1 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.33.0 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.32.1 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.32.0 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.29.1 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.29.0 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.28.1 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.28.0 app/components/primer/open_project/page_header/dialog.rb
openproject-primer_view_components-0.27.0 app/components/primer/open_project/page_header/dialog.rb