Skip to content

Commit ef2c5ef

Browse files
authored
Switch to core application service (#63443) (#66353)
1 parent 6ec9af5 commit ef2c5ef

File tree

339 files changed

+2239
-1706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

339 files changed

+2239
-1706
lines changed

docs/api/features.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The API returns the following:
2929
"id": "discover",
3030
"name": "Discover",
3131
"icon": "discoverApp",
32-
"navLinkId": "kibana:discover",
32+
"navLinkId": "discover",
3333
"app": [
3434
"kibana"
3535
],
@@ -74,7 +74,7 @@ The API returns the following:
7474
"id": "visualize",
7575
"name": "Visualize",
7676
"icon": "visualizeApp",
77-
"navLinkId": "kibana:visualize",
77+
"navLinkId": "visualize",
7878
"app": [
7979
"kibana"
8080
],
@@ -121,7 +121,7 @@ The API returns the following:
121121
"id": "dashboard",
122122
"name": "Dashboard",
123123
"icon": "dashboardApp",
124-
"navLinkId": "kibana:dashboard",
124+
"navLinkId": "dashboards",
125125
"app": [
126126
"kibana"
127127
],
@@ -173,7 +173,7 @@ The API returns the following:
173173
"id": "dev_tools",
174174
"name": "Dev Tools",
175175
"icon": "devToolsApp",
176-
"navLinkId": "kibana:dev_tools",
176+
"navLinkId": "dev_tools",
177177
"app": [
178178
"kibana"
179179
],

docs/developer/plugin/development-plugin-feature-registration.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ init(server) {
153153
defaultMessage: 'Dev Tools',
154154
}),
155155
icon: 'devToolsApp',
156-
navLinkId: 'kibana:dev_tools',
156+
navLinkId: 'dev_tools',
157157
app: ['kibana'],
158158
catalogue: ['console', 'searchprofiler', 'grokdebugger'],
159159
privileges: {
@@ -216,7 +216,7 @@ init(server) {
216216
}),
217217
order: 100,
218218
icon: 'discoverApp',
219-
navLinkId: 'kibana:discover',
219+
navLinkId: 'discover',
220220
app: ['kibana'],
221221
catalogue: ['discover'],
222222
privileges: {

docs/user/dashboard.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ to view an embedded dashboard.
174174
* Generate a PNG report
175175

176176
TIP: To create a link to a dashboard by title, use: +
177-
`${domain}/${basepath?}/app/kibana#/dashboards?title=${yourdashboardtitle}`
177+
`${domain}/${basepath?}/app/dashboards#/list?title=${yourdashboardtitle}`
178178

179179
TIP: When sharing a link to a dashboard snapshot, use the *Short URL*. Snapshot
180180
URLs are long and can be problematic for Internet Explorer and other

src/core/public/chrome/chrome_service.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class ChromeService {
192192
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
193193
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
194194
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
195-
homeHref={http.basePath.prepend('/app/kibana#/home')}
195+
homeHref={http.basePath.prepend('/app/home')}
196196
isVisible$={this.isVisible$}
197197
kibanaVersion={injectedMetadata.getKibanaVersion()}
198198
legacyMode={injectedMetadata.getLegacyMode()}

src/core/public/chrome/ui/header/__snapshots__/collapsible_nav.test.tsx.snap

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

src/core/public/chrome/ui/header/collapsible_nav.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function mockProps() {
6363
storage: new StubBrowserStorage(),
6464
onIsOpenUpdate: () => {},
6565
onIsLockedUpdate: () => {},
66+
navigateToApp: () => {},
6667
};
6768
}
6869

src/core/public/chrome/ui/header/collapsible_nav.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ interface Props {
7878
storage?: Storage;
7979
onIsLockedUpdate: OnIsLockedUpdate;
8080
onIsOpenUpdate: (isOpen?: boolean) => void;
81+
navigateToApp: (appId: string) => void;
8182
}
8283

8384
export function CollapsibleNav({
@@ -89,6 +90,7 @@ export function CollapsibleNav({
8990
onIsOpenUpdate,
9091
homeHref,
9192
id,
93+
navigateToApp,
9294
storage = window.localStorage,
9395
}: Props) {
9496
const lockRef = useRef<HTMLButtonElement>(null);
@@ -124,7 +126,19 @@ export function CollapsibleNav({
124126
label: 'Home',
125127
iconType: 'home',
126128
href: homeHref,
127-
onClick: () => onIsOpenUpdate(false),
129+
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
130+
onIsOpenUpdate(false);
131+
if (
132+
event.isDefaultPrevented() ||
133+
event.altKey ||
134+
event.metaKey ||
135+
event.ctrlKey
136+
) {
137+
return;
138+
}
139+
event.preventDefault();
140+
navigateToApp('home');
141+
},
128142
},
129143
]}
130144
maxWidth="none"

src/core/public/chrome/ui/header/header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export class Header extends Component<HeaderProps, State> {
247247
href={this.props.homeHref}
248248
forceNavigation={this.state.forceNavigation}
249249
navLinks={navLinks}
250+
navigateToApp={this.props.application.navigateToApp}
250251
/>
251252
</EuiHeaderSectionItem>
252253

@@ -287,6 +288,7 @@ export class Header extends Component<HeaderProps, State> {
287288
this.toggleCollapsibleNavRef.current.focus();
288289
}
289290
}}
291+
navigateToApp={this.props.application.navigateToApp}
290292
/>
291293
) : (
292294
// TODO #64541

src/core/public/chrome/ui/header/header_logo.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function findClosestAnchor(element: HTMLElement): HTMLAnchorElement | void {
4141
function onClick(
4242
event: React.MouseEvent<HTMLAnchorElement>,
4343
forceNavigation: boolean,
44-
navLinks: NavLink[]
44+
navLinks: NavLink[],
45+
navigateToApp: (appId: string) => void
4546
) {
4647
const anchor = findClosestAnchor((event as any).nativeEvent.target);
4748
if (!anchor) {
@@ -54,47 +55,47 @@ function onClick(
5455
return;
5556
}
5657

57-
if (
58-
!forceNavigation ||
59-
event.isDefaultPrevented() ||
60-
event.altKey ||
61-
event.metaKey ||
62-
event.ctrlKey
63-
) {
58+
if (event.isDefaultPrevented() || event.altKey || event.metaKey || event.ctrlKey) {
6459
return;
6560
}
6661

67-
const toParsed = Url.parse(anchor.href);
68-
const fromParsed = Url.parse(document.location.href);
69-
const sameProto = toParsed.protocol === fromParsed.protocol;
70-
const sameHost = toParsed.host === fromParsed.host;
71-
const samePath = toParsed.path === fromParsed.path;
62+
if (forceNavigation) {
63+
const toParsed = Url.parse(anchor.href);
64+
const fromParsed = Url.parse(document.location.href);
65+
const sameProto = toParsed.protocol === fromParsed.protocol;
66+
const sameHost = toParsed.host === fromParsed.host;
67+
const samePath = toParsed.path === fromParsed.path;
7268

73-
if (sameProto && sameHost && samePath) {
74-
if (toParsed.hash) {
75-
document.location.reload();
76-
}
69+
if (sameProto && sameHost && samePath) {
70+
if (toParsed.hash) {
71+
document.location.reload();
72+
}
7773

78-
// event.preventDefault() keeps the browser from seeing the new url as an update
79-
// and even setting window.location does not mimic that behavior, so instead
80-
// we use stopPropagation() to prevent angular from seeing the click and
81-
// starting a digest cycle/attempting to handle it in the router.
82-
event.stopPropagation();
74+
// event.preventDefault() keeps the browser from seeing the new url as an update
75+
// and even setting window.location does not mimic that behavior, so instead
76+
// we use stopPropagation() to prevent angular from seeing the click and
77+
// starting a digest cycle/attempting to handle it in the router.
78+
event.stopPropagation();
79+
}
80+
} else {
81+
navigateToApp('home');
82+
event.preventDefault();
8383
}
8484
}
8585

8686
interface Props {
8787
href: string;
8888
navLinks: NavLink[];
8989
forceNavigation: boolean;
90+
navigateToApp: (appId: string) => void;
9091
}
9192

92-
export function HeaderLogo({ href, forceNavigation, navLinks }: Props) {
93+
export function HeaderLogo({ href, forceNavigation, navLinks, navigateToApp }: Props) {
9394
return (
9495
<EuiHeaderLogo
9596
data-test-subj="logo"
9697
iconType="logoElastic"
97-
onClick={e => onClick(e, forceNavigation, navLinks)}
98+
onClick={e => onClick(e, forceNavigation, navLinks, navigateToApp)}
9899
href={href}
99100
aria-label={i18n.translate('core.ui.chrome.headerGlobalNav.goHomePageIconAriaLabel', {
100101
defaultMessage: 'Go to home page',

src/core/server/core_app/integration_tests/default_route_provider_config.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('default route provider', () => {
4949

5050
expect(status).toEqual(302);
5151
expect(header).toMatchObject({
52-
location: '/hello/app/kibana',
52+
location: '/hello/app/home',
5353
});
5454
});
5555

@@ -71,7 +71,7 @@ describe('default route provider', () => {
7171
const { status, header } = await kbnTestServer.request.get(root, '/');
7272
expect(status).toEqual(302);
7373
expect(header).toMatchObject({
74-
location: '/hello/app/kibana',
74+
location: '/hello/app/home',
7575
});
7676
});
7777

0 commit comments

Comments
 (0)