aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-11-03 15:12:29 +0100
committerStas Vilchik <stas.vilchik@sonarsource.com>2017-11-06 08:55:48 +0100
commitf740cb5fde92c4c77aab732390cc2b7a2b39e813 (patch)
treeb88158014663e8ca30faa18865e90dfa2b14bd39
parent5326c7cc97db482803c11f06a45a7e497824765d (diff)
downloadsonarqube-f740cb5fde92c4c77aab732390cc2b7a2b39e813.tar.gz
sonarqube-f740cb5fde92c4c77aab732390cc2b7a2b39e813.zip
SONAR-10044 fix projects permalink redirection
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx13
-rw-r--r--tests/src/test/java/org/sonarqube/pageobjects/Navigation.java4
-rw-r--r--tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java16
3 files changed, 29 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx
index 65bdfac3f43..cd5f60bd1eb 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx
@@ -71,7 +71,9 @@ export default class AllProjects extends React.PureComponent<Props, State> {
}
this.handleQueryChange(true);
const footer = document.getElementById('footer');
- footer && footer.classList.add('page-footer-with-sidebar');
+ if (footer) {
+ footer.classList.add('page-footer-with-sidebar');
+ }
}
componentDidUpdate(prevProps: Props) {
@@ -83,7 +85,9 @@ export default class AllProjects extends React.PureComponent<Props, State> {
componentWillUnmount() {
this.mounted = false;
const footer = document.getElementById('footer');
- footer && footer.classList.remove('page-footer-with-sidebar');
+ if (footer) {
+ footer.classList.remove('page-footer-with-sidebar');
+ }
}
getView = () => this.state.query.view || 'overall';
@@ -92,7 +96,8 @@ export default class AllProjects extends React.PureComponent<Props, State> {
getSort = () => this.state.query.sort || 'name';
- isFiltered = () => Object.values(this.state.query).some(value => value !== undefined);
+ isFiltered = (query = this.state.query) =>
+ Object.values(query).some(value => value !== undefined);
stopLoading = () => {
if (this.mounted) {
@@ -197,7 +202,7 @@ export default class AllProjects extends React.PureComponent<Props, State> {
const savedOptionsSet = savedOptions.sort || savedOptions.view || savedOptions.visualization;
// if there is no filter, but there are saved preferences in the localStorage
- if (initialMount && !this.isFiltered() && savedOptionsSet) {
+ if (initialMount && !this.isFiltered(query) && savedOptionsSet) {
this.context.router.replace({ pathname: this.props.location.pathname, query: savedOptions });
} else {
this.fetchProjects(query);
diff --git a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
index 72d0d27705c..8dbe70f84f4 100644
--- a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
+++ b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java
@@ -84,6 +84,10 @@ public class Navigation {
return open("/organizations/" + organization + "/projects", ProjectsPage.class);
}
+ public ProjectsPage openProjectsWithQuery(String query) {
+ return open("/projects?" + query, ProjectsPage.class);
+ }
+
public IssuesPage openIssues() {
return open("/issues", IssuesPage.class);
}
diff --git a/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java
index c14cc18e9fc..cdd2e9b97d2 100644
--- a/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java
@@ -200,4 +200,20 @@ public class ProjectsPageTest {
page.shouldHaveTotal(1);
page.searchProject("sample").shouldHaveTotal(0);
}
+
+ @Test
+ public void should_open_permalink() {
+ String user = tester.users().generate().getLogin();
+ Navigation nav = tester.openBrowser().logIn().submitCredentials(user);
+
+ // make a search, so its parameters saved to local storage
+ nav.openProjects().changePerspective("Leak");
+
+ // change a page
+ nav.openHome();
+
+ // open a permalink to a particular visualization, it must be kept
+ nav.openProjectsWithQuery("view=visualizations&visualization=coverage");
+ assertThat(url()).contains("view=visualizations&visualization=coverage");
+ }
}