Skip to content

Commit 34ab901

Browse files
zimegClaude
andcommitted
fix(block-kit): wrap file_input and rich_text_input examples in their docs view
The docs.slack.dev reference pages show the file input element inside a modal view and the rich text input element inside a home view. Return those full View payloads (instead of a bare input block) so each example matches its reference JSON field-for-field, and update the tests to assert the full view payload. Descriptive Javadoc lines match the reviewed JS wording. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent 6c590be commit 34ab901

4 files changed

Lines changed: 84 additions & 52 deletions

File tree

block-kit/src/main/java/elements/FileInput.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import static com.slack.api.model.block.composition.BlockCompositions.plainText;
44

55
import com.slack.api.model.block.Blocks;
6-
import com.slack.api.model.block.InputBlock;
76
import com.slack.api.model.block.element.BlockElements;
7+
import com.slack.api.model.view.View;
8+
import com.slack.api.model.view.Views;
89
import java.util.List;
910

1011
/**
@@ -13,14 +14,19 @@
1314
*/
1415
public class FileInput {
1516
/**
16-
* An input block with a file input element.
17+
* A modal view with a file input element hosted in an input block.
1718
*/
18-
public static InputBlock example01() {
19-
InputBlock block = Blocks.input(i -> i.blockId("input_block_id")
20-
.label(plainText("Upload Files"))
21-
.element(BlockElements.fileInput(f -> f.actionId("file_input_action_id_1")
22-
.filetypes(List.of("jpg", "png"))
23-
.maxFiles(5))));
24-
return block;
19+
public static View example01() {
20+
View view = Views.view(v -> v.type("modal")
21+
.title(Views.viewTitle(t -> t.type("plain_text").text("My App").emoji(true)))
22+
.submit(Views.viewSubmit(
23+
s -> s.type("plain_text").text("Submit").emoji(true)))
24+
.close(Views.viewClose(c -> c.type("plain_text").text("Cancel").emoji(true)))
25+
.blocks(List.of(Blocks.input(i -> i.blockId("input_block_id")
26+
.label(plainText("Upload Files"))
27+
.element(BlockElements.fileInput(f -> f.actionId("file_input_action_id_1")
28+
.filetypes(List.of("jpg", "png"))
29+
.maxFiles(5)))))));
30+
return view;
2531
}
2632
}

block-kit/src/main/java/elements/RichTextInput.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import static com.slack.api.model.block.composition.BlockCompositions.plainText;
44

55
import com.slack.api.model.block.Blocks;
6-
import com.slack.api.model.block.InputBlock;
76
import com.slack.api.model.block.composition.DispatchActionConfig;
87
import com.slack.api.model.block.element.BlockElements;
8+
import com.slack.api.model.view.View;
9+
import com.slack.api.model.view.Views;
910
import java.util.List;
1011

1112
/**
@@ -15,17 +16,17 @@
1516
*/
1617
public class RichTextInput {
1718
/**
18-
* An input block with a rich text input element.
19+
* A home view with an input block containing a rich text input element.
1920
*/
20-
public static InputBlock example01() {
21-
InputBlock block =
22-
Blocks.input(i -> i.element(BlockElements.richTextInput(rt -> rt.actionId("rich_text_input-action")
21+
public static View example01() {
22+
View view = Views.view(v -> v.type("home").blocks(List.of(Blocks.input(i -> i.element(
23+
BlockElements.richTextInput(rt -> rt.actionId("rich_text_input-action")
2324
.dispatchActionConfig(DispatchActionConfig.builder()
2425
.triggerActionsOn(List.of("on_character_entered"))
2526
.build())
2627
.focusOnLoad(true)
2728
.placeholder(plainText("Enter text"))))
28-
.label(plainText(l -> l.text("Label").emoji(true))));
29-
return block;
29+
.label(plainText(l -> l.text("Label").emoji(true)))))));
30+
return view;
3031
}
3132
}

block-kit/src/test/java/elements/FileInputTest.java

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,50 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import com.google.gson.JsonParser;
6-
import com.slack.api.model.block.InputBlock;
6+
import com.slack.api.model.view.View;
77
import com.slack.api.util.json.GsonFactory;
88
import org.junit.jupiter.api.Test;
99

1010
public class FileInputTest {
1111
@Test
1212
public void testExample01() {
13-
InputBlock block = FileInput.example01();
14-
String actual = GsonFactory.createSnakeCase().toJson(block);
13+
View view = FileInput.example01();
14+
String actual = GsonFactory.createSnakeCase().toJson(view);
1515
String expected = """
1616
{
17-
"type": "input",
18-
"block_id": "input_block_id",
19-
"label": {
17+
"type": "modal",
18+
"title": {
2019
"type": "plain_text",
21-
"text": "Upload Files"
20+
"text": "My App",
21+
"emoji": true
2222
},
23-
"element": {
24-
"type": "file_input",
25-
"action_id": "file_input_action_id_1",
26-
"filetypes": ["jpg", "png"],
27-
"max_files": 5
23+
"submit": {
24+
"type": "plain_text",
25+
"text": "Submit",
26+
"emoji": true
27+
},
28+
"close": {
29+
"type": "plain_text",
30+
"text": "Cancel",
31+
"emoji": true
2832
},
29-
"optional": false
33+
"blocks": [
34+
{
35+
"type": "input",
36+
"block_id": "input_block_id",
37+
"label": {
38+
"type": "plain_text",
39+
"text": "Upload Files"
40+
},
41+
"element": {
42+
"type": "file_input",
43+
"action_id": "file_input_action_id_1",
44+
"filetypes": ["jpg", "png"],
45+
"max_files": 5
46+
},
47+
"optional": false
48+
}
49+
]
3050
}
3151
""";
3252
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));

block-kit/src/test/java/elements/RichTextInputTest.java

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,43 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import com.google.gson.JsonParser;
6-
import com.slack.api.model.block.InputBlock;
6+
import com.slack.api.model.view.View;
77
import com.slack.api.util.json.GsonFactory;
88
import org.junit.jupiter.api.Test;
99

1010
public class RichTextInputTest {
1111
@Test
1212
public void testExample01() {
13-
InputBlock block = RichTextInput.example01();
14-
String actual = GsonFactory.createSnakeCase().toJson(block);
13+
View view = RichTextInput.example01();
14+
String actual = GsonFactory.createSnakeCase().toJson(view);
1515
String expected = """
1616
{
17-
"type": "input",
18-
"element": {
19-
"type": "rich_text_input",
20-
"action_id": "rich_text_input-action",
21-
"dispatch_action_config": {
22-
"trigger_actions_on": [
23-
"on_character_entered"
24-
]
25-
},
26-
"focus_on_load": true,
27-
"placeholder": {
28-
"type": "plain_text",
29-
"text": "Enter text"
17+
"type": "home",
18+
"blocks": [
19+
{
20+
"type": "input",
21+
"element": {
22+
"type": "rich_text_input",
23+
"action_id": "rich_text_input-action",
24+
"dispatch_action_config": {
25+
"trigger_actions_on": [
26+
"on_character_entered"
27+
]
28+
},
29+
"focus_on_load": true,
30+
"placeholder": {
31+
"type": "plain_text",
32+
"text": "Enter text"
33+
}
34+
},
35+
"label": {
36+
"type": "plain_text",
37+
"text": "Label",
38+
"emoji": true
39+
},
40+
"optional": false
3041
}
31-
},
32-
"label": {
33-
"type": "plain_text",
34-
"text": "Label",
35-
"emoji": true
36-
},
37-
"optional": false
42+
]
3843
}
3944
""";
4045
assertEquals(JsonParser.parseString(expected), JsonParser.parseString(actual));

0 commit comments

Comments
 (0)