-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: Add the ability to set URL
on NewButtonBlockElement
via .WithURL()
#1250
Conversation
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.
I just ran into this in a project I was working on, instead of adding the URL as an argument in my fork I added a WithURL
method similar to what had been done for adding a style or confirm.
slack.NewButtonBlockElement(...).WithURL(url)
Good point, I like that better. Happy to rework this to go that route if maintainers would prefer |
Yeah, I'm really loathe to change a function signature. If this needs to be merged, please use e.g. |
d573676
to
e743e65
Compare
@@ -53,7 +53,7 @@ To preview this block on the builder website, you should copy just the contents | |||
The first example demonstrates usage of Sections, Fields and Action buttons. You can view the [Approval Example](https://api.slack.com/tools/block-kit-builder?blocks=%5B%0A%09%7B%0A%09%09%22type%22%3A%20%22section%22%2C%0A%09%09%22text%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%22text%22%3A%20%22You%20have%20a%20new%20request%3A%5Cn*%3CfakeLink.toEmployeeProfile.com%7CFred%20Enriquez%20-%20New%20device%20request%3E*%22%0A%09%09%7D%0A%09%7D%2C%0A%09%7B%0A%09%09%22type%22%3A%20%22section%22%2C%0A%09%09%22fields%22%3A%20%5B%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%09%22text%22%3A%20%22*Type%3A*%5CnComputer%20(laptop)%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%09%22text%22%3A%20%22*When%3A*%5CnSubmitted%20Aut%2010%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%09%22text%22%3A%20%22*Last%20Update%3A*%5CnMar%2010%2C%202015%20(3%20years%2C%205%20months)%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%09%22text%22%3A%20%22*Reason%3A*%5CnAll%20vowel%20keys%20aren%27t%20working.%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%09%22text%22%3A%20%22*Specs%3A*%5Cn%5C%22Cheetah%20Pro%2015%5C%22%20-%20Fast%2C%20really%20fast%5C%22%22%0A%09%09%09%7D%0A%09%09%5D%0A%09%7D%2C%0A%09%7B%0A%09%09%22type%22%3A%20%22actions%22%2C%0A%09%09%22elements%22%3A%20%5B%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22button%22%2C%0A%09%09%09%09%22text%22%3A%20%7B%0A%09%09%09%09%09%22type%22%3A%20%22plain_text%22%2C%0A%09%09%09%09%09%22emoji%22%3A%20true%2C%0A%09%09%09%09%09%22text%22%3A%20%22Approve%22%0A%09%09%09%09%7D%2C%0A%09%09%09%09%22value%22%3A%20%22click_me_123%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22button%22%2C%0A%09%09%09%09%22text%22%3A%20%7B%0A%09%09%09%09%09%22type%22%3A%20%22plain_text%22%2C%0A%09%09%09%09%09%22emoji%22%3A%20true%2C%0A%09%09%09%09%09%22text%22%3A%20%22Deny%22%0A%09%09%09%09%7D%2C%0A%09%09%09%09%22value%22%3A%20%22click_me_123%22%0A%09%09%09%7D%0A%09%09%5D%0A%09%7D%0A%5D) on the block kit builder website. This example can be generated with the function named `exampleOne`. | |||
|
|||
#### Example 2 - Approval - With Images | |||
The secoond example adds additional complexity by introducing images as accessories to main blocks of text. You can view this [Approval Example with Images](https://api.slack.com/tools/block-kit-builder?blocks=%5B%0A%09%7B%0A%09%09%22type%22%3A%20%22section%22%2C%0A%09%09%22text%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%22text%22%3A%20%22You%20have%20a%20new%20request%3A%5Cn*%3Cgoogle.com%7CFred%20Enriquez%20-%20Time%20Off%20request%3E*%22%0A%09%09%7D%0A%09%7D%2C%0A%09%7B%0A%09%09%22type%22%3A%20%22section%22%2C%0A%09%09%22text%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%22text%22%3A%20%22*Type%3A*%5CnPaid%20time%20off%5Cn*When%3A*%5CnAug%2010-Aug%2013%5Cn*Hours%3A*%2016.0%20(2%20days)%5Cn*Remaining%20balance%3A*%2032.0%20hours%20(4%20days)%5Cn*Comments%3A*%20%5C%22Family%20in%20town%2C%20going%20camping!%5C%22%22%0A%09%09%7D%2C%0A%09%09%22accessory%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22image%22%2C%0A%09%09%09%22image_url%22%3A%20%22https%3A%2F%2Fapi.slack.com%2Fimg%2Fblocks%2Fbkb_template_images%2FapprovalsNewDevice.png%22%2C%0A%09%09%09%22alt_text%22%3A%20%22computer%20thumbnail%22%0A%09%09%7D%0A%09%7D%2C%0A%09%7B%0A%09%09%22type%22%3A%20%22actions%22%2C%0A%09%09%22elements%22%3A%20%5B%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22button%22%2C%0A%09%09%09%09%22text%22%3A%20%7B%0A%09%09%09%09%09%22type%22%3A%20%22plain_text%22%2C%0A%09%09%09%09%09%22emoji%22%3A%20true%2C%0A%09%09%09%09%09%22text%22%3A%20%22Approve%22%0A%09%09%09%09%7D%2C%0A%09%09%09%09%22value%22%3A%20%22click_me_123%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22button%22%2C%0A%09%09%09%09%22text%22%3A%20%7B%0A%09%09%09%09%09%22type%22%3A%20%22plain_text%22%2C%0A%09%09%09%09%09%22emoji%22%3A%20true%2C%0A%09%09%09%09%09%22text%22%3A%20%22Deny%22%0A%09%09%09%09%7D%2C%0A%09%09%09%09%22value%22%3A%20%22click_me_123%22%0A%09%09%09%7D%0A%09%09%5D%0A%09%7D%0A%5D) on the block kit builder website. This example can be generated with the function named `exampleTwo`. | |||
The second example adds additional complexity by introducing images as accessories to main blocks of text. You can view this [Approval Example with Images](https://api.slack.com/tools/block-kit-builder?blocks=%5B%0A%09%7B%0A%09%09%22type%22%3A%20%22section%22%2C%0A%09%09%22text%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%22text%22%3A%20%22You%20have%20a%20new%20request%3A%5Cn*%3Cgoogle.com%7CFred%20Enriquez%20-%20Time%20Off%20request%3E*%22%0A%09%09%7D%0A%09%7D%2C%0A%09%7B%0A%09%09%22type%22%3A%20%22section%22%2C%0A%09%09%22text%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22mrkdwn%22%2C%0A%09%09%09%22text%22%3A%20%22*Type%3A*%5CnPaid%20time%20off%5Cn*When%3A*%5CnAug%2010-Aug%2013%5Cn*Hours%3A*%2016.0%20(2%20days)%5Cn*Remaining%20balance%3A*%2032.0%20hours%20(4%20days)%5Cn*Comments%3A*%20%5C%22Family%20in%20town%2C%20going%20camping!%5C%22%22%0A%09%09%7D%2C%0A%09%09%22accessory%22%3A%20%7B%0A%09%09%09%22type%22%3A%20%22image%22%2C%0A%09%09%09%22image_url%22%3A%20%22https%3A%2F%2Fapi.slack.com%2Fimg%2Fblocks%2Fbkb_template_images%2FapprovalsNewDevice.png%22%2C%0A%09%09%09%22alt_text%22%3A%20%22computer%20thumbnail%22%0A%09%09%7D%0A%09%7D%2C%0A%09%7B%0A%09%09%22type%22%3A%20%22actions%22%2C%0A%09%09%22elements%22%3A%20%5B%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22button%22%2C%0A%09%09%09%09%22text%22%3A%20%7B%0A%09%09%09%09%09%22type%22%3A%20%22plain_text%22%2C%0A%09%09%09%09%09%22emoji%22%3A%20true%2C%0A%09%09%09%09%09%22text%22%3A%20%22Approve%22%0A%09%09%09%09%7D%2C%0A%09%09%09%09%22value%22%3A%20%22click_me_123%22%0A%09%09%09%7D%2C%0A%09%09%09%7B%0A%09%09%09%09%22type%22%3A%20%22button%22%2C%0A%09%09%09%09%22text%22%3A%20%7B%0A%09%09%09%09%09%22type%22%3A%20%22plain_text%22%2C%0A%09%09%09%09%09%22emoji%22%3A%20true%2C%0A%09%09%09%09%09%22text%22%3A%20%22Deny%22%0A%09%09%09%09%7D%2C%0A%09%09%09%09%22value%22%3A%20%22click_me_123%22%0A%09%09%09%7D%0A%09%09%5D%0A%09%7D%0A%5D) on the block kit builder website. This example can be generated with the function named `exampleTwo`. |
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.
small typo fix
URL
on NewButtonBlockElement
via .WithURL()
Implemented as suggested, good call! |
URL
on NewButtonBlockElement
via .WithURL()
URL
on NewButtonBlockElement
via .WithURL()
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.
LGTM
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/slack-go/slack](https://togithub.com/slack-go/slack) | `v0.12.3` -> `v0.13.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fslack-go%2fslack/v0.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fslack-go%2fslack/v0.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fslack-go%2fslack/v0.12.3/v0.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fslack-go%2fslack/v0.12.3/v0.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>slack-go/slack (github.com/slack-go/slack)</summary> ### [`v0.13.0`](https://togithub.com/slack-go/slack/releases/tag/v0.13.0) [Compare Source](https://togithub.com/slack-go/slack/compare/v0.12.5...v0.13.0) > \[!WARNING]\ > This release includes a breaking change since the last release #### What's Changed ##### Breaking changes - Expose `team_id` parameter for use with org-wide app by [@​candiduslynx](https://togithub.com/candiduslynx) in [https://github.com/slack-go/slack/pull/1283](https://togithub.com/slack-go/slack/pull/1283): Changed interface: | Old | New | | --- | --- | | `Client.GetBotInfo(bot string) (*Bot, error)` | `Client.GetBotInfo(parameters GetBotInfoParameters) (*Bot, error)` | | `Client.GetBotInfoContext(ctx context.Context, bot string)` | `Client.GetBotInfoContext(ctx context.Context, parameters GetBotInfoParameters)` | | `Client.GetTeamProfile() (*TeamProfile, error)` | `GetTeamProfile(teamID ...string) (*TeamProfile, error)` | | `GetTeamProfileContext(ctx context.Context) (*TeamProfile, error)` | `GetTeamProfileContext(ctx context.Context, teamID ...string) (*TeamProfile, error)` | | `Client.GetBillableInfo(user string) (map[string]BillingActive, error)` | `Client.GetBillableInfo(params GetBillableInfoParams) (map[string]BillingActive, error)` | | `Client.GetBillableInfoContext(ctx context.Context, user string) (map[string]BillingActive, error)` | `Client.GetBillableInfoContext(ctx context.Context, params GetBillableInfoParams) (map[string]BillingActive, error)` | | `Client.GetBillableInfoForTeam() (map[string]BillingActive, error)` | dropped, use `Client.GetBillableInfo` with empty params | | `Client.GetBillableInfoForTeamContext(ctx context.Context) (map[string]BillingActive, error)` | dropped, use `Client.GetBillableInfoContext` with empty params | ##### Bug fixes - Block Object: Validate text min and max length by [@​Chagui-](https://togithub.com/Chagui-) in [https://github.com/slack-go/slack/pull/1273](https://togithub.com/slack-go/slack/pull/1273) - fix some typos by [@​yutasb](https://togithub.com/yutasb) in [https://github.com/slack-go/slack/pull/1281](https://togithub.com/slack-go/slack/pull/1281) ##### Enhancements - Add missing message option for link_names by [@​robbydyer](https://togithub.com/robbydyer) in [https://github.com/slack-go/slack/pull/1278](https://togithub.com/slack-go/slack/pull/1278) - Expose `team_id` parameter for use with org-wide app by [@​candiduslynx](https://togithub.com/candiduslynx) in [https://github.com/slack-go/slack/pull/1283](https://togithub.com/slack-go/slack/pull/1283) #### New Contributors - [@​Chagui-](https://togithub.com/Chagui-) made their first contribution in [https://github.com/slack-go/slack/pull/1273](https://togithub.com/slack-go/slack/pull/1273) - [@​robbydyer](https://togithub.com/robbydyer) made their first contribution in [https://github.com/slack-go/slack/pull/1278](https://togithub.com/slack-go/slack/pull/1278) - [@​yutasb](https://togithub.com/yutasb) made their first contribution in [https://github.com/slack-go/slack/pull/1281](https://togithub.com/slack-go/slack/pull/1281) - [@​candiduslynx](https://togithub.com/candiduslynx) made their first contribution in [https://github.com/slack-go/slack/pull/1283](https://togithub.com/slack-go/slack/pull/1283) **Full Changelog**: slack-go/slack@v0.12.5...v0.13.0 ### [`v0.12.5`](https://togithub.com/slack-go/slack/releases/tag/v0.12.5) [Compare Source](https://togithub.com/slack-go/slack/compare/v0.12.4...v0.12.5) #### What's Changed BUGFIX - deal with "true", true, "false", false. - Parse string or boolean for SlashCommand.IsEnterpriseInstall by [@​kpaulisse](https://togithub.com/kpaulisse) in [https://github.com/slack-go/slack/pull/1266](https://togithub.com/slack-go/slack/pull/1266) **Full Changelog**: slack-go/slack@v0.12.4...v0.12.5 ### [`v0.12.4`](https://togithub.com/slack-go/slack/releases/tag/v0.12.4): Non-breaking updates roll-up [Compare Source](https://togithub.com/slack-go/slack/compare/v0.12.3...v0.12.4) #### What's Changed - chore: unnecessary use of fmt.Sprintf by [@​testwill](https://togithub.com/testwill) in [https://github.com/slack-go/slack/pull/1212](https://togithub.com/slack-go/slack/pull/1212) - Add Video Block by [@​walkure](https://togithub.com/walkure) in [https://github.com/slack-go/slack/pull/1210](https://togithub.com/slack-go/slack/pull/1210) - Add connected_team_ids optional field to Conversation by [@​zFlabmonsta](https://togithub.com/zFlabmonsta) in [https://github.com/slack-go/slack/pull/1253](https://togithub.com/slack-go/slack/pull/1253) - Add blocks in slackevents.MessageEvent by [@​invzhi](https://togithub.com/invzhi) in [https://github.com/slack-go/slack/pull/1227](https://togithub.com/slack-go/slack/pull/1227) - Add support for Rich Text Lists by [@​daniel-pieper-personio](https://togithub.com/daniel-pieper-personio) in [https://github.com/slack-go/slack/pull/1155](https://togithub.com/slack-go/slack/pull/1155) - Add support for Rich Text Input by [@​peimanja](https://togithub.com/peimanja) in [https://github.com/slack-go/slack/pull/1240](https://togithub.com/slack-go/slack/pull/1240) - Fix: always add context to errors during block serde by [@​yunginnanet](https://togithub.com/yunginnanet) in [https://github.com/slack-go/slack/pull/1259](https://togithub.com/slack-go/slack/pull/1259) - Edited field in the app mention event by [@​IbirbyZh](https://togithub.com/IbirbyZh) in [https://github.com/slack-go/slack/pull/1256](https://togithub.com/slack-go/slack/pull/1256) - Expose is_enterprise_install field by [@​7ail](https://togithub.com/7ail) in [https://github.com/slack-go/slack/pull/1255](https://togithub.com/slack-go/slack/pull/1255) - feat: Add the ability to set `URL` on `NewButtonBlockElement` via `.WithURL()` by [@​joshbranham](https://togithub.com/joshbranham) in [https://github.com/slack-go/slack/pull/1250](https://togithub.com/slack-go/slack/pull/1250) - Add block element type FileInput by [@​elct9620](https://togithub.com/elct9620) in [https://github.com/slack-go/slack/pull/1249](https://togithub.com/slack-go/slack/pull/1249) - Openid connect by [@​danielmichaels](https://togithub.com/danielmichaels) in [https://github.com/slack-go/slack/pull/1242](https://togithub.com/slack-go/slack/pull/1242) - Add is_enterprise_install flag for org wide installation support by [@​hussachai](https://togithub.com/hussachai) in [https://github.com/slack-go/slack/pull/1225](https://togithub.com/slack-go/slack/pull/1225) - Add an example of updating modal by [@​KouWakai](https://togithub.com/KouWakai) in [https://github.com/slack-go/slack/pull/1142](https://togithub.com/slack-go/slack/pull/1142) - add deleted timestamp for deleted msg events by [@​zFlabmonsta](https://togithub.com/zFlabmonsta) in [https://github.com/slack-go/slack/pull/1261](https://togithub.com/slack-go/slack/pull/1261) - Add slack connect events & tests by [@​Birtato](https://togithub.com/Birtato) in [https://github.com/slack-go/slack/pull/1262](https://togithub.com/slack-go/slack/pull/1262) - Add rich_text_quote and rich_text_preformatted by [@​rusq](https://togithub.com/rusq) in [https://github.com/slack-go/slack/pull/1260](https://togithub.com/slack-go/slack/pull/1260) #### New Contributors - [@​testwill](https://togithub.com/testwill) made their first contribution in [https://github.com/slack-go/slack/pull/1212](https://togithub.com/slack-go/slack/pull/1212) - [@​walkure](https://togithub.com/walkure) made their first contribution in [https://github.com/slack-go/slack/pull/1210](https://togithub.com/slack-go/slack/pull/1210) - [@​zFlabmonsta](https://togithub.com/zFlabmonsta) made their first contribution in [https://github.com/slack-go/slack/pull/1253](https://togithub.com/slack-go/slack/pull/1253) - [@​invzhi](https://togithub.com/invzhi) made their first contribution in [https://github.com/slack-go/slack/pull/1227](https://togithub.com/slack-go/slack/pull/1227) - [@​daniel-pieper-personio](https://togithub.com/daniel-pieper-personio) made their first contribution in [https://github.com/slack-go/slack/pull/1155](https://togithub.com/slack-go/slack/pull/1155) - [@​peimanja](https://togithub.com/peimanja) made their first contribution in [https://github.com/slack-go/slack/pull/1240](https://togithub.com/slack-go/slack/pull/1240) - [@​yunginnanet](https://togithub.com/yunginnanet) made their first contribution in [https://github.com/slack-go/slack/pull/1259](https://togithub.com/slack-go/slack/pull/1259) - [@​IbirbyZh](https://togithub.com/IbirbyZh) made their first contribution in [https://github.com/slack-go/slack/pull/1256](https://togithub.com/slack-go/slack/pull/1256) - [@​joshbranham](https://togithub.com/joshbranham) made their first contribution in [https://github.com/slack-go/slack/pull/1250](https://togithub.com/slack-go/slack/pull/1250) - [@​elct9620](https://togithub.com/elct9620) made their first contribution in [https://github.com/slack-go/slack/pull/1249](https://togithub.com/slack-go/slack/pull/1249) - [@​danielmichaels](https://togithub.com/danielmichaels) made their first contribution in [https://github.com/slack-go/slack/pull/1242](https://togithub.com/slack-go/slack/pull/1242) - [@​KouWakai](https://togithub.com/KouWakai) made their first contribution in [https://github.com/slack-go/slack/pull/1142](https://togithub.com/slack-go/slack/pull/1142) - [@​Birtato](https://togithub.com/Birtato) made their first contribution in [https://github.com/slack-go/slack/pull/1262](https://togithub.com/slack-go/slack/pull/1262) **Full Changelog**: slack-go/slack@v0.12.3...v0.12.4 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ymotongpoo/opentelemetry-collector-extra). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This introduces the ability to set the URL for a
ButtonBlockElement
on an existing instance by calling.WithURL("https://myurl")
.Fixes #1085