From 429c72d491b22e5851c949943c065e4f1427b7ff Mon Sep 17 00:00:00 2001 From: hakermi Date: Tue, 28 Nov 2023 09:12:11 +0100 Subject: [PATCH] fix: Update web notification from gtmpl to vue - EXO-66413 This PR updates the web notification old gtmpl templates to vue & vuetify for better UX --- .../CancelRequestNotificationListener.java | 2 + .../RequestCommentNotificationListener.java | 10 +- .../plugin/CancelRequestPlugin.java | 4 + .../provider/WebTemplateProvider.java | 127 ------------------ .../plugin/CancelRequestPluginTest.java | 17 ++- .../ProcessesNotification_en.properties | 7 +- .../processes/notification-configuration.xml | 27 ++-- .../main/webapp/WEB-INF/gatein-resources.xml | 20 +++ .../templates/web/CancelRequestPlugin.gtmpl | 40 ------ .../templates/web/CreateRequestPlugin.gtmpl | 40 ------ .../templates/web/RequestCommentPlugin.gtmpl | 42 ------ .../components/CancelRequestPlugin.vue | 65 +++++++++ .../components/CreateRequestPlugin.vue | 63 +++++++++ .../components/RequestCommentPlugin.vue | 70 ++++++++++ .../notification-extension/extensions.js | 45 +++++++ .../notification-extension/initComponents.js | 30 +++++ .../vue-app/notification-extension/main.js | 31 +++++ processes-webapp/webpack.prod.js | 1 + 18 files changed, 363 insertions(+), 278 deletions(-) delete mode 100644 processes-services/src/main/java/org/exoplatform/processes/notification/provider/WebTemplateProvider.java delete mode 100644 processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CancelRequestPlugin.gtmpl delete mode 100644 processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CreateRequestPlugin.gtmpl delete mode 100644 processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/RequestCommentPlugin.gtmpl create mode 100644 processes-webapp/src/main/webapp/vue-app/notification-extension/components/CancelRequestPlugin.vue create mode 100644 processes-webapp/src/main/webapp/vue-app/notification-extension/components/CreateRequestPlugin.vue create mode 100644 processes-webapp/src/main/webapp/vue-app/notification-extension/components/RequestCommentPlugin.vue create mode 100644 processes-webapp/src/main/webapp/vue-app/notification-extension/extensions.js create mode 100644 processes-webapp/src/main/webapp/vue-app/notification-extension/initComponents.js create mode 100644 processes-webapp/src/main/webapp/vue-app/notification-extension/main.js diff --git a/processes-services/src/main/java/org/exoplatform/processes/listener/CancelRequestNotificationListener.java b/processes-services/src/main/java/org/exoplatform/processes/listener/CancelRequestNotificationListener.java index 04e464078..f974e888a 100644 --- a/processes-services/src/main/java/org/exoplatform/processes/listener/CancelRequestNotificationListener.java +++ b/processes-services/src/main/java/org/exoplatform/processes/listener/CancelRequestNotificationListener.java @@ -18,6 +18,8 @@ public void onEvent(Event event) { ProjectDto projectDto = event.getData(); NotificationContext ctx = NotificationContextImpl.cloneInstance(); ctx.append(NotificationArguments.REQUEST_CREATOR, taskDto.getCreatedBy()); + ctx.append(NotificationArguments.REQUEST_PROCESS, projectDto.getName()); + ctx.append(NotificationArguments.REQUEST_TITLE, taskDto.getTitle()); ctx.append(NotificationArguments.PROCESS_URL, NotificationUtils.getProcessLink(projectDto.getId())); ctx.append(NotificationArguments.REQUEST_URL, NotificationUtils.getRequestLink(taskDto.getId())); ctx.append(NotificationArguments.WORKFLOW_PROJECT_ID, String.valueOf(projectDto.getId())); diff --git a/processes-services/src/main/java/org/exoplatform/processes/listener/RequestCommentNotificationListener.java b/processes-services/src/main/java/org/exoplatform/processes/listener/RequestCommentNotificationListener.java index 3af503924..de8ef1893 100644 --- a/processes-services/src/main/java/org/exoplatform/processes/listener/RequestCommentNotificationListener.java +++ b/processes-services/src/main/java/org/exoplatform/processes/listener/RequestCommentNotificationListener.java @@ -19,6 +19,8 @@ import org.exoplatform.commons.api.notification.NotificationContext; import org.exoplatform.commons.api.notification.model.PluginKey; import org.exoplatform.commons.notification.impl.NotificationContextImpl; +import org.exoplatform.commons.utils.CommonsUtils; +import org.exoplatform.portal.config.UserPortalConfigService; import org.exoplatform.processes.model.WorkFlow; import org.exoplatform.processes.notification.plugin.RequestCommentPlugin; import org.exoplatform.processes.notification.utils.NotificationArguments; @@ -26,6 +28,7 @@ import org.exoplatform.processes.service.ProcessesService; import org.exoplatform.services.listener.Event; import org.exoplatform.services.organization.OrganizationService; +import org.exoplatform.social.core.utils.MentionUtils; import org.exoplatform.task.dto.CommentDto; import org.exoplatform.task.dto.ProjectDto; import org.exoplatform.task.dto.TaskDto; @@ -53,10 +56,15 @@ public void onEvent(Event event) throws Exception { ctx.append(NotificationArguments.REQUEST_TITLE, task.getTitle()); ctx.append(NotificationArguments.REQUEST_PROCESS, workFlow.getTitle()); ctx.append(NotificationArguments.REQUEST_COMMENT_AUTHOR, comment.getAuthor()); - ctx.append(NotificationArguments.REQUEST_COMMENT, comment.getComment()); + ctx.append(NotificationArguments.REQUEST_COMMENT, MentionUtils.substituteUsernames(getPortalOwner(), comment.getComment())); ctx.append(NotificationArguments.PROCESS_URL, NotificationUtils.getProcessLink(project.getId())); ctx.append(NotificationArguments.REQUEST_COMMENT_URL, NotificationUtils.getRequestCommentsLink(task.getId())); ctx.getNotificationExecutor() .with(ctx.makeCommand(PluginKey.key(RequestCommentPlugin.ID))).execute(ctx); } + + + private String getPortalOwner() { + return CommonsUtils.getService(UserPortalConfigService.class).getDefaultPortal(); + } } diff --git a/processes-services/src/main/java/org/exoplatform/processes/notification/plugin/CancelRequestPlugin.java b/processes-services/src/main/java/org/exoplatform/processes/notification/plugin/CancelRequestPlugin.java index 97c4ac5ad..f5e3c6b66 100644 --- a/processes-services/src/main/java/org/exoplatform/processes/notification/plugin/CancelRequestPlugin.java +++ b/processes-services/src/main/java/org/exoplatform/processes/notification/plugin/CancelRequestPlugin.java @@ -34,13 +34,17 @@ public boolean isValid(NotificationContext notificationContext) { protected NotificationInfo makeNotification(NotificationContext notificationContext) { String requester = notificationContext.value(NotificationArguments.REQUEST_CREATOR); String processUrl = notificationContext.value(NotificationArguments.PROCESS_URL); + String processTitle = notificationContext.value(NotificationArguments.REQUEST_PROCESS); String requestUrl = notificationContext.value(NotificationArguments.REQUEST_URL); + String requestTitle = notificationContext.value(NotificationArguments.REQUEST_TITLE); String workflowProjectId = notificationContext.value(NotificationArguments.WORKFLOW_PROJECT_ID); List receivers = NotificationUtils.getReceivers(Long.parseLong(workflowProjectId), requester, true); return NotificationInfo.instance() .setFrom(requester) .to(receivers) .with(NotificationArguments.REQUEST_CREATOR.getKey(), requester) + .with(NotificationArguments.REQUEST_PROCESS.getKey(), processTitle) + .with(NotificationArguments.REQUEST_TITLE.getKey(), requestTitle) .with(NotificationArguments.PROCESS_URL.getKey(), processUrl) .with(NotificationArguments.REQUEST_URL.getKey(), requestUrl) .key(getKey()) diff --git a/processes-services/src/main/java/org/exoplatform/processes/notification/provider/WebTemplateProvider.java b/processes-services/src/main/java/org/exoplatform/processes/notification/provider/WebTemplateProvider.java deleted file mode 100644 index 862548d50..000000000 --- a/processes-services/src/main/java/org/exoplatform/processes/notification/provider/WebTemplateProvider.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.exoplatform.processes.notification.provider; - -import org.exoplatform.commons.api.notification.NotificationContext; -import org.exoplatform.commons.api.notification.NotificationMessageUtils; -import org.exoplatform.commons.api.notification.annotation.TemplateConfig; -import org.exoplatform.commons.api.notification.annotation.TemplateConfigs; -import org.exoplatform.commons.api.notification.channel.template.AbstractTemplateBuilder; -import org.exoplatform.commons.api.notification.channel.template.TemplateProvider; -import org.exoplatform.commons.api.notification.model.MessageInfo; -import org.exoplatform.commons.api.notification.model.NotificationInfo; -import org.exoplatform.commons.api.notification.model.PluginKey; -import org.exoplatform.commons.api.notification.service.template.TemplateContext; -import org.exoplatform.commons.notification.template.TemplateUtils; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.processes.notification.plugin.CancelRequestPlugin; -import org.exoplatform.processes.notification.plugin.CreateRequestPlugin; -import org.exoplatform.processes.notification.plugin.RequestCommentPlugin; -import org.exoplatform.processes.notification.utils.NotificationArguments; -import org.exoplatform.processes.notification.utils.NotificationUtils; -import org.exoplatform.social.core.identity.model.Profile; -import org.exoplatform.webui.utils.TimeConvertUtils; - -import java.io.Writer; -import java.util.Calendar; -import java.util.Locale; - -@TemplateConfigs(templates = { - @TemplateConfig(pluginId = CreateRequestPlugin.ID, template = "war:/notification/templates/web/CreateRequestPlugin.gtmpl"), - @TemplateConfig(pluginId = CancelRequestPlugin.ID, template = "war:/notification/templates/web/CancelRequestPlugin.gtmpl"), - @TemplateConfig(pluginId = RequestCommentPlugin.ID, template = "war:/notification/templates/web/RequestCommentPlugin.gtmpl"),}) -public class WebTemplateProvider extends TemplateProvider { - - public WebTemplateProvider(InitParams initParams) { - super(initParams); - this.templateBuilders.put(PluginKey.key(CreateRequestPlugin.ID), new TemplateBuilder()); - this.templateBuilders.put(PluginKey.key(CancelRequestPlugin.ID), new TemplateBuilder()); - this.templateBuilders.put(PluginKey.key(RequestCommentPlugin.ID), new RequestCommentTemplateBuilder()); - } - - private class TemplateBuilder extends AbstractTemplateBuilder { - - @Override - protected MessageInfo makeMessage(NotificationContext notificationContext) { - NotificationInfo notificationInfo = notificationContext.getNotificationInfo(); - String pluginId = notificationInfo.getKey().getId(); - String requester = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_CREATOR.getKey()); - String processUrl = notificationInfo.getValueOwnerParameter(NotificationArguments.PROCESS_URL.getKey()); - String requestUrl = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_URL.getKey()); - String language = getLanguage(notificationInfo); - TemplateContext templateContext = TemplateContext.newChannelInstance(getChannelKey(), pluginId, language); - - if (pluginId.equals(CreateRequestPlugin.ID)) { - String processTitle = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_PROCESS.getKey()); - templateContext.put("PROCESS_TITLE", processTitle); - } - - templateContext.put("PROCESS_URL", processUrl); - templateContext.put("REQUEST_URL", requestUrl); - buildCommonTemplateParams(templateContext, notificationInfo, language, requester); - - String body = TemplateUtils.processGroovy(templateContext); - notificationContext.setException(templateContext.getException()); - MessageInfo messageInfo = new MessageInfo(); - return messageInfo.body(body).end(); - } - - @Override - protected boolean makeDigest(NotificationContext notificationContext, Writer writer) { - return false; - } - } - - private class RequestCommentTemplateBuilder extends AbstractTemplateBuilder { - - @Override - protected MessageInfo makeMessage(NotificationContext notificationContext) { - NotificationInfo notificationInfo = notificationContext.getNotificationInfo(); - String pluginId = notificationInfo.getKey().getId(); - String processTitle = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_PROCESS.getKey()); - String requestTitle = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_TITLE.getKey()); - String commentAuthor = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_COMMENT_AUTHOR.getKey()); - String comment = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_COMMENT.getKey()); - String requestCommentUrl = notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_COMMENT_URL.getKey()); - String language = getLanguage(notificationInfo); - TemplateContext templateContext = TemplateContext.newChannelInstance(getChannelKey(), pluginId, language); - String commentText = NotificationUtils.formatMention(comment); - - templateContext.put("PROCESS_TITLE", processTitle); - templateContext.put("REQUEST_TITLE", requestTitle); - templateContext.put("REQUEST_COMMENT_AUTHOR", commentAuthor); - templateContext.put("REQUEST_COMMENT_URL", requestCommentUrl); - templateContext.put("REQUEST_COMMENT", commentText); - buildCommonTemplateParams(templateContext, notificationInfo, language, commentAuthor); - - String body = TemplateUtils.processGroovy(templateContext); - notificationContext.setException(templateContext.getException()); - MessageInfo messageInfo = new MessageInfo(); - return messageInfo.body(body).end(); - } - - @Override - protected boolean makeDigest(NotificationContext notificationContext, Writer writer) { - return false; - } - } - - private void buildCommonTemplateParams(TemplateContext templateContext, - NotificationInfo notificationInfo, - String language, - String user) { - Profile userProfile = NotificationUtils.getUserProfile(user); - templateContext.put("USER", userProfile.getFullName()); - templateContext.put("PROFILE_URL", userProfile.getUrl()); - templateContext.put("AVATAR", userProfile.getAvatarUrl()); - Calendar lastModified = Calendar.getInstance(); - lastModified.setTimeInMillis(notificationInfo.getLastModifiedDate()); - templateContext.put("LAST_UPDATED_TIME", - TimeConvertUtils.convertXTimeAgoByTimeServer(lastModified.getTime(), - "EE, dd yyyy", - new Locale(language), - TimeConvertUtils.YEAR)); - boolean isRead = Boolean.parseBoolean(notificationInfo.getValueOwnerParameter(NotificationMessageUtils.READ_PORPERTY.getKey())); - templateContext.put("READ", isRead ? "read" : "unread"); - templateContext.put("NOTIFICATION_ID", notificationInfo.getId()); - } - -} diff --git a/processes-services/src/test/java/org/exoplatform/processes/notification/plugin/CancelRequestPluginTest.java b/processes-services/src/test/java/org/exoplatform/processes/notification/plugin/CancelRequestPluginTest.java index fff2be8cf..3939983b4 100644 --- a/processes-services/src/test/java/org/exoplatform/processes/notification/plugin/CancelRequestPluginTest.java +++ b/processes-services/src/test/java/org/exoplatform/processes/notification/plugin/CancelRequestPluginTest.java @@ -25,23 +25,22 @@ import org.exoplatform.processes.service.ProcessesService; import org.exoplatform.services.idgenerator.IDGeneratorService; - @RunWith(MockitoJUnitRunner.class) public class CancelRequestPluginTest { - private static final MockedStatic COMMONS_UTILS = mockStatic(CommonsUtils.class); + private static final MockedStatic COMMONS_UTILS = mockStatic(CommonsUtils.class); private static final MockedStatic EXO_CONTAINER_CONTEXT = mockStatic(ExoContainerContext.class); - private static final MockedStatic NOTIFICATION_UTILS = mockStatic(NotificationUtils.class); + private static final MockedStatic NOTIFICATION_UTILS = mockStatic(NotificationUtils.class); @Mock - private InitParams initParams; + private InitParams initParams; @Mock - private ProcessesService processesService; + private ProcessesService processesService; - private CancelRequestPlugin cancelRequestPlugin; + private CancelRequestPlugin cancelRequestPlugin; @AfterClass public static void afterRunBare() throws Exception { // NOSONAR @@ -61,16 +60,20 @@ public void setUp() throws Exception { public void makeNotification() { NotificationContext ctx = NotificationContextImpl.cloneInstance(); ctx.append(NotificationArguments.REQUEST_CREATOR, "root"); + ctx.append(NotificationArguments.REQUEST_PROCESS, "processTitle"); + ctx.append(NotificationArguments.REQUEST_TITLE, "requestTitle"); ctx.append(NotificationArguments.WORKFLOW_PROJECT_ID, "1"); List receivers = new ArrayList<>(); receivers.add("user1"); receivers.add("user2"); ctx.append(NotificationArguments.PROCESS_URL, "http://exoplatfrom.com/dw/tasks/projectDetail/1"); - NOTIFICATION_UTILS.when(() -> NotificationUtils.getReceivers(1l , "root", true)).thenReturn(receivers); + NOTIFICATION_UTILS.when(() -> NotificationUtils.getReceivers(1l, "root", true)).thenReturn(receivers); NotificationInfo notificationInfo = cancelRequestPlugin.makeNotification(ctx); assertEquals("root", notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_CREATOR.getKey())); assertEquals("http://exoplatfrom.com/dw/tasks/projectDetail/1", notificationInfo.getValueOwnerParameter(NotificationArguments.PROCESS_URL.getKey())); + assertEquals("processTitle", notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_PROCESS.getKey())); + assertEquals("requestTitle", notificationInfo.getValueOwnerParameter(NotificationArguments.REQUEST_TITLE.getKey())); assertEquals("root", notificationInfo.getFrom()); assertEquals(receivers, notificationInfo.getSendToUserIds()); } diff --git a/processes-webapp/src/main/resources/locale/notification/ProcessesNotification_en.properties b/processes-webapp/src/main/resources/locale/notification/ProcessesNotification_en.properties index 1029b6210..f3aa32c99 100644 --- a/processes-webapp/src/main/resources/locale/notification/ProcessesNotification_en.properties +++ b/processes-webapp/src/main/resources/locale/notification/ProcessesNotification_en.properties @@ -1,4 +1,5 @@ UINotification.label.group.process=Process +Notification.label.types.process=Process #setting UINotification.title.CreateRequestPlugin=For process manager - A new request has been created @@ -9,9 +10,9 @@ UINotification.title.RequestCommentPlugin=A request is commented UINotification.label.RequestCommentPlugin=When someone comments on your request #web -Notification.process.request.created={0} has created a new request on the {1} process -Notification.process.request.cancelled={0} has cancelled the request -Notification.process.request.commented={0} has commented on your request {1} in {2} process +Notification.process.request.created={0} has created a new request for {1} +Notification.process.request.cancelled={0} has cancelled the request of {1} +Notification.process.request.commented={0} has commented on a request of {1} #mail Notification.title.CreateRequestPlugin=A new request has been created diff --git a/processes-webapp/src/main/webapp/WEB-INF/conf/processes/notification-configuration.xml b/processes-webapp/src/main/webapp/WEB-INF/conf/processes/notification-configuration.xml index ba8ba79b2..b3a234d3d 100644 --- a/processes-webapp/src/main/webapp/WEB-INF/conf/processes/notification-configuration.xml +++ b/processes-webapp/src/main/webapp/WEB-INF/conf/processes/notification-configuration.xml @@ -87,6 +87,9 @@ locale.notification.ProcessesNotification + + false + @@ -126,6 +129,9 @@ locale.notification.ProcessesNotification + + false + @@ -165,26 +171,15 @@ locale.notification.ProcessesNotification + + false + - - org.exoplatform.commons.api.notification.channel.ChannelManager - - web.channel.content - registerTemplateProvider - org.exoplatform.processes.notification.provider.WebTemplateProvider - - - channel-id - WEB_CHANNEL - - - - org.exoplatform.commons.api.notification.channel.ChannelManager @@ -199,10 +194,6 @@ - - - - org.exoplatform.commons.api.notification.channel.ChannelManager push.channel.content registerTemplateProvider diff --git a/processes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml b/processes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml index 984708a62..313b5ec41 100644 --- a/processes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/processes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml @@ -46,4 +46,24 @@ + + + processNotificationExtension + notificationGRP + + + vue + + + vuetify + + + eXoVueI18n + + + extensionRegistry + + \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CancelRequestPlugin.gtmpl b/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CancelRequestPlugin.gtmpl deleted file mode 100644 index 0fc8edc03..000000000 --- a/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CancelRequestPlugin.gtmpl +++ /dev/null @@ -1,40 +0,0 @@ -<% -/* -* Copyright (C) 2022 eXo Platform SAS. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero 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 Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see . -* -*/ -%> -
  • -
    -
    - $USER -
    -
    - <% - String URL = PROCESS_URL; - String msg = ""; - - String profileUrl = "" + USER + ""; - msg = _ctx.appRes("Notification.process.request.cancelled", profileUrl); - %> -
    -
    <%=msg%>
    -
    $LAST_UPDATED_TIME
    -
    -
    -
    - -
  • \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CreateRequestPlugin.gtmpl b/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CreateRequestPlugin.gtmpl deleted file mode 100644 index 73b89b0fa..000000000 --- a/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/CreateRequestPlugin.gtmpl +++ /dev/null @@ -1,40 +0,0 @@ -<% -/* -* Copyright (C) 2022 eXo Platform SAS. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero 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 Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see . -* -*/ -%> -
  • -
    -
    - $USER -
    -
    - <% - String URL = REQUEST_URL; - String msg = ""; - - String profileUrl = "" + USER + ""; - msg = _ctx.appRes("Notification.process.request.created", profileUrl, PROCESS_TITLE); - %> -
    -
    <%=msg%>
    -
    $LAST_UPDATED_TIME
    -
    -
    -
    - -
  • \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/RequestCommentPlugin.gtmpl b/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/RequestCommentPlugin.gtmpl deleted file mode 100644 index 9c65968f0..000000000 --- a/processes-webapp/src/main/webapp/WEB-INF/notification/templates/web/RequestCommentPlugin.gtmpl +++ /dev/null @@ -1,42 +0,0 @@ -<% -/* -* Copyright (C) 2022 eXo Platform SAS. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero 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 Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see . -* -*/ -%> -
  • -
    -
    - $USER -
    -
    - <% - String URL = REQUEST_COMMENT_URL; - String msg = ""; - String profileUrl = "" + USER + ""; - msg = _ctx.appRes("Notification.process.request.commented", profileUrl, "" + REQUEST_TITLE + "", "" + PROCESS_TITLE + ""); - %> -
    -
    <%=msg%>
    -
    - $REQUEST_COMMENT -
    -
    $LAST_UPDATED_TIME
    -
    -
    -
    - -
  • \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/vue-app/notification-extension/components/CancelRequestPlugin.vue b/processes-webapp/src/main/webapp/vue-app/notification-extension/components/CancelRequestPlugin.vue new file mode 100644 index 000000000..edff59673 --- /dev/null +++ b/processes-webapp/src/main/webapp/vue-app/notification-extension/components/CancelRequestPlugin.vue @@ -0,0 +1,65 @@ + + + + \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/vue-app/notification-extension/components/CreateRequestPlugin.vue b/processes-webapp/src/main/webapp/vue-app/notification-extension/components/CreateRequestPlugin.vue new file mode 100644 index 000000000..a53366867 --- /dev/null +++ b/processes-webapp/src/main/webapp/vue-app/notification-extension/components/CreateRequestPlugin.vue @@ -0,0 +1,63 @@ + + + + \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/vue-app/notification-extension/components/RequestCommentPlugin.vue b/processes-webapp/src/main/webapp/vue-app/notification-extension/components/RequestCommentPlugin.vue new file mode 100644 index 000000000..fa30fc043 --- /dev/null +++ b/processes-webapp/src/main/webapp/vue-app/notification-extension/components/RequestCommentPlugin.vue @@ -0,0 +1,70 @@ + + + + \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/vue-app/notification-extension/extensions.js b/processes-webapp/src/main/webapp/vue-app/notification-extension/extensions.js new file mode 100644 index 000000000..d9efd9cc0 --- /dev/null +++ b/processes-webapp/src/main/webapp/vue-app/notification-extension/extensions.js @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 eXo Platform SAS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +extensionRegistry.registerExtension('WebNotification', 'notification-group-extension', { + rank: 60, + name: 'process', + plugins: [ + 'CreateRequestPlugin', + 'CancelRequestPlugin', + 'RequestCommentPlugin' + ], + icon: 'fa-clipboard-check', +}); + +extensionRegistry.registerExtension('WebNotification', 'notification-content-extension', { + type: 'CreateRequestPlugin', + rank: 10, + vueComponent: Vue.options.components['user-notification-create-request'], +}); + +extensionRegistry.registerExtension('WebNotification', 'notification-content-extension', { + type: 'CancelRequestPlugin', + rank: 10, + vueComponent: Vue.options.components['user-notification-cancel-request'], +}); + +extensionRegistry.registerExtension('WebNotification', 'notification-content-extension', { + type: 'RequestCommentPlugin', + rank: 10, + vueComponent: Vue.options.components['user-notification-request-comment'], +}); \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/vue-app/notification-extension/initComponents.js b/processes-webapp/src/main/webapp/vue-app/notification-extension/initComponents.js new file mode 100644 index 000000000..ef1c1b524 --- /dev/null +++ b/processes-webapp/src/main/webapp/vue-app/notification-extension/initComponents.js @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 eXo Platform SAS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import CreateRequestPlugin from './components/CreateRequestPlugin.vue'; +import CancelRequestPlugin from './components/CancelRequestPlugin.vue'; +import RequestCommentPlugin from './components/RequestCommentPlugin.vue'; + +const components = { + 'user-notification-create-request': CreateRequestPlugin, + 'user-notification-cancel-request': CancelRequestPlugin, + 'user-notification-request-comment': RequestCommentPlugin, +}; + +for (const key in components) { + Vue.component(key, components[key]); +} \ No newline at end of file diff --git a/processes-webapp/src/main/webapp/vue-app/notification-extension/main.js b/processes-webapp/src/main/webapp/vue-app/notification-extension/main.js new file mode 100644 index 000000000..162584730 --- /dev/null +++ b/processes-webapp/src/main/webapp/vue-app/notification-extension/main.js @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 eXo Platform SAS. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import './initComponents.js'; +import './extensions.js'; + +const lang = eXo.env.portal.language; +const url = `${eXo.env.portal.context}/${eXo.env.portal.rest}/i18n/bundle/locale.notification.ProcessesNotification-${lang}.json`; + +export function init() { + return exoi18n.loadLanguageAsync(lang, url) + .then(() => { + Vue.createApp({ + i18n: exoi18n.i18n, + }); + }); +} \ No newline at end of file diff --git a/processes-webapp/webpack.prod.js b/processes-webapp/webpack.prod.js index 8bb309f89..6834a9a03 100644 --- a/processes-webapp/webpack.prod.js +++ b/processes-webapp/webpack.prod.js @@ -35,6 +35,7 @@ const config = { ], entry: { processes: './src/main/webapp/vue-app/processes/main.js', + notificationExtension: './src/main/webapp/vue-app/notification-extension/main.js', }, output: { path: path.join(__dirname, 'target/processes/'),