-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
On the visualize_listing.tsx component, we list all vis types with edit strings. The types for the savedObject are very loose due to #231528 as shown below...
Lines 87 to 109 in 8c90d48
| const toTableListViewSavedObject = (savedObject: Record<string, unknown>): VisualizeUserContent => { | |
| return { | |
| id: savedObject.id as string, | |
| updatedAt: savedObject.updatedAt as string, | |
| managed: savedObject.managed as boolean, | |
| references: savedObject.references as Array<{ id: string; type: string; name: string }>, | |
| type: savedObject.savedObjectType as string, | |
| icon: savedObject.icon as string, | |
| stage: savedObject.stage as VisualizationStage, | |
| savedObjectType: savedObject.savedObjectType as string, | |
| typeTitle: savedObject.typeTitle as string, | |
| title: (savedObject.title as string) ?? '', | |
| error: (savedObject.error as string) ?? '', | |
| editor: savedObject.editor as any, | |
| attributes: { | |
| id: savedObject.id as string, | |
| title: (savedObject.title as string) ?? '', | |
| description: savedObject.description as string, | |
| readOnly: savedObject.readOnly as boolean, | |
| error: savedObject.error as string, | |
| }, | |
| }; | |
| }; |
But aside from these loose types, the error from the savedObject is completely ignored which can result in the entire page erroring instead of a single vis.
For example, here we are getting the getDetailViewLink for each vis, but in some cases there is an error which leads to editor being undefined. But since we don't catch the error at the vis level, we throw at the page level 🤦🏼♂️.
Lines 439 to 449 in 8c90d48
| getDetailViewLink={({ editor, attributes: { error, readOnly } }) => | |
| readOnly || (editor && 'onEdit' in editor) | |
| ? undefined | |
| : getVisualizeListItemLink( | |
| application, | |
| kbnUrlStateStorage, | |
| editor.editApp, | |
| editor.editUrl, | |
| error | |
| ) | |
| } |
We should be better at catching these issues and displaying errors for each vis and avoid full page errors.