-
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
Bookmarkable modals #1841
Bookmarkable modals #1841
Conversation
Missing test should not covered by the review |
core/src/App.html
Outdated
const params = location.search | ||
? RoutingHelpers.parseParams(location.search.slice(1)) | ||
: {}; | ||
const prevModalPath = params[modalParamName]; |
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.
Shouldn't you check if the param is present in location.search? like...
if (!prevModalPath){
return;
}
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.
In this case there can or cannot be an existing modal. If we would return here, we would never append to the url.
core/src/services/routing.js
Outdated
// handle bookmarkable modal path | ||
const additionalModalPath = RoutingHelpers.getModalPathFromPath(); | ||
if (additionalModalPath) { | ||
const modalParams = RoutingHelpers.getModalParamsFromPath(); | ||
const { nodeObject } = await Navigation.extractDataFromPath(additionalModalPath); | ||
LuigiNavigation.openAsModal(additionalModalPath, nodeObject.openNodeInModal || modalParams); | ||
} | ||
|
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.
async handleRouteChange(path, component, iframeElement, config, withoutSync) function is getting pretty long and complex (it would be nice to refactor).
Could you create a new function:
async handleBookmarkableModalPath(){
const additionalModalPath = RoutingHelpers.getModalPathFromPath();
if (additionalModalPath) {
const modalParams = RoutingHelpers.getModalParamsFromPath();
const { nodeObject } = await Navigation.extractDataFromPath(additionalModalPath);
LuigiNavigation.openAsModal(additionalModalPath, nodeObject.openNodeInModal || modalParams);
}
}
// handle bookmarkable modal path | |
const additionalModalPath = RoutingHelpers.getModalPathFromPath(); | |
if (additionalModalPath) { | |
const modalParams = RoutingHelpers.getModalParamsFromPath(); | |
const { nodeObject } = await Navigation.extractDataFromPath(additionalModalPath); | |
LuigiNavigation.openAsModal(additionalModalPath, nodeObject.openNodeInModal || modalParams); | |
} | |
await this.handleBookmarkableModalPath(); |
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.
Yep, I have not taken time to refactor yet, wanted to get the things working first. I appreciate your thoughts 👍
I have updated the e2e test cases and fixed the implementation. One thing to mention: I have implemented a flexible "getQueryParam" and "getQueryParams" method in RoutingHelpers, since GenericHelpers.getUrlParams did not work properly. It might be an opportunity to consolidate other occurrences if this fits the same use case. Happy to have a talk about it too. Added Unit tests will come in the next days. |
230b479
to
49ea1da
Compare
Summery of the call with Markus: There is one tiny issue. When you open a modal from the left nav the url will not be generated. Markus will take a look and either it is a quick fix he will fix it in this PR or if not we will create a follow up ticket for that. |
…gi into 1772-bookmarkable-modal-mf
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.
Good job!!Looks good to me
…gi into 1772-bookmarkable-modal-mf * '1772-bookmarkable-modal-mf' of github.com:maxmarkus/luigi: Add warning if both virtualTree and children nodes are defined (SAP#1935) Documentation for luigi client angular support library (SAP#1845) Fix withoutSync behavior under hashrouting enabled SAP#1787 (SAP#1893)
…gi into 1772-bookmarkable-modal-mf * '1772-bookmarkable-modal-mf' of github.com:maxmarkus/luigi: SemiCollapse tooltip bug (SAP#1929)
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.
I see an error when attempting with the following configuration:
showModalPathInUrl = true;
modalPathParam = 'modal';
and then for a particular node:
openNodeInModal: true,
It works well with:
openNodeInModal: {title: "test"}
It just seems that for true value it still expects to find a title.
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.
Looks good 👍
Changes proposed in this pull request:
routing.showModalPathInUrl
androuting.modalPathParam
nodeParams
are workingTODO in this draft:
How to reproduce:
npm run simpledev
in corenpm start
in test/e2e-testapplicationcore/dev-tools/simple-app/luigi-config.js
http://localhost:4100/home/child-2?modal=%252Fhome%252Fchild%253F~foo%253Dbar&modalParams=%257B%2522title%2522%253A%2522Hello%2520Luigi%2522%257D
Related issue(s)
Resolves #1772