-
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 replace
option to navigateToApp
API
#68700
add replace
option to navigateToApp
API
#68700
Conversation
it('use `history.replace` instead of `history.push`', async () => { | ||
service.setup(setupDeps); | ||
|
||
const { navigateToApp } = await service.start(startDeps); | ||
|
||
await navigateToApp('myTestApp', { replace: true }); |
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.
Only reproduced/added a subset of the navigateToApp
test suite, as the suite is big and as it's internally using the same logic.
export interface NavigateToAppOptions { | ||
/** | ||
* optional path inside application to deep link to. | ||
* If undefined, will use {@link AppBase.defaultPath | the app's default path}` as default. |
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.
Extracted the options type, as the inline definition was starting to be too big imho.
/** | ||
* if true, will not create a new history entry when navigating (using `replace` instead of `push`) | ||
* | ||
* @remarks | ||
* This option not be used when navigating from and/or to legacy applications. | ||
*/ | ||
replace?: boolean; |
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.
@flash1293 as discussed on slack, I only implemented this option for KP apps. (KP to KP navigation). Can you confirm that it's alright?
navigateToApp(appId: string, options?: { path?: string; state?: any }): Promise<void>; | ||
navigateToApp(appId: string, options?: NavigateToAppOptions): Promise<void>; |
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.
Should I also add the option to navigateToUrl
?
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 might need to do it for the sake of consistency. However, we can wait until someone requests this functionality.
Pinging @elastic/kibana-platform (Team:Platform) |
src/core/public/application/types.ts
Outdated
/** | ||
* optional state to forward to the application | ||
*/ | ||
state?: any; |
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: shouldn't it be unknown
?
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.
unknown
probably makes more sense. Can change that in this PR, that should be quite small.
navigateToApp(appId: string, options?: { path?: string; state?: any }): Promise<void>; | ||
navigateToApp(appId: string, options?: NavigateToAppOptions): Promise<void>; |
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 might need to do it for the sake of consistency. However, we can wait until someone requests this functionality.
@@ -924,6 +924,63 @@ describe('#start()', () => { | |||
await navigateToApp('baseApp:legacyApp1'); | |||
expect(setupDeps.redirectTo).toHaveBeenCalledWith('/test/app/baseApp'); | |||
}); | |||
|
|||
describe('when `replace` option is true', () => { |
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.
optional: we could add a test with replace: false
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* add `replace` option to `navigateToApp` * use `unknown` type for state * add test when `replace` is false
Summary
Fix #68527
Add a
replace
option to thenavigateToApp
application API to usehistory.replace
instead ofhistory.push
Checklist