-
Notifications
You must be signed in to change notification settings - Fork 60
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
Unable to set $elements values in Laravel Slack notification block classes #93
Comments
Thanks @sedwardsgt. Again assigning @jbrooksuk but highly unlikely he'll be able to help any time soon. Would appreciate PR's if anything can be improved here. Thanks. |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
@sedwardsgt does something like this not work?
|
The API of this implementation is quite a bit different from my package's implementation. You will probably be served better by reading the docs and recreating the messages following the doc examples than trying to convert the code used for my package. |
Yeah, that's what I ended up doing. To answer your question above, yes, that was what I ended up doing. However, it seems that there are many options available for Slack message customization that are not available via the new implementation, that are allowed by allowing direct access to the |
I believe this update #98 will help with this issue. You should now be able to use anything you find in https://app.slack.com/block-kit-builder. |
Slack Notification Channel Version
3.2.0
Laravel Version
11.9.2
PHP Version
8.2
Database Driver & Version
mongodb/laravel-mongodb v4.4
Description
I am converting a Laravel app from using Nathanhelfley/laravel-slack-blocks to using the built in Illuminate\Notifications\Slack\BlockKit\Blocks blocks, and I can't figure out how to pass in the
$elements
value. For instance, with aSlackBlock
class, I would do this for a context block;However, with the
ContextBlock
class, there is no interface to pass in the entire element (e.g.type => markdown
) because there is no setter for$elements
and it is protected. The same is true for the other block types. How do I pass in the other values for a block other than the text and the id?Per one suggestion, the correct implementation is something like this
But there are two problems
MarkdownText
class doesn't existTextObject
class does, and it has amarkdown()
setter. However, thetext()
method takes a string, not an object.Something like this doesn't work, for the same reason
But it's not just the
markdown
property. If you look at the doc block for the$elements
property in ActionsBlock, you seewhich indicates to me that there somewhere is a way to add to those elements (up to 25), since the Slack Blocks Reference indicates that there are many more things that can be added other than what these block kit classes allow.
As another example, the ActionsBlock has a
button()
method, but all it does is pass the text to the button:with no option to pass the url. Do I have to somehow override that with a custom ButtonElement?
Yes, I've seen the Laravel Notifications docs, but that doesn't really answer this question, either (unless I'm missing something).
So it seems there is no way to build the blocks with all of the
$elements
values. Apologies if this is not a bug and I'm just mis-reading the code, but if it is a feature, some guidance would be appreciated.Steps To Reproduce
SlackMessage
class$elements
arraySee above for examples
The text was updated successfully, but these errors were encountered: