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

Add support for statement messages in FlashMessenger class #19169

Merged

Conversation

MauricioFauth
Copy link
Member

Besides standard feedback messages, is also common to have a feedback message with the executed statement after an action is executed. This allows to use HTTP redirection in those cases.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This class handles the flash messages instead of being a collection
of flash messages, so FlashMessenger is a better name.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>

/** @var mixed[] */
private array $storage;

/** @var array<string, string[]> */
/** @psalm-var list<array{context: string, message: string, statement: string}> */
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's anything Psalm-specific here anymore. Both list and array shape are universally supported.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think sudo-bot/action-doctum does not support this format yet. Am I right, @williamdes?

resources/templates/export.twig Outdated Show resolved Hide resolved
/** @inheritDoc */
public function getFunctions(): array
{
return [new TwigFunction('statement_message', Generator::getMessage(...), ['is_safe' => ['html']])];
Copy link
Contributor

Choose a reason for hiding this comment

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

That match statement would fit here more than inside the function. You can do an anonymous function and as a default throw an exception so that we avoid typos.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will left MessageType::Notice as default for now, as I think Generator::getMessage() should be refactored to extract all the HTML from it, and maybe a view helper for MessageType to match with the Bootstrap classes.

Does not group the messages by context.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
@MauricioFauth MauricioFauth merged commit fefd6d1 into phpmyadmin:master May 18, 2024
42 checks passed
@MauricioFauth MauricioFauth deleted the flash-messages-statement branch May 18, 2024 23:53
@MauricioFauth MauricioFauth self-assigned this May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants