[Lens] Provide a way to intercept and rewrite user messages #183514
+411
−178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is a simple POC that provides a way to intercept, review and modify user messages coming from a Lens embeddable.
The property
handleUserMessages?: (userMessages: UserMessage[]) => UserMessage[];
can be used from the lens embeddable to remap/rewrite/filter theUserMessages
that the embeddable is throwing to the user.This includes both
info
,warning
anderror
messages.The
UserMessage
type needs to be extended a few more property to be able to correctly manipulate the user messages:messageType
property should be added to identify the message type. An enum/string can be used to represent each specific message type and have a specific semantic meaning (for exampleLENS_FORMULA_MISSING_FIELD_ERROR
.messageType
there could be some context variables that provide more information about the error itself (in the case of formulamissing field
we can provide for example the associated field names.At the dashboard level, we can probably implement all the necessary logic to filter/review/modify the messages for
managed
dashboard at the Lens embeddable bootstrap.