77import com .slack .api .model .event .MessageChangedEvent ;
88import com .slack .api .model .event .MessageDeletedEvent ;
99import com .slack .api .model .event .MessageEvent ;
10+ import com .slack .api .model .view .ViewState ;
1011import config .Constants ;
1112
1213import static com .slack .api .model .block .Blocks .asBlocks ;
1314import static com .slack .api .model .block .Blocks .input ;
1415import static com .slack .api .model .block .composition .BlockCompositions .plainText ;
15- import static com .slack .api .model .block .element .BlockElements .plainTextInput ;
16+ import static com .slack .api .model .block .element .BlockElements .* ;
1617import static com .slack .api .model .view .Views .*;
1718
1819public class SimpleApp {
@@ -26,10 +27,6 @@ public static void main(String[] args) throws Exception {
2627 return chain .next (req );
2728 });
2829
29- app .command ("/hi-socket-mode" , (req , ctx ) -> {
30- return ctx .ack ("Yes, I'm running in the Socket Mode!" );
31- });
32-
3330 app .event (AppMentionEvent .class , (req , ctx ) -> {
3431 ctx .say ("Hi there!" );
3532 return ctx .ack ();
@@ -47,7 +44,7 @@ public static void main(String[] args) throws Exception {
4744 app .event (MessageChangedEvent .class , (req , ctx ) -> ctx .ack ());
4845 app .event (MessageDeletedEvent .class , (req , ctx ) -> ctx .ack ());
4946
50- app .globalShortcut ( " socket-mode-global-shortcut " , (req , ctx ) -> {
47+ app .command ( "/hello- socket-mode" , (req , ctx ) -> {
5148 ctx .asyncClient ().viewsOpen (r -> r
5249 .triggerId (req .getContext ().getTriggerId ())
5350 .view (view (v -> v
@@ -56,16 +53,32 @@ public static void main(String[] args) throws Exception {
5653 .title (viewTitle (vt -> vt .type ("plain_text" ).text ("Modal by Global Shortcut" )))
5754 .close (viewClose (vc -> vc .type ("plain_text" ).text ("Close" )))
5855 .submit (viewSubmit (vs -> vs .type ("plain_text" ).text ("Submit" )))
59- .blocks (asBlocks (input (input -> input
60- .blockId ("agenda-block" )
61- .element (plainTextInput (pti -> pti .actionId ("agenda-action" ).multiline (true )))
62- .label (plainText (pt -> pt .text ("Detailed Agenda" ).emoji (true )))
63- )))
56+ .blocks (asBlocks (
57+ input (input -> input
58+ .blockId ("agenda-block" )
59+ .element (plainTextInput (pti -> pti .actionId ("agenda-action" ).multiline (true )))
60+ .label (plainText (pt -> pt .text ("Detailed Agenda" ).emoji (true )))
61+ ),
62+ input (input -> input
63+ .blockId ("date-block" )
64+ .element (datePicker (pti -> pti .actionId ("date-action" )))
65+ .label (plainText (pt -> pt .text ("Date" ).emoji (true )))
66+ ),
67+ input (input -> input
68+ .blockId ("time-block" )
69+ .element (timePicker (pti -> pti .actionId ("time-action" ).timezone ("America/Los_Angeles" )))
70+ .label (plainText (pt -> pt .text ("Time" ).emoji (true )))
71+ )
72+ ))
6473 )));
6574 return ctx .ack ();
6675 });
6776
68- app .viewSubmission ("test-view" , (req , ctx ) -> ctx .ack ());
77+ app .viewSubmission ("test-view" , (req , ctx ) -> {
78+ ViewState .Value time = req .getPayload ().getView ().getState ().getValues ().get ("time-block" ).get ("time-action" );
79+ assert time .getTimezone ().equals ("America/Los_Angeles" );
80+ return ctx .ack ();
81+ });
6982
7083 app .messageShortcut ("socket-mode-message-shortcut" , (req , ctx ) -> {
7184 ctx .respond ("It works!" );
0 commit comments