-
Notifications
You must be signed in to change notification settings - Fork 429
announcements: integration with notifications #4378 #4816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
announcements: integration with notifications #4378 #4816
Conversation
Hello @kurtaking, @gaelgoth, @04kash , I have to raise this new PR for issue #4378 with all the comments addressed from @kurtaking as the old PR #4793 had merge conflicts and it was not allowing me to resolve them locally. So I have to use the UI option "Discard 1 commit" & then create this new PR again. Kindly have a look at this PR and let me know if any comments / concerns |
fa2d8c6
to
5d67d89
Compare
Changed Packages
|
Looks like you need to run |
6ff401c
to
f83091c
Compare
Thanks for the contribution! |
Signed-off-by: Lavanya Sainik <[email protected]>
…and dev app (backstage#4798) Signed-off-by: Christoph Jerolimov <[email protected]> Signed-off-by: Lavanya Sainik <[email protected]>
v1.40.2 version bump --------- Signed-off-by: Saif Chaudhry <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Saif Chaudhry <[email protected]> Signed-off-by: Lavanya Sainik <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Lavanya Sainik <[email protected]>
f83091c
to
6fd4a54
Compare
Hello @04kash and All, Thanks for your comment. I have added the yarn.lock file . Looks like other issues are also solved related to build. Kindly have a look and let me know if any further comments or concerns. |
title: 'New Announcement', | ||
description: 'New announcement has been added', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we allow the user to specify the title and description via params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const notificationsConfig = | ||
announcementNotificationOpts.config.getOptionalConfig( | ||
'announcements.notification', | ||
); | ||
|
||
const notifications = announcementNotificationOpts.notifications; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking - you could consider destructuring right here
const { config, notifications } = announcementNotificationOpts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed now based on @gaelgoth next comment. But do revert if nay concern.
workspaces/announcements/plugins/announcements-backend/src/router.ts
Outdated
Show resolved
Hide resolved
workspaces/announcements/plugins/announcements-backend/src/router.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if you could set up Notifications on the Backstage dev instance 🙏🏾. This will help with trying/testing notifications locally.
workspaces/announcements/plugins/announcements-backend/src/router.ts
Outdated
Show resolved
Hide resolved
workspaces/announcements/plugins/announcements-backend/src/router.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Lavanya Sainik <[email protected]>
Hello @kurtaking , @gaelgoth Thanks a lot for your comments. Have updated the PR with the comments included. Kindly review and do let me know if any further concerns or improvements. Also @gaelgoth , could you please guide on how to set up the Backstage dev instance for you to test as you have mentioned in the comment ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lavanya-sainik-ericsson, thank you for iterating through this. It's looking great. I've got another round of review for you.
@@ -209,6 +211,9 @@ export async function createRouter( | |||
tags: validatedTags, | |||
}); | |||
|
|||
// Send announcement notification | |||
sendAnnouncementNotification(req, announcement.id, notifications); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notifications plugin requires events. We need to put this next to await signalAnnouncement(announcement, signals)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what happens if we call both signalAnnouncement
and sendAnnouncementNotification
. Does that cause two separate signals to go out?
I'm wondering if they have notifications enabled, we call sendAnnouncementNotification
, else if they have have signals enabled, we call signalAnnouncement
, else do nothing.
export const sendAnnouncementNotification = ( | ||
request: any, | ||
announcementId: string, | ||
notifications?: NotificationService, | ||
) => { | ||
const reqData: AnnouncementRequest = request.body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendAnnouncementNotification
shouldn't need to know about the request object. Notice how you now have to import from the router now. This is a circular dependency and tightly couples sending an announcement notification to a request object.
By the time you call your function, you should already have a complete announcement that you can pass in. I highly recommend aligning this as closely to the signalAnnouncements
fn as possible.
|
||
interface AnnouncementRequest { | ||
export interface AnnouncementRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this based on this thread.
title: `New Announcement "${reqData.title}"`, | ||
description: reqData.excerpt, | ||
link: `/announcements/view/${announcementId}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will also get type safety back if the function is updated to take an announcement. Right now we are blindly trusting an any.
You can follow the installation guide here: https://backstage.io/docs/notifications/#installation Run the The signals backend is already installed, you can skip that step. I did try the set up on my side, so far it's look good 😄 ![]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be necessary to update the documentation to mention the prerequisites for Notifications
Hey, I just made a Pull Request!
✔️ Checklist
Signed-off-by
line in the message. (more info)