-
Notifications
You must be signed in to change notification settings - Fork 171
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 goBack support for normal navigation #595
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c172f62
Merge remote-tracking branch 'upstream/master'
maxmarkus c09690a
Merge remote-tracking branch 'upstream/master'
maxmarkus 76fa8db
Merge remote-tracking branch 'upstream/master'
maxmarkus 9c86254
Merge remote-tracking branch 'upstream/master'
maxmarkus 640e287
Merge remote-tracking branch 'upstream/master'
maxmarkus 2397ede
Merge remote-tracking branch 'upstream/master'
maxmarkus c052644
Merge remote-tracking branch 'upstream/master'
maxmarkus 37b1b60
Merge remote-tracking branch 'upstream/master'
maxmarkus 2b4d1b5
send doHistoryBack
maxmarkus f63bf45
history listener not required in client
maxmarkus 2d47924
e2e tets for goback
maxmarkus 895b84a
documented that goBackContext is only available when using preserved …
maxmarkus 1f147cb
added warning when using goBackContext if it not available
maxmarkus 20ed7dc
Merge branch 'master' into 265-goback-internal-routes
pekura bcfd55c
Merge branch 'master' into 265-goback-internal-routes
maxmarkus 35dcac4
Merge branch '265-goback-internal-routes' of github.com:maxmarkus/lui…
maxmarkus 5ef5da0
some iframe tets to make coverage happy
maxmarkus 4111db3
Merge branch 'master' into 265-goback-internal-routes
maxmarkus a2593c0
Merge branch '265-goback-internal-routes' of github.com:maxmarkus/lui…
maxmarkus f6e4255
built client docu
maxmarkus d471ec9
docu updates thanks to basia
maxmarkus 9945f6a
Apply suggestions from code review
maxmarkus 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -206,22 +206,20 @@ export class linkManager extends LuigiClientBase { | |||||
} | ||||||
|
||||||
/** | ||||||
* Discards the active view and navigates back to the last visited view (preserved view), if a preserved view was set before. | ||||||
* Discards the active view and navigates back to the last visited view. Works with preserved views, as well as classical browser back substitute. `goBackContext` is only available when using preserved views. | ||||||
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.
Suggested change
|
||||||
* @memberof linkManager | ||||||
* @param {any} goBackValue data that is passed in the `goBackContext` field to the last visited view | ||||||
* @param {any} goBackValue data that is passed in the `goBackContext` field to the last visited view, when using preserved views. | ||||||
maxmarkus marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
* @example | ||||||
* LuigiClient.linkManager().goBack({ foo: 'bar' }); | ||||||
* LuigiClient.linkManager().goBack(true); | ||||||
*/ | ||||||
goBack(goBackValue) { | ||||||
if (this.hasBack()) { | ||||||
window.parent.postMessage( | ||||||
{ | ||||||
msg: 'luigi.navigation.back', | ||||||
goBackContext: goBackValue && JSON.stringify(goBackValue) | ||||||
}, | ||||||
'*' | ||||||
); | ||||||
} | ||||||
window.parent.postMessage( | ||||||
{ | ||||||
msg: 'luigi.navigation.back', | ||||||
goBackContext: goBackValue && JSON.stringify(goBackValue) | ||||||
}, | ||||||
'*' | ||||||
); | ||||||
} | ||||||
} |
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
128 changes: 70 additions & 58 deletions
128
core/examples/luigi-sample-angular/e2e/tests/modal-microfrontend.spec.js
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 |
---|---|---|
@@ -1,71 +1,83 @@ | ||
describe('Modal Microfrontend', () => { | ||
let iframeBody; | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
cy.login('tets', 'tets'); | ||
|
||
let iframeBody; | ||
//wait for the iFrame to be loaded | ||
cy.get('iframe', { timeout: 1000 }).then(ifr => { | ||
iframeBody = ifr.contents().find('body'); | ||
}); | ||
}); | ||
|
||
describe('Behaviour when used in LinkManager', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
cy.login('tets', 'tets'); | ||
cy.goToLinkManagerMethods(iframeBody); | ||
}); | ||
|
||
//wait for the iFrame to be loaded | ||
cy.get('iframe', { timeout: 1000 }).then(ifr => { | ||
iframeBody = ifr.contents().find('body'); | ||
}); | ||
|
||
it(`doesn't change URL when opened`, () => { | ||
cy.expectPathToBe('/projects/pr2'); | ||
|
||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
cy.expectPathToBe('/projects/pr2'); | ||
}); | ||
|
||
describe('Behaviour when used in LinkManager', () => { | ||
beforeEach(() => { | ||
cy.goToLinkManagerMethods(iframeBody); | ||
}); | ||
|
||
it(`doesn't change URL when opened`, () => { | ||
cy.expectPathToBe('/projects/pr2'); | ||
|
||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
cy.expectPathToBe('/projects/pr2'); | ||
}); | ||
|
||
it(`can be closed by Close Button`, () => { | ||
|
||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
cy.wrap(iframeBody) | ||
.get('[data-e2e=modal-mf]') | ||
.should('be.visible'); | ||
|
||
cy.wrap(iframeBody) | ||
.get('[data-e2e=modal-mf] [aria-label=close]') | ||
.click(); | ||
|
||
cy.wrap(iframeBody) | ||
.get('[data-e2e=modal-mf]') | ||
.should('not.be.visible'); | ||
}); | ||
it(`can be closed by Close Button`, () => { | ||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
it(`sets proper URL inside iframe`, () => { | ||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
cy.wrap(iframeBody) | ||
.get('[data-e2e=modal-mf]') | ||
.should('be.visible'); | ||
|
||
cy.get('[data-e2e=modal-mf] iframe').then(ifr => { | ||
expect(ifr.attr('src')).to.equal('/sampleapp.html#/settings'); | ||
}); | ||
}); | ||
cy.wrap(iframeBody) | ||
.get('[data-e2e=modal-mf] [aria-label=close]') | ||
.click(); | ||
|
||
it(`has the size set directly`, () => { | ||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
cy.wrap(iframeBody) | ||
.get('[data-e2e=modal-mf]') | ||
.should('not.be.visible'); | ||
}); | ||
|
||
it(`sets proper URL inside iframe`, () => { | ||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
cy.get('[data-e2e=modal-mf] iframe').then(ifr => { | ||
expect(ifr.attr('src')).to.equal('/sampleapp.html#/settings'); | ||
}); | ||
}); | ||
|
||
it(`has the size set directly`, () => { | ||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
cy.get('[data-e2e=modal-mf]').then(modal => { | ||
expect(modal.attr('style')).to.contain('width:'); | ||
expect(modal.attr('style')).to.contain('height:'); | ||
}); | ||
cy.get('[data-e2e=modal-mf]').then(modal => { | ||
expect(modal.attr('style')).to.contain('width:'); | ||
expect(modal.attr('style')).to.contain('height:'); | ||
}); | ||
}); | ||
|
||
it(`go back closes the modal`, () => { | ||
cy.wrap(iframeBody) | ||
.contains('rendered in a modal') | ||
.click(); | ||
|
||
cy.get('[data-e2e=modal-mf] iframe') | ||
.iframe() | ||
.then(modal => { | ||
cy.wrap(modal) | ||
.contains('Go back') | ||
.click(); | ||
}); | ||
|
||
cy.expectPathToBe('/projects/pr2'); | ||
}); | ||
}); | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -192,11 +192,11 @@ Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/ | |||||
|
||||||
### goBack | ||||||
|
||||||
Discards the active view and navigates back to the last visited view (preserved view), if a preserved view was set before. | ||||||
Discards the active view and navigates back to the last visited view. Works with preserved views, as well as classical browser back substitute. `goBackContext` is only available when using preserved views. | ||||||
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.
Suggested change
|
||||||
|
||||||
#### Parameters | ||||||
|
||||||
- `goBackValue` **any** data that is passed in the `goBackContext` field to the last visited view | ||||||
- `goBackValue` **any** data that is passed in the `goBackContext` field to the last visited view, when using preserved views. | ||||||
maxmarkus marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
#### Examples | ||||||
|
||||||
|
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.