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

Add flag to opt out from sub url tracking #55672

Merged
merged 9 commits into from
Jan 28, 2020
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[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)

## ChromeNavLink.disableSubUrlTracking property

> Warning: This API is now obsolete.
>
>

A flag that tells legacy chrome to ignore the link when tracking sub-urls

<b>Signature:</b>

```typescript
readonly disableSubUrlTracking?: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ChromeNavLink
| [baseUrl](./kibana-plugin-public.chromenavlink.baseurl.md) | <code>string</code> | The base route used to open the root of an application. |
| [category](./kibana-plugin-public.chromenavlink.category.md) | <code>AppCategory</code> | The category the app lives in |
| [disabled](./kibana-plugin-public.chromenavlink.disabled.md) | <code>boolean</code> | Disables a link from being clickable. |
| [disableSubUrlTracking](./kibana-plugin-public.chromenavlink.disablesuburltracking.md) | <code>boolean</code> | A flag that tells legacy chrome to ignore the link when tracking sub-urls |
| [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. |
| [hidden](./kibana-plugin-public.chromenavlink.hidden.md) | <code>boolean</code> | Hides a link from the navigation. |
| [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. |
Expand Down
1 change: 1 addition & 0 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export interface LegacyApp extends AppBase {
appUrl: string;
subUrlBase?: string;
linkToLastSubUrl?: boolean;
disableSubUrlTracking?: boolean;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/core/public/chrome/nav_links/nav_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ export interface ChromeNavLink {
*/
readonly subUrlBase?: string;

/**
* A flag that tells legacy chrome to ignore the link when
* tracking sub-urls
*
* @internalRemarks
* This should be removed once legacy apps are gone.
*
* @deprecated
*/
readonly disableSubUrlTracking?: boolean;

/**
* Whether or not the subUrl feature should be enabled.
*
Expand Down
1 change: 1 addition & 0 deletions src/core/public/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class LegacyPlatformService {
subUrlBase: navLink.subUrlBase,
linkToLastSubUrl: navLink.linkToLastSubUrl,
category: navLink.category,
disableSubUrlTracking: navLink.disableSubUrlTracking,
})
);

Expand Down
2 changes: 2 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ export interface ChromeNavLink {
readonly category?: AppCategory;
// @deprecated
readonly disabled?: boolean;
// @deprecated
readonly disableSubUrlTracking?: boolean;
readonly euiIconType?: string;
readonly hidden?: boolean;
readonly icon?: string;
Expand Down
1 change: 1 addition & 0 deletions src/core/server/legacy/plugins/find_legacy_plugin_specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function getNavLinks(uiExports: LegacyUiExports, pluginSpecs: LegacyPluginSpec[]
order: typeof spec.order === 'number' ? spec.order : 0,
url: spec.url,
subUrlBase: spec.subUrlBase || spec.url,
disableSubUrlTracking: spec.disableSubUrlTracking,
icon: spec.icon,
euiIconType: spec.euiIconType,
linkToLastSub: 'linkToLastSubUrl' in spec ? spec.linkToLastSubUrl : false,
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/chrome/api/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function initChromeNavApi(chrome: any, internals: NavInternals) {
coreNavLinks
.getAll()
// Filter only legacy links
.filter(link => link.legacy)
.filter(link => link.legacy && !link.disableSubUrlTracking)
.forEach(link => {
const active = url.startsWith(link.subUrlBase!);
link = coreNavLinks.update(link.id, { active })!;
Expand Down
4 changes: 4 additions & 0 deletions src/legacy/ui/ui_apps/ui_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class UiApp {
euiIconType,
hidden,
linkToLastSubUrl,
disableSubUrlTracking,
listed,
category,
url = `/app/${id}`,
Expand All @@ -47,6 +48,7 @@ export class UiApp {
this._icon = icon;
this._euiIconType = euiIconType;
this._linkToLastSubUrl = linkToLastSubUrl;
this._disableSubUrlTracking = disableSubUrlTracking;
this._category = category;
this._hidden = hidden;
this._listed = listed;
Expand All @@ -70,6 +72,7 @@ export class UiApp {
euiIconType: this._euiIconType,
url: this._url,
linkToLastSubUrl: this._linkToLastSubUrl,
disableSubUrlTracking: this._disableSubUrlTracking,
category: this._category,
});
}
Expand Down Expand Up @@ -118,6 +121,7 @@ export class UiApp {
main: this._main,
navLink: this._navLink,
linkToLastSubUrl: this._linkToLastSubUrl,
disableSubUrlTracking: this._disableSubUrlTracking,
category: this._category,
};
}
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/ui_nav_links/__tests__/ui_nav_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('UiNavLink', () => {

// defaults
linkToLastSubUrl: true,
disableSubUrlTracking: undefined,
tooltip: '',
});
});
Expand Down
3 changes: 3 additions & 0 deletions src/legacy/ui/ui_nav_links/ui_nav_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class UiNavLink {
order = 0,
url,
subUrlBase,
disableSubUrlTracking,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll also need to add this to src/legacy/ui/ui_apps/ui_app.js which is also a source of navLinks

icon,
euiIconType,
linkToLastSubUrl = true,
Expand All @@ -39,6 +40,7 @@ export class UiNavLink {
this._order = order;
this._url = url;
this._subUrlBase = subUrlBase || url;
this._disableSubUrlTracking = disableSubUrlTracking;
this._icon = icon;
this._euiIconType = euiIconType;
this._linkToLastSubUrl = linkToLastSubUrl;
Expand All @@ -62,6 +64,7 @@ export class UiNavLink {
icon: this._icon,
euiIconType: this._euiIconType,
linkToLastSubUrl: this._linkToLastSubUrl,
disableSubUrlTracking: this._disableSubUrlTracking,
hidden: this._hidden,
disabled: this._disabled,
tooltip: this._tooltip,
Expand Down