Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
65b9e5c
cake-6064 | Add message wall content types
Nov 3, 2020
f33dc21
cake-6064 | updated build files
Nov 3, 2020
18edc6c
cake-6064 | Create notification types for message wall
Nov 4, 2020
5429c3e
cake-6064 | Update notification type
Nov 4, 2020
84f393e
cake-6064 | Map notification type
Nov 5, 2020
66dc0c3
cake-6064 | Use wall thread type
Nov 5, 2020
725f75f
cake-6064 | Update notification types
Nov 5, 2020
fc3f0bc
cake-6064 | Use wall post removed
Nov 5, 2020
d4d75b5
cake-6064 | update build file
Nov 5, 2020
2e17ec3
cake-6064 | add debugger log
Nov 5, 2020
7867443
cake-6064 | build with logging
Nov 5, 2020
f5bf9ae
cake-6064 | add notification type for html
Nov 5, 2020
161c55f
CAKE-6064 Handle metadata field from API data
mklucsarits Nov 5, 2020
6ec9f3a
Revert "Revert "CAKE-5920 Update some notifications to include wall o…
mklucsarits Nov 4, 2020
a198fc7
23.11.1
mklucsarits Nov 4, 2020
93744b5
cake-6064 | Add build files
Nov 5, 2020
e0c21ff
cake-6064 | update notifcation card
Nov 5, 2020
e93df11
cake-6064 | Update i18n files
Nov 5, 2020
3e9c5be
cake-6064 | Update i18n and icon
Nov 5, 2020
b9dca58
cake-6064 | user translated message
Nov 6, 2020
3303577
cake-6064 | build files
Nov 6, 2020
0ab15ed
cake-6064 | i18n
Nov 6, 2020
86db679
Merge branch 'master' into cake-6064
Nov 6, 2020
4dc9a9b
cake-6064 | No empty catch
Nov 6, 2020
bbdfaa5
cake-6064 | fix indentations
Nov 6, 2020
1e99e56
cake-6064 | update properties
Nov 6, 2020
cf95b94
Merge branch 'master' into cake-6064
Nov 6, 2020
1de59c9
cake-6064 | remove ws
Nov 6, 2020
1a13aaa
cake-6064 | Remove comment
Nov 6, 2020
b7f9609
cake-6064 | Add logging
Nov 9, 2020
51f7bef
cake-6064 | more logging
Nov 9, 2020
c416274
cake-6064 | update user prop
Nov 9, 2020
a49d615
cake-6064 | Remove logging
Nov 9, 2020
9718461
cake-6064 | reply logging
Nov 9, 2020
f5df34e
cake-6064 | Add content creator name
Nov 9, 2020
8cc1942
cake-6064 | add metadata logging
Nov 9, 2020
829cc81
cake-6064 | post logging
Nov 9, 2020
4aa8f41
cake-6064 | log metadata
Nov 9, 2020
67432b9
cake-6064 | get user id
Nov 9, 2020
f1d67ab
cake-6064 | check wall by id
Nov 9, 2020
6c892ac
cake-6064 | add logging
Nov 9, 2020
fb299b9
cake-6064 | get current user name
Nov 9, 2020
0081f7e
cake-6064 | logging
Nov 9, 2020
29d29eb
cake-6064 | check for wall owner
Nov 9, 2020
26cca0b
cake-6064 | User current user name
Nov 9, 2020
99740b5
cake-6064 | get metadata wall owner name
Nov 10, 2020
797c2bd
cake-6064 | Add additional case for own message and multiple users
Nov 10, 2020
8755539
cake-6064 | add logging for notifications wall reply
Nov 10, 2020
7861fa2
cake-6064 | remove logging and add build files
Nov 10, 2020
6041eed
cake-6064 | merge master and fix conflicts
Nov 10, 2020
271db20
cake=6064 | Remove comment
Nov 10, 2020
ccd78c5
cake-6064 | Get translations in different ticket
Nov 10, 2020
fe4d39d
cake-6064 | remove untranslated changes
Nov 10, 2020
205ef9b
remove ws
Nov 10, 2020
39fffa7
remove ws
Nov 10, 2020
8f4e17b
cake-6064 | use coalescing operator for metadata
Nov 11, 2020
4978e68
Revert "cake-6064 | use coalescing operator for metadata"
Nov 11, 2020
f16d3f3
Merge branch 'master' into cake-6064
Nov 12, 2020
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
100 changes: 100 additions & 0 deletions app/components/on-site-notifications/notification-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default Component.extend(
case notificationTypes.discussionReply:
case notificationTypes.postAtMention:
case notificationTypes.threadAtMention:
case notificationTypes.messageWallPost:
case notificationTypes.messageWallReply:
return 'wds-icons-comment-small';
case notificationTypes.announcement:
return 'wds-icons-flag-small';
Expand Down Expand Up @@ -86,6 +88,12 @@ export default Component.extend(
return this.getArticleCommentAtMentionMessageBody(this.model);
case notificationTypes.articleCommentReplyAtMention:
return this.getArticleCommentReplyAtMentionMessageBody(this.model);
case notificationTypes.messageWallPost:
return this.getMessageWallPostBody(this.model);
case notificationTypes.messageWallReply:
return this.getMessageWallReplyBody(this.model);
case notificationTypes.messageWallPostRemoved:
return this.getMessageWallPostRemovedBody(this.model);
default:
return null;
}
Expand Down Expand Up @@ -295,6 +303,98 @@ export default Component.extend(
});
},

getMessageWallPostBody(model) {
let wallOwner = model.get('metadata.wallOwnerName');
const currentUsername = this.wdsOnSiteNotifications.currentUser.name;

if (!wallOwner) {
wallOwner = this.getMessageWallOwner(model.get('uri'));
}

const isOwnWall = wallOwner === currentUsername;
const args = {
postTitle: model.get('title'),
wallOwner,
};

if (isOwnWall) {
args.user = this.getPossiblyAnonActorName(model);
return this.getTranslatedMessage('notifications-own-wall-post', args);
}

args.firstUser = this.getPossiblyAnonActorName(model);
return this.getTranslatedMessage('notifications-wall-post', args);
},

getMessageWallReplyBody(model) {
let wallOwner = model.get('metadata.wallOwnerName');
const currentUsername = this.wdsOnSiteNotifications.currentUser.name;

if (!wallOwner) {
wallOwner = this.getMessageWallOwner(model.get('uri'));
}

const isOwnWall = wallOwner === currentUsername;
const args = {
postTitle: model.get('title'),
wallOwner,
};

if (model.get('totalUniqueActors') > 1) {
args.number = model.get('totalUniqueActors') - 1;

if (isOwnWall) {
args.user = this.getPossiblyAnonActorName(model);
return this.getTranslatedMessage('notifications-own-wall-reply-multiple-users', args);
}

args.firstUser = this.getPossiblyAnonActorName(model);

if (model.get('contentCreatorName') === currentUsername) {
return this.getTranslatedMessage('notifications-wall-reply-multiple-users-own-message', args);
}

args.secondUser = model.get('contentCreatorName') || this.getTranslatedMessage('username-anonymous');
return this.getTranslatedMessage('notifications-wall-reply-multiple-users', args);
}

if (isOwnWall) {
args.user = this.getPossiblyAnonActorName(model);
return this.getTranslatedMessage('notifications-own-wall-reply', args);
}

if (model.get('contentCreatorName') === currentUsername) {
args.user = this.getPossiblyAnonActorName(model);
return this.getTranslatedMessage('notifications-wall-reply-own-message', args);
}

args.firstUser = this.getPossiblyAnonActorName(model);
args.secondUser = model.get('contentCreatorName') || this.getTranslatedMessage('username-anonymous');

return this.getTranslatedMessage('notifications-wall-reply', args);
},

getMessageWallPostRemovedBody(model) {
return this.getTranslatedMessage('notifications-own-wall-post-removed', {
postTitle: model.get('title'),
});
},

getMessageWallOwner(url) {
const regex = /\/Message_Wall:(.+?)([?#/].*)?$/i;
const result = regex.exec(url);

if (!result || !result[1]) {
return null;
}

return result[1];
},

getPossiblyAnonActorName(model) {
return model.get('latestActors.0.name') ? model.get('latestActors.0.name') : this.getTranslatedMessage('username-anonymous');
},

getTranslatedMessage(key, context) {
const fullContext = extend({}, {
ns: 'design-system',
Expand Down
22 changes: 22 additions & 0 deletions app/models/wds-on-site-notifications/wds-on-site-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default EmberObject.extend({

setNormalizedData(notificationData) {
this.setProperties({
contentCreatorName: get(notificationData, 'refersTo.createdByName'),
title: get(notificationData, 'refersTo.title'),
snippet: get(notificationData, 'refersTo.snippet'),
uri: get(notificationData, 'refersTo.uri'),
Expand All @@ -42,6 +43,7 @@ export default EmberObject.extend({
totalUniqueActors: get(notificationData, 'events.totalUniqueActors'),
latestActors: this.createActors(get(notificationData, 'events.latestActors')),
type: this.getTypeFromApiData(notificationData),
metadata: this.getMetadata(notificationData),
});
},

Expand Down Expand Up @@ -77,9 +79,29 @@ export default EmberObject.extend({
return notificationTypes.articleCommentAtMention;
case 'article-comment-reply-at-mention-notification':
return notificationTypes.articleCommentReplyAtMention;
case 'message-wall-post-notification':
return notificationTypes.messageWallPost;
case 'message-wall-reply-notification':
return notificationTypes.messageWallReply;
case 'wall-post-removed-notification':
return notificationTypes.messageWallPostRemoved;
}
},

getMetadata(notification) {
let metadata =
typeof notification.metadata === 'undefined' || notification.metadata === null ? null : notification.metadata;
if (typeof metadata === 'string') {
try {
metadata = JSON.parse(metadata);
} catch (e) {
// continue regardless of error
}
}
// Caveat: if the metadata was not serialized JSON, a string could be returned instead of an object
return metadata;
},

markAsRead(willUnloadPage) {
if (willUnloadPage && window.navigator.sendBeacon) {
return this.markAsReadUsingSendBeacon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default EmberObject.extend({
'article-comment-reply',
'article-comment-at-mention',
'article-comment-reply-at-mention',
'message-wall-post',
'message-wall-thread',
];

return `contentType=${supportedContentTypes.join('&contentType=')}`;
Expand Down
3 changes: 3 additions & 0 deletions app/utils/notification-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export default {
articleCommentReply: 'article-comment-reply',
articleCommentAtMention: 'article-comment-at-mention',
articleCommentReplyAtMention: 'article-comment-reply-at-mention',
messageWallPost: 'message-wall-post',
messageWallReply: 'message-wall-reply',
messageWallPostRemoved: 'message-wall-post-removed',
};
2 changes: 1 addition & 1 deletion dist/css/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/design-system.css

Large diffs are not rendered by default.

Loading