]> source.dussan.org Git - sonarqube.git/commitdiff
Correctly display Issues graph as default if no custom metrics are selected.
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 21 Jul 2017 11:32:19 +0000 (13:32 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 24 Jul 2017 06:20:48 +0000 (08:20 +0200)
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
server/sonar-web/src/main/js/helpers/storage.js

index 01a3a09af367f3e024dbf9ec64f49ca62ca2f86e..d5ea86bad0c5095e0d4e7dde1b6b268cfd378b69 100644 (file)
@@ -273,9 +273,12 @@ class ProjectActivityAppContainer extends React.PureComponent {
         key => key !== 'id' && locationQuery[key] !== ''
       );
 
-      // if there is no filter, but there are saved preferences in the localStorage
       const graph = getGraph();
-      return !filtered && graph != null && graph !== DEFAULT_GRAPH;
+      const emptyCustomGraph = isCustomGraph(graph) && getCustomGraph().length <= 0;
+
+      // if there is no filter, but there are saved preferences in the localStorage
+      // also don't redirect to custom if there is no metrics selected for it
+      return !filtered && graph != null && graph !== DEFAULT_GRAPH && !emptyCustomGraph;
     }
   };
 
index 977f184443e4145914e9355910aee17d6d5da01b..763aa3d64b10ece137ea32472e9d3af0c7fec2ce 100644 (file)
@@ -66,8 +66,10 @@ export const getSort = () => window.localStorage.getItem(PROJECTS_SORT);
 
 export const saveCustomGraph = (metrics: ?Array<string>) =>
   save(PROJECT_ACTIVITY_GRAPH_CUSTOM, metrics ? metrics.join(',') : '');
-export const getCustomGraph = (): Array<string> =>
-  (window.localStorage.getItem(PROJECT_ACTIVITY_GRAPH_CUSTOM) || '').split(',');
+export const getCustomGraph = (): Array<string> => {
+  const customGraphs = window.localStorage.getItem(PROJECT_ACTIVITY_GRAPH_CUSTOM);
+  return customGraphs ? customGraphs.split(',') : [];
+};
 
 export const saveGraph = (graph: ?string) => save(PROJECT_ACTIVITY_GRAPH, graph);
 export const getGraph = (): string =>