Skip to content

Use app id instead of pluginId to generate navlink from legacy apps#57542

Merged
pgayvallet merged 7 commits intoelastic:masterfrom
pgayvallet:kbn-57470-fix-legacy-multi-apps
Feb 14, 2020
Merged

Use app id instead of pluginId to generate navlink from legacy apps#57542
pgayvallet merged 7 commits intoelastic:masterfrom
pgayvallet:kbn-57470-fix-legacy-multi-apps

Conversation

@pgayvallet
Copy link
Copy Markdown
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 Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// 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
Copy Markdown
Contributor

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

@pgayvallet
Copy link
Copy Markdown
Contributor Author

retest

@sergibondarenko
Copy link
Copy Markdown

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

@pgayvallet
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

retest

@kibanamachine
Copy link
Copy Markdown
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 Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// 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