-
Notifications
You must be signed in to change notification settings - Fork 31
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
Adding rich text block support #185
Adding rich text block support #185
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #185 +/- ##
==========================================
- Coverage 99.16% 96.71% -2.45%
==========================================
Files 46 59 +13
Lines 962 1189 +227
==========================================
+ Hits 954 1150 +196
- Misses 8 39 +31 ☔ View full report in Codecov by Sentry. |
Hey @GetOutOfMyBakery -- thanks for taking this on 🙇♂️ Let me know when you're happy for a review and I'll get to it as soon as possible. \cc @dmorgan-fa -- would be keen to hear your feedback on this from, if you're able to begin integrating agains this branch for your use-case. |
👋 Hey @CGA1123, that's my personal GitHub account and this is my work one 😄 I started on it last night and got into a flow, so it's in pretty good shape just now, but I've not had a chance to validate against Slack's Block Kit Builder yet, since I didn't have access to a workspace from my personal machine. On an unrelated note, I really appreciated how easy it was to work with your framework! It's really well architected and made it super easy to work on 🙏 |
Ha, in that case syncing up between the both of you should be a breeeeeze! 😄 Glad to hear it! It is a relatively simple (if not quite repetitive) flow, but it's quite cathartic working in some plain old ruby as a change of pace, with a fast test suite to go with it! Will take a look later this evening and have play around with these new block on a Slack workspace 👍 |
df1ad72
to
959d349
Compare
I'm happy to do another pass and tidy up the commit history, etc., later but functionality-wise it's looking good. Let me know if there's anything that jumps out at you that you don't like, or if you want to give some pointers about what you want updated before getting it ready to merge. Slightly off-topic but there's a few places that Slack mention some hard limits:
section_fields, but it applies to It's a small tripping hazard if you're composing complicated messages with lost of rich text elements, or if you're creating single long messages it can be a bit confusing initially. Is this something you'd be up for gaurding against in the gem, or would you prefer to let Slack respond with the error messaging when limits are exceeded? |
This is very much in tune with what was wanted in #176 -- I think that would be quite useful to have, I wonder what the "right" behaviour is in these circumstances, truncations, erroring, some other way of handling it. I think for the time being (in the scope of this PR) we can leave this functionality out. When implemented it would only be useful if consistent across the library I think. |
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.
Apologies for the delay in getting back to this -- turned out to be a busier end to the week than anticipated.
A couple of minor changes to keep behaviour as similar as the Slack API as possible!
FYI -- have dropped ruby 2.6 from the matrix (as EOL) and added 3.3 which required the addition of racc
in the Gemfile which is now on master
already. Quick rebase should sort bits out and make the build 🟢
Looking fantastic. Appreciate the time taken to work through adding this feature 🙇♂️
There are some minor gaps on the spec coverage, although nothing major. Might be nice to have a shared example for RichText::RichTextElements
to include into the container objects if time allows -- non-blocking though from my perspective. 👍
lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb
Outdated
Show resolved
Hide resolved
lib/slack/block_kit/layout/rich_text/rich_text_elements/style_helper.rb
Outdated
Show resolved
Hide resolved
443b213
to
9409472
Compare
@CGA1123, no need to apologise, you've been super responsive, don't sweat it. I've rebased and taken on board your suggestions, take a look from commit Applying Christian's suggested changes 4949baf onwards. I've:
I've not:
|
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.
Build failures are unrelated (codecov being unhappy for some reason), specs all running fine 👍
I've tested out posting directly to slack and it's working a charm as best I can tell -- really like this addition of the examples/
and related helpers (also TIL [!TIP]
and [!NOTE]
) 👏
Quick squash of commits + an entry to CHANGELOG
would be much appreciated and I'll get this merged and released. Nice one 🚀
# What Adding support for [Rich Text Blocks](https://api.slack.com/reference/block-kit/blocks#rich_text): - resolves: CGA1123#184 Rich Text Blocks are a bit unique compared to other blocks: > It is also the output of the Slack client's WYSIWYG message composer, so all messages sent by end-users will have this format. Use this block to include user-defined formatted text in your Block Kit payload. While it is possible to format text with `mrkdwn`, `rich_text` is strongly preferred and allows greater flexibility. Most of the other blocks have separate "compatible block elements" and tend to be relatively shallow, whereas Rich Text Blocks can be "[deeply nested](https://api.slack.com/reference/block-kit/blocks#rich_fields)" and it's elements have no reuse outside of a `rich_text` block. Also added: - `./examples/`: scripts to generate example message that can either be: - directly posted to to Slack - copied and pasted to Slack's [Block Builder Kit](https://app.slack.com/block-kit-builder) UI to validate the output This makes it much easier to build confidence in changes being made to the Gem by semi-automating validation against Slack's schema. Since it looks like there's no future opportunity to validate against the JSON schema automatically: - slackapi/slack-api-specs#18 (and the repo is now archived) this strategy might be the best solution going forward.
c6895c4
to
9bdada9
Compare
Thanks @CGA1123, great to have confirmation that the examples scripts are posting to Slack as expected 🙏 There's a few others: I've squashed it all down, updated the Thanks for the fast feedback and turn around on this 🙏 |
Thanks for contributing @GetOutOfMyBakery 🙇♂️ This has now shipped out in |
What
Adding support for Rich Text Blocks:
Rich Text Blocks are a bit unique compared to other blocks:
Most of the other blocks have separate "compatible block elements" and tend to be relatively shallow, whereas Rich Text Blocks can be "deeply nested" and it's elements have no reuse outside of a
rich_text
block.Also added in this PR:
./examples/
: scripts to generate example message that can either be:This makes it much easier to build confidence in changes being made to the Gem by semi-automating validation against Slack's schema. Since it looks like there's no future opportunity to validate against the JSON schema automatically:
this strategy might be the best solution going forward.