diff --git a/block-kit/README.md b/block-kit/README.md index ee77ff0..f062272 100644 --- a/block-kit/README.md +++ b/block-kit/README.md @@ -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). diff --git a/block-kit/src/blocks/alert.py b/block-kit/src/blocks/alert.py new file mode 100644 index 0000000..316e347 --- /dev/null +++ b/block-kit/src/blocks/alert.py @@ -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 diff --git a/block-kit/tests/blocks/test_alert.py b/block-kit/tests/blocks/test_alert.py new file mode 100644 index 0000000..b1e359c --- /dev/null +++ b/block-kit/tests/blocks/test_alert.py @@ -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)