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

XWIKI-21452: Macros info, success, warning and error are only distinguished by colors #3023

Merged
merged 56 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
e893a59
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 8, 2023
ce0d296
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 9, 2023
a2864ea
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 10, 2023
9cb73e8
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 10, 2023
8cd50de
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 10, 2023
9b0ef83
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 10, 2023
83571f1
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Nov 15, 2023
31eb18a
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Dec 12, 2023
ab5e55f
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Dec 13, 2023
ce3be8c
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Dec 13, 2023
7fa4083
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Dec 14, 2023
e47c7f8
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Dec 14, 2023
980a360
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 5, 2024
b9393db
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 5, 2024
131db3c
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 8, 2024
5840570
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 10, 2024
2df7497
XWIKI-21009: LiveData alternative to drag controls
Sereza7 Jan 17, 2024
521e428
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 17, 2024
504cd67
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 17, 2024
e3a0914
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 18, 2024
fd80d5b
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 22, 2024
6c0b9e2
XWIKI-21452: Macros info, success, warning and error are only disting…
tkrieck Jan 29, 2024
c8944cc
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jan 29, 2024
255e082
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Feb 16, 2024
0b7dc8a
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Feb 19, 2024
6598952
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Feb 20, 2024
448e564
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Feb 20, 2024
9be5a4f
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Mar 8, 2024
5a75166
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Mar 8, 2024
f4a1f06
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Mar 8, 2024
963e697
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Mar 11, 2024
cf5cee1
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Mar 18, 2024
3ba8e1d
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Mar 21, 2024
03aba25
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Mar 21, 2024
82b894d
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Mar 21, 2024
90e15c5
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Mar 21, 2024
a61c518
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Mar 25, 2024
cc763ee
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Mar 25, 2024
13c360b
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Apr 11, 2024
287f092
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Apr 11, 2024
1ff7bb4
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Apr 17, 2024
b99cef0
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Apr 22, 2024
ba7838d
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Jun 21, 2024
9e77593
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jun 21, 2024
40015cd
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Jun 21, 2024
67a10e1
Merge branch 'xwiki:master' into XWIKI-21452
Sereza7 Aug 6, 2024
43ae07e
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 6, 2024
4a8cecb
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 6, 2024
3dbf161
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 6, 2024
b62ecdd
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 7, 2024
3415d2e
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 7, 2024
03bc9cd
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 7, 2024
56f6565
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 7, 2024
d4e7cca
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 7, 2024
a9bf1fb
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 7, 2024
2df9eec
XWIKI-21452: Macros info, success, warning and error are only disting…
Sereza7 Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,52 @@
// Messages
// --------------------------------------------------

.successmessage, .errormessage, .warningmessage, .infomessage,
span.successmessage, span.errormessage, span.warningmessage, span.infomessage,
span.box { // Used by: Inline boxes and messages
padding: floor(@font-size-base * 0.2);
// Used by: Inline boxes
span.successmessage, span.errormessage, span.warningmessage, span.infomessage {
border: none;
}

span.box, span.successmessage, span.errormessage, span.warningmessage, span.infomessage {
padding: 0 floor(@font-size-base * 0.2);
box-shadow: none;
& > img {
// Style the silk icons
margin: 0 .6rem 0 .2rem;
vertical-align: sub;
}

& > span.fa {
// Style the font awesome icons
margin: 0 .6rem 0 .2rem;
}
}

// Used by: message boxes
div.successmessage, div.errormessage, div.warningmessage, div.infomessage {
display: flex;
gap: 2rem;
justify-content: left;
align-items: baseline;
padding: 2rem;
border: none;
border-left: 4px solid;
box-shadow: none;

& > img {
// Improve alignment for silk icons
align-self: flex-start;
}

& > div > .box-title,
& > div > .xwiki-metadata-container[data-xwiki-parameter-name="title"] {
font-weight: bold;
}

// Main message content
& > div > p,
& > div > [data-cke-display-name="$content"] {
margin: 0;
}
}

.box, .plainmessage, // Used by: Code Macro, Success Macro, etc.
Expand All @@ -27,18 +69,26 @@ fieldset.xwikimessage { // Used by: Login form, Delete messages

.successmessage {
.alert-success;
background-color: @state-success-bg;
border-color: @brand-success;
}

.errormessage {
.alert-danger;
background-color: @state-danger-bg;
border-color: @brand-danger;
}

.warningmessage {
.alert-warning;
background-color: @state-warning-bg;
border-color: @brand-warning;
}

.infomessage {
.alert-info;
background-color: @state-info-bg;
border-color: @brand-primary;
}

// --------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void sendMailToTwoAddresses() throws Exception
assertMessageValid(messageB);

// Check that the page has the table and the messages.
assertTrue(sent.getMessageBoxContent().contains("Your message has been sent."));
assertTrue(sent.getMessageBoxContent().contains("Information\nYour message has been sent."));
TableElement table = sent.getTable();
assertEquals(3, table.numberOfRows());
assertEquals(3, table.numberOfColumns());
Expand Down Expand Up @@ -299,7 +299,7 @@ void unpermittedUserCannotSendToMultipleAddresses(TestUtils setup) throws Except
getGreenMail().waitForIncomingEmail(2000, 2);
MimeMessage[] messages = getGreenMail().getReceivedMessages();
assertEquals(0, messages.length, "Messages were received when they shouldn't have been sent!");
assertEquals("Your message could not be sent because there were no valid email addresses to send to.",
assertEquals("Error\nYour message could not be sent because there were no valid email addresses to send to.",
sent.getMessageBoxContent(),
"User was not shown the correct error message.");
stopGreenMail();
Expand All @@ -321,7 +321,7 @@ void unpermittedUserCannotSendToMultipleAddresses(TestUtils setup) throws Except
getGreenMail().waitForIncomingEmail(10000, 2);
messages = getGreenMail().getReceivedMessages();
assertEquals(2, messages.length, "Non admins cannot send mail to even with permission");
assertEquals("Your message has been sent.", sent.getMessageBoxContent(),
assertEquals("Information\nYour message has been sent.", sent.getMessageBoxContent(),
"User was not given the message that their mail was sent.");
} finally {
stopGreenMail();
Expand Down Expand Up @@ -404,7 +404,7 @@ void spamReporting(TestUtils setup, LogCaptureConfiguration logCaptureConfigurat
"The message by the spam reporter is not shown to the admin.");

String memo = "Actually the email lottery is quite legitimate.";
String expectedSuccessMessage = "Invitation successfully marked as not spam. Log entry: " + memo;
String expectedSuccessMessage = "Information\nInvitation successfully marked as not spam. Log entry: " + memo;
// Return their sending privilege.
String successMessage = inspect.notSpam("Actually the email lottery is quite legitimate.");

Expand Down Expand Up @@ -634,7 +634,7 @@ void cancelInvitation(TestUtils setup) throws Exception
confirm.getLabel().toLowerCase());

confirm.setMemo("Sorry, wrong email address.");
assertEquals("Invitation successfully rescinded.", confirm.confirm());
assertEquals("Information\nInvitation successfully rescinded.", confirm.confirm());

// Now switch to guest.
setup.forceGuestUser();
Expand All @@ -646,13 +646,13 @@ void cancelInvitation(TestUtils setup) throws Exception
InvitationGuestActionsPage guestPage =
InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.ACCEPT);
assertNotEquals("", guestPage.getMessage(), "Guest was able to accept a message which had been canceled.");
assertEquals("We're sorry but this invitation has been rescinded." + commonPart,
assertEquals("Error\nWe're sorry but this invitation has been rescinded." + commonPart,
guestPage.getMessage());

// Prove that invitation cannot be declined
guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.DECLINE);
assertNotEquals("", guestPage.getMessage(), "Guest was able to decline a message which had been canceled.");
assertEquals("This invitation has been rescinded and thus cannot be declined." + commonPart,
assertEquals("Error\nThis invitation has been rescinded and thus cannot be declined." + commonPart,
guestPage.getMessage());

// Prove that the message report spam page still shows up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int myPendingInvitations()
}
String message = getDriver().findElementsWithoutWaiting(this.footer,
By.id("my-pending-invitations")).get(0).getText().trim();
return Integer.parseInt(message.substring(0, message.indexOf(" pending")));
return Integer.parseInt(message.substring(message.indexOf("\n") + 1, message.indexOf(" pending")));
}

public int spamReports()
Expand All @@ -80,6 +80,6 @@ public int spamReports()
}
String message = getDriver().findElementsWithoutWaiting(this.footer,
By.id("spam-reports")).get(0).getText().trim();
return Integer.parseInt(message.substring(0, message.indexOf(" reported as spam")));
return Integer.parseInt(message.substring(message.indexOf("\n") + 1, message.indexOf(" reported as spam")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean userIsSpammer()
{
for (WebElement error : getDriver().findElementsWithoutWaiting(By.id("invitation-permission-error"))) {
if (error.getText().equals(
"A message which you sent was reported as spam and your privilege to send mail has"
"Error\nA message which you sent was reported as spam and your privilege to send mail has"
+ " been suspended pending investigation, we apologize for the inconvenience.")) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void inplaceEditableMacro(TestReference testReference, TestUtils setup, MultiUse

// Save and check the result.
ViewPage viewPage = secondEditPage.clickSaveAndView();
assertEquals("my info message\none two three", viewPage.getContent());
assertEquals("Information\nmy info message\none two three", viewPage.getContent());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Thus it is forbidden to depend on the HTML Macro.
<module>xwiki-platform-rendering-macro-gallery</module>
<module>xwiki-platform-rendering-macro-groovy</module>
<module>xwiki-platform-rendering-macro-include</module>
<module>xwiki-platform-rendering-macro-message</module>
<module>xwiki-platform-rendering-macro-python</module>
<module>xwiki-platform-rendering-macro-script</module>
<module>xwiki-platform-rendering-macro-toc</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-rendering-macros</artifactId>
<version>16.7.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-rendering-macro-message</artifactId>
<name>XWiki Platform - Rendering - Macro - Message</name>
<description>Extends the default message macro to provide translations.</description>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-localization-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.rendering</groupId>
<artifactId>xwiki-rendering-macro-message</artifactId>
<version>${rendering.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.rendering.internal.macro.message;

import org.xwiki.component.annotation.Component;
import org.xwiki.localization.ContextualLocalizationManager;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
* XWiki specific component to provide an alternative text for an icon.
*
* @version $Id$
* @since 16.7.0RC1
*/
@Component(roles = MacroIconPrettyNameProvider.class)
@Singleton
public class MacroIconPrettyNameProvider
Copy link
Member

@tmortagne tmortagne Aug 9, 2024

Choose a reason for hiding this comment

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

This does not override anything (it just conflict with the rendering class at classloader lever, so one or the other is randomly used), it should have extended the xwiki-rendering MacroIconPrettyNameProvider (and be named XWikiMacroIconPrettyNameProvider to be more clear).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in eb30e70 👍 Thank you

{
private static final String TRANSLATION_KEY_PREFIX = "rendering.macro.message.icon.alternative.";
@Inject
private ContextualLocalizationManager l10n;

/**
* @param macroId the id of the macro whose icon needs an alternative text
* @return the alternative text associated to the provided icon
*/
public String getIconPrettyName(String macroId)
{
return l10n.getTranslationPlain(TRANSLATION_KEY_PREFIX + macroId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ---------------------------------------------------------------------------
Copy link
Member

@tmortagne tmortagne Aug 8, 2024

Choose a reason for hiding this comment

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

Shouldn't this file be removed ? All those translations are already provided by xwiki-rendering-macro-message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 2df9eec 👍

# See the NOTICE file distributed with this work for additional
# information regarding copyright ownership.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
# ---------------------------------------------------------------------------

###############################################################################
# XWiki Core localization
#
# This contains the translations of the module in the default language
# (generally English).
#
# See https://dev.xwiki.org/xwiki/bin/view/Community/L10N/Conventions/ for more details about
# translation key naming.
#
# Comments: it's possible to add some detail about a key to make easier to
# translate it by adding a comment before it. To make sure a comment is not
# assigned to the following key use at least three sharps (###) for the comment
# or after it.
#
# Deprecated keys:
# * when deleting a key it should be moved to deprecated section at the end
# of the file (between #@deprecatedstart and #@deprecatedend) and associated to the
# first version in which it started to be deprecated
# * when renaming a key, it should be moved to the same deprecated section
# and a comment should be added with the following syntax:
# #@deprecated new.key.name
# old.key.name=Some translation
###############################################################################

# Those entries are used by the message boxes as labels.
rendering.macro.message.icon.alternative.information=Information
rendering.macro.message.icon.alternative.accept=Success
rendering.macro.message.icon.alternative.exclamation=Error
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
500:org.xwiki.rendering.internal.macro.message.MacroIconPrettyNameProvider
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-icon-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-localization-api</artifactId>
<version>${project.version}</version>
</dependency>
<!--dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down
Loading