-
Notifications
You must be signed in to change notification settings - Fork 233
feat: support mrkdwn descriptions on OptionObject (#1471) #1645
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| package com.slack.api.model.kotlin_extension.block.composition | ||
|
|
||
| import com.slack.api.model.block.composition.MarkdownTextObject | ||
| import com.slack.api.model.block.composition.OptionObject | ||
| import com.slack.api.model.block.composition.PlainTextObject | ||
| import com.slack.api.model.block.composition.TextObject | ||
| import com.slack.api.model.kotlin_extension.block.BlockLayoutBuilder | ||
| import com.slack.api.model.kotlin_extension.block.Builder | ||
| import com.slack.api.model.kotlin_extension.block.composition.container.SingleTextObjectContainer | ||
|
|
@@ -14,7 +16,7 @@ class OptionObjectBuilder private constructor( | |
| ) : Builder<OptionObject>, TextObjectDsl by textContainer { | ||
| private var value: String? = null | ||
| private var url: String? = null | ||
| private var description: PlainTextObject? = null | ||
| private var description: TextObject? = null | ||
|
|
||
| constructor() : this(SingleTextObjectContainer()) | ||
|
|
||
|
|
@@ -40,15 +42,27 @@ class OptionObjectBuilder private constructor( | |
| } | ||
|
|
||
| /** | ||
| * a line of descriptive text shown below the text field beside the radio button. Maximum length for the text | ||
| * object within this field is 75 characters. | ||
| * A plain_text text object that defines a line of descriptive text shown below the text field beside a single | ||
| * selectable item in a select menu, multi-select menu, checkbox group, radio button group, or overflow menu. | ||
| * Maximum length for the text within this field is 75 characters. | ||
| * | ||
| * @see <a href="https://docs.slack.dev/reference/block-kit/composition-objects/option-object">Option object documentation</a> | ||
| */ | ||
| fun description(text: String, emoji: Boolean? = null) { | ||
| description = PlainTextObject(text, emoji) | ||
| } | ||
|
|
||
| /** | ||
| * A mrkdwn text object that defines a line of descriptive text shown below the text field beside a single | ||
| * selectable item. Only checkbox group and radio button group items can use mrkdwn formatting. | ||
| * Maximum length for the text within this field is 75 characters. | ||
| * | ||
| * @see <a href="https://docs.slack.dev/reference/block-kit/composition-objects/option-object">Option object documentation</a> | ||
| */ | ||
| fun markdownDescription(text: String, verbatim: Boolean? = null) { | ||
| description = MarkdownTextObject(text, verbatim) | ||
| } | ||
|
Comment on lines
+62
to
+64
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👁️🗨️ note: This pattern is similar to how the text object is supported although I understand this isn't identical for the current description object:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ☁️ note: Calling this out here because I'm uncertain if we're using the best pattern without introducing a break:
|
||
|
|
||
| override fun build(): OptionObject { | ||
| return OptionObject.builder() | ||
| .description(description) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,13 @@ public class OptionObject { | |
| private String value; | ||
|
|
||
| /** | ||
| * A plain_text only text object that defines a line of descriptive text shown | ||
| * below the text field beside the radio button. | ||
| * Maximum length for the text object within this field is 75 characters. | ||
| * A plain_text text object that defines a line of descriptive text shown below | ||
| * the text field beside a single selectable item in a select menu, multi-select | ||
| * menu, checkbox group, radio button group, or overflow menu. Checkbox group and | ||
| * radio button group items can also use mrkdwn formatting. | ||
| * Maximum length for the text within this field is 75 characters. | ||
| */ | ||
| private PlainTextObject description; | ||
| private TextObject description; | ||
|
Comment on lines
+32
to
+38
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤓 note: This matches reference and becomes more general to support API requests with validation left to blocks itself. 🔗 https://docs.slack.dev/reference/block-kit/composition-objects/option-object |
||
|
|
||
| /** | ||
| * A URL to load in the user's browser when the option is clicked. | ||
|
|
||
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.
🔭 note: These
descriptionvalues are added to tests so JSON reflections don't error when deciding betweenplain_textandmrkdwnvalues.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.
👾 note: This is a test change and wouldn't require similar from developers as I understand.