-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Switch to core application service #63443
Changes from 206 commits
ae8c4df
2ce021c
b36a750
2a5e63f
03143d7
325de83
b73d9aa
dbd1946
aa27888
a7edd02
38c8d67
4daf88c
d1b51a0
215806f
0887558
00f29d8
004e312
cb9fa1b
941d82a
0f1eddd
5f1407e
39387b1
dde7972
d2c1ee6
420b22b
7e837cf
fc66957
d503069
5cd1d59
6e76950
fd861e7
3911e57
a7cb184
30ec2a4
02efdae
57f8338
99197ad
e87d994
12d8176
1eadee8
f6fcdd6
c3cefe4
8f331f3
a861935
2a038b2
68867d9
05a5e9e
ebbb1be
cdd25d2
d37f000
62ced26
9c0f47e
eefb960
cf58cc1
c1970bd
74c1708
efda5b3
55f77fb
93983b5
c2bc5df
7b54319
afacf40
ae26cff
ca5f1b3
c59d718
9f8293c
096eed9
d66eb1a
08fa8ab
124f9a3
cfa58b1
6a82d9c
835cf4a
9b12ef6
ab99f53
1b15e83
1e1c59d
071ee2e
b4fa07d
ee97f24
3ae2f6e
a5a3554
52538ae
08d81af
337c9b5
5122bbb
7e39626
34bf966
1cf393c
a3080f2
81fdcaa
e473744
580e5b8
6e016f7
fe40d88
47e6f7a
1cf6e94
e9d942d
7387782
9a171e8
e6ab5de
de9006b
200fdf9
47e7751
2cd6cc4
b4dbdac
e9004ee
1c59432
108ac96
c29a44a
d538add
7a0822b
6ad680e
79a9ba5
74f44b2
6ad81ea
dfa1cf2
3189e7b
cee590e
e74be94
db32134
0abd002
1f50853
c43cdeb
62115a1
484f9f9
784e268
e8e5131
eac477b
df39caf
855bab0
ff5991c
7757c99
07d00de
7f3c1f0
c346e7f
f00d980
8fb0107
e7f0c88
18edc73
6bcf7dd
630c259
0c62578
a4a6fea
79d4c88
e65d74b
220aca6
2b95e23
30253a3
b85e80a
3eca079
e9620fe
2ef124c
70262f4
741bbe7
580701b
9cee8f2
8ec3ee2
fd60629
7e4b19b
de9f491
e84b54e
2873ff0
23cc318
ab2287b
2487db4
0e55642
65c4a81
a1f981c
88b1743
ad8c4d8
ac7387e
a1d5b4a
1de8a10
e6b8f12
ea85056
9465eb5
a1a5563
4fdb8fd
3dcf518
f8ca0ae
481c401
e5d4a34
4af2bd2
f8f3768
9f1824e
bc366f1
f8f0d55
d7f1dac
78e7bc4
2f3d8d5
5708d88
ea4f1a5
4e9a0bb
939c963
4efb7e7
3c6cb34
26f1614
c852079
ee8367a
fd0a4fc
23fefbd
cc3bd45
7c602d1
e5a1744
d4e6b9a
a395d9e
579ee9f
1547f7b
a77ca6d
bc83e30
c898b47
d55fb32
3ca3f12
15be0e6
7e960cf
af5b294
6f6a695
e481dc1
0f581df
49157fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ function findClosestAnchor(element: HTMLElement): HTMLAnchorElement | void { | |
function onClick( | ||
event: React.MouseEvent<HTMLAnchorElement>, | ||
forceNavigation: boolean, | ||
navLinks: NavLink[] | ||
navLinks: NavLink[], | ||
navigateToApp: (appId: string) => void | ||
) { | ||
const anchor = findClosestAnchor((event as any).nativeEvent.target); | ||
if (!anchor) { | ||
|
@@ -54,47 +55,47 @@ function onClick( | |
return; | ||
} | ||
|
||
if ( | ||
!forceNavigation || | ||
event.isDefaultPrevented() || | ||
event.altKey || | ||
event.metaKey || | ||
event.ctrlKey | ||
) { | ||
if (event.isDefaultPrevented() || event.altKey || event.metaKey || event.ctrlKey) { | ||
return; | ||
} | ||
|
||
const toParsed = Url.parse(anchor.href); | ||
const fromParsed = Url.parse(document.location.href); | ||
const sameProto = toParsed.protocol === fromParsed.protocol; | ||
const sameHost = toParsed.host === fromParsed.host; | ||
const samePath = toParsed.path === fromParsed.path; | ||
if (forceNavigation) { | ||
const toParsed = Url.parse(anchor.href); | ||
const fromParsed = Url.parse(document.location.href); | ||
const sameProto = toParsed.protocol === fromParsed.protocol; | ||
const sameHost = toParsed.host === fromParsed.host; | ||
const samePath = toParsed.path === fromParsed.path; | ||
|
||
if (sameProto && sameHost && samePath) { | ||
if (toParsed.hash) { | ||
document.location.reload(); | ||
} | ||
if (sameProto && sameHost && samePath) { | ||
if (toParsed.hash) { | ||
document.location.reload(); | ||
} | ||
|
||
// event.preventDefault() keeps the browser from seeing the new url as an update | ||
// and even setting window.location does not mimic that behavior, so instead | ||
// we use stopPropagation() to prevent angular from seeing the click and | ||
// starting a digest cycle/attempting to handle it in the router. | ||
event.stopPropagation(); | ||
// event.preventDefault() keeps the browser from seeing the new url as an update | ||
// and even setting window.location does not mimic that behavior, so instead | ||
// we use stopPropagation() to prevent angular from seeing the click and | ||
// starting a digest cycle/attempting to handle it in the router. | ||
event.stopPropagation(); | ||
} | ||
} else { | ||
navigateToApp('home'); | ||
event.preventDefault(); | ||
Comment on lines
+80
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The (probably over-engineered and unused) logic in the |
||
} | ||
} | ||
|
||
interface Props { | ||
href: string; | ||
navLinks: NavLink[]; | ||
forceNavigation: boolean; | ||
navigateToApp: (appId: string) => void; | ||
} | ||
|
||
export function HeaderLogo({ href, forceNavigation, navLinks }: Props) { | ||
export function HeaderLogo({ href, forceNavigation, navLinks, navigateToApp }: Props) { | ||
return ( | ||
<EuiHeaderLogo | ||
data-test-subj="logo" | ||
iconType="logoElastic" | ||
onClick={e => onClick(e, forceNavigation, navLinks)} | ||
onClick={e => onClick(e, forceNavigation, navLinks, navigateToApp)} | ||
href={href} | ||
aria-label={i18n.translate('core.ui.chrome.headerGlobalNav.goHomePageIconAriaLabel', { | ||
defaultMessage: 'Go to home page', | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,9 @@ export class LocalApplicationService { | |
template: '<span></span>', | ||
controller($location: ILocationService) { | ||
const newPath = forwardDefinition.rewritePath($location.url()); | ||
npStart.core.application.navigateToApp(forwardDefinition.newAppId, { path: newPath }); | ||
window.location.replace( | ||
npStart.core.http.basePath.prepend(`/app/${forwardDefinition.newAppId}/${newPath}`) | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you give me some context on this change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the code path redirecting the old URLs to the new ones (e.g.
Edit: I remember now why this was necessary - |
||
}, | ||
}); | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: proto+host can be replaced by
origin