Skip to content
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

Notification: support new notifications through API #259

Closed
2 tasks done
agjohnson opened this issue Jan 4, 2024 · 9 comments
Closed
2 tasks done

Notification: support new notifications through API #259

agjohnson opened this issue Jan 4, 2024 · 9 comments
Assignees
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code Needed: design decision A core team decision is required

Comments

@agjohnson
Copy link
Contributor

agjohnson commented Jan 4, 2024

Edit: in discussion below we narrowed the focus of this for right now. Currently, everything is template driven, but the build detail page needs to be API driven still. We'll punt on the rest of the items as there isn't a huge amount of value in API driven user/organization notifications yet.

  • Remove page reload to view errors on build detail view and render errors from the API response
  • Ensure cold storage builds show errors as well, these should come from cold storage API data. (This is assuming the modeling has these new errors too, I'm not sure if we touched on this one at the modeling level yet)

Decisions

  • Will project/organization/user notifications be rendered by templates? Is there a need to make these API driven?

Work

  • Create a common Notification listing include template
    • Include this template on project base template, organization base template, and profile base template
    • If API driven, pass the notification API URL to the relevant Knockout view. There will be distinct URLs for project notifications, organization notifications, and user notifications (?).
    • Iterate over Notification instances and render. Reuse and tune current messages template for this
  • Create a Notification listing for build detail page
    • Most of the logic above is still applicable, but this will be rendered slightly differently and in a different location than other notifications
  • We did talk about how to use the bell icon menu and what notifications might go there. I feel we still aren't settled here, and maybe need to try out some options like news messages and high priority messages.

cc @humitos, you might have some input on what is needed here

@agjohnson agjohnson added Improvement Minor improvement to code Accepted Accepted issue on our roadmap labels Jan 4, 2024
@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Jan 4, 2024
@agjohnson agjohnson added the Needed: design decision A core team decision is required label Jan 4, 2024
@humitos
Copy link
Member

humitos commented Jan 4, 2024

Will project/organization/user notifications be rendered by templates? Is there a need to make these API driven?

Regarding template rendering vs. API driven, there are a few things to consider IMO:

  • 👍🏼 template rendering is a lot easier to me
  • 😐 API driven is useful if we want more dynamic UX (similar to build detail's page), but I think it's not required for the notifications in the other resources at this point
  • 👍🏼 using API driven will give us parity with the build detail's page
  • 👎🏼 API driven will require writing and maintaining extra endpoints only for this use case

With that in mind, I would start with template rendering because it's easier to implement. We can keep thinking about this and change the approach if we find a more dynamic UX is required.

We need to create the PATCH endpoint to mark them as read / dismissed either way (see readthedocs/readthedocs.org#10983)

Create a Notification listing for build detail page

This is already implemented and it's working.

Since we will mark the notification as read dynamically here, we need to add the _links field in the notification response for this use case (see readthedocs/readthedocs.org#10982)

We did talk about how to use the bell icon menu and what notifications might go there. I feel we still aren't settled here, and maybe need to try out some options like news messages and high priority messages.

I still don't have a great answer. I'm happy to discuss more these approaches and figure it out while working on this or after implementing the initial version of the front-end. I think that will give us some valuable input to make a better decision here.

humitos added a commit to readthedocs/readthedocs.org that referenced this issue Jan 4, 2024
Keep rendering regular one-time Django messages attached to the request, but
remove the logic used for sticky/permanent messages from
`django-messages-extends`.

Closes #10988
Related readthedocs/ext-theme#259
@agjohnson
Copy link
Contributor Author

With that in mind, I would start with template rendering because it's easier to implement.

Cool, those are all my exact thoughts too, we're on the same page 👍

Create a Notification listing for build detail page

This is already implemented and it's working.

Sorry, I wasn't super clear here. I was trying to refer to the notification listing UI elements in the build detail page, created from the Notification API. Your first pass in #254 on that UI will be close, but we need to add styling for the message levels, custom icons, etc, and feed it API data.

I still don't have a great answer.

Same. I think I need to see it in aciton. When I get to theme pieces, I'll try to mock something up -- I've had a hard time making time to do this so far

humitos added a commit to readthedocs/readthedocs.org that referenced this issue Jan 4, 2024
Keep rendering regular one-time Django messages attached to the request, but
remove the logic used for sticky/permanent messages from
`django-messages-extends`.

Closes #10988
Related readthedocs/ext-theme#259
humitos added a commit that referenced this issue Jan 11, 2024
Render notifications attached to these objects.
This is the first pass of this work and there are some things we need to make
decisions and improve.

- Where (what pages) these notifications should render?
- How "global" they should be considered?

Note we are rendering these notifications in the template for now,
but in the future they will be rendered using the APIv3: #259
humitos added a commit that referenced this issue Jan 11, 2024
Render notifications attached to these objects.
This is the first pass of this work and there are some things we need to make
decisions and improve.

- Where (what pages) these notifications should render?
- How "global" they should be considered?

Note we are rendering these notifications in the template for now,
but in the future they will be rendered using the APIv3: #259

Closes #260
humitos added a commit that referenced this issue Jan 18, 2024
…261)

* Notifications: show attached to `User`, `Project` and `Organization`

Render notifications attached to these objects.
This is the first pass of this work and there are some things we need to make
decisions and improve.

- Where (what pages) these notifications should render?
- How "global" they should be considered?

Note we are rendering these notifications in the template for now,
but in the future they will be rendered using the APIv3: #259

Closes #260

* Render notifications before project/organization header

* Apply suggestions from code review

Co-authored-by: Anthony <[email protected]>

---------

Co-authored-by: Anthony <[email protected]>
@agjohnson
Copy link
Contributor Author

@humitos Can this be closed?

@agjohnson
Copy link
Contributor Author

agjohnson commented Feb 27, 2024

Nevermind, this is still a valid issue. I thought we got rid of this hack but we do need to return to it:

// HACK: this is a small hack to avoid implementing the new notification system
// on ext-theme at this point. This will come in a future PR.
// The notifications are rendered properly via Django template in a static way.
// So, we refresh the page once the build has finished to make Django render the notifications.
// We use a check of 1 API poll for those builds that are already finished when opened.
// The new dashboard will implement the new notification system in a nicer way using APIv3.
if (this.poll_api_counts !== 1) {
location.reload();
}

The other notifications are fine to drive with template logic however, I don't feel we need to adjust those yet. We can focus this issue on the build detail notifications instead.

So the question instead is: can we finish this work now, or are we still blocked?

@humitos
Copy link
Member

humitos commented Feb 28, 2024

This work is about "rendering all the notifications via APIv3". This requires creating all the KO structure/pattern to consume the APIv3 endpoints --which is not implemented already and think you are the best one to do this work here.

Besides, there are some other work here missing as well:

  • design the UI notification element to expose the header + body
  • add the ability to dismiss the notification
  • remove the hack that refreshes the page

Note that rending the notifications by using template logic was only just a temporal workaround to allow us to move forward with the implementation of the new notification system.

@agjohnson agjohnson assigned agjohnson and unassigned humitos Feb 28, 2024
@agjohnson
Copy link
Contributor Author

From our chat on this:

  • I can take a look into this to start, this might be a good issue to start with too however
  • This is probably starting with build detail errors first, as these definitely should be API driven
  • Separate but related work would be using the API pattern for all notifications, so some of the build detail view notifications work might be reusable or might extend a general pattern
  • And as we are implementing the KO view/etc for general API driven notifications, we should implement the dismiss URL. Or rather, it probably doesn't make sense to implement this for template driven notifications as that work might be replaced.

@agjohnson
Copy link
Contributor Author

agjohnson commented Mar 2, 2024

I started poking this on the build detail view and found that we can't use the APIv3 build endpoint still. This view uses the build v2 API for access to BuildCommands. I opened up

I didn't realize we implemented the Notifications in v2 API, so can at least start there.

@agjohnson agjohnson moved this from Planned to In progress in 📍Roadmap Mar 2, 2024
@agjohnson
Copy link
Contributor Author

I started poking this last night when I got back to my desk, it did go in fairly easy on the build detail view. Still some rough edges but solid improvement:

Image

@agjohnson agjohnson moved this from In progress to Needs review in 📍Roadmap Mar 25, 2024
@humitos
Copy link
Member

humitos commented Mar 26, 2024

This can be closed since it was implemented in #300

@humitos humitos closed this as completed Mar 26, 2024
@github-project-automation github-project-automation bot moved this from Needs review to Done in 📍Roadmap Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code Needed: design decision A core team decision is required
Projects
Archived in project
Development

No branches or pull requests

2 participants