Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions block-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes
### Blocks

- **[Actions](https://docs.slack.dev/reference/block-kit/blocks/actions-block)**: Holds multiple interactive elements. [Implementation](./src/blocks/actions.py).
- **[Alert](https://docs.slack.dev/reference/block-kit/blocks/alert-block)**: Displays a notification message within a modal. [Implementation](./src/blocks/alert.py).
- **[Context](https://docs.slack.dev/reference/block-kit/blocks/context-block)**: Provides contextual info, which can include both images and text. [Implementation](./src/blocks/context.py).
- **[Context actions](https://docs.slack.dev/reference/block-kit/blocks/context-actions-block)**: Displays actions as contextual info, which can include both feedback buttons and icon buttons. [Implementation](./src/blocks/context_actions.py).
- **[Divider](https://docs.slack.dev/reference/block-kit/blocks/divider-block)**: Visually separates pieces of info inside of a message. [Implementation](./src/blocks/divider.py).
Expand Down
16 changes: 16 additions & 0 deletions block-kit/src/blocks/alert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from slack_sdk.models.blocks import AlertBlock
from slack_sdk.models.blocks.basic_components import MarkdownTextObject


def example01() -> AlertBlock:
"""
Displays a notification message within a modal.
https://docs.slack.dev/reference/block-kit/blocks/alert-block/

An informational alert.
"""
block = AlertBlock(
text=MarkdownTextObject(text="The work is mysterious and important."),
level="info",
)
return block
17 changes: 17 additions & 0 deletions block-kit/tests/blocks/test_alert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json

from src.blocks import alert


def test_example01():
block = alert.example01()
actual = block.to_dict()
expected = {
"type": "alert",
"text": {
"type": "mrkdwn",
"text": "The work is mysterious and important.",
},
"level": "info",
}
assert json.dumps(actual, sort_keys=True) == json.dumps(expected, sort_keys=True)