-
Notifications
You must be signed in to change notification settings - Fork 236
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
🐛 Fix: 'cancel' button redirects to console instead of portal #387
base: develop
Are you sure you want to change the base?
Conversation
// Try to close the window | ||
window.close(); | ||
|
||
if(window.history.length > 1) { |
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.
window.history.length
greater than 1 means no history? Seems counter intuitive. Isn't it equals 0?
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.
Absolutely right, should have been == 1 (it's always at least 1 = current location)
var regexPortal = new RegExp('(pages\\/exec\\.php)(.*?)(\\?exec_module=itop-portal-base&exec_page=index\\.php&portal_id=.*?)(&|$)'); | ||
var aRegexMatch = window.location.href.match(regexPortal); | ||
|
||
if(aRegexMatch !== null) { | ||
|
||
sHomepageUrl += aRegexMatch[1] + aRegexMatch[3]; | ||
|
||
} |
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'm not sure hacking the URL through the regex is the best approach here. To me it's more like the this.options.base_url
isn't set properly in the first place. It should be set with app['combodo.portal.base.absolute_url']
in datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig
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.
True, also some customers might have different path e.g. set up.
For example they use another portal base or portal_id is not the third argument or the portal url is rewritten..
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.
True, but I think it will be a minority? (Perhaps you guys have a better view on that).
It addresses the most common implementation. About the order of arguments: I could rewrite it like that, but I'm not sure if there's a different order somewhere in the native implementation?
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.
Anyway, is the RegEx needed? The filename (portal_form_handler.js
) kind of suggests we are always in the portal?
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 explained the fix as we would accept it in the first message :)
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.
It definitely needs the portal ID parameter. The other parts I added to be more certain of where it was used and to re-use in the final URL
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.
@Molkobain so I should just change this line to use app['combodo.portal.base.absolute_url']
instead in the create object Twig template?
base_url: "{{ app['combodo.absolute_url'] }}",
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 :)
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.
Alright, I updated the PR to be a mix of @Molkobain's suggestion and also just some basic 'go back' logic.
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.
Thanks, that new behavior will need to be tested / validated. We'll see that during next functional review
5bd1860
to
8a36c42
Compare
I'm wondering if this now also messes up when the form was created by going to the services browser. As if I do that, clicking cancel on the modal, the modal is closed. If I make the form open as a new page by right clicking on the link, It just closes the window by clicking on cancel (Safari & FF 102) So in this scenario, everything works as expected. |
8a36c42
to
3318570
Compare
3318570
to
2b3f1ea
Compare
datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js
Outdated
Show resolved
Hide resolved
datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js
Outdated
Show resolved
Hide resolved
datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js
Outdated
Show resolved
Hide resolved
…andler.js Co-authored-by: Molkobain <[email protected]>
…andler.js Co-authored-by: Molkobain <[email protected]>
Accepted during technical review. |
Discussed during functional review:
So long story short, revert the changes on the JS file and the PR will be good to merge :) |
Thanks for the feedback! Well, it doesn't make sense the page would be "closed" at some point. Image this scenario:
Isn't the current logic only based on the assumption that the above URL is shown in a modal dialog (while this could be much more versatile, I'm using it outside a modal)? |
Before:
After PR: user with console permissions should stay in the portal. Either a simple 'go back 1 page' is executed, or the user is redirected to the portal's home page.