Skip to content

Commit 6952eef

Browse files
authored
Add timezone property to timepicker block element (#1010)
1 parent 010182c commit 6952eef

File tree

14 files changed

+132
-12
lines changed

14 files changed

+132
-12
lines changed

bolt-socket-mode/src/test/java/samples/SimpleApp.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import com.slack.api.model.event.MessageChangedEvent;
88
import com.slack.api.model.event.MessageDeletedEvent;
99
import com.slack.api.model.event.MessageEvent;
10+
import com.slack.api.model.view.ViewState;
1011
import config.Constants;
1112

1213
import static com.slack.api.model.block.Blocks.asBlocks;
1314
import static com.slack.api.model.block.Blocks.input;
1415
import 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.*;
1617
import static com.slack.api.model.view.Views.*;
1718

1819
public 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!");

json-logs/samples/api/views.open.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
"emoji": false
375375
},
376376
"initial_time": "",
377+
"timezone": "",
377378
"confirm": {
378379
"title": {
379380
"type": "plain_text",
@@ -1065,6 +1066,7 @@
10651066
"emoji": false
10661067
},
10671068
"initial_time": "",
1069+
"timezone": "",
10681070
"confirm": {
10691071
"title": {
10701072
"type": "plain_text",

json-logs/samples/api/views.publish.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
"emoji": false
375375
},
376376
"initial_time": "",
377+
"timezone": "",
377378
"confirm": {
378379
"title": {
379380
"type": "plain_text",
@@ -1065,6 +1066,7 @@
10651066
"emoji": false
10661067
},
10671068
"initial_time": "",
1069+
"timezone": "",
10681070
"confirm": {
10691071
"title": {
10701072
"type": "plain_text",

json-logs/samples/api/views.push.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
"emoji": false
375375
},
376376
"initial_time": "",
377+
"timezone": "",
377378
"confirm": {
378379
"title": {
379380
"type": "plain_text",
@@ -1065,6 +1066,7 @@
10651066
"emoji": false
10661067
},
10671068
"initial_time": "",
1069+
"timezone": "",
10681070
"confirm": {
10691071
"title": {
10701072
"type": "plain_text",

json-logs/samples/api/views.update.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
"emoji": false
375375
},
376376
"initial_time": "",
377+
"timezone": "",
377378
"confirm": {
378379
"title": {
379380
"type": "plain_text",
@@ -1065,6 +1066,7 @@
10651066
"emoji": false
10661067
},
10671068
"initial_time": "",
1069+
"timezone": "",
10681070
"confirm": {
10691071
"title": {
10701072
"type": "plain_text",

json-logs/samples/rtm/MessageEvent.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376
"emoji": false
377377
},
378378
"initial_time": "",
379+
"timezone": "",
379380
"confirm": {
380381
"title": {
381382
"type": "plain_text",
@@ -2790,6 +2791,7 @@
27902791
"emoji": false
27912792
},
27922793
"initial_time": "",
2794+
"timezone": "",
27932795
"confirm": {
27942796
"title": {
27952797
"type": "plain_text",
@@ -3840,6 +3842,7 @@
38403842
"emoji": false
38413843
},
38423844
"initial_time": "",
3845+
"timezone": "",
38433846
"confirm": {
38443847
"title": {
38453848
"type": "plain_text",
@@ -6254,6 +6257,7 @@
62546257
"emoji": false
62556258
},
62566259
"initial_time": "",
6260+
"timezone": "",
62576261
"confirm": {
62586262
"title": {
62596263
"type": "plain_text",

json-logs/samples/rtm/PinAddedEvent.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@
385385
"emoji": false
386386
},
387387
"initial_time": "",
388+
"timezone": "",
388389
"confirm": {
389390
"title": {
390391
"type": "plain_text",
@@ -2799,6 +2800,7 @@
27992800
"emoji": false
28002801
},
28012802
"initial_time": "",
2803+
"timezone": "",
28022804
"confirm": {
28032805
"title": {
28042806
"type": "plain_text",
@@ -3849,6 +3851,7 @@
38493851
"emoji": false
38503852
},
38513853
"initial_time": "",
3854+
"timezone": "",
38523855
"confirm": {
38533856
"title": {
38543857
"type": "plain_text",
@@ -6263,6 +6266,7 @@
62636266
"emoji": false
62646267
},
62656268
"initial_time": "",
6269+
"timezone": "",
62666270
"confirm": {
62676271
"title": {
62686272
"type": "plain_text",

json-logs/samples/rtm/PinRemovedEvent.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@
385385
"emoji": false
386386
},
387387
"initial_time": "",
388+
"timezone": "",
388389
"confirm": {
389390
"title": {
390391
"type": "plain_text",
@@ -2799,6 +2800,7 @@
27992800
"emoji": false
28002801
},
28012802
"initial_time": "",
2803+
"timezone": "",
28022804
"confirm": {
28032805
"title": {
28042806
"type": "plain_text",
@@ -3849,6 +3851,7 @@
38493851
"emoji": false
38503852
},
38513853
"initial_time": "",
3854+
"timezone": "",
38523855
"confirm": {
38533856
"title": {
38543857
"type": "plain_text",
@@ -6263,6 +6266,7 @@
62636266
"emoji": false
62646267
},
62656268
"initial_time": "",
6269+
"timezone": "",
62666270
"confirm": {
62676271
"title": {
62686272
"type": "plain_text",

json-logs/samples/rtm/StarAddedEvent.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@
385385
"emoji": false
386386
},
387387
"initial_time": "",
388+
"timezone": "",
388389
"confirm": {
389390
"title": {
390391
"type": "plain_text",
@@ -2799,6 +2800,7 @@
27992800
"emoji": false
28002801
},
28012802
"initial_time": "",
2803+
"timezone": "",
28022804
"confirm": {
28032805
"title": {
28042806
"type": "plain_text",
@@ -3849,6 +3851,7 @@
38493851
"emoji": false
38503852
},
38513853
"initial_time": "",
3854+
"timezone": "",
38523855
"confirm": {
38533856
"title": {
38543857
"type": "plain_text",
@@ -6263,6 +6266,7 @@
62636266
"emoji": false
62646267
},
62656268
"initial_time": "",
6269+
"timezone": "",
62666270
"confirm": {
62676271
"title": {
62686272
"type": "plain_text",

json-logs/samples/rtm/StarRemovedEvent.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@
384384
"emoji": false
385385
},
386386
"initial_time": "",
387+
"timezone": "",
387388
"confirm": {
388389
"title": {
389390
"type": "plain_text",
@@ -2798,6 +2799,7 @@
27982799
"emoji": false
27992800
},
28002801
"initial_time": "",
2802+
"timezone": "",
28012803
"confirm": {
28022804
"title": {
28032805
"type": "plain_text",
@@ -3848,6 +3850,7 @@
38483850
"emoji": false
38493851
},
38503852
"initial_time": "",
3853+
"timezone": "",
38513854
"confirm": {
38523855
"title": {
38533856
"type": "plain_text",
@@ -6262,6 +6265,7 @@
62626265
"emoji": false
62636266
},
62646267
"initial_time": "",
6268+
"timezone": "",
62656269
"confirm": {
62666270
"title": {
62676271
"type": "plain_text",

0 commit comments

Comments
 (0)