Skip to content

Commit

Permalink
VCST-1251: Add unregister notification (#160)
Browse files Browse the repository at this point in the history
fix: Impoved Unregistered Notifcation UX with displaying correct original type.
  • Loading branch information
OlegoO authored Jun 4, 2024
1 parent 265443a commit 7d0a503
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ namespace VirtoCommerce.NotificationsModule.Core.Model
//The special type for handle cases when the system have stored the notification objects with unregistered types.
public class UnregisteredNotification : Notification
{
public UnregisteredNotification(string type) : base(type)
{

}

public UnregisteredNotification() : base(nameof(UnregisteredNotification))
{
Templates = new List<NotificationTemplate>();
}
public override string Kind => "undef";


public override void SetFromToMembers(string from, string to)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ public NotificationBuilder OverrideNotificationType<TOldNotificationType, TNewNo

return builder;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static Notification ToModel(NotificationEntity entity)
entity.ToModel(result);
}

return result ?? new UnregisteredNotification();
return result ?? new UnregisteredNotification(typeName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"dialogs": {
"unknown-kind": {
"title": "Error",
"message": "Unable to edit template of an unknown type: '{{kind}}'."
"message": "Unable to open '{{type}}' notification. Please contact your Site Administrator(s) for information."
},
"notification-details-save": {
"title": "Save changes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"dialogs": {
"unknown-kind": {
"title": "Ошибка",
"message": "Невозможно изменить шаблон неопределенного типа:: '{{kind}}'."
"message": "Невозможно открыть уведомление '{{type}}'. Обратитесь к администратору(ам) вашего сайта за информацией."
},
"notification-details-save": {
"title": "Сохранить изменения",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ angular.module('virtoCommerce.notificationsModule')
return _.toArray(templatesToDisplay);
}

function resolveType(kind) {
function resolveType(kind, type) {
var foundTemplate = notificationTemplatesResolverService.resolve(kind);
if (foundTemplate && foundTemplate.knownChildrenTypes && foundTemplate.knownChildrenTypes.length) {
return foundTemplate;
Expand All @@ -49,13 +49,14 @@ angular.module('virtoCommerce.notificationsModule')
id: "error",
title: "notifications.dialogs.unknown-kind.title",
message: "notifications.dialogs.unknown-kind.message",
messageValues: { kind: kind },
messageValues: { kind: kind, type: type },
});
return null;
}
}

blade.openTemplate = function (template) {
var foundTemplate = resolveType(blade.currentEntity.kind);
var foundTemplate = resolveType(blade.currentEntity.kind, blade.currentEntity.type);
if (foundTemplate) {
var newBlade = {
id: foundTemplate.detailBlade.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ angular.module('virtoCommerce.notificationsModule')
});
}

function resolveType(kind) {
function resolveType(kind, type) {
var foundNotification = notificationTypesResolverService.resolve(kind);
if (foundNotification && foundNotification.knownChildrenTypes && foundNotification.knownChildrenTypes.length) {
return foundNotification;
Expand All @@ -58,14 +58,15 @@ angular.module('virtoCommerce.notificationsModule')
id: "error",
title: "notifications.dialogs.unknown-kind.title",
message: "notifications.dialogs.unknown-kind.message",
messageValues: { kind: kind },
});
messageValues: { kind: kind, type: type },
});
return null;
}
}

if (authService.checkPermission('notifications:access')) {
blade.editNotification = function (item) {
var foundNotification = resolveType(item.kind);
var foundNotification = resolveType(item.kind, item.type);
var newBlade = {
id: 'editNotification',
title: 'notifications.blades.notification-details.title',
Expand Down

0 comments on commit 7d0a503

Please sign in to comment.