-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfirmationDialog.java
More file actions
37 lines (34 loc) · 1.72 KB
/
Copy pathConfirmationDialog.java
File metadata and controls
37 lines (34 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package compositionobjects;
import static com.slack.api.model.block.composition.BlockCompositions.markdownText;
import static com.slack.api.model.block.composition.BlockCompositions.plainText;
import com.slack.api.model.block.ActionsBlock;
import com.slack.api.model.block.Blocks;
import com.slack.api.model.block.composition.ConfirmationDialogObject;
import com.slack.api.model.block.element.BlockElements;
import java.util.List;
/**
* Defines a dialog that adds a confirmation step to interactive elements.
* {@link https://docs.slack.dev/reference/block-kit/composition-objects/confirmation-dialog-object/}
*/
public class ConfirmationDialog {
/**
* An actions block with a button carrying a confirmation dialog.
*/
public static ActionsBlock example01() {
ActionsBlock block = Blocks.actions(a -> a.elements(List.of(
BlockElements.button(
b -> b.text(plainText(pt -> pt.text("Approve").emoji(true)))
.confirm(ConfirmationDialogObject.builder()
.title(plainText("Are you sure?"))
.text(markdownText("Would you not prefer a good game of _chess_?"))
.confirm(plainText("Do it"))
.deny(plainText("Stop, I changed my mind!"))
.build())
.style("primary")
.value("click_me_123")),
BlockElements.button(b -> b.text(plainText(pt -> pt.text("Deny").emoji(true)))
.style("danger")
.value("click_me_123")))));
return block;
}
}