-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use app id instead of pluginId to generate navlink from legacy apps #57542
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
this._navLink = new UiNavLink({ | |
id: this._id, | |
title: this._title, | |
order: this._order, | |
icon: this._icon, | |
euiIconType: this._euiIconType, | |
url: this._url, | |
linkToLastSubUrl: this._linkToLastSubUrl, | |
disableSubUrlTracking: this._disableSubUrlTracking, | |
category: this._category, | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('initializes the linkToLastSubUrl property to true by default', () => { |
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