|
| 1 | +package compositions; |
| 2 | + |
| 3 | +import com.slack.api.model.block.Blocks; |
| 4 | +import com.slack.api.model.block.LayoutBlock; |
| 5 | +import com.slack.api.model.block.composition.BlockCompositions; |
| 6 | +import com.slack.api.model.block.composition.OptionGroupObject; |
| 7 | +import com.slack.api.model.block.composition.OptionObject; |
| 8 | +import com.slack.api.model.block.element.BlockElements; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +/** |
| 12 | + * Defines a way to group options in a menu. |
| 13 | + * {@link https://docs.slack.dev/reference/block-kit/composition-objects/option-group-object/} |
| 14 | + */ |
| 15 | +public class OptionGroup { |
| 16 | + /** |
| 17 | + * A static select menu containing the option group object. |
| 18 | + */ |
| 19 | + public static List<LayoutBlock> example01() { |
| 20 | + List<LayoutBlock> blocks = List.of( |
| 21 | + Blocks.section(s -> s.text(BlockCompositions.markdownText(":mag: Search results for *Cata*"))), |
| 22 | + Blocks.divider(), |
| 23 | + Blocks.section(s -> s.text( |
| 24 | + BlockCompositions.markdownText( |
| 25 | + "*<fakeLink.toYourApp.com|Use Case Catalogue>*\nUse Case Catalogue for the following departments/roles...")) |
| 26 | + .accessory(BlockElements.staticSelect(m -> m.placeholder(BlockCompositions.plainText( |
| 27 | + pt -> pt.text("Manage").emoji(true))) |
| 28 | + .optionGroups(List.of( |
| 29 | + OptionGroupObject.builder() |
| 30 | + .label(BlockCompositions.plainText("Group 1")) |
| 31 | + .options(List.of( |
| 32 | + OptionObject.builder() |
| 33 | + .text( |
| 34 | + BlockCompositions.plainText( |
| 35 | + "*this is plain_text text*")) |
| 36 | + .value("value-0") |
| 37 | + .build(), |
| 38 | + OptionObject.builder() |
| 39 | + .text( |
| 40 | + BlockCompositions.plainText( |
| 41 | + "*this is plain_text text*")) |
| 42 | + .value("value-1") |
| 43 | + .build(), |
| 44 | + OptionObject.builder() |
| 45 | + .text( |
| 46 | + BlockCompositions.plainText( |
| 47 | + "*this is plain_text text*")) |
| 48 | + .value("value-2") |
| 49 | + .build())) |
| 50 | + .build(), |
| 51 | + OptionGroupObject.builder() |
| 52 | + .label(BlockCompositions.plainText("Group 2")) |
| 53 | + .options(List.of(OptionObject.builder() |
| 54 | + .text(BlockCompositions.plainText("*this is plain_text text*")) |
| 55 | + .value("value-3") |
| 56 | + .build())) |
| 57 | + .build())))))); |
| 58 | + return blocks; |
| 59 | + } |
| 60 | +} |
0 commit comments