Skip to content

Commit

Permalink
fix: Update web notification from gtmpl to vue - EXO-66413
Browse files Browse the repository at this point in the history
This PR updates the web notification old gtmpl templates to vue & vuetify for better UX
  • Loading branch information
hakermi committed Nov 28, 2023
1 parent 2cb588b commit 429c72d
Show file tree
Hide file tree
Showing 18 changed files with 363 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public void onEvent(Event<TaskDto, ProjectDto> 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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
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;
import org.exoplatform.processes.notification.utils.NotificationUtils;
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;
Expand Down Expand Up @@ -53,10 +56,15 @@ public void onEvent(Event<TaskDto, CommentDto> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<CommonsUtils> COMMONS_UTILS = mockStatic(CommonsUtils.class);
private static final MockedStatic<CommonsUtils> COMMONS_UTILS = mockStatic(CommonsUtils.class);

private static final MockedStatic<ExoContainerContext> EXO_CONTAINER_CONTEXT = mockStatic(ExoContainerContext.class);

private static final MockedStatic<NotificationUtils> NOTIFICATION_UTILS = mockStatic(NotificationUtils.class);
private static final MockedStatic<NotificationUtils> 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
Expand All @@ -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<String> 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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<field name="bundlePath">
<string>locale.notification.ProcessesNotification</string>
</field>
<field name="mutable">
<boolean>false</boolean>
</field>
</object>
</object-param>
</init-params>
Expand Down Expand Up @@ -126,6 +129,9 @@
<field name="bundlePath">
<string>locale.notification.ProcessesNotification</string>
</field>
<field name="mutable">
<boolean>false</boolean>
</field>
</object>
</object-param>
</init-params>
Expand Down Expand Up @@ -165,26 +171,15 @@
<field name="bundlePath">
<string>locale.notification.ProcessesNotification</string>
</field>
<field name="mutable">
<boolean>false</boolean>
</field>
</object>
</object-param>
</init-params>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
<target-component>org.exoplatform.commons.api.notification.channel.ChannelManager</target-component>
<component-plugin>
<name>web.channel.content</name>
<set-method>registerTemplateProvider</set-method>
<type>org.exoplatform.processes.notification.provider.WebTemplateProvider</type>
<init-params>
<value-param>
<name>channel-id</name>
<value>WEB_CHANNEL</value>
</value-param>
</init-params>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
<target-component>org.exoplatform.commons.api.notification.channel.ChannelManager</target-component>
Expand All @@ -199,10 +194,6 @@
</value-param>
</init-params>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
<target-component>org.exoplatform.commons.api.notification.channel.ChannelManager</target-component>
<component-plugin>
<name>push.channel.content</name>
<set-method>registerTemplateProvider</set-method>
Expand Down
20 changes: 20 additions & 0 deletions processes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,24 @@
</depends>
</module>
</portlet>

<module>
<name>processNotificationExtension</name>
<load-group>notificationGRP</load-group>
<script>
<path>/js/notificationExtension.bundle.js</path>
</script>
<depends>
<module>vue</module>
</depends>
<depends>
<module>vuetify</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
<depends>
<module>extensionRegistry</module>
</depends>
</module>
</gatein-resources>

This file was deleted.

Loading

0 comments on commit 429c72d

Please sign in to comment.