From 47599d466accdc837e41d5f843d2ee4b532dd486 Mon Sep 17 00:00:00 2001 From: Ale Mercado Date: Thu, 27 Aug 2026 15:54:39 -0400 Subject: [PATCH 1/3] feat: add alert block example --- block-kit/src/main/java/blocks/Alert.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 block-kit/src/main/java/blocks/Alert.java diff --git a/block-kit/src/main/java/blocks/Alert.java b/block-kit/src/main/java/blocks/Alert.java new file mode 100644 index 0000000..ea75d7d --- /dev/null +++ b/block-kit/src/main/java/blocks/Alert.java @@ -0,0 +1,21 @@ +package blocks; + +import com.slack.api.model.block.AlertBlock; +import com.slack.api.model.block.Blocks; +import com.slack.api.model.block.composition.BlockCompositions; + +/** + * Displays alerts, warnings, and informational messages. + * {@link https://docs.slack.dev/reference/block-kit/blocks/alert-block/} + */ +public class Alert { + /** + * An informational alert. + */ + public static AlertBlock example01() { + AlertBlock block = + Blocks.alert(a -> a.text(BlockCompositions.markdownText("The work is mysterious and important.")) + .level("info")); + return block; + } +} From aaf36ea8a8533e96f01497d0dfa95f204bb0c0b6 Mon Sep 17 00:00:00 2001 From: Ale Mercado Date: Fri, 28 Aug 2026 10:24:20 -0400 Subject: [PATCH 2/3] test: add alert block test --- block-kit/src/test/java/blocks/AlertTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 block-kit/src/test/java/blocks/AlertTest.java diff --git a/block-kit/src/test/java/blocks/AlertTest.java b/block-kit/src/test/java/blocks/AlertTest.java new file mode 100644 index 0000000..4185b99 --- /dev/null +++ b/block-kit/src/test/java/blocks/AlertTest.java @@ -0,0 +1,27 @@ +package blocks; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.JsonParser; +import com.slack.api.model.block.AlertBlock; +import com.slack.api.util.json.GsonFactory; +import org.junit.jupiter.api.Test; + +public class AlertTest { + @Test + public void testExample01() { + AlertBlock block = Alert.example01(); + String actual = GsonFactory.createSnakeCase().toJson(block); + String expected = """ + { + "type": "alert", + "text": { + "type": "mrkdwn", + "text": "The work is mysterious and important." + }, + "level": "info" + } + """; + assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual)); + } +} From a07003713b1f82532b63bc65931dcad241a800ee Mon Sep 17 00:00:00 2001 From: Ale Mercado Date: Fri, 28 Aug 2026 10:26:46 -0400 Subject: [PATCH 3/3] docs: add alert block to readme --- block-kit/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/block-kit/README.md b/block-kit/README.md index 3cd3768..77114fa 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/main/java/blocks/Actions.java). +- **[Alert](https://docs.slack.dev/reference/block-kit/blocks/alert-block)**: Displays alerts, warnings, and informational messages. [Implementation](./src/main/java/blocks/Alert.java). - **[Context](https://docs.slack.dev/reference/block-kit/blocks/context-block)**: Provides contextual info, which can include both images and text. [Implementation](./src/main/java/blocks/Context.java). - **[Divider](https://docs.slack.dev/reference/block-kit/blocks/divider-block)**: Visually separates pieces of info inside of a message. [Implementation](./src/main/java/blocks/Divider.java). - **[File](https://docs.slack.dev/reference/block-kit/blocks/file-block)**: Displays info about remote files. [Implementation](./src/main/java/blocks/File.java).