slack-ruby-block-kit 0.8.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.deepsource.toml +15 -0
- data/.github/workflows/ci.yml +33 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +23 -1
- data/.rubocop_todo.yml +10 -0
- data/CHANGELOG.md +93 -0
- data/Gemfile +14 -1
- data/README.md +3 -1
- data/lib/slack/block_kit.rb +46 -2
- data/lib/slack/block_kit/blocks.rb +12 -0
- data/lib/slack/block_kit/composition/confirmation_dialog.rb +16 -0
- data/lib/slack/block_kit/composition/option.rb +6 -1
- data/lib/slack/block_kit/composition/option_group.rb +2 -2
- data/lib/slack/block_kit/element/button.rb +3 -11
- data/lib/slack/block_kit/element/channels_select.rb +3 -11
- data/lib/slack/block_kit/element/checkboxes.rb +53 -0
- data/lib/slack/block_kit/element/conversations_select.rb +3 -11
- data/lib/slack/block_kit/element/date_picker.rb +3 -9
- data/lib/slack/block_kit/element/external_select.rb +3 -12
- data/lib/slack/block_kit/element/multi_channels_select.rb +5 -14
- data/lib/slack/block_kit/element/multi_conversations_select.rb +5 -14
- data/lib/slack/block_kit/element/multi_external_select.rb +5 -14
- data/lib/slack/block_kit/element/multi_static_select.rb +18 -25
- data/lib/slack/block_kit/element/multi_users_select.rb +5 -14
- data/lib/slack/block_kit/element/overflow_menu.rb +4 -11
- data/lib/slack/block_kit/element/radio_buttons.rb +53 -0
- data/lib/slack/block_kit/element/static_select.rb +20 -25
- data/lib/slack/block_kit/element/timepicker.rb +49 -0
- data/lib/slack/block_kit/element/users_select.rb +3 -11
- data/lib/slack/block_kit/layout/header.rb +29 -0
- data/lib/slack/block_kit/layout/image.rb +1 -4
- data/lib/slack/block_kit/layout/input.rb +198 -3
- data/lib/slack/block_kit/layout/section.rb +21 -1
- data/lib/slack/block_kit/version.rb +7 -0
- data/lib/slack/surfaces/home.rb +35 -0
- data/lib/slack/surfaces/message.rb +34 -0
- data/lib/slack/surfaces/modal.rb +76 -0
- data/slack-ruby-block-kit.gemspec +1 -18
- metadata +20 -138
- data/.circleci/config.yml +0 -49
- data/Gemfile.lock +0 -74
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0f8259eb752347ee6abf3210ab4b0f0c44ee962d238e3034185735c4762a8063
         | 
| 4 | 
            +
              data.tar.gz: 7649061472dff64eddb8704311ee17afbd0c29d07ac6d101982725fbf55fbd35
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d9ab666ea3cca8ca7ade809cb1fc3881e534d5a9ffb1651f2de2d1ddc30266e6d44ac1a89947b1cba62d35ba59e292479ec33e0098fe50d1b6d7a1d1e77a0184
         | 
| 7 | 
            +
              data.tar.gz: 709140300213ec4afef7c43665e56dd9ccfe673118284d2cb5efbe5a03c87ee9d42fed94e6c8277cc49ffec74d5232108d1b0555c53dcc7e23cc77f6cc70413d
         | 
    
        data/.deepsource.toml
    ADDED
    
    
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            name: Test & Lint
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            on:
         | 
| 4 | 
            +
              push:
         | 
| 5 | 
            +
                branches: [ master ]
         | 
| 6 | 
            +
              pull_request:
         | 
| 7 | 
            +
                branches: [ master ]
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            env:
         | 
| 10 | 
            +
              DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            jobs:
         | 
| 13 | 
            +
              build:
         | 
| 14 | 
            +
                runs-on: ubuntu-latest
         | 
| 15 | 
            +
                continue-on-error: ${{ matrix.experimental }}
         | 
| 16 | 
            +
                strategy:
         | 
| 17 | 
            +
                  fail-fast: false
         | 
| 18 | 
            +
                  matrix:
         | 
| 19 | 
            +
                    ruby: [ '2.6', '2.7', '3.0' ]
         | 
| 20 | 
            +
                    experimental: [ false ]
         | 
| 21 | 
            +
                name: Ruby ${{ matrix.ruby }}
         | 
| 22 | 
            +
                steps:
         | 
| 23 | 
            +
                  - uses: actions/checkout@v2
         | 
| 24 | 
            +
                  - uses: ruby/setup-ruby@v1
         | 
| 25 | 
            +
                    with:
         | 
| 26 | 
            +
                      ruby-version: ${{ matrix.ruby }}
         | 
| 27 | 
            +
                  - run: curl https://deepsource.io/cli | sh
         | 
| 28 | 
            +
                  - run: gem install bundler:2.1.4
         | 
| 29 | 
            +
                  - run: bundle install
         | 
| 30 | 
            +
                  - run: bundle exec rubocop
         | 
| 31 | 
            +
                  - run: bundle exec rspec --format progress
         | 
| 32 | 
            +
                  - run: ./bin/deepsource report --analyzer test-coverage --key ruby --value-file ./coverage/.resultset.json
         | 
| 33 | 
            +
                    if: (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository) # don't run on forks which don't have access to DEEPSOURCE_DSN
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -1,8 +1,12 @@ | |
| 1 | 
            -
            require: | 
| 1 | 
            +
            require:
         | 
| 2 | 
            +
              - rubocop-rake
         | 
| 3 | 
            +
              - rubocop-rspec
         | 
| 4 | 
            +
             | 
| 2 5 | 
             
            inherit_from: .rubocop_todo.yml
         | 
| 3 6 |  | 
| 4 7 | 
             
            AllCops:
         | 
| 5 8 | 
             
              TargetRubyVersion: 2.5.3
         | 
| 9 | 
            +
              NewCops: enable
         | 
| 6 10 |  | 
| 7 11 | 
             
            Layout/LineLength:
         | 
| 8 12 | 
             
              Max: 120
         | 
| @@ -53,3 +57,21 @@ Style/HashTransformValues: | |
| 53 57 |  | 
| 54 58 | 
             
            Style/SlicingWithRange:
         | 
| 55 59 | 
             
              Enabled: true
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            Lint/MixedRegexpCaptureTypes:
         | 
| 62 | 
            +
              Enabled: true
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            Style/RedundantFetchBlock:
         | 
| 65 | 
            +
              Enabled: true
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            Style/RedundantRegexpCharacterClass:
         | 
| 68 | 
            +
              Enabled: true
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            Style/RedundantRegexpEscape:
         | 
| 71 | 
            +
              Enabled: true
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            RSpec/MultipleMemoizedHelpers:
         | 
| 74 | 
            +
              Max: 10
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            RSpec/NestedGroups:
         | 
| 77 | 
            +
              Max: 4
         | 
    
        data/.rubocop_todo.yml
    CHANGED
    
    | @@ -17,6 +17,12 @@ Metrics/BlockLength: | |
| 17 17 | 
             
            Metrics/ClassLength:
         | 
| 18 18 | 
             
              Max: 117
         | 
| 19 19 |  | 
| 20 | 
            +
            # Offense count: 1
         | 
| 21 | 
            +
            # Configuration parameters: IgnoredMethods.
         | 
| 22 | 
            +
            Metrics/CyclomaticComplexity:
         | 
| 23 | 
            +
              Exclude:
         | 
| 24 | 
            +
                - 'lib/slack/block_kit/element/multi_static_select.rb'
         | 
| 25 | 
            +
             | 
| 20 26 | 
             
            # Offense count: 5
         | 
| 21 27 | 
             
            # Configuration parameters: Max.
         | 
| 22 28 | 
             
            RSpec/ExampleLength:
         | 
| @@ -24,6 +30,10 @@ RSpec/ExampleLength: | |
| 24 30 | 
             
                - 'spec/lib/slack/block_kit/composition/confirmation_dialog_spec.rb'
         | 
| 25 31 | 
             
                - 'spec/lib/slack/block_kit/composition/option_group_spec.rb'
         | 
| 26 32 | 
             
                - 'spec/lib/slack/block_kit/composition/option_spec.rb'
         | 
| 33 | 
            +
                - 'spec/lib/slack/block_kit/element/checkboxes_spec.rb'
         | 
| 34 | 
            +
                - 'spec/lib/slack/block_kit/element/radio_buttons_spec.rb'
         | 
| 35 | 
            +
                - 'spec/lib/slack/block_kit/composition/option_spec.rb'
         | 
| 36 | 
            +
                - 'spec/lib/slack/block_kit/element/multi_static_select_spec.rb'
         | 
| 27 37 |  | 
| 28 38 | 
             
            # Offense count: 4
         | 
| 29 39 | 
             
            Style/Documentation:
         | 
    
        data/CHANGELOG.md
    ADDED
    
    | @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            # Changelog
         | 
| 2 | 
            +
            All notable changes to this project will be documented in this file.
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
         | 
| 5 | 
            +
            and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## [Unreleased]
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### Added
         | 
| 10 | 
            +
            - N/A
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ### Changed
         | 
| 13 | 
            +
            - N/A
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ### Deprecated
         | 
| 16 | 
            +
            - N/A
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            ### Removed
         | 
| 19 | 
            +
            - N/A
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ### Fixed
         | 
| 22 | 
            +
            - N/A
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            ### Security
         | 
| 25 | 
            +
            - N/A
         | 
| 26 | 
            +
             | 
| 27 | 
            +
             | 
| 28 | 
            +
            ---
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            ## [0.13.0] - 2020-12-29
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            ### Added
         | 
| 33 | 
            +
            - Ruby3 Support
         | 
| 34 | 
            +
            - `Slack::BlockKit::Element::Timepicker` (#72)
         | 
| 35 | 
            +
            - Add `input` to `Slack::BlockKit::Blocks` and elements to `Slack::BlockKit::Layout::Input` (#73)
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            ### Changed
         | 
| 38 | 
            +
            - Development dependencies now managed by bundler via Gemfile, rather than in gemspec
         | 
| 39 | 
            +
             | 
| 40 | 
            +
             | 
| 41 | 
            +
            ---
         | 
| 42 | 
            +
             | 
| 43 | 
            +
             | 
| 44 | 
            +
            ## [0.12.0] - 2020-10-06
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            ### Added
         | 
| 47 | 
            +
            - `Slack::BlockKit::Layout::Header` (#57)
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            ### Removed
         | 
| 50 | 
            +
            - `Slack::BlockKit::Element::Checkboxes#initial`, use the `initial:` keyword on `#option`
         | 
| 51 | 
            +
            - `Slack::BlockKit::Element::MultiStaticSelect#initial`, use the `initial:` keyword on `#option`
         | 
| 52 | 
            +
            - `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
         | 
| 53 | 
            +
             | 
| 54 | 
            +
             | 
| 55 | 
            +
            ---
         | 
| 56 | 
            +
             | 
| 57 | 
            +
             | 
| 58 | 
            +
            ## [0.11.0] - 2020-10-03
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            ### Added
         | 
| 61 | 
            +
            - Add `Slack::BlockKit::Element::RadioButtons` (#52 by @caalberts)
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            ### Changed
         | 
| 64 | 
            +
            - Internal refactoring of `#confirmation_dialog` methods into a shared `Confirmable` module. (#48)
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            ### Fixed
         | 
| 67 | 
            +
            - Ruby2.7 kwarg deprecation warnings
         | 
| 68 | 
            +
             | 
| 69 | 
            +
             | 
| 70 | 
            +
            ---
         | 
| 71 | 
            +
             | 
| 72 | 
            +
             | 
| 73 | 
            +
            ## [0.10.0] - 2020-09-11
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            ### Added
         | 
| 76 | 
            +
            - Add `Slack::BlockKit::Element::Checkboxes` (#44 by @caalberts)
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            ### Fixed
         | 
| 79 | 
            +
            - Fixed initial options in multi select blocks (#46 by @caalberts)
         | 
| 80 | 
            +
             | 
| 81 | 
            +
             | 
| 82 | 
            +
            ---
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            See [releases] for previous changes.
         | 
| 85 | 
            +
             | 
| 86 | 
            +
             | 
| 87 | 
            +
            [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...HEAD
         | 
| 88 | 
            +
            [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
         | 
| 89 | 
            +
            [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
         | 
| 90 | 
            +
            [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
         | 
| 91 | 
            +
            [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            [releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
         | 
    
        data/Gemfile
    CHANGED
    
    | @@ -2,5 +2,18 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            source 'https://rubygems.org'
         | 
| 4 4 |  | 
| 5 | 
            -
            # Specify your gem's dependencies in tenios-rb.gemspec
         | 
| 6 5 | 
             
            gemspec
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            gem 'dotenv', '~> 2'
         | 
| 8 | 
            +
            gem 'faraday', '~> 1'
         | 
| 9 | 
            +
            gem 'pry', '~> 0.13'
         | 
| 10 | 
            +
            gem 'rake', '~> 13'
         | 
| 11 | 
            +
            gem 'rspec', '~> 3'
         | 
| 12 | 
            +
            gem 'rspec_junit_formatter', '~> 0.4'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            gem 'rubocop', '~> 1', require: false
         | 
| 15 | 
            +
            gem 'rubocop-rake', '~> 0.5', require: false
         | 
| 16 | 
            +
            gem 'rubocop-rspec', '~> 2', require: false
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            gem 'codecov', '~> 0.2', require: false
         | 
| 19 | 
            +
            gem 'simplecov', '~> 0.20', require: false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 | 
            -
            [](https://circleci.com/gh/CGA1123/slack-ruby-block-kit/tree/master)
         | 
| 2 1 | 
             
            [](https://badge.fury.io/rb/slack-ruby-block-kit)
         | 
| 2 | 
            +
            [](https://codecov.io/gh/CGA1123/slack-ruby-block-kit)
         | 
| 3 | 
            +
            [](https://deepsource.io/gh/CGA1123/slack-ruby-block-kit/?ref=repository-badge)
         | 
| 4 | 
            +
            [](https://deepsource.io/gh/CGA1123/slack-ruby-block-kit/?ref=repository-badge)
         | 
| 3 5 |  | 
| 4 6 | 
             
            # Slack::BlockKit
         | 
| 5 7 |  | 
    
        data/lib/slack/block_kit.rb
    CHANGED
    
    | @@ -3,15 +3,16 @@ | |
| 3 3 | 
             
            module Slack
         | 
| 4 4 | 
             
              module BlockKit
         | 
| 5 5 | 
             
                module Composition; end
         | 
| 6 | 
            +
             | 
| 6 7 | 
             
                module Element; end
         | 
| 7 | 
            -
                module Layout; end
         | 
| 8 8 |  | 
| 9 | 
            -
                 | 
| 9 | 
            +
                module Layout; end
         | 
| 10 10 |  | 
| 11 11 | 
             
                Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
         | 
| 12 12 | 
             
                Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
         | 
| 13 13 | 
             
                Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].sort.each { |file| require file }
         | 
| 14 14 | 
             
                Dir[File.join(__dir__, 'block_kit', '*.rb')].sort.each { |file| require file }
         | 
| 15 | 
            +
                Dir[File.join(__dir__, 'surfaces', '*.rb')].sort.each { |file| require file }
         | 
| 15 16 |  | 
| 16 17 | 
             
                module_function
         | 
| 17 18 |  | 
| @@ -22,5 +23,48 @@ module Slack | |
| 22 23 |  | 
| 23 24 | 
             
                  blocks
         | 
| 24 25 | 
             
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def home(blocks: nil,
         | 
| 28 | 
            +
                         private_metadata: nil, callback_id: nil, external_id: nil)
         | 
| 29 | 
            +
                  home_surface = Slack::Surfaces::Home.new(blocks: blocks,
         | 
| 30 | 
            +
                                                           private_metadata: private_metadata,
         | 
| 31 | 
            +
                                                           callback_id: callback_id,
         | 
| 32 | 
            +
                                                           external_id: external_id)
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  yield(home_surface) if block_given?
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  home_surface
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def modal(title: nil,
         | 
| 40 | 
            +
                          blocks: nil,
         | 
| 41 | 
            +
                          private_metadata: nil, callback_id: nil, external_id: nil,
         | 
| 42 | 
            +
                          clear_on_close: nil, notify_on_close: nil)
         | 
| 43 | 
            +
                  modal_surface = Slack::Surfaces::Modal.new(title: title,
         | 
| 44 | 
            +
                                                             blocks: blocks,
         | 
| 45 | 
            +
                                                             private_metadata: private_metadata,
         | 
| 46 | 
            +
                                                             callback_id: callback_id,
         | 
| 47 | 
            +
                                                             external_id: external_id,
         | 
| 48 | 
            +
                                                             clear_on_close: clear_on_close,
         | 
| 49 | 
            +
                                                             notify_on_close: notify_on_close)
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  yield(modal_surface) if block_given?
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  modal_surface
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def message(blocks: nil, channel: nil, thread_ts: nil, as_user: nil, text: nil)
         | 
| 57 | 
            +
                  message_surface = Slack::Surfaces::Message.new(
         | 
| 58 | 
            +
                    blocks: blocks,
         | 
| 59 | 
            +
                    channel: channel,
         | 
| 60 | 
            +
                    thread_ts: thread_ts,
         | 
| 61 | 
            +
                    text: text,
         | 
| 62 | 
            +
                    as_user: as_user
         | 
| 63 | 
            +
                  )
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  yield(message_surface) if block_given?
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  message_surface
         | 
| 68 | 
            +
                end
         | 
| 25 69 | 
             
              end
         | 
| 26 70 | 
             
            end
         | 
| @@ -57,6 +57,18 @@ module Slack | |
| 57 57 | 
             
                    append(block)
         | 
| 58 58 | 
             
                  end
         | 
| 59 59 |  | 
| 60 | 
            +
                  def input(label:, hint: nil, block_id: nil)
         | 
| 61 | 
            +
                    block = Layout::Input.new(
         | 
| 62 | 
            +
                      label: label,
         | 
| 63 | 
            +
                      hint: hint,
         | 
| 64 | 
            +
                      block_id: block_id
         | 
| 65 | 
            +
                    )
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                    yield(block) if block_given?
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                    append(block)
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
             | 
| 60 72 | 
             
                  def append(block)
         | 
| 61 73 | 
             
                    @blocks << block
         | 
| 62 74 |  | 
| @@ -9,6 +9,22 @@ module Slack | |
| 9 9 | 
             
                  #
         | 
| 10 10 | 
             
                  # https://api.slack.com/reference/messaging/composition-objects#confirm
         | 
| 11 11 | 
             
                  class ConfirmationDialog
         | 
| 12 | 
            +
                    # {Confirmable} contains the common behaviour for configuring a
         | 
| 13 | 
            +
                    # {ConfirmationDialog}
         | 
| 14 | 
            +
                    module Confirmable
         | 
| 15 | 
            +
                      def self.included(klass)
         | 
| 16 | 
            +
                        klass.attr_accessor :confirm
         | 
| 17 | 
            +
                      end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                      def confirmation_dialog
         | 
| 20 | 
            +
                        self.confirm = Composition::ConfirmationDialog.new
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                        yield(confirm) if block_given?
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                        self
         | 
| 25 | 
            +
                      end
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
             | 
| 12 28 | 
             
                    def initialize
         | 
| 13 29 | 
             
                      @title, @confirm, @text, @style = nil
         | 
| 14 30 | 
             
                    end
         | 
| @@ -8,11 +8,16 @@ module Slack | |
| 8 8 | 
             
                  # https://api.slack.com/reference/messaging/composition-objects#option
         | 
| 9 9 | 
             
                  # https://api.slack.com/reference/messaging/block-elements#select
         | 
| 10 10 | 
             
                  class Option
         | 
| 11 | 
            -
                    def initialize(value:, text:, emoji: nil, description: nil, url: nil)
         | 
| 11 | 
            +
                    def initialize(value:, text:, initial: false, emoji: nil, description: nil, url: nil)
         | 
| 12 12 | 
             
                      @text = PlainText.new(text: text, emoji: emoji)
         | 
| 13 13 | 
             
                      @value = value
         | 
| 14 14 | 
             
                      @description = description && PlainText.new(text: description, emoji: emoji)
         | 
| 15 15 | 
             
                      @url = url
         | 
| 16 | 
            +
                      @initial = initial
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    def initial?
         | 
| 20 | 
            +
                      !!@initial
         | 
| 16 21 | 
             
                    end
         | 
| 17 22 |  | 
| 18 23 | 
             
                    def as_json(*)
         | 
| @@ -17,8 +17,8 @@ module Slack | |
| 17 17 | 
             
                      yield(self) if block_given?
         | 
| 18 18 | 
             
                    end
         | 
| 19 19 |  | 
| 20 | 
            -
                    def option(text:, value:, emoji: nil)
         | 
| 21 | 
            -
                      @options << Option.new(text: text, value: value, emoji: emoji)
         | 
| 20 | 
            +
                    def option(text:, value:, emoji: nil, initial: false)
         | 
| 21 | 
            +
                      @options << Option.new(text: text, value: value, emoji: emoji, initial: initial)
         | 
| 22 22 |  | 
| 23 23 | 
             
                      self
         | 
| 24 24 | 
             
                    end
         | 
| @@ -9,9 +9,9 @@ module Slack | |
| 9 9 | 
             
                  #
         | 
| 10 10 | 
             
                  # https://api.slack.com/reference/messaging/block-elements#button
         | 
| 11 11 | 
             
                  class Button
         | 
| 12 | 
            -
                     | 
| 12 | 
            +
                    include Composition::ConfirmationDialog::Confirmable
         | 
| 13 13 |  | 
| 14 | 
            -
                     | 
| 14 | 
            +
                    TYPE = 'button'
         | 
| 15 15 |  | 
| 16 16 | 
             
                    def initialize(text:, action_id:, style: nil, emoji: nil, url: nil, value: nil)
         | 
| 17 17 | 
             
                      @text = Composition::PlainText.new(text: text, emoji: emoji)
         | 
| @@ -23,14 +23,6 @@ module Slack | |
| 23 23 | 
             
                      yield(self) if block_given?
         | 
| 24 24 | 
             
                    end
         | 
| 25 25 |  | 
| 26 | 
            -
                    def confirmation_dialog
         | 
| 27 | 
            -
                      @confirm = Composition::ConfirmationDialog.new
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                      yield(@confirm) if block_given?
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                      @confirm
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
             | 
| 34 26 | 
             
                    def as_json(*)
         | 
| 35 27 | 
             
                      {
         | 
| 36 28 | 
             
                        type: TYPE,
         | 
| @@ -39,7 +31,7 @@ module Slack | |
| 39 31 | 
             
                        url: @url,
         | 
| 40 32 | 
             
                        value: @value,
         | 
| 41 33 | 
             
                        style: @style,
         | 
| 42 | 
            -
                        confirm:  | 
| 34 | 
            +
                        confirm: confirm&.as_json
         | 
| 43 35 | 
             
                      }.compact
         | 
| 44 36 | 
             
                    end
         | 
| 45 37 | 
             
                  end
         | 
| @@ -13,9 +13,9 @@ module Slack | |
| 13 13 | 
             
                  #
         | 
| 14 14 | 
             
                  # https://api.slack.com/reference/messaging/block-elements#channel-select
         | 
| 15 15 | 
             
                  class ChannelsSelect
         | 
| 16 | 
            -
                     | 
| 16 | 
            +
                    include Composition::ConfirmationDialog::Confirmable
         | 
| 17 17 |  | 
| 18 | 
            -
                     | 
| 18 | 
            +
                    TYPE = 'channels_select'
         | 
| 19 19 |  | 
| 20 20 | 
             
                    def initialize(placeholder:, action_id:, initial: nil, emoji: nil)
         | 
| 21 21 | 
             
                      @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
         | 
| @@ -25,21 +25,13 @@ module Slack | |
| 25 25 | 
             
                      yield(self) if block_given?
         | 
| 26 26 | 
             
                    end
         | 
| 27 27 |  | 
| 28 | 
            -
                    def confirmation_dialog
         | 
| 29 | 
            -
                      @confirm = Composition::ConfirmationDialog.new
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                      yield(@confirm) if block_given?
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                      self
         | 
| 34 | 
            -
                    end
         | 
| 35 | 
            -
             | 
| 36 28 | 
             
                    def as_json(*)
         | 
| 37 29 | 
             
                      {
         | 
| 38 30 | 
             
                        type: TYPE,
         | 
| 39 31 | 
             
                        placeholder: @placeholder.as_json,
         | 
| 40 32 | 
             
                        action_id: @action_id,
         | 
| 41 33 | 
             
                        initial_channel: @initial_channel,
         | 
| 42 | 
            -
                        confirm:  | 
| 34 | 
            +
                        confirm: confirm&.as_json
         | 
| 43 35 | 
             
                      }.compact
         | 
| 44 36 | 
             
                    end
         | 
| 45 37 | 
             
                  end
         |