From: Grégoire Aubert Date: Fri, 30 Jun 2017 15:57:51 +0000 (+0200) Subject: SONAR-8550 Don't scroll top when doing an action on an event X-Git-Tag: 6.5-M2~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=18fca4d04ae579382448dc3ff795a2d601cf3b21;p=sonarqube.git SONAR-8550 Don't scroll top when doing an action on an event --- diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js index 9644ad770e1..a2aa8084c66 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js @@ -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'); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js index 9b4f2a595dd..f7d094778eb 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js @@ -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} />
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap index 0f5a433fbfe..b97c9aa9054 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap @@ -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", + } + } />