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

XRENDERING-764: Add an option for messages to be set as status #319

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Sereza7
Copy link
Contributor

@Sereza7 Sereza7 commented Dec 2, 2024

Jira URL

https://jira.xwiki.org/browse/XRENDERING-764

Changes

Description

  • Created a class for the parameters specific to message macros (right now, only the new isActive
  • Used this new parameter in the macro execution to change the result accordingly.
  • Updated tests to fit the new method requirements.

Clarifications

  • Note that when this is merged, a new page of documentation will need to be created to contain doc about all messages that is not for generic boxes.
  • The CKEditor macro editor uses its own logic to find what to put under the more section. We set the new property as Advanced, so that it would only be displayed when it is set as True.

Screenshots & Video

2024-12-02.16-40-15.mp4

In this video, we can see multiple uses of the info macro, with the status property set as true or left as false. Everything behaves as expected.

Executed Tests

Built the rendering module with: mvn clean install -f xwiki-rendering-macros/xwiki-rendering-macro-message/ -Pquality.
Manual tests with a local instance (see video above).
This PR should not change the default behaviour of the message macros (this added an option but actually never used this option). The only change in UI that could break some tests is the addition of a field in the CKEditor macro editor. This is the last field, so I highly doubt this would break any xpath even if there were some poorly defined ones.

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • None

* Created a class for the parameters specific to message macros (right now, only the new `isActive`
* Used this new parameter in the macro execution to change the result accordingly.
* Updated tests to fit the new method requirements.
* Fix on feature, I mixed things up earlier.
* Added the `advanced` flag to the property. This way it gets displayed with a lower priority in the CKEditor macro editor.

/**
* @since 17.0.0RC1
* @return whether or not the current message is a status.
Copy link
Member

Choose a reason for hiding this comment

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

Might need some more documentation on what exactly a "status" is and why would one set that to true.

@tmortagne
Copy link
Member

tmortagne commented Dec 3, 2024

You need to add translation keys for all those new parameters (yes, you added only one, but each macro which expose MessageMacroParameters will have its own translation key for the status parameter with the current system). We tend to forget those too often (me included).

/**
* @see #isStatus()
*/
private boolean isStatus;
Copy link
Member

Choose a reason for hiding this comment

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

When the getter is isStatus, the field name is generally expected to be status.

* @since 17.0.0RC1
* @param isStatus refers to {@link #isStatus()}
*/
@PropertyDescription("Whether or not this message should be announced as a status.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a much better description as otherwise users will be completely lost when this flag should be set. The description should clearly explain what consequences this has and when it should be used. Also, I'm wondering if it could make sense to more generically expose a "role" parameter - or is it clear that there is no other role that could be interesting?

*
* @version $Id$
* @since 17.0.0RC1
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the whole class should be marked as @Unstable. Further, macro parameter classes normally aren't internal in XWiki.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, macro parameters being APIs, it's safer to put them under revapi scrutiny.

Copy link
Contributor

@michitux michitux left a comment

Choose a reason for hiding this comment

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

As Thomas said, translation keys are missing. Further, you should add least one or two tests that verify that the new parameter works as expected. Apart from this and the other small comments, this looks good, thank you for taking care of this!

throws MacroExecutionException
{
List<Block> boxFoundation = super.execute(parameters, content, context);
if (!boxFoundation.isEmpty() && getIconName() != null) {
Block defaultBox = boxFoundation.get(0);
if (parameters.isStatus()) {
defaultBox.setParameter("role", "status");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this parameter only used when the icon name is set?

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.

3 participants