Skip to content
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

[Notifier] [Slack] Add button block element and emoji/verbatim options to section block #54737

Open
wants to merge 5 commits into
base: 7.1
Choose a base branch
from

Conversation

cvergne
Copy link

@cvergne cvergne commented Apr 26, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

Hi,

When using the Slack Notifier bridge, I've noticed it wasn't possible to add a button as accessory to a section because button is only managed in the SlackActionsBlock, which is not allowed as an accessory in a Section block.
So the first purpose of this PR is add a SlackButtonBlockElement we can use as accessory into a section block (and use that block into SlackActionsBlock as it follows the same structure).

Then, I noticed verbatim (for markdown) and emoji (for plain text) options were not available in SectionBlock (but available in ContextBlock), so I've added them.
Note that originally, I was going to add them as optional arguments (?bool $verbatim = null) to avoid adding them if not explicitly given and keep the Slack default value, but the ContextBlock adds a default value (the same as Slack) for them, so I kept the same argument signature.

You can see an example of both use of button as accessory and verbatim param with the following link on Slack Block Kit Builder (must be logged in to a Slack Account).

These minor additions are in the same PR, but tell me if I should split them into two PRs.

Thanks :)

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after my comment

src/Symfony/Component/Notifier/Bridge/Slack/CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
Comment on lines +35 to +39
if ($markdown) {
$this->options['text']['verbatim'] = $verbatim;
} else {
$this->options['text']['emoji'] = $emoji;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's 3 correlated options, that makes it hard to reason about them.
Would it make sense to add only one option, either verbatim or emoji and send the appropriate setting to slack automatically?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well in term of behavior on Slack, verbatim == !emoji) (except verbatim is for auto-URL parsing, emoji for emoji escaping).
So maybe we can keep only verbatim option then having the following code if it's what you have in mind ? :)

        if ($markdown) {
            $this->options['text']['verbatim'] = $verbatim;
        } else {
            $this->options['text']['emoji'] = !$verbatim
        }

But what about SlackContextBlock already having these two options and same condition ?
Removing emoji would be a BC (or we need to deprecate it ?), but keeping only emoji has less sense that verbatim in the meaning of the option in Slack :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants