File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import static com .slack .api .model .block .composition .BlockCompositions .plainText ;
44
55import com .slack .api .model .block .Blocks ;
6- import com .slack .api .model .block .InputBlock ;
76import com .slack .api .model .block .element .BlockElements ;
7+ import com .slack .api .model .view .View ;
8+ import com .slack .api .model .view .Views ;
89import java .util .List ;
910
1011/**
1314 */
1415public 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}
Original file line number Diff line number Diff line change 33import static com .slack .api .model .block .composition .BlockCompositions .plainText ;
44
55import com .slack .api .model .block .Blocks ;
6- import com .slack .api .model .block .InputBlock ;
76import com .slack .api .model .block .composition .DispatchActionConfig ;
87import com .slack .api .model .block .element .BlockElements ;
8+ import com .slack .api .model .view .View ;
9+ import com .slack .api .model .view .Views ;
910import java .util .List ;
1011
1112/**
1516 */
1617public 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}
Original file line number Diff line number Diff line change 33import static org .junit .jupiter .api .Assertions .assertEquals ;
44
55import com .google .gson .JsonParser ;
6- import com .slack .api .model .block . InputBlock ;
6+ import com .slack .api .model .view . View ;
77import com .slack .api .util .json .GsonFactory ;
88import org .junit .jupiter .api .Test ;
99
1010public 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 ));
Original file line number Diff line number Diff line change 33import static org .junit .jupiter .api .Assertions .assertEquals ;
44
55import com .google .gson .JsonParser ;
6- import com .slack .api .model .block . InputBlock ;
6+ import com .slack .api .model .view . View ;
77import com .slack .api .util .json .GsonFactory ;
88import org .junit .jupiter .api .Test ;
99
1010public 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 ));
You can’t perform that action at this time.
0 commit comments