Skip to content
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

Merged
merged 7 commits into from
Feb 14, 2020

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Feb 13, 2020

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

@pgayvallet pgayvallet added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:fix Feature:New Platform v8.0.0 v7.7.0 v7.6.1 labels Feb 13, 2020
@pgayvallet pgayvallet requested a review from a team as a code owner February 13, 2020 09:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@pgayvallet
Copy link
Contributor Author

retest

@sergibondarenko
Copy link

@pgayvallet will the fix be backported to 7.6.0? I don't see v7.6.0 label

@pgayvallet
Copy link
Contributor Author

pgayvallet commented Feb 13, 2020

@sergibondarenko The 7.6.0 release is already out. This will lands in 7.6.1, which is due for around end of feb.

throw new Error('Every app must specify an id');
}

if (spec.pluginId && !pluginSpecs.some(plugin => plugin.getId() === spec.pluginId)) {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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?

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,
});

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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...

@pgayvallet
Copy link
Contributor Author

retest

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pgayvallet pgayvallet merged commit f87053e into elastic:master Feb 14, 2020
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Feb 14, 2020
…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
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Feb 14, 2020
…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
pgayvallet added a commit that referenced this pull request Feb 14, 2020
…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
pgayvallet added a commit that referenced this pull request Feb 14, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:fix Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.6.1 v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple apps don't work anymore
5 participants