Skip to content

Commit

Permalink
Slack header block support in DSL (https://api.slack.com/reference/bl…
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Aug 5, 2020
1 parent 1768dab commit 96db05a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ trait SlackBlocksTemplateDsl extends SlackBlocksTemplateDslInternals {
protected def fileBlock = SlackFileBlock
protected def actionsBlock = SlackActionsBlock
protected def imageBlock = SlackImageBlock
protected def headerBlock = SlackHeaderBlock
protected def richBlock = SlackRichTextBlock

protected def sectionFields( defs: SlackDslItemDef[SlackBlockText]* ): Option[List[SlackBlockText]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ case class SlackFileBlock(
override val block_id: Option[SlackBlockId] = None
) extends SlackBlock

/**
* https://api.slack.com/reference/block-kit/blocks#header
*/
@JsonAdt( "header" )
case class SlackHeaderBlock(
text: SlackBlockPlainText,
override val block_id: Option[SlackBlockId] = None
) extends SlackBlock

@JsonAdt( "rich_text" )
case class SlackRichTextBlock(
elements: List[SlackRichBlockElement],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SlackMessageTemplatingTestSuite extends AnyFlatSpec {
blocks(
blocks(
dividerBlock(),
headerBlock( text = pt"Header" ),
sectionBlock( text = md"Test: ${testCond}" ),
optionally( testCond > 0 )( dividerBlock() ),
sectionBlock(
Expand Down
1 change: 1 addition & 0 deletions site/docs/docs/blocks-templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ Available DSL terms:
* `fileBlock` : ["file"](https://api.slack.com/reference/block-kit/blocks#file)
* `actionsBlock` : ["actions"](https://api.slack.com/reference/block-kit/blocks#actions)
* `imageBlock` : ["image"](https://api.slack.com/reference/block-kit/blocks#image)
* `headerBlock` : ["image"](https://api.slack.com/reference/block-kit/blocks#header)
* `blockElements` : list of elements of block (not all blocks support all these elements, it would be checked at the compile time):
* `button` : ["button"](https://api.slack.com/reference/block-kit/block-elements#button)
* `image` : ["image"](https://api.slack.com/reference/block-kit/block-elements#image)
Expand Down

0 comments on commit 96db05a

Please sign in to comment.