avo
avo copied to clipboard
In-UI error reporting
Depends on https://github.com/avo-hq/avo/issues/2352
We need to improve the way we report errors to the developer in the Avo UI in development.
Common errors
- [ ] model class not found
- [ ] bad block arguments
- [ ] The developer tried to use field types that are inexistent
- [ ] more errors from https://github.com/avo-hq/avo/issues/2310
- [ ] bad initializer settings (from here
undefined method 'tabs_style=' for #<Avo::Configuration
)
Ideally we'd use the same error reporting system for both this issue and https://github.com/avo-hq/avo/issues/2310
Build a UI for it
I'm thinking of having a tiny icon/button somewhere that highlights the number of errors that are present. When that button is pressed, an overlay slides in, showing a list with all the errors and the next steps on how to correct them or link to the docs.
I have a couple cases right now where I'm creating fields for non-existent fields, and handling it via the format_using
attribute. Since that would interact badly with this feature, and this feature is very much worth having, a better solution for my use-case would be welcome.
An example:
Product.all.each do |product|
field(:"Missing #{product.name} Perms",
as: :text,
readonly: true,
format_using: -> { (product.gsuite_scopes - record.scopes).join("<br/>\n").html_safe }) # rubocop:disable Rails/OutputSafety,Layout/LineLength
end
(In this case, Product
is not an ActiveRecord model, so this isn't a degenerate association of some kind.)
I could perhaps push these into accessor methods on the model, but they wouldn't show up as "fields" if querying ActiveRecord metadata. So if you made it allowable to make a read-only field refer to an arbitrary instance method on the model class (and non-read-only fields would have to refer to DB fields), that would cover such use-cases while still allowing robust, proactive error reporting for the developer.
Ok. I made a mistake in the description (and corrected). Instead of inexistent field names I meant field types.
field :name, as: :string # should show a warning that the `string` field does not exist
I use that technique of "virtual" fields as well. It's rather powerful!
This issue has been marked as stale because there was no activity for the past 15 days.
Some brainstorming
Closing in favor of https://github.com/avo-hq/avo/issues/2311