]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8550 Don't scroll top when doing an action on an event
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 30 Jun 2017 15:57:51 +0000 (17:57 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 4 Jul 2017 12:15:34 +0000 (14:15 +0200)
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap

index 9644ad770e1f942920991ec14828ba5ba414ae71..a2aa8084c66600f385257522dcdf73f9ed2409bd 100644 (file)
@@ -25,8 +25,8 @@ import { throttle } from 'lodash';
 import ProjectActivityAnalysis from './ProjectActivityAnalysis';
 import FormattedDate from '../../../components/ui/FormattedDate';
 import { translate } from '../../../helpers/l10n';
-import { getAnalysesByVersionByDay } from '../utils';
-import type { Analysis } from '../types';
+import { activityQueryChanged, getAnalysesByVersionByDay } from '../utils';
+import type { Analysis, Query } from '../types';
 
 type Props = {
   addCustomEvent: (analysis: string, name: string, category?: string) => Promise<*>,
@@ -38,7 +38,8 @@ type Props = {
   changeEvent: (event: string, name: string) => Promise<*>,
   deleteAnalysis: (analysis: string) => Promise<*>,
   deleteEvent: (analysis: string, event: string) => Promise<*>,
-  loading: boolean
+  loading: boolean,
+  query: Query
 };
 
 export default class ProjectActivityAnalysesList extends React.PureComponent {
@@ -57,7 +58,9 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
 
   componentDidUpdate(prevProps: Props) {
     if (prevProps.analysis !== this.props.analyses && this.scrollContainer) {
-      this.scrollContainer.scrollTop = 0;
+      if (activityQueryChanged(prevProps.query, this.props.query)) {
+        this.scrollContainer.scrollTop = 0;
+      }
       for (let i = 1; i < this.badges.length; i++) {
         this.badges[i].removeAttribute('originOffsetTop');
         this.badges[i].classList.remove('sticky');
index 9b4f2a595dd41a8287d0c8767ccbe08d14f6762e..f7d094778eb099eb634e70ce0d0f43bb71d269af 100644 (file)
@@ -111,6 +111,7 @@ export default class ProjectActivityApp extends React.PureComponent {
               deleteAnalysis={this.props.deleteAnalysis}
               deleteEvent={this.props.deleteEvent}
               loading={this.props.loading}
+              query={this.props.query}
             />
           </div>
           <div className="project-activity-layout-page-main">
index 0f5a433fbfed7ed9ecb448558289316aa136c695..b97c9aa90541772fc5c549c2d33ccf51b04fbbfe 100644 (file)
@@ -110,6 +110,13 @@ exports[`should render correctly 1`] = `
         deleteAnalysis={[Function]}
         deleteEvent={[Function]}
         loading={false}
+        query={
+          Object {
+            "category": "",
+            "graph": "overview",
+            "project": "org.sonarsource.sonarqube:sonarqube",
+          }
+        }
       />
     </div>
     <div