slack-ruby-block-kit 0.5.0 → 0.9.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/.circleci/config.yml +1 -1
- data/.github/dependabot.yml +9 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +50 -1
- data/Gemfile.lock +44 -29
- data/README.md +2 -2
- data/bin/console +13 -0
- data/lib/slack/block_kit.rb +49 -5
- data/lib/slack/block_kit/composition/confirmation_dialog.rb +13 -2
- data/lib/slack/block_kit/composition/conversation_filter.rb +33 -0
- data/lib/slack/block_kit/composition/option.rb +7 -3
- data/lib/slack/block_kit/element/conversations_select.rb +15 -1
- data/lib/slack/block_kit/element/external_select.rb +2 -1
- data/lib/slack/block_kit/element/multi_channels_select.rb +51 -0
- data/lib/slack/block_kit/element/multi_conversations_select.rb +66 -0
- data/lib/slack/block_kit/element/multi_external_select.rb +61 -0
- data/lib/slack/block_kit/element/multi_static_select.rb +88 -0
- data/lib/slack/block_kit/element/multi_users_select.rb +51 -0
- data/lib/slack/block_kit/element/overflow_menu.rb +4 -2
- data/lib/slack/block_kit/element/plain_text_input.rb +1 -1
- data/lib/slack/block_kit/layout/context.rb +1 -0
- data/lib/slack/block_kit/layout/image.rb +1 -4
- data/lib/slack/block_kit/layout/section.rb +9 -1
- data/lib/slack/block_kit/layout/section/multi_select_elements.rb +92 -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 +4 -1
- metadata +60 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31d357b44cc9c6e928a1ddc3e469393befde7bcc565416167e76767835551115
|
|
4
|
+
data.tar.gz: 942fb2311a0e388e7fe4d2fe40a76b2c398583fe06facdac05547b2d3102b6b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93c87de2988ede207c6950fd00ed7c68a84cb30cefeeeb105ce8309595f7135ef5db5ed3a9fa2ebf02e06b0744c0633ac3cd551ac9d93c43462ca1c8a1cb9d9f
|
|
7
|
+
data.tar.gz: 591a9b52614a626dccbe11dd1ddbf3ec6114f54f509209643d7e6eeac5a213d2e1262842c345ffab18af86e58fecec90ea7f5372403a2f8a03f36e131b5933dc
|
data/.circleci/config.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -4,7 +4,7 @@ inherit_from: .rubocop_todo.yml
|
|
|
4
4
|
AllCops:
|
|
5
5
|
TargetRubyVersion: 2.5.3
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Layout/LineLength:
|
|
8
8
|
Max: 120
|
|
9
9
|
|
|
10
10
|
Style/AsciiComments:
|
|
@@ -16,3 +16,52 @@ Naming/FileName:
|
|
|
16
16
|
|
|
17
17
|
Metrics/ParameterLists:
|
|
18
18
|
Max: 8
|
|
19
|
+
|
|
20
|
+
Metrics/BlockLength:
|
|
21
|
+
Exclude:
|
|
22
|
+
- 'Rakefile'
|
|
23
|
+
- '**/*.rake'
|
|
24
|
+
- 'spec/**/*.rb'
|
|
25
|
+
- '**/*.gemspec'
|
|
26
|
+
|
|
27
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
28
|
+
Enabled: true
|
|
29
|
+
|
|
30
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
31
|
+
Enabled: true
|
|
32
|
+
|
|
33
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
34
|
+
Enabled: true
|
|
35
|
+
|
|
36
|
+
Lint/RaiseException:
|
|
37
|
+
Enabled: true
|
|
38
|
+
|
|
39
|
+
Lint/StructNewOverride:
|
|
40
|
+
Enabled: true
|
|
41
|
+
|
|
42
|
+
Style/ExponentialNotation:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
45
|
+
Style/HashEachMethods:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Style/HashTransformKeys:
|
|
49
|
+
Enabled: true
|
|
50
|
+
|
|
51
|
+
Style/HashTransformValues:
|
|
52
|
+
Enabled: true
|
|
53
|
+
|
|
54
|
+
Style/SlicingWithRange:
|
|
55
|
+
Enabled: true
|
|
56
|
+
|
|
57
|
+
Lint/MixedRegexpCaptureTypes:
|
|
58
|
+
Enabled: true
|
|
59
|
+
|
|
60
|
+
Style/RedundantFetchBlock:
|
|
61
|
+
Enabled: true
|
|
62
|
+
|
|
63
|
+
Style/RedundantRegexpCharacterClass:
|
|
64
|
+
Enabled: true
|
|
65
|
+
|
|
66
|
+
Style/RedundantRegexpEscape:
|
|
67
|
+
Enabled: true
|
data/Gemfile.lock
CHANGED
|
@@ -1,53 +1,68 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
slack-ruby-block-kit (0.
|
|
4
|
+
slack-ruby-block-kit (0.9.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
ast (2.4.
|
|
9
|
+
ast (2.4.1)
|
|
10
|
+
coderay (1.1.2)
|
|
10
11
|
diff-lcs (1.3)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
dotenv (2.7.5)
|
|
13
|
+
faraday (1.0.1)
|
|
14
|
+
multipart-post (>= 1.2, < 3)
|
|
15
|
+
method_source (1.0.0)
|
|
16
|
+
multipart-post (2.1.1)
|
|
17
|
+
parallel (1.19.2)
|
|
18
|
+
parser (2.7.1.4)
|
|
19
|
+
ast (~> 2.4.1)
|
|
20
|
+
pry (0.13.1)
|
|
21
|
+
coderay (~> 1.1)
|
|
22
|
+
method_source (~> 1.0)
|
|
16
23
|
rainbow (3.0.0)
|
|
17
24
|
rake (13.0.1)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rspec-
|
|
22
|
-
|
|
23
|
-
rspec-
|
|
24
|
-
rspec-
|
|
25
|
+
regexp_parser (1.7.1)
|
|
26
|
+
rexml (3.2.4)
|
|
27
|
+
rspec (3.9.0)
|
|
28
|
+
rspec-core (~> 3.9.0)
|
|
29
|
+
rspec-expectations (~> 3.9.0)
|
|
30
|
+
rspec-mocks (~> 3.9.0)
|
|
31
|
+
rspec-core (3.9.2)
|
|
32
|
+
rspec-support (~> 3.9.3)
|
|
33
|
+
rspec-expectations (3.9.2)
|
|
25
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
26
|
-
rspec-support (~> 3.
|
|
27
|
-
rspec-mocks (3.
|
|
35
|
+
rspec-support (~> 3.9.0)
|
|
36
|
+
rspec-mocks (3.9.1)
|
|
28
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
29
|
-
rspec-support (~> 3.
|
|
30
|
-
rspec-support (3.
|
|
38
|
+
rspec-support (~> 3.9.0)
|
|
39
|
+
rspec-support (3.9.3)
|
|
31
40
|
rspec_junit_formatter (0.4.1)
|
|
32
41
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
33
|
-
rubocop (0.
|
|
34
|
-
jaro_winkler (~> 1.5.1)
|
|
42
|
+
rubocop (0.86.0)
|
|
35
43
|
parallel (~> 1.10)
|
|
36
|
-
parser (>= 2.
|
|
37
|
-
powerpack (~> 0.1)
|
|
44
|
+
parser (>= 2.7.0.1)
|
|
38
45
|
rainbow (>= 2.2.2, < 4.0)
|
|
46
|
+
regexp_parser (>= 1.7)
|
|
47
|
+
rexml
|
|
48
|
+
rubocop-ast (>= 0.0.3, < 1.0)
|
|
39
49
|
ruby-progressbar (~> 1.7)
|
|
40
|
-
unicode-display_width (
|
|
41
|
-
rubocop-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
51
|
+
rubocop-ast (0.0.3)
|
|
52
|
+
parser (>= 2.7.0.1)
|
|
53
|
+
rubocop-rspec (1.40.0)
|
|
54
|
+
rubocop (>= 0.68.1)
|
|
55
|
+
ruby-progressbar (1.10.1)
|
|
56
|
+
unicode-display_width (1.7.0)
|
|
45
57
|
|
|
46
58
|
PLATFORMS
|
|
47
59
|
ruby
|
|
48
60
|
|
|
49
61
|
DEPENDENCIES
|
|
50
|
-
bundler
|
|
62
|
+
bundler
|
|
63
|
+
dotenv
|
|
64
|
+
faraday
|
|
65
|
+
pry
|
|
51
66
|
rake
|
|
52
67
|
rspec
|
|
53
68
|
rspec_junit_formatter
|
|
@@ -56,4 +71,4 @@ DEPENDENCIES
|
|
|
56
71
|
slack-ruby-block-kit!
|
|
57
72
|
|
|
58
73
|
BUNDLED WITH
|
|
59
|
-
1.
|
|
74
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://circleci.com/gh/CGA1123/
|
|
1
|
+
[](https://circleci.com/gh/CGA1123/slack-ruby-block-kit/tree/master)
|
|
2
2
|
[](https://badge.fury.io/rb/slack-ruby-block-kit)
|
|
3
3
|
|
|
4
4
|
# Slack::BlockKit
|
|
@@ -86,7 +86,7 @@ You can also check out the [`slackerduty`](https://github.com/CGA1123/slackerdut
|
|
|
86
86
|
|
|
87
87
|
## Contributing
|
|
88
88
|
|
|
89
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/CGA1123/
|
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/CGA1123/slack-ruby-block-kit
|
|
90
90
|
|
|
91
91
|
See [issues](https://github.com/CGA1123/slack-ruby-block-kit/issues) if you want any inspiration as to what to help with!
|
|
92
92
|
|
data/bin/console
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
lib = File.expand_path('../lib', __dir__)
|
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
|
+
|
|
7
|
+
require 'bundler/setup'
|
|
8
|
+
require 'dotenv/load'
|
|
9
|
+
require 'slack-ruby-block-kit'
|
|
10
|
+
require 'faraday'
|
|
11
|
+
require 'pry'
|
|
12
|
+
|
|
13
|
+
Pry.start
|
data/lib/slack/block_kit.rb
CHANGED
|
@@ -6,12 +6,13 @@ module Slack
|
|
|
6
6
|
module Element; end
|
|
7
7
|
module Layout; end
|
|
8
8
|
|
|
9
|
-
VERSION = '0.
|
|
9
|
+
VERSION = '0.9.0'
|
|
10
10
|
|
|
11
|
-
Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].each { |file| require file }
|
|
12
|
-
Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].each { |file| require file }
|
|
13
|
-
Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].each { |file| require file }
|
|
14
|
-
Dir[File.join(__dir__, 'block_kit', '*.rb')].each { |file| require file }
|
|
11
|
+
Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
|
|
12
|
+
Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
|
|
13
|
+
Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].sort.each { |file| require file }
|
|
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
|
|
@@ -9,6 +9,10 @@ module Slack
|
|
|
9
9
|
#
|
|
10
10
|
# https://api.slack.com/reference/messaging/composition-objects#confirm
|
|
11
11
|
class ConfirmationDialog
|
|
12
|
+
def initialize
|
|
13
|
+
@title, @confirm, @text, @style = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
12
16
|
def title(text:, emoji: nil)
|
|
13
17
|
@title = PlainText.new(text: text, emoji: emoji)
|
|
14
18
|
|
|
@@ -33,6 +37,12 @@ module Slack
|
|
|
33
37
|
self
|
|
34
38
|
end
|
|
35
39
|
|
|
40
|
+
def style(value)
|
|
41
|
+
@style = value
|
|
42
|
+
|
|
43
|
+
self
|
|
44
|
+
end
|
|
45
|
+
|
|
36
46
|
def mrkdwn(text:, verbatim: nil)
|
|
37
47
|
@text = Mrkdwn.new(text: text, verbatim: verbatim)
|
|
38
48
|
|
|
@@ -44,8 +54,9 @@ module Slack
|
|
|
44
54
|
title: @title.as_json,
|
|
45
55
|
text: @text.as_json,
|
|
46
56
|
confirm: @confirm.as_json,
|
|
47
|
-
deny: @deny.as_json
|
|
48
|
-
|
|
57
|
+
deny: @deny.as_json,
|
|
58
|
+
style: @style
|
|
59
|
+
}.compact
|
|
49
60
|
end
|
|
50
61
|
end
|
|
51
62
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Composition
|
|
6
|
+
# Provides a way to filter the list of options in a conversations select menu
|
|
7
|
+
# or conversations multi-select menu.
|
|
8
|
+
#
|
|
9
|
+
# @param [Array] only - "include" field
|
|
10
|
+
#
|
|
11
|
+
# https://api.slack.com/reference/block-kit/composition-objects#filter_conversations
|
|
12
|
+
# https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select
|
|
13
|
+
# https://api.slack.com/reference/block-kit/block-elements#conversation_select
|
|
14
|
+
class ConversationFilter
|
|
15
|
+
def initialize(only: nil,
|
|
16
|
+
exclude_external_shared_channels: nil,
|
|
17
|
+
exclude_bot_users: nil)
|
|
18
|
+
@only = only
|
|
19
|
+
@exclude_external_shared_channels = exclude_external_shared_channels
|
|
20
|
+
@exclude_bot_users = exclude_bot_users
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def as_json(*)
|
|
24
|
+
{
|
|
25
|
+
include: @only,
|
|
26
|
+
exclude_external_shared_channels: @exclude_external_shared_channels,
|
|
27
|
+
exclude_bot_users: @exclude_bot_users
|
|
28
|
+
}.compact
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -8,16 +8,20 @@ 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)
|
|
11
|
+
def initialize(value:, text:, emoji: nil, description: nil, url: nil)
|
|
12
12
|
@text = PlainText.new(text: text, emoji: emoji)
|
|
13
13
|
@value = value
|
|
14
|
+
@description = description && PlainText.new(text: description, emoji: emoji)
|
|
15
|
+
@url = url
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def as_json(*)
|
|
17
19
|
{
|
|
18
20
|
text: @text.as_json,
|
|
19
|
-
value: @value
|
|
20
|
-
|
|
21
|
+
value: @value,
|
|
22
|
+
description: @description&.as_json,
|
|
23
|
+
url: @url
|
|
24
|
+
}.compact
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -22,6 +22,7 @@ module Slack
|
|
|
22
22
|
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
23
23
|
@action_id = action_id
|
|
24
24
|
@initial_conversation = initial
|
|
25
|
+
@filter = nil
|
|
25
26
|
|
|
26
27
|
yield(self) if block_given?
|
|
27
28
|
end
|
|
@@ -34,13 +35,26 @@ module Slack
|
|
|
34
35
|
self
|
|
35
36
|
end
|
|
36
37
|
|
|
38
|
+
def filter(only: nil,
|
|
39
|
+
exclude_external_shared_channels: nil,
|
|
40
|
+
exclude_bot_users: nil)
|
|
41
|
+
@filter = Composition::ConversationFilter.new(
|
|
42
|
+
only: only,
|
|
43
|
+
exclude_external_shared_channels: exclude_external_shared_channels,
|
|
44
|
+
exclude_bot_users: exclude_bot_users
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
self
|
|
48
|
+
end
|
|
49
|
+
|
|
37
50
|
def as_json(*)
|
|
38
51
|
{
|
|
39
52
|
type: TYPE,
|
|
40
53
|
placeholder: @placeholder.as_json,
|
|
41
54
|
action_id: @action_id,
|
|
42
55
|
initial_conversation: @initial_conversation,
|
|
43
|
-
confirm: @confirm&.as_json
|
|
56
|
+
confirm: @confirm&.as_json,
|
|
57
|
+
filter: @filter&.as_json
|
|
44
58
|
}.compact
|
|
45
59
|
end
|
|
46
60
|
end
|
|
@@ -28,6 +28,7 @@ module Slack
|
|
|
28
28
|
@action_id = action_id
|
|
29
29
|
@initial_option = initial
|
|
30
30
|
@min_query_length = min_query_length
|
|
31
|
+
@confirm = nil
|
|
31
32
|
|
|
32
33
|
yield(self) if block_given?
|
|
33
34
|
end
|
|
@@ -46,7 +47,7 @@ module Slack
|
|
|
46
47
|
placeholder: @placeholder.as_json,
|
|
47
48
|
action_id: @action_id,
|
|
48
49
|
initial_option: @initial_option&.as_json,
|
|
49
|
-
min_query_length: min_query_length,
|
|
50
|
+
min_query_length: @min_query_length,
|
|
50
51
|
confirm: @confirm&.as_json
|
|
51
52
|
}.compact
|
|
52
53
|
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Element
|
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
|
9
|
+
# all of an option string to filter the list.
|
|
10
|
+
#
|
|
11
|
+
# This multi-select menu will populate its options with a list of public
|
|
12
|
+
# channels visible to the current user in the active workspace.
|
|
13
|
+
#
|
|
14
|
+
# https://api.slack.com/reference/block-kit/block-elements#channel_multi_select
|
|
15
|
+
class MultiChannelsSelect
|
|
16
|
+
TYPE = 'multi_channels_select'
|
|
17
|
+
|
|
18
|
+
attr_accessor :confirm
|
|
19
|
+
|
|
20
|
+
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
|
21
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
22
|
+
@action_id = action_id
|
|
23
|
+
@initial_channel = initial
|
|
24
|
+
@confirm = nil
|
|
25
|
+
@max_selected_items = max_selected_items
|
|
26
|
+
|
|
27
|
+
yield(self) if block_given?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def confirmation_dialog
|
|
31
|
+
@confirm = Composition::ConfirmationDialog.new
|
|
32
|
+
|
|
33
|
+
yield(@confirm) if block_given?
|
|
34
|
+
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def as_json(*)
|
|
39
|
+
{
|
|
40
|
+
type: TYPE,
|
|
41
|
+
placeholder: @placeholder.as_json,
|
|
42
|
+
action_id: @action_id,
|
|
43
|
+
initial_channel: @initial_channel,
|
|
44
|
+
confirm: @confirm&.as_json,
|
|
45
|
+
max_selected_items: @max_selected_items
|
|
46
|
+
}.compact
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Element
|
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
|
9
|
+
# all of an option string to filter the list.
|
|
10
|
+
#
|
|
11
|
+
# This multi-select menu will populate its options with a list of public and
|
|
12
|
+
# private channels, DMs, and MPIMs visible to the current user in the
|
|
13
|
+
# active workspace.
|
|
14
|
+
#
|
|
15
|
+
# https://api.slack.com/reference/block-kit/block-elements#conversation_multi_select
|
|
16
|
+
class MultiConversationsSelect
|
|
17
|
+
TYPE = 'multi_conversations_select'
|
|
18
|
+
|
|
19
|
+
attr_accessor :confirm
|
|
20
|
+
|
|
21
|
+
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
|
22
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
23
|
+
@action_id = action_id
|
|
24
|
+
@initial_conversation = initial
|
|
25
|
+
@confirm = nil
|
|
26
|
+
@max_selected_items = max_selected_items
|
|
27
|
+
@filter = nil
|
|
28
|
+
|
|
29
|
+
yield(self) if block_given?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def confirmation_dialog
|
|
33
|
+
@confirm = Composition::ConfirmationDialog.new
|
|
34
|
+
|
|
35
|
+
yield(@confirm) if block_given?
|
|
36
|
+
|
|
37
|
+
self
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def filter(only: nil,
|
|
41
|
+
exclude_external_shared_channels: nil,
|
|
42
|
+
exclude_bot_users: nil)
|
|
43
|
+
@filter = Composition::ConversationFilter.new(
|
|
44
|
+
only: only,
|
|
45
|
+
exclude_external_shared_channels: exclude_external_shared_channels,
|
|
46
|
+
exclude_bot_users: exclude_bot_users
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def as_json(*)
|
|
53
|
+
{
|
|
54
|
+
type: TYPE,
|
|
55
|
+
placeholder: @placeholder.as_json,
|
|
56
|
+
action_id: @action_id,
|
|
57
|
+
initial_conversation: @initial_conversation,
|
|
58
|
+
confirm: @confirm&.as_json,
|
|
59
|
+
max_selected_items: @max_selected_items,
|
|
60
|
+
filter: @filter&.as_json
|
|
61
|
+
}.compact
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Element
|
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
|
9
|
+
# all of an option string to filter the list.
|
|
10
|
+
#
|
|
11
|
+
# This select menu will load its options from an external data source,
|
|
12
|
+
# allowing for a dynamic list of options.
|
|
13
|
+
#
|
|
14
|
+
# Each time a select menu of this type is opened or the user starts typing
|
|
15
|
+
# in the typeahead field, we'll send a request to your specified URL. Your
|
|
16
|
+
# app should return an HTTP 200 OK response, along with an
|
|
17
|
+
# application/json post body with an object containing either an options
|
|
18
|
+
# array, or an option_groups array.
|
|
19
|
+
#
|
|
20
|
+
# https://api.slack.com/reference/block-kit/block-elements#external_multi_select
|
|
21
|
+
class MultiExternalSelect
|
|
22
|
+
TYPE = 'multi_external_select'
|
|
23
|
+
|
|
24
|
+
attr_accessor :confirm
|
|
25
|
+
|
|
26
|
+
def initialize(placeholder:, action_id:,
|
|
27
|
+
initial: nil, min_query_length: nil, emoji: nil, max_selected_items: nil)
|
|
28
|
+
|
|
29
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
30
|
+
@action_id = action_id
|
|
31
|
+
@initial_option = initial
|
|
32
|
+
@min_query_length = min_query_length
|
|
33
|
+
@confirm = nil
|
|
34
|
+
@max_selected_items = max_selected_items
|
|
35
|
+
|
|
36
|
+
yield(self) if block_given?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def confirmation_dialog
|
|
40
|
+
@confirm = Composition::ConfirmationDialog.new
|
|
41
|
+
|
|
42
|
+
yield(@confirm) if block_given?
|
|
43
|
+
|
|
44
|
+
self
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def as_json(*)
|
|
48
|
+
{
|
|
49
|
+
type: TYPE,
|
|
50
|
+
placeholder: @placeholder.as_json,
|
|
51
|
+
action_id: @action_id,
|
|
52
|
+
initial_option: @initial_option&.as_json,
|
|
53
|
+
min_query_length: @min_query_length,
|
|
54
|
+
confirm: @confirm&.as_json,
|
|
55
|
+
max_selected_items: @max_selected_items
|
|
56
|
+
}.compact
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Element
|
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
|
9
|
+
# all of an option string to filter the list.
|
|
10
|
+
#
|
|
11
|
+
# This is the simplest form of select menu, with a static list of options
|
|
12
|
+
# passed in when defining the element.
|
|
13
|
+
#
|
|
14
|
+
# https://api.slack.com/reference/block-kit/block-elements#static_multi_select
|
|
15
|
+
class MultiStaticSelect
|
|
16
|
+
TYPE = 'multi_static_select'
|
|
17
|
+
|
|
18
|
+
attr_accessor :confirm, :options, :option_groups, :initial_option
|
|
19
|
+
|
|
20
|
+
def initialize(placeholder:, action_id:, emoji: nil, max_selected_items: nil)
|
|
21
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
22
|
+
@action_id = action_id
|
|
23
|
+
@confirm = nil
|
|
24
|
+
@max_selected_items = max_selected_items
|
|
25
|
+
|
|
26
|
+
@options = nil
|
|
27
|
+
@option_groups = nil
|
|
28
|
+
@initial_option = nil
|
|
29
|
+
|
|
30
|
+
yield(self) if block_given?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def confirmation_dialog
|
|
34
|
+
@confirm = Composition::ConfirmationDialog.new
|
|
35
|
+
|
|
36
|
+
yield(@confirm) if block_given?
|
|
37
|
+
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def option(value:, text:, emoji: nil)
|
|
42
|
+
@options ||= []
|
|
43
|
+
@options << Composition::Option.new(
|
|
44
|
+
value: value,
|
|
45
|
+
text: text,
|
|
46
|
+
emoji: emoji
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def option_group(label:, emoji: nil)
|
|
53
|
+
option_group = Composition::OptionGroup.new(label: label, emoji: emoji)
|
|
54
|
+
|
|
55
|
+
yield(option_group) if block_given?
|
|
56
|
+
|
|
57
|
+
@option_groups ||= []
|
|
58
|
+
@option_groups << option_group
|
|
59
|
+
|
|
60
|
+
self
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def initial(value:, text:, emoji: nil)
|
|
64
|
+
@initial_option = Composition::Option.new(
|
|
65
|
+
value: value,
|
|
66
|
+
text: text,
|
|
67
|
+
emoji: emoji
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
self
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def as_json(*)
|
|
74
|
+
{
|
|
75
|
+
type: TYPE,
|
|
76
|
+
placeholder: @placeholder.as_json,
|
|
77
|
+
action_id: @action_id,
|
|
78
|
+
options: @options&.map(&:as_json),
|
|
79
|
+
option_groups: @option_groups&.map(&:as_json),
|
|
80
|
+
initial_option: @initial_option&.as_json,
|
|
81
|
+
confirm: @confirm&.as_json,
|
|
82
|
+
max_selected_items: @max_selected_items
|
|
83
|
+
}.compact
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Element
|
|
6
|
+
# A select menu, just as with a standard HTML <select> tag, creates a drop
|
|
7
|
+
# down menu with a list of options for a user to choose. The select menu
|
|
8
|
+
# also includes type-ahead functionality, where a user can type a part or
|
|
9
|
+
# all of an option string to filter the list.
|
|
10
|
+
#
|
|
11
|
+
# This multi-select menu will populate its options with a list of Slack users
|
|
12
|
+
# visible to the current user in the active workspace.
|
|
13
|
+
#
|
|
14
|
+
# https://api.slack.com/reference/block-kit/block-elements#users_multi_select
|
|
15
|
+
class MultiUsersSelect
|
|
16
|
+
TYPE = 'multi_users_select'
|
|
17
|
+
|
|
18
|
+
attr_accessor :confirm
|
|
19
|
+
|
|
20
|
+
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
|
21
|
+
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
22
|
+
@action_id = action_id
|
|
23
|
+
@initial_user = initial
|
|
24
|
+
@confirm = nil
|
|
25
|
+
@max_selected_items = max_selected_items
|
|
26
|
+
|
|
27
|
+
yield(self) if block_given?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def confirmation_dialog
|
|
31
|
+
@confirm = Composition::ConfirmationDialog.new
|
|
32
|
+
|
|
33
|
+
yield(@confirm) if block_given?
|
|
34
|
+
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def as_json(*)
|
|
39
|
+
{
|
|
40
|
+
type: TYPE,
|
|
41
|
+
placeholder: @placeholder.as_json,
|
|
42
|
+
action_id: @action_id,
|
|
43
|
+
initial_user: @initial_user,
|
|
44
|
+
confirm: @confirm&.as_json,
|
|
45
|
+
max_selected_items: @max_selected_items
|
|
46
|
+
}.compact
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -22,15 +22,17 @@ module Slack
|
|
|
22
22
|
def initialize(action_id:)
|
|
23
23
|
@action_id = action_id
|
|
24
24
|
@options = []
|
|
25
|
+
@confirm = nil
|
|
25
26
|
|
|
26
27
|
yield(self) if block_given?
|
|
27
28
|
end
|
|
28
29
|
|
|
29
|
-
def option(value:, text:, emoji: nil)
|
|
30
|
+
def option(value:, text:, emoji: nil, url: nil)
|
|
30
31
|
@options << Composition::Option.new(
|
|
31
32
|
value: value,
|
|
32
33
|
text: text,
|
|
33
|
-
emoji: emoji
|
|
34
|
+
emoji: emoji,
|
|
35
|
+
url: url
|
|
34
36
|
)
|
|
35
37
|
|
|
36
38
|
self
|
|
@@ -22,7 +22,7 @@ module Slack
|
|
|
22
22
|
min_length: nil,
|
|
23
23
|
max_length: nil
|
|
24
24
|
)
|
|
25
|
-
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
25
|
+
@placeholder = placeholder && Composition::PlainText.new(text: placeholder, emoji: emoji)
|
|
26
26
|
@initial_value = initial_value
|
|
27
27
|
@action_id = action_id
|
|
28
28
|
@multiline = multiline
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative './section/multi_select_elements'
|
|
4
|
+
|
|
3
5
|
module Slack
|
|
4
6
|
module BlockKit
|
|
5
7
|
module Layout
|
|
@@ -8,13 +10,19 @@ module Slack
|
|
|
8
10
|
# with any of the available block elements.
|
|
9
11
|
#
|
|
10
12
|
# https://api.slack.com/reference/messaging/blocks#section
|
|
13
|
+
# rubocop:disable Metrics/ClassLength
|
|
11
14
|
class Section
|
|
15
|
+
# rubocop:enable Metrics/ClassLength
|
|
16
|
+
|
|
17
|
+
include Section::MultiSelectElements
|
|
12
18
|
TYPE = 'section'
|
|
13
19
|
|
|
14
20
|
attr_accessor :fields, :text, :accessory
|
|
15
21
|
|
|
16
22
|
def initialize(block_id: nil)
|
|
17
23
|
@block_id = block_id
|
|
24
|
+
@fields = nil
|
|
25
|
+
@accessory = nil
|
|
18
26
|
|
|
19
27
|
yield(self) if block_given?
|
|
20
28
|
end
|
|
@@ -149,7 +157,7 @@ module Slack
|
|
|
149
157
|
end
|
|
150
158
|
|
|
151
159
|
def image(url:, alt_text:)
|
|
152
|
-
|
|
160
|
+
accessorise(Element::Image.new(image_url: url, alt_text: alt_text))
|
|
153
161
|
end
|
|
154
162
|
|
|
155
163
|
def accessorise(element)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module BlockKit
|
|
5
|
+
module Layout
|
|
6
|
+
class Section
|
|
7
|
+
# Helper methods for Multi Select to inject to section
|
|
8
|
+
module MultiSelectElements
|
|
9
|
+
def multi_channels_select(placeholder:, action_id:,
|
|
10
|
+
initial: nil, emoji: nil, max_selected_items: nil)
|
|
11
|
+
element = Element::MultiChannelsSelect.new(
|
|
12
|
+
placeholder: placeholder,
|
|
13
|
+
action_id: action_id,
|
|
14
|
+
initial: initial,
|
|
15
|
+
emoji: emoji,
|
|
16
|
+
max_selected_items: max_selected_items
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
yield(element) if block_given?
|
|
20
|
+
|
|
21
|
+
accessorise(element)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def multi_conversations_select(placeholder:, action_id:,
|
|
25
|
+
initial: nil, emoji: nil, max_selected_items: nil)
|
|
26
|
+
element = Element::MultiConversationsSelect.new(
|
|
27
|
+
placeholder: placeholder,
|
|
28
|
+
action_id: action_id,
|
|
29
|
+
initial: initial,
|
|
30
|
+
emoji: emoji,
|
|
31
|
+
max_selected_items: max_selected_items
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
yield(element) if block_given?
|
|
35
|
+
|
|
36
|
+
accessorise(element)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def multi_external_select(placeholder:, action_id:,
|
|
40
|
+
initial: nil,
|
|
41
|
+
min_query_length: nil,
|
|
42
|
+
emoji: nil,
|
|
43
|
+
max_selected_items: nil)
|
|
44
|
+
element = Element::MultiExternalSelect.new(
|
|
45
|
+
placeholder: placeholder,
|
|
46
|
+
action_id: action_id,
|
|
47
|
+
initial: initial,
|
|
48
|
+
min_query_length: min_query_length,
|
|
49
|
+
emoji: emoji,
|
|
50
|
+
max_selected_items: max_selected_items
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
yield(element) if block_given?
|
|
54
|
+
|
|
55
|
+
accessorise(element)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def multi_static_select(placeholder:, action_id:,
|
|
59
|
+
emoji: nil, max_selected_items: nil)
|
|
60
|
+
element = Element::MultiStaticSelect.new(
|
|
61
|
+
placeholder: placeholder,
|
|
62
|
+
action_id: action_id,
|
|
63
|
+
emoji: emoji,
|
|
64
|
+
max_selected_items: max_selected_items
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
yield(element) if block_given?
|
|
68
|
+
|
|
69
|
+
accessorise(element)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def multi_users_select(placeholder:, action_id:,
|
|
73
|
+
initial: nil,
|
|
74
|
+
emoji: nil,
|
|
75
|
+
max_selected_items: nil)
|
|
76
|
+
element = Element::MultiUsersSelect.new(
|
|
77
|
+
placeholder: placeholder,
|
|
78
|
+
action_id: action_id,
|
|
79
|
+
emoji: emoji,
|
|
80
|
+
initial: initial,
|
|
81
|
+
max_selected_items: max_selected_items
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
yield(element) if block_given?
|
|
85
|
+
|
|
86
|
+
accessorise(element)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module Surfaces
|
|
5
|
+
# The Home tab is a persistent, yet dynamic interface
|
|
6
|
+
# for apps that lives within the App Home.
|
|
7
|
+
#
|
|
8
|
+
# https://api.slack.com/surfaces#tabs
|
|
9
|
+
# https://api.slack.com/reference/surfaces/views
|
|
10
|
+
class Home
|
|
11
|
+
TYPE = 'home'
|
|
12
|
+
|
|
13
|
+
def initialize(blocks: nil,
|
|
14
|
+
private_metadata: nil, callback_id: nil, external_id: nil)
|
|
15
|
+
@blocks = blocks || Slack::BlockKit::Blocks.new
|
|
16
|
+
|
|
17
|
+
@private_metadata = private_metadata
|
|
18
|
+
@callback_id = callback_id
|
|
19
|
+
@external_id = external_id
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
attr_reader :blocks
|
|
23
|
+
|
|
24
|
+
def as_json(*)
|
|
25
|
+
{
|
|
26
|
+
type: TYPE,
|
|
27
|
+
blocks: @blocks.as_json,
|
|
28
|
+
private_metadata: @private_metadata,
|
|
29
|
+
callback_id: @callback_id,
|
|
30
|
+
external_id: @external_id
|
|
31
|
+
}.compact
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module Surfaces
|
|
5
|
+
# App-published messages are dynamic yet transient spaces.
|
|
6
|
+
# They allow users to complete workflows among their Slack conversations.
|
|
7
|
+
#
|
|
8
|
+
# https://api.slack.com/surfaces#messages
|
|
9
|
+
# https://api.slack.com/messaging/composing#complex_layouts
|
|
10
|
+
class Message
|
|
11
|
+
TYPE = 'message'
|
|
12
|
+
|
|
13
|
+
def initialize(blocks: nil, text: nil, channel: nil, thread_ts: nil, as_user: nil)
|
|
14
|
+
@blocks = blocks || Slack::BlockKit::Blocks.new
|
|
15
|
+
@channel = channel
|
|
16
|
+
@thread_ts = thread_ts
|
|
17
|
+
@as_user = as_user
|
|
18
|
+
@text = text
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
attr_reader :blocks
|
|
22
|
+
|
|
23
|
+
def as_json(*)
|
|
24
|
+
{
|
|
25
|
+
channel: @channel,
|
|
26
|
+
thread_ts: @thread_ts,
|
|
27
|
+
as_user: @as_user,
|
|
28
|
+
text: @text,
|
|
29
|
+
blocks: @blocks.as_json
|
|
30
|
+
}.compact
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module Surfaces
|
|
5
|
+
# Modals provide focused spaces ideal for requesting and collecting data from users,
|
|
6
|
+
# or temporarily displaying dynamic and interactive information.
|
|
7
|
+
#
|
|
8
|
+
# https://api.slack.com/surfaces#modals
|
|
9
|
+
# https://api.slack.com/reference/surfaces/views
|
|
10
|
+
#
|
|
11
|
+
# @param title [String] title is required. Must be set as an initial argument
|
|
12
|
+
# or using #title for detail setup
|
|
13
|
+
#
|
|
14
|
+
class Modal
|
|
15
|
+
TYPE = 'modal'
|
|
16
|
+
|
|
17
|
+
def initialize(
|
|
18
|
+
title: nil,
|
|
19
|
+
blocks: nil,
|
|
20
|
+
private_metadata: nil,
|
|
21
|
+
callback_id: nil,
|
|
22
|
+
external_id: nil,
|
|
23
|
+
clear_on_close: nil,
|
|
24
|
+
notify_on_close: nil
|
|
25
|
+
)
|
|
26
|
+
@blocks = blocks || Slack::BlockKit::Blocks.new
|
|
27
|
+
|
|
28
|
+
@private_metadata = private_metadata
|
|
29
|
+
@callback_id = callback_id
|
|
30
|
+
@external_id = external_id
|
|
31
|
+
|
|
32
|
+
@clear_on_close = clear_on_close
|
|
33
|
+
@notify_on_close = notify_on_close
|
|
34
|
+
|
|
35
|
+
@title = Slack::BlockKit::Composition::PlainText.new(text: title) if title
|
|
36
|
+
|
|
37
|
+
@close, @submit = nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
attr_reader :blocks
|
|
41
|
+
|
|
42
|
+
def title(text:, emoji: nil)
|
|
43
|
+
@title = Slack::BlockKit::Composition::PlainText.new(text: text, emoji: emoji)
|
|
44
|
+
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def close(text:, emoji: nil)
|
|
49
|
+
@close = Slack::BlockKit::Composition::PlainText.new(text: text, emoji: emoji)
|
|
50
|
+
|
|
51
|
+
self
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def submit(text:, emoji: nil)
|
|
55
|
+
@submit = Slack::BlockKit::Composition::PlainText.new(text: text, emoji: emoji)
|
|
56
|
+
|
|
57
|
+
self
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def as_json(*) # rubocop:disable Metrics/MethodLength
|
|
61
|
+
{
|
|
62
|
+
type: TYPE,
|
|
63
|
+
blocks: @blocks.as_json,
|
|
64
|
+
title: @title&.as_json,
|
|
65
|
+
close: @close&.as_json,
|
|
66
|
+
submit: @submit&.as_json,
|
|
67
|
+
clear_on_close: @clear_on_close,
|
|
68
|
+
notify_on_close: @notify_on_close,
|
|
69
|
+
private_metadata: @private_metadata,
|
|
70
|
+
callback_id: @callback_id,
|
|
71
|
+
external_id: @external_id
|
|
72
|
+
}.compact
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -28,7 +28,10 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.require_paths = ['lib']
|
|
29
29
|
spec.required_ruby_version = '>= 2.5'
|
|
30
30
|
|
|
31
|
-
spec.add_development_dependency 'bundler'
|
|
31
|
+
spec.add_development_dependency 'bundler'
|
|
32
|
+
spec.add_development_dependency 'dotenv'
|
|
33
|
+
spec.add_development_dependency 'faraday'
|
|
34
|
+
spec.add_development_dependency 'pry'
|
|
32
35
|
spec.add_development_dependency 'rake'
|
|
33
36
|
spec.add_development_dependency 'rspec'
|
|
34
37
|
spec.add_development_dependency 'rspec_junit_formatter'
|
metadata
CHANGED
|
@@ -1,29 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slack-ruby-block-kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Gregg
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dotenv
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
18
32
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
33
|
+
version: '0'
|
|
20
34
|
type: :development
|
|
21
35
|
prerelease: false
|
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
37
|
requirements:
|
|
24
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: faraday
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
25
46
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
27
69
|
- !ruby/object:Gem::Dependency
|
|
28
70
|
name: rake
|
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,6 +144,7 @@ extensions: []
|
|
|
102
144
|
extra_rdoc_files: []
|
|
103
145
|
files:
|
|
104
146
|
- ".circleci/config.yml"
|
|
147
|
+
- ".github/dependabot.yml"
|
|
105
148
|
- ".gitignore"
|
|
106
149
|
- ".rspec"
|
|
107
150
|
- ".rubocop.yml"
|
|
@@ -111,10 +154,12 @@ files:
|
|
|
111
154
|
- LICENSE.txt
|
|
112
155
|
- README.md
|
|
113
156
|
- Rakefile
|
|
157
|
+
- bin/console
|
|
114
158
|
- lib/slack-ruby-block-kit.rb
|
|
115
159
|
- lib/slack/block_kit.rb
|
|
116
160
|
- lib/slack/block_kit/blocks.rb
|
|
117
161
|
- lib/slack/block_kit/composition/confirmation_dialog.rb
|
|
162
|
+
- lib/slack/block_kit/composition/conversation_filter.rb
|
|
118
163
|
- lib/slack/block_kit/composition/mrkdwn.rb
|
|
119
164
|
- lib/slack/block_kit/composition/option.rb
|
|
120
165
|
- lib/slack/block_kit/composition/option_group.rb
|
|
@@ -125,6 +170,11 @@ files:
|
|
|
125
170
|
- lib/slack/block_kit/element/date_picker.rb
|
|
126
171
|
- lib/slack/block_kit/element/external_select.rb
|
|
127
172
|
- lib/slack/block_kit/element/image.rb
|
|
173
|
+
- lib/slack/block_kit/element/multi_channels_select.rb
|
|
174
|
+
- lib/slack/block_kit/element/multi_conversations_select.rb
|
|
175
|
+
- lib/slack/block_kit/element/multi_external_select.rb
|
|
176
|
+
- lib/slack/block_kit/element/multi_static_select.rb
|
|
177
|
+
- lib/slack/block_kit/element/multi_users_select.rb
|
|
128
178
|
- lib/slack/block_kit/element/overflow_menu.rb
|
|
129
179
|
- lib/slack/block_kit/element/plain_text_input.rb
|
|
130
180
|
- lib/slack/block_kit/element/static_select.rb
|
|
@@ -135,6 +185,10 @@ files:
|
|
|
135
185
|
- lib/slack/block_kit/layout/image.rb
|
|
136
186
|
- lib/slack/block_kit/layout/input.rb
|
|
137
187
|
- lib/slack/block_kit/layout/section.rb
|
|
188
|
+
- lib/slack/block_kit/layout/section/multi_select_elements.rb
|
|
189
|
+
- lib/slack/surfaces/home.rb
|
|
190
|
+
- lib/slack/surfaces/message.rb
|
|
191
|
+
- lib/slack/surfaces/modal.rb
|
|
138
192
|
- slack-ruby-block-kit.gemspec
|
|
139
193
|
homepage: https://github.com/CGA1123/slack-ruby-block-kit
|
|
140
194
|
licenses:
|