Skip to content

Commit

Permalink
feat: Refactor Wallet Administration to move in Setup UI - MEED-2896 -
Browse files Browse the repository at this point in the history
…Meeds-io/meeds#1271

This change will move Settings into centralized Recognition UI.
  • Loading branch information
boubaker committed Dec 4, 2023
1 parent c039f02 commit b024acb
Show file tree
Hide file tree
Showing 30 changed files with 588 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import org.exoplatform.commons.api.notification.NotificationContext;
import org.exoplatform.commons.api.notification.model.NotificationInfo;
import org.exoplatform.commons.api.notification.plugin.BaseNotificationPlugin;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.commons.utils.HTMLSanitizer;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.wallet.model.ContractDetail;
import org.exoplatform.wallet.model.Wallet;
import org.exoplatform.wallet.model.transaction.FundsRequest;
import org.exoplatform.wallet.utils.WalletUtils;

public class FundsRequestNotificationPlugin extends BaseNotificationPlugin {

private static final Log LOG = ExoLogger.getLogger(FundsRequestNotificationPlugin.class);

public FundsRequestNotificationPlugin(InitParams initParams) {
super(initParams);
}
Expand Down Expand Up @@ -66,6 +73,16 @@ protected NotificationInfo makeNotification(NotificationContext ctx) {
ContractDetail contractDetail = WalletUtils.getContractDetail();
String symbol = contractDetail == null ? null : contractDetail.getSymbol();

String message = fundsRequest.getMessage() == null ? "" : fundsRequest.getMessage();
if (StringUtils.isNotBlank(message)) {
try {
message = HTMLSanitizer.sanitize(message);
} catch (Exception e) {
LOG.warn("error sanitizing wallet transaction message {}. Use empty message", message, e);
message = "";
}
}

return NotificationInfo.instance()
.to(toList)
.with(AMOUNT, String.valueOf(fundsRequest.getAmount()))
Expand All @@ -79,7 +96,7 @@ protected NotificationInfo makeNotification(NotificationContext ctx) {
.with(SENDER, requestSenderAccountDetail.getName())
.with(RECEIVER, requestReceiverAccountDetail.getName())
.with(SYMBOL, symbol)
.with(MESSAGE, fundsRequest.getMessage() == null ? "" : fundsRequest.getMessage())
.with(MESSAGE, message)
.key(getKey())
.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,27 @@
*/
package org.exoplatform.wallet.notification.plugin;

import static org.exoplatform.wallet.utils.WalletUtils.*;
import static org.exoplatform.wallet.utils.WalletUtils.ACCOUNT_TYPE;
import static org.exoplatform.wallet.utils.WalletUtils.AMOUNT;
import static org.exoplatform.wallet.utils.WalletUtils.AMOUNT_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.AVATAR;
import static org.exoplatform.wallet.utils.WalletUtils.CONTRACT_ADDRESS;
import static org.exoplatform.wallet.utils.WalletUtils.CONTRACT_ADDRESS_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.HASH;
import static org.exoplatform.wallet.utils.WalletUtils.HASH_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.MESSAGE;
import static org.exoplatform.wallet.utils.WalletUtils.MESSAGE_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER;
import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_ACCOUNT_DETAIL_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_TYPE;
import static org.exoplatform.wallet.utils.WalletUtils.RECEIVER_URL;
import static org.exoplatform.wallet.utils.WalletUtils.SENDER;
import static org.exoplatform.wallet.utils.WalletUtils.SENDER_ACCOUNT_DETAIL_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.SENDER_URL;
import static org.exoplatform.wallet.utils.WalletUtils.SYMBOL;
import static org.exoplatform.wallet.utils.WalletUtils.SYMBOL_PARAMETER;
import static org.exoplatform.wallet.utils.WalletUtils.getNotificationReceiversUsers;
import static org.exoplatform.wallet.utils.WalletUtils.getPermanentLink;

import java.util.List;

Expand All @@ -26,13 +46,18 @@
import org.exoplatform.commons.api.notification.model.NotificationInfo;
import org.exoplatform.commons.api.notification.plugin.BaseNotificationPlugin;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.commons.utils.HTMLSanitizer;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.social.core.service.LinkProvider;
import org.exoplatform.wallet.model.Wallet;
import org.exoplatform.wallet.model.transaction.TransactionNotificationType;

public class WalletReceiverNotificationPlugin extends BaseNotificationPlugin {

private static final Log LOG = ExoLogger.getLogger(WalletReceiverNotificationPlugin.class);

public WalletReceiverNotificationPlugin(InitParams initParams) {
super(initParams);
}
Expand All @@ -56,6 +81,14 @@ protected NotificationInfo makeNotification(NotificationContext ctx) {
double amount = ctx.value(AMOUNT_PARAMETER);
String message = ctx.value(MESSAGE_PARAMETER);
String hash = ctx.value(HASH_PARAMETER);
if (StringUtils.isNotBlank(message)) {
try {
message = HTMLSanitizer.sanitize(message);
} catch (Exception e) {
LOG.warn("error sanitizing wallet transaction message {}. Use empty message", message, e);
message = "";
}
}

List<String> toList = getNotificationReceiversUsers(receiverAccountDetail, senderAccountDetail.getId());
if (toList == null || toList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
import org.exoplatform.commons.api.notification.model.NotificationInfo;
import org.exoplatform.commons.api.notification.plugin.BaseNotificationPlugin;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.commons.utils.HTMLSanitizer;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.social.core.service.LinkProvider;
import org.exoplatform.wallet.model.Wallet;
import org.exoplatform.wallet.model.transaction.TransactionNotificationType;

public class WalletSenderNotificationPlugin extends BaseNotificationPlugin {

private static final Log LOG = ExoLogger.getLogger(WalletSenderNotificationPlugin.class);

public WalletSenderNotificationPlugin(InitParams initParams) {
super(initParams);
}
Expand All @@ -56,6 +61,14 @@ protected NotificationInfo makeNotification(NotificationContext ctx) {
double amount = ctx.value(AMOUNT_PARAMETER);
String message = ctx.value(MESSAGE_PARAMETER);
String hash = ctx.value(HASH_PARAMETER);
if (StringUtils.isNotBlank(message)) {
try {
message = HTMLSanitizer.sanitize(message);
} catch (Exception e) {
LOG.warn("error sanitizing wallet transaction message {}. Use empty message", message, e);
message = "";
}
}

// Don't send notifications about Admin wallet sending funds
if (senderAccountDetail == null || StringUtils.equals(senderAccountDetail.getId(), WALLET_ADMIN_REMOTE_ID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,19 @@ exoplatform.wallet.message.followTransaction=See transaction
wallet.mainCurrency=Matic
wallet.mainCurrencySymbol=Matic
wallet.addressAlreadyInUse=Address already in use by another wallet

wallet.administration.title=Wallet
wallet.administration.subtitle=Define the amount to send to new wallet
wallet.administration.drawer.title=Setup wallet
wallet.administration.introduction1=The following parameters define the amout to send to new wallet.
wallet.administration.introduction2=Initial Meeds Token quantity is a free grant you offer to new users in order to engage them in the exchange system.
wallet.administration.introduction3=We recommend 10 Meeds to start.
wallet.administration.introduction4=In addition to this token, {0} gas will be sent to your users to cover the transaction fees on the blockchain network.
wallet.administration.initialFundsFormLabel=Define initial funds
wallet.administration.gas=Gas
wallet.administration.meeds=Meeds
wallet.administration.initialFundsMessageLabel=Set a message to send with initial funds
wallet.administration.initialFundsMessagePlaceholder=Enter a default message to send with initial funds
wallet.administration.apply=Apply
wallet.administration.cancel=Cancel
wallet.administration.reset=Reset
1 change: 1 addition & 0 deletions wallet-webapps/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
4 changes: 1 addition & 3 deletions wallet-webapps/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,44 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</module>
</portlet>

<portlet>
<name>WalletSetupAdmin</name>
<module>
<script>
<minify>false</minify>
<path>/js/walletSetupAdmin.bundle.js</path>
</script>
<depends>
<module>walletCommon</module>
<as>WalletCommon</as>
</depends>
<depends>
<module>vue</module>
</depends>
<depends>
<module>vuetify</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
<depends>
<module>jquery</module>
<as>$</as>
</depends>
<depends>
<module>Web3</module>
<as>LocalWeb3</as>
</depends>
<depends>
<module>ethQRCode</module>
<as>EthereumQRPlugin</as>
</depends>
<depends>
<module>commons-cometd3</module>
<as>cCometd</as>
</depends>
</module>
</portlet>

<portlet>
<name>WalletSettings</name>
Expand Down
23 changes: 23 additions & 0 deletions wallet-webapps/src/main/webapp/WEB-INF/portlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,29 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<role-link>admin</role-link>
</security-role-ref>
</portlet>
<portlet>
<portlet-name>WalletSetupAdmin</portlet-name>
<display-name xml:lang="EN">Wallet Setup Administration</display-name>
<portlet-class>org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet</portlet-class>
<init-param>
<name>portlet-view-dispatched-file-path</name>
<value>/html/walletSetupAdmin.html</value>
</init-param>
<expiration-cache>-1</expiration-cache>
<cache-scope>PUBLIC</cache-scope>
<supports>
<mime-type>text/html</mime-type>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>Wallet Setup Administration</title>
<keywords>Wallet Setup Administration</keywords>
</portlet-info>
<security-role-ref>
<role-name>admin</role-name>
<role-link>admin</role-link>
</security-role-ref>
</portlet>
<portlet>
<portlet-name>WalletSettings</portlet-name>
<portlet-class>org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet</portlet-class>
Expand Down
16 changes: 0 additions & 16 deletions wallet-webapps/src/main/webapp/html/rewardAdmin.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 Meeds Association
[email protected]
This program 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 3 of the License, or (at your option) any later version.
This program 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 program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<div class="VuetifyApp">
<div id="RewardApp">
<script>
Expand Down
16 changes: 0 additions & 16 deletions wallet-webapps/src/main/webapp/html/spaceWallet.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 Meeds Association
[email protected]
This program 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 3 of the License, or (at your option) any later version.
This program 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 program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<div class="VuetifyApp">
<div id="SpaceWalletApp">
<script>
Expand Down
16 changes: 0 additions & 16 deletions wallet-webapps/src/main/webapp/html/walletAPI.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 Meeds Association
[email protected]
This program 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 3 of the License, or (at your option) any later version.
This program 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 program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<div id="WalletAPIApp">
<script>
eXo.env.portal.addOnLoadCallback(() => {
Expand Down
16 changes: 0 additions & 16 deletions wallet-webapps/src/main/webapp/html/walletAdmin.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 Meeds Association
[email protected]
This program 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 3 of the License, or (at your option) any later version.
This program 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 program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<div class="VuetifyApp">
<div id="WalletAdminApp">
<script>
Expand Down
16 changes: 0 additions & 16 deletions wallet-webapps/src/main/webapp/html/walletLink.html
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2020 Meeds Association
[email protected]
This program 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 3 of the License, or (at your option) any later version.
This program 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 program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
7 changes: 7 additions & 0 deletions wallet-webapps/src/main/webapp/html/walletSetupAdmin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="VuetifyApp">
<div id="WalletSetupAdmin">
<script>
require(['PORTLET/wallet/WalletSetupAdmin'], app => app.init())
</script>
</div>
</div>
Loading

0 comments on commit b024acb

Please sign in to comment.