-
Notifications
You must be signed in to change notification settings - Fork 232
feat(model): add card, carousel, and alert Block Kit blocks #1624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
54a1056
feat(model): add card layout block
srtaalej 5a28b4f
feat(model): add carousel layout block
srtaalej 49d84f6
feat(model): add alert layout block
srtaalej d9fa377
test: add BlocksTest entries for alert, card, and carousel blocks
srtaalej fb48484
Merge branch 'main' into ale-add-card-carousel-alert-blocks
srtaalej be95843
fix(model): remove empty list initialization from CarouselBlock.elements
srtaalej ac33ff6
feat(model): add SlackIconObject composition object for CardBlock.sla…
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
slack-api-model/src/main/java/com/slack/api/model/block/AlertBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.slack.api.model.block; | ||
|
|
||
| import com.slack.api.model.block.composition.TextObject; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * https://docs.slack.dev/reference/block-kit/blocks/alert-block | ||
| * <p> | ||
| * Displays an inline alert message. Alert blocks are currently only supported in modals. | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class AlertBlock implements LayoutBlock { | ||
| public static final String TYPE = "alert"; | ||
| private final String type = TYPE; | ||
|
|
||
| /** | ||
| * The message content of the alert, as a plain_text or mrkdwn text object. | ||
| * Maximum length for the text in this field is 200 characters. | ||
| */ | ||
| private TextObject text; | ||
|
|
||
| /** | ||
| * The severity level of the alert. One of default, info, warning, error, or success. | ||
| * Will be default if omitted. | ||
| */ | ||
| private String level; | ||
|
|
||
| /** | ||
| * A string acting as a unique identifier for a block. If not specified, one will be generated. | ||
| * Maximum length for this field is 255 characters. | ||
| * block_id should be unique for each message and each iteration of a message. | ||
| * If a message is updated, use a new block_id. | ||
| */ | ||
| private String blockId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
slack-api-model/src/main/java/com/slack/api/model/block/CardBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package com.slack.api.model.block; | ||
|
|
||
| import com.slack.api.model.block.composition.SlackIconObject; | ||
| import com.slack.api.model.block.composition.TextObject; | ||
| import com.slack.api.model.block.element.BlockElement; | ||
| import com.slack.api.model.block.element.ImageElement; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A card is a layout block used to display a compact, structured summary of content. It can be used on | ||
| * its own or grouped together inside a {@link CarouselBlock carousel}. At least one of {@code heroImage}, | ||
| * {@code title}, {@code actions}, or {@code body} must be provided. | ||
| * | ||
| * https://docs.slack.dev/reference/block-kit/blocks/card-block | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class CardBlock implements LayoutBlock { | ||
| public static final String TYPE = "card"; | ||
| private final String type = TYPE; | ||
|
|
||
| /** | ||
| * A top banner image for the card in the form of an image element. | ||
| * The image URL may be up to 3000 characters and the alt text up to 2000 characters. | ||
| */ | ||
| private ImageElement heroImage; | ||
|
|
||
| /** | ||
| * A small icon displayed next to the title and subtitle in the form of an image element. | ||
| * The image URL may be up to 3000 characters and the alt text up to 2000 characters. | ||
| * Mutually exclusive with {@code slackIcon}. | ||
| */ | ||
| private ImageElement icon; | ||
|
|
||
| /** | ||
| * A built-in Slack icon displayed next to the title and subtitle. | ||
| * Mutually exclusive with {@code icon}. | ||
| */ | ||
| private SlackIconObject slackIcon; | ||
|
|
||
| /** | ||
| * The title of the card. Maximum length for the text in this field is 150 characters. | ||
| */ | ||
| private TextObject title; | ||
|
|
||
| /** | ||
| * The subtitle of the card. Maximum length for the text in this field is 150 characters. | ||
| */ | ||
| private TextObject subtitle; | ||
|
|
||
| /** | ||
| * The body text of the card. Maximum length for the text in this field is 200 characters. | ||
| */ | ||
| private TextObject body; | ||
|
|
||
| /** | ||
| * Secondary text displayed beneath the body of the card. Maximum length for the text in this field | ||
| * is 200 characters. | ||
| */ | ||
| private TextObject subtext; | ||
|
|
||
| /** | ||
| * Interactive elements (such as buttons) displayed at the bottom of the card. Up to 3 buttons. | ||
| */ | ||
| private List<BlockElement> actions; | ||
|
|
||
| private String blockId; | ||
| } |
30 changes: 30 additions & 0 deletions
30
slack-api-model/src/main/java/com/slack/api/model/block/CarouselBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.slack.api.model.block; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A carousel is a layout block used to display a horizontally scrollable collection of | ||
| * {@link CardBlock cards}. It must contain between 1 and 10 cards. | ||
| * | ||
| * https://docs.slack.dev/reference/block-kit/blocks/carousel-block | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class CarouselBlock implements LayoutBlock { | ||
| public static final String TYPE = "carousel"; | ||
| private final String type = TYPE; | ||
|
|
||
| /** | ||
| * An array of {@link CardBlock card} blocks. Must contain between 1 and 10 cards. | ||
| */ | ||
| private List<CardBlock> elements; | ||
|
|
||
| private String blockId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
slack-api-model/src/main/java/com/slack/api/model/block/composition/SlackIconObject.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.slack.api.model.block.composition; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * Defines a built-in Slack icon that can be displayed next to the title and subtitle of a card block. | ||
| * | ||
| * @see <a href="https://docs.slack.dev/reference/block-kit/composition-objects/slack-icon-object">document</a> | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class SlackIconObject { | ||
| public static final String TYPE = "icon"; | ||
| private final String type = TYPE; | ||
|
|
||
| /** | ||
| * The name of the built-in Slack icon. | ||
| */ | ||
| private String name; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🚀