Page MenuHomePhabricator

Design a "notification" component and API
Closed, ResolvedPublic

Description

@srishakatux and @bd808 have been discussing the various challenges of displaying "toast" messages to the user within our Vue frontend. Currently we have notification widgets embedded in each page that has a need for one (or multiple in some cases). This repetition has implications for both the developers (more code) and the users (variation of notifications by page).

@bd808 thinks we can and should build a central notification component with vuex integration. Flask and Django have a notion of "flash messages" that feels like a good model. Code anywhere can call a method like messages.info() or messages.error() to pass a UI notice to the user on the next page load. In our Vue frontend this information would be presented on the next tick, but could work functionally the same way.

If we expose this as a proper Vue plugin then from just about anywhere you could make a call like Vue.$notify.warning(...) to add a notice. Wiring it all to vuex on the back would then notify a component to render the message. That component could be a part of the App.vue scaffolding which would display in a way that is consistent no matter what screen you are on.

It should be possible for multiple notices to be displayed at the same time.

Inspiration:

Event Timeline

The vuetify alert component looks like a good building block for the display side of this. Emulating snackbar's timeout property might be interesting for some messages too.

The vuetify alert component looks like a good building block for the display side of this. Emulating snackbar's timeout property might be interesting for some messages too.

v-snackbar might be good for short, non-actionable messages that notify of a change and should disappear soon:
"Copied to clipboard"
"App updated"

v-alert might be good for status messages, API errors, actionable messages that should not disappear soon:
"App deleted with id"
"App registration success" with client id/ secret details

v-snackbar might be good for short, non-actionable messages that notify of a change and should disappear soon:
"Copied to clipboard"
"App updated"

v-alert might be good for status messages, API errors, actionable messages that should not disappear soon:
"App deleted with id"
"App registration success" with client id/ secret details

+1. I have a working alert based system for messages that need to be manually dismissed that I hope to get into gerrit soon. (Blocked on some tangentially related issues with mocha tests right now.) What I have built does not yet cover the non-actionable message need, but I think it could be extended to include it as well. One way to do that would be still using v-alert components for rendering but adding a timer to "light" messages (based on severity or another flag) that would automatically close them after a predefined interval in the manner that v-snackbar does.

Change 657414 had a related patch set uploaded (by BryanDavis; owner: Bryan Davis):
[wikimedia/toolhub@main] ui: Add a global notification component

https://gerrit.wikimedia.org/r/657414

bd808 moved this task from Backlog to In Progress on the Toolhub board.

Change 657414 merged by jenkins-bot:
[wikimedia/toolhub@main] ui: Add a global notification component

https://gerrit.wikimedia.org/r/657414