Use app id instead of pluginId to generate navlink from legacy apps#57542
Conversation
|
Pinging @elastic/kibana-platform (Team:Platform) |
|
retest |
|
@pgayvallet will the fix be backported to 7.6.0? I don't see v7.6.0 label |
|
@sergibondarenko The |
| throw new Error('Every app must specify an id'); | ||
| } | ||
|
|
||
| if (spec.pluginId && !pluginSpecs.some(plugin => plugin.getId() === spec.pluginId)) { |
There was a problem hiding this comment.
minor: Does it belong here? Such checks are more appropriate in find_legacy_plugin_specs.ts
the same for id
There was a problem hiding this comment.
For the id, we could perform the check after in find_legacy_plugin_specs.ts, However for the pluginId check, as the pluginId value is actually not present in the generated navlinks structure, that would mean looking twice to perform this validation.
There was a problem hiding this comment.
I moved it outside of the mapping function (well, at least for the pluginId check). That seems the best I can do without more heavy changes, unless you see something better?
| icon: spec.icon, | ||
| euiIconType: spec.euiIconType, | ||
| url: spec.url || `/app/${id}`, | ||
| linkToLastSubUrl: spec.linkToLastSubUrl, |
There was a problem hiding this comment.
seems to be optional and should repeat this logic https://github.com/elastic/kibana/pull/57542/files#diff-d1ea0ed9e7f4c8bacd7b2ecc4453fa05R71
I'd suggest normalizing spec content, even though this code will be removed soon-ish
There was a problem hiding this comment.
I'd suggest normalizing spec content
These are two distinct types though, LegacyNavLinkSpec and LegacyAppSpec, with different fields and optionals on field (because, 'reasons' I guess). Not really confident on touching these things?
There was a problem hiding this comment.
Can try to extract a mapping function that would accept either of those though
| category: spec.category, | ||
| title: spec.title, | ||
| order: typeof spec.order === 'number' ? spec.order : 0, | ||
| icon: spec.icon, |
There was a problem hiding this comment.
what about other fields from https://github.com/elastic/kibana/pull/57542/files#diff-d1ea0ed9e7f4c8bacd7b2ecc4453fa05R62-R74 ? subUrlBase, disableSubUrlTracking, tooltip, etc.
There was a problem hiding this comment.
disableSubUrlTracking seems to be indeed missing when compared to the pre-#52161 version, even if not present in our TS type
export type LegacyAppSpec = Pick<
ChromeNavLink,
'title' | 'order' | 'icon' | 'euiIconType' | 'url' | 'linkToLastSubUrl' | 'hidden' | 'category'
> & { pluginId?: string; id?: string; listed?: boolean };However the other properties were just not present when generating the navlink from the legacy app... So I guess I should not add them, wdyt?
kibana/src/legacy/ui/ui_apps/ui_app.js
Lines 67 to 77 in 8c29802
There was a problem hiding this comment.
So I guess I should not add them, wdyt?
agree. probably we should clean up types as well
There was a problem hiding this comment.
I ended up by doing the opposite of what I suggested to be able to factorize the mapping method...
export type LegacyNavLinkSpec = Partial<ChromeNavLink>;
export type LegacyAppSpec = Partial<ChromeNavLink> & {
pluginId?: string;
listed?: boolean;
};PTAL, tell me if you think this is a risk.
There was a problem hiding this comment.
The typo in linkToLastSub instead of linkToLastSubUrl was actually countering the wrong false default value in the mapping function...
|
retest |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…lastic#57542) * properly use app id instead of pluginId to generate navlink * extract convertToNavLink, add more tests * use distinct mapping methods * fix linkToLastSubUrl default value * nits & doc
…lastic#57542) * properly use app id instead of pluginId to generate navlink * extract convertToNavLink, add more tests * use distinct mapping methods * fix linkToLastSubUrl default value * nits & doc
…apps (#57542) (#57672) * Use app id instead of pluginId to generate navlink from legacy apps (#57542) * properly use app id instead of pluginId to generate navlink * extract convertToNavLink, add more tests * use distinct mapping methods * fix linkToLastSubUrl default value * nits & doc * remove category, add disableSubUrlTracking * update doc
…apps (#57542) (#57670) * Use app id instead of pluginId to generate navlink from legacy apps (#57542) * properly use app id instead of pluginId to generate navlink * extract convertToNavLink, add more tests * use distinct mapping methods * fix linkToLastSubUrl default value * nits & doc * update generated doc
Summary
Fix #57470
Use the app id and not pluginId when generating navlinks from legacy app specs, as it was the case before #52161
Checklist
For maintainers