[ML] Add recognized modules links for Index data visualizer#131342
[ML] Add recognized modules links for Index data visualizer#131342qn895 merged 8 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/ml-ui (:ml) |
x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx
Outdated
Show resolved
Hide resolved
| const [FileDataVisualizer, setFileDataVisualizer] = useState<FileDataVisualizerSpec | null>(null); | ||
|
|
||
| const links: ResultLink[] = useMemo( | ||
| const asyncLinkCards = useMemo( |
There was a problem hiding this comment.
These show up when accessing the file view from within the ML plugin, but not when I upload a file from the Kibana Home page - Upload a file.
There was a problem hiding this comment.
If I'm remembering correctly, we purposely didn't add any ML links to the file data vis when being used inside kibana's Add Data page.
It would be a lot more work to register the links on start up. We'd have to add a registry for the links to be stored in. Whereas currently the links are passed on component render.
Also most users will not be jumping from there to ML.
There are far more popular plugins in kibana that should come before ML in that list. but when using it inside ML, it makes sense to have links to other parts of ML
| return false; | ||
| } | ||
| }, | ||
| } as ResultLink), |
There was a problem hiding this comment.
rather than asserting ResultLink here, the asyncLinkCards declaration could be asyncLinkCards: AsyncLinkCards
| dataTestSubj: 'dataVisualizerCreateAdvancedJobCard', | ||
| }, | ||
| 'data-test-subj': 'dataVisualizerCreateAdvancedJobCard', | ||
| } as ResultLink, |
There was a problem hiding this comment.
Rather than asserting as ResultLink, this function could have a return signature of Promise<ResultLink[]>
| } | ||
|
|
||
| export type AsyncLinkCards = Array< | ||
| (params: AsyncLinkCardParams) => Promise<ResultLink | ResultLink[] | undefined> |
There was a problem hiding this comment.
It would probably simplify the code if we only ever returned an array of ResultLink rather than having to deal with single links.
| ); | ||
| } | ||
|
|
||
| if (results) { |
There was a problem hiding this comment.
as mentioned above, if we only ever dealt with ResultLink arrays, this logic could be removed
There was a problem hiding this comment.
alternatively, if we do still need single result links, the single link could be put in an array and processed the same, e.g.
const tempResults = Array.isArray(results) ? results : [results];
return await Promise.all(results.map ....| globalState?: any; | ||
| } | ||
|
|
||
| export type AsyncLinkCards = Array< |
There was a problem hiding this comment.
I'm not sure about the name AsyncLinkCards
It implies that there are also non-async links cards.
The functions that return the ResultsLinks are all async, so adding the word async to the name seems unnecessary.
Maybe something like GetResultLinks would be more accurate? Although i'm not crazy about that name.
| createDataView: boolean; | ||
| showFilebeatFlyout(): void; | ||
| additionalLinks: ResultLink[]; | ||
| asyncLinkCards?: AsyncLinkCards; |
There was a problem hiding this comment.
IMO the original additionalLinks name is better here.
Possibly changed to getAdditionalLinks?
peteharverson
left a comment
There was a problem hiding this comment.
Tested latest changes and LGTM
|
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Any counts in public APIs
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @qn895 |
…131342) * [ML] Add dynamic registration of links for both index and file * [ML] Consolidate type imports * [ML] Revert uptime changes * [ML] Fix cards visible when canDisplay is false * [ML] Shorten create job text * [ML] Remove as assertions * [ML] Rename to GetAdditionalLinks Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
Part of #86387. This PR re-adds recognized module links for the Index data visualizer. It also removes

additionalLinksas a props for both Index data visualizer and File data visualizer. It's replaced asyncasyncLinkCardswhich is an array of promises that allows for us to pass in multiple links, and to be able to format the content dynamically.This PR also moves the link to Discover up top.
Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers