Skip to content

Commit 60de534

Browse files
authored
[7.6] Use app id instead of pluginId to generate navlink from legacy 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
1 parent 3cafe10 commit 60de534

File tree

10 files changed

+450
-73
lines changed

10 files changed

+450
-73
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [ChromeNavLink](./kibana-plugin-public.chromenavlink.md) &gt; [disableSubUrlTracking](./kibana-plugin-public.chromenavlink.disablesuburltracking.md)
4+
5+
## ChromeNavLink.disableSubUrlTracking property
6+
7+
> Warning: This API is now obsolete.
8+
>
9+
>
10+
11+
A flag that tells legacy chrome to ignore the link when tracking sub-urls
12+
13+
<b>Signature:</b>
14+
15+
```typescript
16+
readonly disableSubUrlTracking?: boolean;
17+
```

docs/development/core/public/kibana-plugin-public.chromenavlink.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface ChromeNavLink
1818
| [active](./kibana-plugin-public.chromenavlink.active.md) | <code>boolean</code> | Indicates whether or not this app is currently on the screen. |
1919
| [baseUrl](./kibana-plugin-public.chromenavlink.baseurl.md) | <code>string</code> | The base route used to open the root of an application. |
2020
| [disabled](./kibana-plugin-public.chromenavlink.disabled.md) | <code>boolean</code> | Disables a link from being clickable. |
21+
| [disableSubUrlTracking](./kibana-plugin-public.chromenavlink.disablesuburltracking.md) | <code>boolean</code> | A flag that tells legacy chrome to ignore the link when tracking sub-urls |
2122
| [euiIconType](./kibana-plugin-public.chromenavlink.euiicontype.md) | <code>string</code> | A EUI iconType that will be used for the app's icon. This icon takes precendence over the <code>icon</code> property. |
2223
| [hidden](./kibana-plugin-public.chromenavlink.hidden.md) | <code>boolean</code> | Hides a link from the navigation. |
2324
| [icon](./kibana-plugin-public.chromenavlink.icon.md) | <code>string</code> | A URL to an image file used as an icon. Used as a fallback if <code>euiIconType</code> is not provided. |

src/core/public/chrome/nav_links/nav_link.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ export interface ChromeNavLink {
7272
*/
7373
readonly subUrlBase?: string;
7474

75+
/**
76+
* A flag that tells legacy chrome to ignore the link when
77+
* tracking sub-urls
78+
*
79+
* @internalRemarks
80+
* This should be removed once legacy apps are gone.
81+
*
82+
* @deprecated
83+
*/
84+
readonly disableSubUrlTracking?: boolean;
85+
7586
/**
7687
* Whether or not the subUrl feature should be enabled.
7788
*

src/core/public/public.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ export interface ChromeNavLink {
253253
readonly baseUrl: string;
254254
// @deprecated
255255
readonly disabled?: boolean;
256+
// @deprecated
257+
readonly disableSubUrlTracking?: boolean;
256258
readonly euiIconType?: string;
257259
readonly hidden?: boolean;
258260
readonly icon?: string;

src/core/server/legacy/plugins/__snapshots__/get_nav_links.test.ts.snap

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/server/legacy/plugins/find_legacy_plugin_specs.ts

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -30,69 +30,8 @@ import { collectUiExports as collectLegacyUiExports } from '../../../../legacy/u
3030

3131
import { LoggerFactory } from '../../logging';
3232
import { PackageInfo } from '../../config';
33-
34-
import {
35-
LegacyUiExports,
36-
LegacyNavLink,
37-
LegacyPluginSpec,
38-
LegacyPluginPack,
39-
LegacyConfig,
40-
} from '../types';
41-
42-
const REMOVE_FROM_ARRAY: LegacyNavLink[] = [];
43-
44-
function getUiAppsNavLinks({ uiAppSpecs = [] }: LegacyUiExports, pluginSpecs: LegacyPluginSpec[]) {
45-
return uiAppSpecs.flatMap(spec => {
46-
if (!spec) {
47-
return REMOVE_FROM_ARRAY;
48-
}
49-
50-
const id = spec.pluginId || spec.id;
51-
52-
if (!id) {
53-
throw new Error('Every app must specify an id');
54-
}
55-
56-
if (spec.pluginId && !pluginSpecs.some(plugin => plugin.getId() === spec.pluginId)) {
57-
throw new Error(`Unknown plugin id "${spec.pluginId}"`);
58-
}
59-
60-
const listed = typeof spec.listed === 'boolean' ? spec.listed : true;
61-
62-
if (spec.hidden || !listed) {
63-
return REMOVE_FROM_ARRAY;
64-
}
65-
66-
return {
67-
id,
68-
title: spec.title,
69-
order: typeof spec.order === 'number' ? spec.order : 0,
70-
icon: spec.icon,
71-
euiIconType: spec.euiIconType,
72-
url: spec.url || `/app/${id}`,
73-
linkToLastSubUrl: spec.linkToLastSubUrl,
74-
};
75-
});
76-
}
77-
78-
function getNavLinks(uiExports: LegacyUiExports, pluginSpecs: LegacyPluginSpec[]) {
79-
return (uiExports.navLinkSpecs || [])
80-
.map<LegacyNavLink>(spec => ({
81-
id: spec.id,
82-
title: spec.title,
83-
order: typeof spec.order === 'number' ? spec.order : 0,
84-
url: spec.url,
85-
subUrlBase: spec.subUrlBase || spec.url,
86-
icon: spec.icon,
87-
euiIconType: spec.euiIconType,
88-
linkToLastSub: 'linkToLastSubUrl' in spec ? spec.linkToLastSubUrl : false,
89-
hidden: 'hidden' in spec ? spec.hidden : false,
90-
disabled: 'disabled' in spec ? spec.disabled : false,
91-
tooltip: spec.tooltip || '',
92-
}))
93-
.concat(getUiAppsNavLinks(uiExports, pluginSpecs))
94-
.sort((a, b) => a.order - b.order);
95-
}
33+
import { LegacyPluginSpec, LegacyPluginPack, LegacyConfig } from '../types';
34+
import { getNavLinks } from './get_nav_links';
9635

9736
export async function findLegacyPluginSpecs(
9837
settings: unknown,

0 commit comments

Comments
 (0)