Skip to content
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

Use $location.search to store & change currently viewed page in UI instead of stead of $location.path #8805

Merged
merged 6 commits into from Sep 22, 2015

Conversation

diosmosis
Copy link
Member

As title. Includes backwards compatibility for old URLs that use #/....

When using $location.path(), angular will decode the entire path before setting/getting, eventually resulting in the bug that occurs in #8776.

Please test extensively before merging.

CC @tsteur I remember you saying angular search didn't work in some cases, if you remember why, could you take a look?

Fixes #8776

@diosmosis diosmosis added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Sep 16, 2015
@diosmosis diosmosis added this to the 2.15.0 milestone Sep 16, 2015
@diosmosis diosmosis changed the title Use $.search to store & change currently viewed page in UI instead of stead of $location.path Use $location.search to store & change currently viewed page in UI instead of stead of $location.path Sep 17, 2015
@mattab
Copy link
Member

mattab commented Sep 18, 2015

@diosmosis the PR fixes the issue 👍

can you please add a UI test for this use case? UI test for Apply Segment and then click Row Evolution, and another one Apply segment and then click Visitor profile.

@sgiehl
Copy link
Member

sgiehl commented Sep 18, 2015

Maybe that also fixes #8323

@diosmosis
Copy link
Member Author

@mattab I don't know what you mean by 'open visitor profile'. I am going to assume you mean the segmented visitor log.

@diosmosis
Copy link
Member Author

@mattab Added UI tests.

…stead of $location.path. Includes backwards compatibility for old URLs that use #/...
@tsteur
Copy link
Member

tsteur commented Sep 21, 2015

See https://github.com/piwik/piwik/blob/3.0/plugins/CoreHome/angularjs/common/services/piwik-url.js#L38 ($location.search() returns empty when query params are not preceded by hash meaning when there is no /?... in the URL) and https://github.com/piwik/piwik/blob/3.0/plugins/CoreHome/angularjs/common/services/piwik-url.js#L46 use last one. Eg when having period=day&period=year angular would otherwise return ['day', 'year'] instead of 'year' which causes tests to fail (or the application doesn't work correctly anymore)

@tsteur
Copy link
Member

tsteur commented Sep 21, 2015

Some UI tests are failing see http://builds-artifacts.piwik.org/piwik/piwik/8776_angular_query/15503/ possibly due to the different behaviour of $location.search as explained earlier

@diosmosis
Copy link
Member Author

Some UI tests are failing see http://builds-artifacts.piwik.org/piwik/piwik/8776_angular_query/15503/ possibly due to the different behaviour of $location.search as explained earlier

I just fixed some of these. After about 3.5 hours of debugging :) I'll look into the other issues you mentioned.

@tsteur
Copy link
Member

tsteur commented Sep 21, 2015

I think it took me more than 3.5 hours :) (when I worked on Page layout refactoring for 3.0)

@diosmosis
Copy link
Member Author

I think it took me more than 3.5 hours :)

Well it definitely felt longer ;)

@diosmosis
Copy link
Member Author

$location.search() returns empty when query params are not preceded by hash meaning when there is no /?... in the URL

I don't think this will be an issue for this PR since the history service is only used to change the fragment URL and does not read the URL except when initializing.

use last one. Eg when having period=day&period=year angular would otherwise return ['day', 'year'] instead of 'year'

This could be a problem.. will have to test it quickly.

…ke into account angular's behavior when multiple query parameters w/ the same name exist (ie, use the last one angular sees instead of using an array).
@diosmosis
Copy link
Member Author

Fixed the multiple query param value issue @tsteur mentioned. Ready for more testing, review or a merge if the build passes.

@tsteur
Copy link
Member

tsteur commented Sep 22, 2015

I don't think this will be an issue for this PR since the history service is only used to change the fragment URL and does not read the URL except when initializing.

I think it was only a problem for me in Admin when using $location.search there and maybe Overlay.

Tests pass and code looks fine. @mattab maybe worth releasing a new beta anytime soon in case there something broke that isn't covered by tests

tsteur added a commit that referenced this pull request Sep 22, 2015
Use $location.search to store & change currently viewed page in UI instead of stead of $location.path
@tsteur tsteur merged commit 8cd9a93 into master Sep 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants