Skip to content

Commit 78c6264

Browse files
committed
feat: showcase the 'actions' block matching examples in documentation
0 parents  commit 78c6264

File tree

9 files changed

+405
-0
lines changed

9 files changed

+405
-0
lines changed

.github/MAINTAINERS_GUIDE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Maintainers guide
2+
3+
Let's hope to have matching examples of documentation and reference for various runtimes be consistent!
4+
5+
## Development
6+
7+
Bringing ongoing changes from the [Java Slack SDK](https://github.com/slackapi/java-slack-sdk) requires [building from source](https://docs.slack.dev/tools/java-slack-sdk/guides/web-api-client-setup#build-from-source) with these commands:
8+
9+
```sh
10+
$ git clone [email protected]:slackapi/java-slack-sdk.git
11+
$ cd java-slack-sdk
12+
$ mvn install -Dmaven.test.skip=true
13+
```
14+
15+
This adds a snapshot to the `$HOME/.m2` path that are used after updating the versions found in a `pom.xml` file.
16+
17+
```diff
18+
<dependency>
19+
<groupId>com.slack.api</groupId>
20+
<artifactId>slack-api-model</artifactId>
21+
- <version>1.45.4</version>
22+
+ <version>1.45.4-SNAPSHOT</version>
23+
</dependency>
24+
```

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "maven"
8+
directory: "block-kit"
9+
schedule:
10+
interval: "weekly"
11+
groups:
12+
slack:
13+
patterns:
14+
- "com.slack.api:*"

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
test:
7+
name: "maven@java17"
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
showcase:
12+
- "block-kit"
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
- name: Install JDK
17+
uses: actions/setup-java@v5
18+
with:
19+
java-version: 17
20+
distribution: "adopt"
21+
- name: Run tests
22+
run: |
23+
cd "${{ matrix.showcase }}"
24+
mvn --batch-mode spotless:check
25+
mvn --batch-mode test -Dspotless.apply.skip

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Bolt for Java Showcase
2+
3+
This collections of examples highlights features of a Slack app in the language of Bolt for Java.
4+
5+
## Available demonstration
6+
7+
- [Block Kit](./block-kit): the framework of visual components arranged to create app layouts.

block-kit/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.classpath
2+
.project
3+
.settings
4+
target

block-kit/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Block Kit
2+
3+
The framework of visual components arranged to create app layouts.
4+
5+
Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind these constructions, or explore [reference](https://docs.slack.dev/reference/block-kit) pages for attribute details.
6+
7+
## What's on display
8+
9+
### Blocks
10+
11+
- **[Actions block](https://docs.slack.dev/reference/block-kit/blocks/actions-block)**: Holds multiple interactive elements. [Implementation](./src/main/java/blocks/Actions.java).
12+

block-kit/pom.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.slack.api</groupId>
6+
<artifactId>bolt-showcase</artifactId>
7+
<version>0.1-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
<properties>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
</properties>
12+
<build>
13+
<plugins>
14+
<plugin>
15+
<groupId>org.apache.maven.plugins</groupId>
16+
<artifactId>maven-compiler-plugin</artifactId>
17+
<version>3.11.0</version>
18+
<configuration>
19+
<release>17</release>
20+
</configuration>
21+
</plugin>
22+
<plugin>
23+
<groupId>com.diffplug.spotless</groupId>
24+
<artifactId>spotless-maven-plugin</artifactId>
25+
<version>2.44.5</version>
26+
<configuration>
27+
<formats>
28+
<format>
29+
<includes>
30+
<include>.gitignore</include>
31+
</includes>
32+
<trimTrailingWhitespace/>
33+
<endWithNewline/>
34+
<indent>
35+
<tabs>true</tabs>
36+
<spacesPerTab>4</spacesPerTab>
37+
</indent>
38+
</format>
39+
</formats>
40+
<java>
41+
<palantirJavaFormat/>
42+
</java>
43+
<pom/>
44+
<markdown>
45+
<includes>
46+
<include>**/*.md</include>
47+
</includes>
48+
<flexmark/>
49+
</markdown>
50+
</configuration>
51+
<executions>
52+
<execution>
53+
<goals>
54+
<goal>apply</goal>
55+
</goals>
56+
<phase>compile</phase>
57+
</execution>
58+
</executions>
59+
</plugin>
60+
</plugins>
61+
</build>
62+
<dependencies>
63+
<dependency>
64+
<groupId>com.slack.api</groupId>
65+
<artifactId>slack-api-model</artifactId>
66+
<version>1.45.4</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>com.slack.api</groupId>
70+
<artifactId>slack-api-client</artifactId>
71+
<version>1.45.4</version>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>com.google.code.gson</groupId>
76+
<artifactId>gson</artifactId>
77+
<version>2.10.1</version>
78+
<scope>test</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.junit.jupiter</groupId>
82+
<artifactId>junit-jupiter</artifactId>
83+
<version>5.10.2</version>
84+
<scope>test</scope>
85+
</dependency>
86+
</dependencies>
87+
</project>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package blocks;
2+
3+
import static com.slack.api.model.block.composition.BlockCompositions.plainText;
4+
5+
import com.slack.api.model.block.ActionsBlock;
6+
import com.slack.api.model.block.Blocks;
7+
import com.slack.api.model.block.composition.BlockCompositions;
8+
import com.slack.api.model.block.composition.OptionObject;
9+
import com.slack.api.model.block.element.BlockElements;
10+
import java.util.List;
11+
12+
/**
13+
* Holds multiple interactive elements.
14+
* {@link https://docs.slack.dev/reference/block-kit/blocks/actions-block/}
15+
*/
16+
public class Actions {
17+
/**
18+
* An actions block with a select menu and a button.
19+
*/
20+
public static ActionsBlock example01() {
21+
ActionsBlock block = Blocks.actions(a -> a.blockId("actions1")
22+
.elements(List.of(
23+
BlockElements.staticSelect(s -> s.actionId("select_2")
24+
.placeholder(BlockCompositions.plainText("Which witch is the witchiest witch?"))
25+
.options(List.of(
26+
OptionObject.builder()
27+
.text(plainText("Matilda"))
28+
.value("matilda")
29+
.build(),
30+
OptionObject.builder()
31+
.text(plainText("Glinda"))
32+
.value("glinda")
33+
.build(),
34+
OptionObject.builder()
35+
.text(plainText("Granny Weatherwax"))
36+
.value("grannyWeatherwax")
37+
.build(),
38+
OptionObject.builder()
39+
.text(plainText("Hermione"))
40+
.value("hermione")
41+
.build()))),
42+
BlockElements.button(b -> b.text(BlockCompositions.plainText("Cancel"))
43+
.value("cancel")
44+
.actionId("button_1")))));
45+
return block;
46+
}
47+
48+
/**
49+
* An actions block with a datepicker, an overflow, and a button.
50+
*/
51+
public static ActionsBlock example02() {
52+
ActionsBlock block = Blocks.actions(a -> a.blockId("actionblock789")
53+
.elements(List.of(
54+
BlockElements.datePicker(d -> d.actionId("datepicker123")
55+
.initialDate("1990-04-28")
56+
.placeholder(BlockCompositions.plainText("Select a date"))),
57+
BlockElements.overflowMenu(o -> o.actionId("overflow")
58+
.options(List.of(
59+
OptionObject.builder()
60+
.text(plainText("*this is plain_text text*"))
61+
.value("value-0")
62+
.build(),
63+
OptionObject.builder()
64+
.text(plainText("*this is plain_text text*"))
65+
.value("value-1")
66+
.build(),
67+
OptionObject.builder()
68+
.text(plainText("*this is plain_text text*"))
69+
.value("value-2")
70+
.build(),
71+
OptionObject.builder()
72+
.text(plainText("*this is plain_text text*"))
73+
.value("value-3")
74+
.build(),
75+
OptionObject.builder()
76+
.text(plainText("*this is plain_text text*"))
77+
.value("value-4")
78+
.build()))),
79+
BlockElements.button(b -> b.text(BlockCompositions.plainText("Click Me"))
80+
.value("click_me_123")
81+
.actionId("button")))));
82+
return block;
83+
}
84+
}

0 commit comments

Comments
 (0)