Backstage: Make Error API work for any kind of Snackbar variant

Created on 27 Mar 2020  路  4Comments  路  Source: backstage/backstage


I'm thinking it may make more sense, rather than having a ErrorApi, just to have a general AlertApi or SnackBarApi, and have .post() take an optional second argument for the variant to use.

Feature Suggestion

  • Use the API pattern you have established to support other variants besides error for the Snackbar

Possible Implementation

  • Rename the ErrorApi to SnackbarApi
  • Support an optional variant override, default it to empty
  • Expose an ErrorApi as well, which always sets the variant to error

Context



This would be helpful in the plugin I'm building, which could benefit from a small dismissable alert on a page transition that informs the user that the API request they just made was successful.

Most helpful comment

Maybe not name it "snackbar" - that's an implementation detail.

All 4 comments

What do you think about adding the SnackbarApi in addition to the ErrorApi? The rationale for having a separate error API is showing a snackbar is just one of many things you might want to do with errors that are reported by plugins. The current error api implementation would then be replaced with a thing wrapper that forwards the error to the snackbar api.

Maybe not name it "snackbar" - that's an implementation detail.

i can pick this up

Fixed in #605

Was this page helpful?
0 / 5 - 0 ratings