-
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
Add application.navigateToUrl
core API
#67110
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0f13ee5
implement `navigateToUrl` core API
pgayvallet 07b955d
Merge remote-tracking branch 'upstream/master' into kbn-xxx-navigateT…
pgayvallet 365d00b
Merge remote-tracking branch 'upstream/master' into kbn-xxx-navigateT…
pgayvallet 94c5da4
fix lint
pgayvallet 89446c7
review comments
pgayvallet 4518461
Merge remote-tracking branch 'upstream/master' into kbn-xxx-navigateT…
pgayvallet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...lopment/core/public/kibana-plugin-core-public.applicationstart.navigatetourl.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ApplicationStart](./kibana-plugin-core-public.applicationstart.md) > [navigateToUrl](./kibana-plugin-core-public.applicationstart.navigatetourl.md) | ||
|
||
## ApplicationStart.navigateToUrl() method | ||
|
||
Navigate to given url, which can either be an absolute url or a relative path, in a SPA friendly way when possible. | ||
|
||
If all these criteria are true for the given url: - (only for absolute URLs) The origin of the URL matches the origin of the browser's current location - The pathname of the URL starts with the current basePath (eg. /mybasepath/s/my-space) - The pathname segment after the basePath matches any known application route (eg. /app/<id>/ or any application's `appRoute` configuration) | ||
|
||
Then a SPA navigation will be performed using `navigateToApp` using the corresponding application and path. Otherwise, fallback to a full page reload to navigate to the url using `window.location.assign` | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
navigateToUrl(url: string): Promise<void>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| url | <code>string</code> | an absolute url, or a relative path, to navigate to. | | ||
|
||
<b>Returns:</b> | ||
|
||
`Promise<void>` | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
// current url: `https://kibana:8080/base-path/s/my-space/app/dashboard` | ||
|
||
// will call `application.navigateToApp('discover', { path: '/some-path?foo=bar'})` | ||
application.navigateToUrl('https://kibana:8080/base-path/s/my-space/app/discover/some-path?foo=bar') | ||
application.navigateToUrl('/base-path/s/my-space/app/discover/some-path?foo=bar') | ||
|
||
// will perform a full page reload using `window.location.assign` | ||
application.navigateToUrl('https://elsewhere:8080/base-path/s/my-space/app/discover/some-path') // origin does not match | ||
application.navigateToUrl('/app/discover/some-path') // does not include the current basePath | ||
application.navigateToUrl('/base-path/s/my-space/app/unknown-app/some-path') // unknown application | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not use a real call? The logic there is rather simple.
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.
We could remove the mock and perform a real call but as
parseAppUrl
is heavily tested in its own suite, I think current approach is slightly better in term of testing isolation.