Skip to content
Open
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 @@ -21,6 +21,7 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes
- **[Image](https://docs.slack.dev/reference/block-kit/blocks/image-block)**: Displays an image. [Implementation](./src/main/java/blocks/Image.java).
- **[Input](https://docs.slack.dev/reference/block-kit/blocks/input-block)**: Collects information from users via elements. [Implementation](./src/main/java/blocks/Input.java).
- **[Markdown](https://docs.slack.dev/reference/block-kit/blocks/markdown-block)**: Displays formatted markdown. [Implementation](./src/main/java/blocks/Markdown.java).
- **[Plan](https://docs.slack.dev/reference/block-kit/blocks/plan-block)**: Displays a collection of related tasks. [Implementation](./src/main/java/blocks/Plan.java).
- **[Section](https://docs.slack.dev/reference/block-kit/blocks/section-block)**: Displays text, possibly alongside elements. [Implementation](./src/main/java/blocks/Section.java).
- **[Task card](https://docs.slack.dev/reference/block-kit/blocks/task-card-block)**: Displays a single task, representing a single action. [Implementation](./src/main/java/blocks/TaskCard.java).
- **[Video](https://docs.slack.dev/reference/block-kit/blocks/video-block)**: Displays an embedded video player. [Implementation](./src/main/java/blocks/Video.java).
Expand Down
55 changes: 55 additions & 0 deletions block-kit/src/main/java/blocks/Plan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package blocks;

import com.slack.api.model.block.Blocks;
import com.slack.api.model.block.PlanBlock;

Check failure on line 4 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol

Check failure on line 4 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol
import com.slack.api.model.block.RichTextBlock;
import com.slack.api.model.block.element.RichTextSectionElement;
import java.util.List;

/**
* Displays a collection of related tasks.
* {@link https://docs.slack.dev/reference/block-kit/blocks/plan-block/}
*/
public class Plan {
/**
* A plan block with multiple task cards in various states.
*/
public static PlanBlock example01() {

Check failure on line 17 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol

Check failure on line 17 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol
PlanBlock block = Blocks.plan(p -> p.title("Thinking completed")

Check failure on line 18 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol

Check failure on line 18 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol

Check failure on line 18 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol

Check failure on line 18 in block-kit/src/main/java/blocks/Plan.java

View workflow job for this annotation

GitHub Actions / maven@java17 (block-kit)

cannot find symbol

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Matches the TaskCard example and the docs payload 👌 The block-kit build fails until a java-slack-sdk release with PlanBlock lands and the pom is bumped to it, so let's merge once that's in.

.tasks(List.of(
Blocks.taskCard(t -> t.taskId("call_001")
.title("Fetched user profile information")
.status("in_progress")
.details(RichTextBlock.builder()
.blockId("viMWO")
.elements(List.of(RichTextSectionElement.builder()
.elements(List.of(RichTextSectionElement.Text.builder()
.text("Searched database...")
.build()))
.build()))
.build())
.output(RichTextBlock.builder()
.blockId("viMWO")
.elements(List.of(RichTextSectionElement.builder()
.elements(List.of(RichTextSectionElement.Text.builder()
.text("Profile data loaded")
.build()))
.build()))
.build())),
Blocks.taskCard(t -> t.taskId("call_002")
.title("Checked user permissions")
.status("in_progress")),
Blocks.taskCard(t -> t.taskId("call_003")
.title("Generated comprehensive user report")
.status("complete")
.output(RichTextBlock.builder()
.blockId("crsk")
.elements(List.of(RichTextSectionElement.builder()
.elements(List.of(RichTextSectionElement.Text.builder()
.text("15 data points compiled")
.build()))
.build()))
.build())))));
return block;
}
}
88 changes: 88 additions & 0 deletions block-kit/src/test/java/blocks/PlanTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package blocks;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.google.gson.JsonParser;
import com.slack.api.model.block.PlanBlock;
import com.slack.api.util.json.GsonFactory;
import org.junit.jupiter.api.Test;

public class PlanTest {
@Test
public void testExample01() {
PlanBlock block = Plan.example01();
String actual = GsonFactory.createSnakeCase().toJson(block);
String expected = """
{
"type": "plan",
"title": "Thinking completed",
"tasks": [
{
"type": "task_card",
"task_id": "call_001",
"title": "Fetched user profile information",
"status": "in_progress",
"details": {
"type": "rich_text",
"block_id": "viMWO",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Searched database..."
}
]
}
]
},
"output": {
"type": "rich_text",
"block_id": "viMWO",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Profile data loaded"
}
]
}
]
}
},
{
"type": "task_card",
"task_id": "call_002",
"title": "Checked user permissions",
"status": "in_progress"
},
{
"type": "task_card",
"task_id": "call_003",
"title": "Generated comprehensive user report",
"status": "complete",
"output": {
"type": "rich_text",
"block_id": "crsk",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "15 data points compiled"
}
]
}
]
}
}
]
}
""";
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));
}
}
Loading