feat(model): add table Block Kit block - #1611
Conversation
Add support for the `table` layout block, which renders tabular data as a grid of rows and cells. Cells may be `raw_text`, `raw_number`, or a `rich_text` block, with optional per-column alignment/wrapping settings. - TableBlock (type "table") with rows, columnSettings, blockId - TableCell interface + RawTextTableCell, RawNumberTableCell impls; RichTextBlock now also implements TableCell for rich_text cells - TableColumnSetting (align, isWrapped) - GsonTableCellFactory for polymorphic cell (de)serialization, registered in GsonFactory; TableBlock registered in GsonLayoutBlockFactory - Blocks.table(...) builder helper - Tests covering parse, round-trip, and builder usage Docs: https://docs.slack.dev/reference/block-kit/blocks/table-block Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1611 +/- ##
============================================
+ Coverage 72.84% 72.86% +0.02%
- Complexity 4533 4543 +10
============================================
Files 482 483 +1
Lines 14423 14442 +19
Branches 1512 1512
============================================
+ Hits 10506 10523 +17
- Misses 3022 3023 +1
- Partials 895 896 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
@zimeg Thanks for this PR. Can this be merged please to bring parity? |
zimeg
left a comment
There was a problem hiding this comment.
📝 Leaving some thoughts on the first shot implementation that I think we might want to consider before merge. I'm curious if we start with a less complete implementation - table but no cells - for sake of aligning the data_table block properties but I haven't investigated too much more.
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class RawNumberTableCell implements TableCell { |
There was a problem hiding this comment.
👁️🗨️ question: Is this pattern more standard than perhaps reversing the order for more "direct" imports?
- RawNumberTableCell
+ TableCellRawNumber🪬 note: I might prefer the latter but not a blocker!
| case RawTextTableCell.TYPE: | ||
| return RawTextTableCell.class; | ||
| case RawNumberTableCell.TYPE: | ||
| return RawNumberTableCell.class; |
There was a problem hiding this comment.
🧮 question: Without testing on a personal sandbox I forget if this is stable? It's documented so no blocker here either!
| public class RawNumberTableCell implements TableCell { | ||
| public static final String TYPE = "raw_number"; | ||
| private final String type = TYPE; | ||
| private Double value; | ||
| private String text; | ||
| } |
There was a problem hiding this comment.
📝 note: I find raw_number is also supported with the Data Table block which makes me curious if this should be exported as a composition object instead?
Summary
Adds support for the
tableBlock Kit layout block to the Java SDK, bringing it to parity with the JS (@slack/types) and Python (slack_sdk) SDKs, which already ship this block.A
tableblock renders tabular data as a grid of rows and cells:TableBlock(type: "table") —rows(list of rows, each a list of cells; up to 100 rows, 20 cells/row), optionalcolumnSettings, andblockId.TableCellinterface implemented by the three cell types:RawTextTableCell(raw_text) —textRawNumberTableCell(raw_number) —value, optional displaytextRichTextBlock(rich_text) — the existing rich text block now also implementsTableCellTableColumnSetting—align(left/center/right),isWrappedGsonTableCellFactory— polymorphic (de)serialization of cells bytype, registered inGsonFactory(and the test-local factory);TableBlockregistered inGsonLayoutBlockFactoryBlocks.table(...)builder helper, mirroring the other block helpersFollows the existing block-model conventions (Lombok
@Data @Builder @NoArgsConstructor @AllArgsConstructor,public static final String TYPE, javadoc linking to the docs).Docs
https://docs.slack.dev/reference/block-kit/blocks/table-block
Validation
Run in this branch's worktree:
./mvnw -pl slack-api-model -am test -Dtest=BlockKitTest -Djacoco.skip=true→ Tests run: 45, Failures: 0, Errors: 0 (includes the 2 newparseTableBlock/buildTableBlockcases)./mvnw -pl slack-api-client -am compile -Djacoco.skip=true→ BUILD SUCCESS (validates theGsonFactoryregistration)Note:
jacoco.skip=truewas required because the locally available JDK is Java 25 and the project's JaCoCo agent cannot instrument class file major version 69 (Unsupported class file major version 69). This is an environment limitation unrelated to these changes; compilation and the tests themselves pass. CI (running the project's supported JDK) should exercise coverage normally.No changeset added — this repo uses Maven +
jSlack_changelog.md, not the.changeset/workflow.🤖 Generated with Claude Code